     1                                  ; ****************************************************************************
     2                                  ; sncomni.s (TRDOS 386, TRDOS v2.0 - sample binary file, 'sncomni.prg')
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; SNCOMNI.PRG ! TEST program !  TRDOS 386 VGA Functionality test !
     5                                  ;
     6                                  ; 02/09/2016
     7                                  ;
     8                                  ; [ Last Modification: 12/08/2017 ]
     9                                  ;
    10                                  ; Derived from source code of 'OMNISCENT.ASM' by Dirk Kppers
    11                                  ;          SNC_OMNI.COM	(MSDOS) intro file, 1997
    12                                  ;
    13                                  ; Assembler: NASM 2.11
    14                                  
    15                                  ; (Original TASM -msdos- code has been modifed for TRDOS 386 system calls and
    16                                  ; other protected mode (TRDOS 386) interrupts.)
    17                                  ; ****************************************************************************
    18                                  
    19                                  ;		   ----====> Omniscent <====----
    20                                  ;
    21                                  ;   Omniscent was done by Pinker of SANCTION for the Mekka '97. The song
    22                                  ;   was written by Nyphton. It place XXX out of XXX.
    23                                  ;
    24                                  ;   Special thanks in alphabetical order :
    25                                  ;
    26                                  ;       Andreas Mautsch     (beta testing)
    27                                  ;       Axel Scheel Meyer   (MACM sources, nice IRC chat's)
    28                                  ;       Christian Cohnen    (for his help on perspective texture mapping and
    29                                  ;			     designing world and script)
    30                                  ;       Daniel Weinand	    (song)
    31                                  ;       Funk                (for give me the idea trying a 4K Descent)
    32                                  ;       Stephanie Schepers  (moral and food support ;-) )
    33                                  ;
    34                                  ;       and all other SANCTION dudes for supporting this product !
    35                                  
    36                                  ; 01/03/2017
    37                                  ; 16/10/2016
    38                                  ; 29/04/2016
    39                                  ; TRDOS 386 system calls (temporary list!)
    40                                  _ver 	equ 0
    41                                  _exit 	equ 1
    42                                  _fork 	equ 2
    43                                  _read 	equ 3
    44                                  _write	equ 4
    45                                  _open	equ 5
    46                                  _close 	equ 6
    47                                  _wait 	equ 7
    48                                  _creat 	equ 8
    49                                  _link 	equ 9
    50                                  _unlink	equ 10
    51                                  _exec	equ 11
    52                                  _chdir	equ 12
    53                                  _time 	equ 13
    54                                  _mkdir 	equ 14
    55                                  _chmod	equ 15
    56                                  _chown	equ 16
    57                                  _break	equ 17
    58                                  _stat	equ 18
    59                                  _seek	equ 19
    60                                  _tell 	equ 20
    61                                  _mount	equ 21
    62                                  _umount	equ 22
    63                                  _setuid	equ 23
    64                                  _getuid	equ 24
    65                                  _stime	equ 25
    66                                  _quit	equ 26	
    67                                  _intr	equ 27
    68                                  _fstat	equ 28
    69                                  _emt 	equ 29
    70                                  _mdate 	equ 30
    71                                  _video 	equ 31
    72                                  _audio	equ 32
    73                                  _timer	equ 33
    74                                  _sleep	equ 34
    75                                  _msg    equ 35
    76                                  _geterr	equ 36
    77                                  _fpsave	equ 37
    78                                  _pri	equ 38
    79                                  _rele	equ 39
    80                                  _fff	equ 40
    81                                  _fnf	equ 41
    82                                  _alloc	equ 42
    83                                  _dalloc equ 43
    84                                  _calbac equ 44	
    85                                  
    86                                  [BITS 32] ; 80386 Protected Mode (32 bit) intructions
    87                                  
    88                                  %macro sys 1-4
    89                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    90                                      ; 03/09/2015	
    91                                      ; 13/04/2015
    92                                      ; Retro UNIX 386 v1 system call.	
    93                                      %if %0 >= 2   
    94                                          mov ebx, %2
    95                                          %if %0 >= 3    
    96                                              mov ecx, %3
    97                                              %if %0 = 4
    98                                                 mov edx, %4   
    99                                              %endif
   100                                          %endif
   101                                      %endif
   102                                      mov eax, %1
   103                                      ;int 30h
   104                                      int 40h ; TRDOS 386 (TRDOS v2.0)	   
   105                                  %endmacro
   106                                  
   107                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
   108                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
   109                                  
   110                                  ; SNCOMNI.ASM
   111                                  ; ͻ
   112                                  ; 	This file is generated by The Interactive Disassembler (IDA)	    
   113                                  ; 	Copyright (c) 2010 by Hex-Rays SA, <support@hex-rays.com>	    
   114                                  ; 			 Licensed to: Freeware version			    
   115                                  ; ͼ
   116                                  ;
   117                                  ; Input	MD5   :	933E2716A5E585459024215F4468CDBC
   118                                  
   119                                  ; File Name   :	C:\dosprogs\MEMDUMP.COM ; SNC_OMNI.COM UNPACKED!
   120                                  ; Format      :	MS-DOS COM-file
   121                                  ; Base Address:	0h Range: 100h-60100h Loaded length: 60000h
   122                                  
   123                                  ; NASM version: Erdogan Tan, 14/08/2016 (Modified from MEMDUMP.ASM)
   124                                  ; (SNC_OMNI.COM -> unpacking by using DosBox Debug -> MEMDUMP.COM ->
   125                                  ; disassembling by using IDA Pro Free -> MEMDUMP.ASM -> converting to
   126                                  ; NASM syntax (manual) -> test with DosBox -> correcting different code by
   127                                  ; matching MEMDUMP.LST and SNCOMNI.LST files -> this file !!!)
   128                                  
   129                                  ;==============================================================================
   130                                  ;		   constants
   131                                  ;==============================================================================
   132                                  
   133                                  GMPort		equ 0331h
   134                                  CMD_NOTEON      equ 090h
   135                                  CMD_NOTEOFF     equ 080h
   136                                  CMD_CHANGEPARAM equ 0B0h
   137                                  CMD_CHANGEPRG   equ 0C0h
   138                                  MOD_ALLNOTESOFF equ 07Bh
   139                                  MAXFACES	equ 400
   140                                  MAXPOINTS	equ 400
   141                                  SONGSPEED   	equ 29
   142                                  XMAX		equ 320
   143                                  YMIN		equ 21
   144                                  YMAX		equ 179
   145                                  SUBRANGE	equ 16
   146                                  %define ASPECT_RATIO 1.2
   147                                  CENTERX		equ 160
   148                                  CENTERY		equ 100
   149                                  
   150                                  ;==============================================================================
   151                                  ;		   structures
   152                                  ;==============================================================================
   153                                  
   154                                  struc channel
   155 00000000 <res 00000002>           .del:	resw 1
   156 00000002 <res 00000001>           .trk:	resb 1
   157 00000003 <res 00000001>           .ln:	resb 1
   158 00000004 <res 00000002>           .adr:	resw 1
   159                                  endstruc
   160                                  
   161                                  struc matrix
   162 00000000 <res 00000024>          	resd 9
   163                                   .size:
   164                                  endstruc
   165                                  
   166                                  struc vector
   167 00000000 <res 00000004>           .x:	resd 1
   168 00000004 <res 00000004>           .y:	resd 1
   169 00000008 <res 00000004>           .z:	resd 1
   170                                   .size:
   171                                  endstruc
   172                                  
   173                                  struc point
   174 00000000 <res 00000002>           .x:	resw 1
   175 00000002 <res 00000002>           .y:	resw 1
   176 00000004 <res 00000002>           .z:	resw 1
   177 00000006 <res 00000002>           .s:	resw 1
   178                                   .size:
   179                                  endstruc
   180                                  
   181                                  struc face
   182 00000000 <res 0000000A>          	resw 5
   183                                   .size: 	
   184                                  endstruc
   185                                  
   186                                  ;struc object
   187                                  ; .panz: resw 1
   188                                  ; .fanz: resw 1
   189                                  ; .p:	resb point.size*MAXPOINTS
   190                                  ; .f:	resb face.size*MAXFACES
   191                                  ; .size:
   192                                  ;endstruc
   193                                  
   194                                  struc edges
   195 00000000 <res 00000004>           .x:	resd 1
   196 00000004 <res 00000004>           .u:	resd 1
   197 00000008 <res 00000004>           .v:	resd 1
   198 0000000C <res 00000004>           .w:	resd 1
   199 00000010 <res 00000004>           .s:	resd 1
   200                                   .size:	
   201                                  endstruc
   202                                  
   203                                  struc edge
   204 00000000 <res 0000000C>           .p:	resb vector.size
   205 0000000C <res 00000004>           .py:	resd 1
   206 00000010 <res 00000014>           .e:	resb edges.size
   207                                   .size:
   208                                  endstruc
   209                                  
   210                                  struc poly
   211 00000000 <res 000000B4>          	resb edge.size*5
   212                                   .size:	
   213                                  endstruc
   214                                  
   215                                  ;==============================================================================
   216                                  ;		      %macros
   217                                  ;==============================================================================
   218                                  ;***********************************************
   219                                  ;* description	: start timer interrupt 70/s   *
   220                                  ;* parameter	: none			       *
   221                                  ;* sideeffect	: all		 	       *
   222                                  ;* back		: none			       *
   223                                  ;***********************************************
   224                                  %macro		startTimer 0
   225                                                  ;mov     ax,03508h
   226                                                  ;int     21h
   227                                                  ;mov     [word ptr Old08Irqseg],es
   228                                                  ;mov     [word ptr Old08Irqofs],bx
   229                                                  ;mov     ax,02508h
   230                                                  ;mov     dx,offset irqHandler08
   231                                                  ;int     21h
   232                                  		
   233                                  		mov	bx, 3409 ; 1193180/3409 = 350 ticks per second (*!)
   234                                  		call	setTimer
   235                                  
   236                                  		; start timer event
   237                                  		mov	ebx, 8400h ; Current Timer setup, Callback method 	
   238                                  		mov	ecx, 1	 ; 1 tick 
   239                                  		mov	edx, timer_callback ; timer callback service addr
   240                                  		mov	eax, 33	; 'systimer'
   241                                  		int	40h	; TRDOS 386 system call
   242                                  		jc	loc_err_exit
   243                                  
   244                                  		mov	[timer_event_number], al 
   245                                  %endmacro
   246                                  
   247                                  ;***********************************************
   248                                  ;* description	: stop timer interrupt         *
   249                                  ;* parameter	: none			       *
   250                                  ;* sideeffect	: all		 	       *
   251                                  ;* back		: none			       *
   252                                  ;***********************************************
   253                                  %macro		stopTimer 0
   254                                                  ;push    ds
   255                                                  ;xor     bx,bx                  ; set timer to default
   256                                                  ;call    setTimer		; 18.2 ticks per second
   257                                                  ;mov     ax,02508h              ; restore old IRQ-vector
   258                                                  ;lds     dx,[Old08Irqptr]
   259                                                  ;int     21h
   260                                                  ;pop     ds
   261                                  
   262                                  		xor	bx, bx	; set timer to default (18.2 Hz) value
   263                                  		call	setTimer
   264                                  
   265                                  		; Stop timer event
   266                                  		movzx	ebx, byte [timer_event_number]
   267                                  		;and	bl, bl
   268                                  		;jz	short r_t_m ; 0 = error (no timer event)
   269                                   		; bh = 0 -> stop timer event
   270                                  		mov	eax, 33	; 'systimer'
   271                                  		int	40h	; TRDOS 386 system call
   272                                  ;r_t_m:
   273                                  %endmacro
   274                                  
   275                                  ;***********************************************
   276                                  ;* description	: start keyboard handler       *
   277                                  ;* parameter	: none			       *
   278                                  ;* sideeffect	: all		 	       *
   279                                  ;* back		: none			       *
   280                                  ;***********************************************
   281                                  %macro		startKBDHandler 0
   282                                                  ;mov     ax,03509h
   283                                                  ;int     21h
   284                                                  ;mov     [word ptr Old09Irqseg],es
   285                                                  ;mov     [word ptr Old09Irqofs],bx
   286                                                  ;mov     ax,02509h
   287                                                  ;mov     dx,offset irqHandler09
   288                                                  ;int     21h
   289                                  
   290                                  		; TRDOS 386 already have a CRTL+BRK
   291                                  		; preview feature to call 'sysexit'
   292                                  		; /// nothing to do here ! ///
   293                                  		; 10/12/2016 - Erdogan Tan
   294                                  		nop
   295                                  %endmacro
   296                                  
   297                                  ;***********************************************
   298                                  ;* description	: stop keyboard handler	       *
   299                                  ;* parameter	: none			       *
   300                                  ;* sideeffect	: all		               *
   301                                  ;* back		: none		               *
   302                                  ;***********************************************
   303                                  %macro		stopKBDHandler 0
   304                                                  ;push    ds
   305                                                  ;mov     ax,02509h             ; restore old IRQ-vector
   306                                                  ;lds     dx,[Old09Irqptr]      ;
   307                                                  ;int     21h
   308                                                  ;pop     ds
   309                                  
   310                                  		; TRDOS 386 already have a CRTL+BRK
   311                                  		; preview feature to call 'sysexit'
   312                                  		; /// nothing to do here ! ///
   313                                  		; 10/12/2016 - Erdogan Tan
   314                                  		nop
   315                                  %endmacro
   316                                  
   317                                  ;***********************************************
   318                                  ;* description	: zero null-initialized data   *
   319                                  ;* parameter	: none			       *
   320                                  ;* sideeffect	: all		               *
   321                                  ;* back		: none		               *
   322                                  ;***********************************************
   323                                  %macro		nullData 0
   324                                  		;mov	di, nullstart
   325                                                  mov	edi, nullstart
   326                                  		;mov	cx, nullend-nullstart
   327                                                  ;mov	ecx, nullend-nullstart 
   328                                  		xor	eax, eax
   329                                                  ;rep	stosb
   330                                  		;mov	ecx, (bss_end-nullstart)+3 ; 06/02/2017
   331                                  		;shr	cx, 2
   332                                  		; 12/08/2017
   333                                  		mov	ecx ((bss_end-nullstart)+3)/4
   334                                  		rep	stosd
   335                                  %endmacro
   336                                  
   337                                  ;***********************************************
   338                                  ;* description	: set textmode		       *
   339                                  ;* parameter	: none		               *
   340                                  ;* sideeffect	: all		               *
   341                                  ;* back		: none		               *
   342                                  ;***********************************************
   343                                  %macro		set80x25 0
   344                                  		mov	ax, 3
   345                                  		;int	10h	; - VIDEO - SET	VIDEO MODE
   346                                  				; AL = mode
   347                                  		int	31h	; TRDOS 386 Video interrupt 
   348                                  %endmacro
   349                                  
   350                                  ;***********************************************
   351                                  ;* description	: set gfx-mode 320x200	       *
   352                                  ;* parameter	: none		               *
   353                                  ;* sideeffect	: all		               *
   354                                  ;* back		: none		               *
   355                                  ;***********************************************
   356                                  %macro		set320x200 0
   357                                  		mov	ax, 13h
   358                                  		;int	10h		; - VIDEO - SET	VIDEO MODE
   359                                  					; AL = mode
   360                                  		int	31h ; TRDOS 386 - Video interrupt
   361                                  %endmacro
   362                                  
   363                                  ;************************************************
   364                                  ;* description	: calculate a smooth colorrange	*
   365                                  ;* parameter	: none				*
   366                                  ;* sideeffect	: all				*
   367                                  ;* back		: none				*
   368                                  ;************************************************
   369                                  %macro		makePalette 0
   370                                  		;mov	bx, 3
   371                                  		mov	ebx, 3
   372                                  mPcolor:
   373                                  		;mov	si, colors
   374                                  		mov	esi, colors
   375                                  		mov	edi, palette
   376                                  		xor	dh, dh
   377                                  		lodsb
   378                                  		;movzx	cx, al
   379                                  		movzx	ecx, al ; ??
   380                                  mPouter:
   381                                  		push	ecx
   382                                  		mov	cl, [esi]
   383                                  		mov	ah, [ebx+esi]
   384                                  		sub	ax, dx
   385                                  		push	edx
   386                                  		cwd
   387                                  		idiv	cx
   388                                  		pop	edx
   389                                  mPinner:
   390                                  		add	dx, ax
   391                                  		mov	[edi+ebx-1], dh
   392                                  		add	di, 3
   393                                  		loop	mPinner
   394                                  		add	si, 4
   395                                  		pop	ecx
   396                                  		loop	mPouter
   397                                  		dec	bx
   398                                  		jnz	short mPcolor
   399                                  %endmacro
   400                                  
   401                                  ;**************************************************
   402                                  ;* description	: reset the GM-Port and switch to *
   403                                  ;*		  UART mode.		 	  *
   404                                  ;* parameter	: none			 	  *
   405                                  ;* sideeffect	: dx,al		          	  *
   406                                  ;* back		: none		           	  *
   407                                  ;**************************************************
   408                                  %macro		resetGM 0
   409                                  		mov	dx, GMPort
   410                                  		mov	al, 0FFh
   411                                  		;out	dx, al
   412                                  	
   413                                  		mov	ah, 1 ; out (byte)
   414                                  		int	34h ; TRDOS 386 - IOCTL interrupt
   415                                  		; cl = 0
   416                                  		dec	ah ; 0
   417                                  		;sub	cl, cl
   418                                  resGMbusy1:
   419                                  		dec	cl
   420                                  		jz	short rGMerror	;{ timeout }
   421                                  		;in	al, dx		;{ read acknowledge }
   422                                  		
   423                                  		;mov	ah, 0 ; in (byte)
   424                                  		int	34h ; TRDOS 386 - IOCTL interrupt
   425                                  		
   426                                  		test	al, 80h
   427                                  		jnz	short resGMbusy1
   428                                  		dec	dx
   429                                  		;in	al, dx
   430                                  
   431                                  		;mov	ah, 0 ; in (byte)
   432                                  		int	34h ; TRDOS 386 - IOCTL interrupt
   433                                  
   434                                  		cmp	al, 0FEh
   435                                  		jne	short rGMerror
   436                                  		inc	dx		;{ switch into UART mode }
   437                                  resGMbusy2:
   438                                  		;in	al, dx
   439                                  
   440                                  		;mov	ah, 0 ; in (byte)
   441                                  		int	34h ; TRDOS 386 - IOCTL interrupt
   442                                  		
   443                                  		test	al, 40h
   444                                  		jnz	short resGMbusy2
   445                                  		mov	al, 3Fh
   446                                  		;out	dx, al
   447                                  
   448                                  		;mov	ah, 1 ; out (byte)
   449                                  		inc	ah ; 1
   450                                  		int	34h ; TRDOS 386 - IOCTL interrupt
   451                                  rGMerror:
   452                                  %endmacro
   453                                  
   454                                  ;***********************************************
   455                                  ;* description	: mute midi channels 0..15     *
   456                                  ;* parameter	: none                	       *
   457                                  ;* sideeffect	: ax,cx		               *
   458                                  ;* back		: none                	       *
   459                                  ;***********************************************
   460                                  %macro		silence 0
   461                                  		mov	cx, 15 ; 0Fh
   462                                  Siloop:	
   463                                  		mov	ax, cx
   464                                  		add	al, CMD_CHANGEPARAM ; 0B0h
   465                                  		call	writeGM
   466                                  		mov	al, MOD_ALLNOTESOFF ; 7Bh
   467                                  		call	writeGM
   468                                  		xor	al, al
   469                                  		call	writeGM
   470                                  		loop	Siloop
   471                                  Sinosound:
   472                                  %endmacro
   473                                  
   474                                  ;**************************************************
   475                                  ;* description	: create the reactor wall texture *
   476                                  ;* parameter	: none		               	  *
   477                                  ;* sideeffect	: ax,bx,cx,di,es               	  *
   478                                  ;* back		: none			       	  *
   479                                  ;* length	: 45 bytes		       	  * 
   480                                  ;**************************************************
   481                                  %macro		reactorWall 0
   482                                  		; 26/07/2017
   483                                  		movzx	ebp, word [tseg]
   484                                  		shl	ebp, 4
   485                                  		mov	[_es], ebp
   486                                  		xor	edi, edi
   487                                  		mov	ecx, 4096 ; 1000h
   488                                  rsmloop:
   489                                  		mov	eax, edi
   490                                  		test	al, 8
   491                                  		jle	short rsnonot1
   492                                  		not	al
   493                                  rsnonot1:
   494                                  		and	al, 15 ; 0Fh
   495                                  		mov	ebx, eax
   496                                  		mov	eax, edi
   497                                  		shr	ax, 6
   498                                  		test	al, 8
   499                                  		jle	short rsnonot2
   500                                  		not	al
   501                                  rsnonot2:
   502                                  		and	al, 15 ; 0Fh
   503                                  		cmp	al, bl
   504                                  		jle	short rstakeal
   505                                  		mov	eax, ebx
   506                                  rstakeal:
   507                                  		add	al, 224 ; 0E0h
   508                                  		add	edi, ebp
   509                                  		stosb
   510                                  		sub	edi, ebp
   511                                  		loop	rsmloop
   512                                  %endmacro
   513                                  
   514                                  ;***********************************************
   515                                  ;* description	: calc background-fractal      *
   516                                  ;* parameter	: none		               *
   517                                  ;* sideeffect	: ax,bx,cx,si,di,es	       *
   518                                  ;* back		: none			       *
   519                                  ;***********************************************
   520                                  %macro		createFrac2 0
   521                                  		; 12/08/2017
   522                                  		; 26/07/2017
   523                                  		movzx	ebp, word [tseg+36]
   524                                  		shl	ebp, 4
   525                                  		mov	[_es], ebp
   526                                  		mov	al, 20	; 14h
   527                                  		call	setFrac
   528                                  		mov	edi, 64
   529                                  		;mov	ecx, 4096-64 ; 0FC0h
   530                                  		mov	cx, 4096-64
   531                                  		mov	ebx, 4  ; 16/12/2016
   532                                  cF1loop:
   533                                  		;mov	bx, 4
   534                                  		call	rnd
   535                                  		; 12/08/2017
   536                                  		;add	edi, ebp
   537                                  		;add	al, [edi-64]  ; byte [es:di-64]
   538                                  		;add	al, [edi-63]  ; byte [es:di-63]
   539                                  		add	al, [ebp+edi-64]
   540                                  		add	al, [ebp+edi-63]
   541                                  		dec	ax
   542                                  		shr	ax, 1
   543                                  		;stosb
   544                                  		;sub	edi, ebp
   545                                  		mov	[ebp+edi], al
   546                                  		inc	edi
   547                                  		loop	cF1loop
   548                                  %endmacro
   549                                  
   550                                  ;***********************************************
   551                                  ;* description	: calc random noise fractal    *
   552                                  ;* parameter	: none		               *
   553                                  ;* sideeffect	: ax,bx,cx,si,di,es	       *
   554                                  ;* back		: none			       *
   555                                  ;***********************************************
   556                                  %macro		createFrac3 0
   557                                  		; 26/07/2017
   558                                  		movzx	ebp, word [tseg+38]
   559                                  		shl	ebp, 4
   560                                  		mov	[_es], ebp
   561                                  		mov	al, 3
   562                                  		call	setFrac
   563                                  		;mov	ecx, 4096
   564                                  		mov	cx, 4096 ; 1000h
   565                                  		mov	ebx, ecx
   566                                  cF3loop:
   567                                  		;mov	bx, 4096 ; 1000h
   568                                  		call	rnd
   569                                  		movzx	edi, ax
   570                                  		inc	byte [ebp+edi]
   571                                  		loop	cF3loop
   572                                  %endmacro
   573                                  
   574                                  ;**************************************************
   575                                  ;* description	: init stars (positions and state)*
   576                                  ;* parameter	: none			          *
   577                                  ;* sideeffect	: eax,bx,cx,edx,si,di,es	  *
   578                                  ;* back		: none		                  *
   579                                  ;**************************************************
   580                                  %macro		initStars 0
   581                                  		; 26/07/2017
   582                                  		;mov	cx, 30 ; 1Eh
   583                                  		;mov	ecx, 30 ;
   584                                  		mov	cl, 30
   585                                  		mov	edi, stars
   586                                  		xor	ebx, ebx
   587                                  		mov	[_es], ebx ; 0
   588                                  iSloop:	
   589                                  		mov	bx, 256 ; 100h
   590                                  		call	rnd
   591                                  		stosb
   592                                  		mov	bx, 4096-(64*5) ; 0EC0h
   593                                  		add	bx, 128 ; 80h
   594                                  		call	rnd
   595                                  		add	ax, 64  ; 40h
   596                                  		stosw
   597                                  		loop	iSloop
   598                                  %endmacro
   599                                  
   600                                  ;***********************************************
   601                                  ;* description	: add effects to fractals      *
   602                                  ;* parameter	: none		               *
   603                                  ;* sideeffect	: ax,bx,cx,di,es	       *
   604                                  ;* back		: none		               *
   605                                  ;***********************************************
   606                                  %macro		effects 0
   607                                  		; 26/07/2017
   608                                  		; effects
   609                                  		;mov	cx, 26 ; 1Ah
   610                                  		;mov	ecx, 26 ;
   611                                  		mov	cl, 26
   612                                  		mov	esi, aE
   613                                  		;mov	si, aE
   614                                  		xor	ebx, ebx
   615                                  		xor	edi, edi
   616                                  effmloop:
   617                                  		push	ecx
   618                                  		mov	bl, [esi]	; mseg+effect
   619                                  		mov	dl, bl
   620                                  		shr	dl, 4
   621                                  		and	bl, 0Fh ; 15
   622                                  		; 11/02/2017
   623                                  		shl	bl, 1
   624                                  		; 26/07/2017
   625                                  		movzx	ebp, word [ebx+tseg]
   626                                  		shl	ebp, 4
   627                                  		mov	[_es], ebp
   628                                  		;
   629                                  		movzx	ecx, byte [esi+2] ; y1
   630                                  effyloop:
   631                                  		movzx	ebx, byte [esi+1] ; x1
   632                                  effxloop:
   633                                  		mov	edi, ecx
   634                                  		shl	di, 6
   635                                  		;add	di, bx
   636                                  		add	edi, ebx
   637                                  		mov	al, dl
   638                                  		dec	al
   639                                  		jz	short effect1
   640                                  		dec	al
   641                                  		jz	short effect2
   642                                  		;mov	ax, bx
   643                                  		mov	eax, ebx
   644                                  		;add	ax, cx
   645                                  		add	eax, ecx
   646                                  		and	al, 4
   647                                  		;jz	short effdonot
   648                                  		jz	short effect1
   649                                  		mov	al, 152 ; 98h
   650                                  effdonot:
   651                                  		jmp	short effect1
   652                                  effect2:
   653                                  		mov	al, [ebp+edi]	; 16/12/2016
   654                                  effect1:
   655                                  		add	al, [esi+5]	; value
   656                                  		mov	[ebp+edi], al	; 16/12/2016
   657                                  		inc	bl
   658                                  		cmp	bl, [esi+3] 	; x2
   659                                  		jle	short effxloop
   660                                  		;inc	cx
   661                                  		inc	cl
   662                                  		cmp	cl, [esi+4]	; y2
   663                                  		jle	short effyloop
   664                                  		add	si, 6
   665                                  		pop	ecx
   666                                  		loop	effmloop
   667                                  %endmacro
   668                                  
   669                                  ;***********************************************
   670                                  ;* description	: copy fractals and add value  *
   671                                  ;* parameter	: none		               *
   672                                  ;* sideeffect	: al,cx,di,es,fs	       *
   673                                  ;* back		: none		               *
   674                                  ;***********************************************
   675                                  %macro		addFractals 0
   676                                  		; 26/07/2017
   677                                  		;mov	si, aF
   678                                  		mov	esi, aF
   679                                  		mov	dl, 4
   680                                  aFloop:
   681                                  		movzx	ebx, dl
   682                                  		movzx	ebp, word [ebx+tseg] ; es:
   683                                  		shl	ebp, 4
   684                                  		mov	[_es], ebp
   685                                  		xor	edi, edi
   686                                  		lodsw
   687                                  		mov	bl, al 
   688                                  		;
   689                                  		movzx	ebp, word [ebx+tseg] ; fs:
   690                                  		shl	ebp, 4
   691                                  		mov	[_fs], ebp
   692                                  		;
   693                                  		mov	cx, 4096 ; 1000h
   694                                  		;mov	ecx, 4096 ;
   695                                  		mov	ebx, [_es]
   696                                  aFiloop:
   697                                  		mov	al, [ebp+edi]  ; [fs:di]
   698                                  		add	al, ah
   699                                  		;stosb
   700                                  		mov	[ebx+edi], al
   701                                  		inc	edi
   702                                  		loop	aFiloop
   703                                  		;
   704                                  		inc	dl
   705                                  		inc	dl
   706                                  		cmp	dl, 30
   707                                  		jle	short aFloop
   708                                  %endmacro
   709                                  
   710                                  ;***************************************************
   711                                  ;* description	: calculate and initalize textures *
   712                                  ;* parameter	: none			       	   *
   713                                  ;* sideeffect	: al,cx,di,es,fs		   *
   714                                  ;* back		: none			       	   *
   715                                  ;***************************************************
   716                                  %macro		addLava 0
   717                                  		; 28/07/2017
   718                                  		; 26/07/2017
   719                                  		movzx	ebp, word [tseg+22]
   720                                  		shl	ebp, 4
   721                                  		mov	[_es], ebp
   722                                  		;
   723                                  		mov	edi, 4095	; 0FFFh
   724                                  		;mov	cx, 20		; 14h
   725                                  		;mov	ecx, 20 ;
   726                                  		mov	cl, 20
   727                                  		;mov	al, 94		; 5Eh
   728                                  		mov	eax, 94
   729                                  aLyloop:
   730                                  		push	ecx
   731                                  		shl	cx, 3
   732                                  aLxloop:
   733                                  		push	edi
   734                                  		push	eax
   735                                  		;mov	bx, 64		; 40h
   736                                  		mov	ebx, 64
   737                                  		call	rnd
   738                                  		sub	di, ax
   739                                  		;sub	edi, eax
   740                                  		pop	eax
   741                                  		mov	[ebp+edi], al ; 17/01/2017
   742                                  		pop	edi
   743                                  		loop	aLxloop
   744                                  		pop	ecx
   745                                  		dec	al
   746                                  		sub	di, 64 		; 40h
   747                                  		loop	aLyloop
   748                                  %endmacro
   749                                  
   750                                  ;***************************************************
   751                                  ;* description	: calculate and initalize textures *
   752                                  ;* parameter	: none		                   *
   753                                  ;* sideeffect	: al,cx,di,es,fs		   *
   754                                  ;* back		: none		                   *
   755                                  ;***************************************************
   756                                  %macro		initTextures 0
   757                                  		; 26/07/2017
   758                                  		;mov	bx, 34	; 22h
   759                                  		mov	ebx, 34
   760                                  		push	800	; 320h
   761                                  		push	5
   762                                  		call	createFrac1
   763                                  		;mov	bx, 32	; 20h
   764                                  		mov	ebx, 32
   765                                  		push	112	; 70h
   766                                  		push	15	; 0Fh
   767                                  		call	createFrac1
   768                                  		createFrac2
   769                                  		createFrac3
   770                                  		initStars
   771                                  		reactorWall
   772                                  		addFractals
   773                                  		effects
   774                                  		addLava
   775                                  %endmacro
   776                                  
   777                                  ;**************************************************
   778                                  ;* description	: cycle "range" colors at "base"  *
   779                                  ;* parameter	: none		                  *
   780                                  ;* sideeffect	: ax,(bl),cx,si,di,es             *
   781                                  ;* back		: none			          *
   782                                  ;**************************************************
   783                                  %macro		colorCycle 0
   784                                  		; 26/07/2017
   785                                  
   786                                  		base	equ 6*32
   787                                                  range	equ 32
   788                                  
   789                                  		mov	dword [_es], 0 ; es = ds
   790                                  		
   791                                  		mov	edi, palette+(base*3)
   792                                  		mov	esi, edi
   793                                  		lodsw
   794                                  		;mov	bl, [esi] ; works only with fire (no blue)
   795                                  		inc	esi
   796                                  		;mov	cx, (range*3-3)
   797                                  		mov	ecx, (range*3-3)
   798                                  		rep movsb
   799                                  		stosw
   800                                  		;mov	[edi], bl ; works only with fire (no blue)
   801                                  %endmacro
   802                                  
   803                                  ;***********************************************
   804                                  ;* description	: animate the stars	       *
   805                                  ;* parameter	: none			       *
   806                                  ;* sideeffect	: ax,bx,cx,dl,si,di,es	       *
   807                                  ;* back		: none			       *
   808                                  ;***********************************************
   809                                  %macro		animStars 0
   810                                  		; 26/07/2017
   811                                  
   812                                  		_base	equ 7*32
   813                                  
   814                                  		movzx	ebp, word [tseg+2]
   815                                  		shl	ebp, 4
   816                                  		mov	[_es], ebp
   817                                  
   818                                  		call	clearFrac
   819                                  
   820                                  		;mov	ecx, 30
   821                                  		mov	cl, 30	; 1Eh
   822                                  		
   823                                  		;mov	bx, stars
   824                                  		mov	ebx, stars
   825                                  aSoloop:
   826                                  		dec	byte [ebx]
   827                                  		mov	ah, [ebx]
   828                                  		and	ah, 63	; 3Fh
   829                                  		cmp	ah, 31	; 1Fh
   830                                  		jbe	short aSnonot
   831                                  		not	ah
   832                                  		and	ah, 31	; 1Fh
   833                                  aSnonot:
   834                                  		shr	ah, 1
   835                                  		; 05/02/2017
   836                                  		movzx	edi, word [ebx+1]
   837                                  
   838                                  		push	ecx
   839                                  		push	ebx
   840                                  
   841                                  		mov	edx, 64-5 ; 3Bh
   842                                  		mov	cx, _base*256+0 ; 0E000h
   843                                  		; 26/07/2017
   844                                  		;ebp = [_es]
   845                                  		call	setstarbob
   846                                  
   847                                  		pop	ebx
   848                                  		pop	ecx
   849                                  
   850                                  		add	bx, 3
   851                                  		loop	aSoloop
   852                                  %endmacro
   853                                  
   854                                  ;***********************************************
   855                                  ;* description	: calculate shading tab	       *
   856                                  ;* parameter	: none		               *
   857                                  ;* sideeffect	: ax,bl,cx,di,es               *
   858                                  ;* back		: none		               *
   859                                  ;***********************************************
   860                                  %macro		calcShadeTab 0
   861                                  		; 26/07/2017
   862                                  		mov	dword [_es], 0 ; es = ds
   863                                  
   864                                  		mov	edi, shadetab
   865                                  		xor	bl, bl
   866                                  cSolp:
   867                                  		inc	bl
   868                                  		;xor	cx, cx
   869                                  		xor	ecx, ecx
   870                                  cSilp1:
   871                                  		mov	al, cl
   872                                  		and	al, 31	; 1Fh
   873                                  		mul	bl
   874                                  		add	ax, ax
   875                                  		mov	al, cl
   876                                  		and	al, 224	; 0E0h
   877                                  		add	al, ah
   878                                  		stosb
   879                                  		inc	cl
   880                                  		cmp	cl, 192 ; 0C0h
   881                                  		jne	short cSilp1
   882                                  cSilp2:
   883                                  		mov	al, cl
   884                                  		stosb
   885                                  		inc	cl
   886                                  		jnz	short cSilp2
   887                                  		cmp	bl, 128	; 80h
   888                                  		jne	short cSolp
   889                                  %endmacro
   890                                  
   891                                  ;***********************************************
   892                                  ;* description	: expand a song       	       *
   893                                  ;* parameter	: si:song base adress	       *
   894                                  ;* sideeffect	: ax,bx,cx,dx,si,di	       *
   895                                  ;* back		: none                	       *
   896                                  ;***********************************************
   897                                  %macro		expandSong 0
   898                                                  mov	esi, credits
   899                                                  mov	ebx, channels
   900                                                  mov	edi, songdata
   901                                  EPSwhile:	lodsw
   902                                                  dec	al
   903                                                  js      short EPSendwhile
   904                                                  mov	[ebx+channel.trk], al ; [ebx+2]
   905                                                  add	al, CMD_CHANGEPRG ; 0C0h
   906                                                  call	setinstr
   907                                                  mov	[ebx+channel.adr], di ; [ebx+4]	
   908                                                 	call	expand
   909                                                  xor	al, al
   910                                                  stosb
   911                                                  add	bx, 6
   912                                                  inc	word [tracks]
   913                                                  jmp	short EPSwhile
   914                                  EPSendwhile:
   915                                  %endmacro
   916                                  
   917                                  ;***************************************************
   918                                  ;* description	: parse the script,rotate and move *
   919                                  ;* parameter	: none                	           *
   920                                  ;* sideeffect	: all		                   *
   921                                  ;* back		: none		                   *
   922                                  ;***************************************************
   923                                  %macro		scriptIt 0
   924                                  		; 11/08/2017
   925                                  
   926                                   		; scriptIt
   927                                  		;mov	cx, [ticker]
   928                                  		movzx	ecx, word [ticker] ; 22/01/2017
   929                                  		mov	word [ticker], 0
   930                                  		or	cx, cx
   931                                  		jz	sItickerNull
   932                                  sImloop:
   933                                  		push	ecx
   934                                  		mov	esi, zspeed
   935                                  		;mov	si, zspeed
   936                                  		;dec	word [esi+10]	      ; scriptanz
   937                                  		dec	word [scriptanz]
   938                                  		jns	short sIwaitTimer
   939                                  		;mov	bx, [esi+8]	      ;	scriptptr
   940                                  		;movzx	ebx, word [esi+8]	
   941                                  		movzx	ebx, word [scriptptr]
   942                                  		mov	al, [ebx+script]
   943                                  		or	al, al
   944                                  		jz	_exit_
   945                                  		mov	bx, ax
   946                                  		and	bl, 7
   947                                  		;mov	[esi+12], bl	      ;	scriptins
   948                                  		mov	[scriptins], bl
   949                                  		dec	bl
   950                                  		jnz	short sInegateTurn
   951                                  		; (cmd = NEG ZSTEP)  
   952                                  		neg	word [zstep]
   953                                  sInegateTurn:
   954                                  		and	ax, 0F8h
   955                                  		add	ax, ax
   956                                  		;mov	[esi+10], ax	      ; scriptanz
   957                                  		mov	[scriptanz], ax
   958                                  		;inc	word [esi+8]	      ; scriptptr
   959                                  		inc	word [scriptptr]
   960                                  sIwaitTimer:
   961                                  		;mov	al, [esi+12]	      ;	scriptins
   962                                  		mov	al, [scriptins]
   963                                  		cbw
   964                                  		sub	ch, ch ; 23/01/2017
   965                                  		dec	ax
   966                                  		jnz	short sInoturn
   967                                  		; (cmd = NEG ZSTEP)  
   968                                  		mov	bx, [zstep]
   969                                  		;add	[esi+6], bx	      ; ozw
   970                                  		add	[ozw], bx
   971                                  		jmp	short sI_1 ; 23/01/2017	
   972                                  sInoturn:
   973                                  		mov	cl, 3
   974                                  sIrotateLoop:
   975                                  		dec	ax
   976                                  		jnz	short sInoIncrement
   977                                  		; (cmd = INC SPEED or INC XSTEP or INC YSTEP)  
   978                                  		inc	word [esi]	      ; zspeed, oxw, oyw
   979                                  		jmp	short sI_1 ; 23/01/2017	 	   	
   980                                  sInoIncrement:
   981                                  		dec	ax
   982                                  		jnz	short sInoDecrement
   983                                  		; (cmd = DEC SPEED or DEC XSTEP or DEC YSTEP)  
   984                                  		dec	word [esi]	      ; zspeed, oxw, oyw
   985                                  		jmp	short sI_1 ; 23/01/2017	 
   986                                  sInoDecrement:
   987                                  		inc	esi
   988                                  		inc	esi
   989                                  		loop	sIrotateLoop
   990                                  sI_1: 		; 23/01/2017
   991                                  		;mov	si, zspeed+2	      ; oxw 	
   992                                  		mov	si, oxw	
   993                                  		mov	cl, 3
   994                                  		; 11/08/2017 (16 bits pushes)
   995                                  		;xor	eax, eax
   996                                  sIpushloop:
   997                                  		lodsw			      ; oxw, oyw, ozw	
   998                                  		sar	ax, 2
   999                                  		push	ax ; 16 bits push !! (esp = esp - 2)
  1000                                  		loop	sIpushloop
  1001                                  
  1002                                  		imul	ax, word [si-4], 16   ; [oyw]*16 	
  1003                                  
  1004                                  		push	ax ; 16 bits push !! (esp = esp - 2)
  1005                                  
  1006                                  		; [esp] = [oyw]*16 ; angle or YSTEP * 16 ?		        	
  1007                                  		; [esp+2] = [ozw] ; ZSTEP
  1008                                  		; [esp+4] = [oyw] ; YSTEP
  1009                                  		; [esp+6] = [oxw] ; XSTEP
  1010                                  
  1011                                  		call	calcRotMat
  1012                                  
  1013                                  		mov	cl, 3
  1014                                  		xor	esi, esi
  1015                                  sImoveLoop:
  1016                                  		fld	dword [esi+owmat+24]
  1017                                  		fimul	word [zspeed]
  1018                                  		fidiv	word [CONST1792]
  1019                                  		fadd	dword [esi+ob]
  1020                                  		fstp	dword [esi+ob]
  1021                                  		add	si, 4
  1022                                  		loop	sImoveLoop
  1023                                  		pop	ecx
  1024                                  		;dec	cx
  1025                                  		dec	ecx ; 26/07/2017
  1026                                  		jnz	sImloop
  1027                                  sItickerNull:
  1028                                  %endmacro
  1029                                  
  1030                                  ;**************************************************
  1031                                  ;* description	: rotate all points from o -> rp  *
  1032                                  ;* parameter	: none                	          *
  1033                                  ;* sideeffect	: all		                  *
  1034                                  ;* back		: none		                  *
  1035                                  ;**************************************************
  1036                                  %macro		rotation 0
  1037                                  		; 26/07/2017
  1038                                  		;;mov	cx, [o+object.panz]
  1039                                  		;movzx	ecx, word [o+object.panz]
  1040                                  		movzx	ecx, word [object.panz]
  1041                                  		;mov	esi, o+object.p
  1042                                  		mov	esi, object.p
  1043                                  		mov	edi, rp
  1044                                  rotmlp:
  1045                                  		;mov	bx, wmat
  1046                                  		mov	ebx, wmat
  1047                                  		mov	dx, 3
  1048                                  rotilp:	
  1049                                  		fild	word [esi+0] ; point.x
  1050                                  		fsub	dword [ob+vector.x]
  1051                                  		fmul	dword [ebx+0]
  1052                                  		fild	word [esi+2] ; point.y
  1053                                  		fsub	dword [ob+vector.y]
  1054                                  		fmul	dword [ebx+4]
  1055                                  		fild	word [esi+4] ; point.z
  1056                                  		fsub	dword [ob+vector.z]
  1057                                  		fmul	dword [ebx+8]
  1058                                  		;fadd	
  1059                                  		;fadd
  1060                                  		faddp
  1061                                  		faddp
  1062                                  		fstp	dword [edi]
  1063                                  		add	di, 4
  1064                                  		;add	edi, 4
  1065                                  		add	bx, 12	; 0Ch
  1066                                  		dec	dx
  1067                                  		jnz	short rotilp
  1068                                  		add	si, 8 ; next point (29/01/2017)
  1069                                  		;add	esi, 8
  1070                                  		loop	rotmlp
  1071                                  %endmacro
  1072                                  
  1073                                  ;***********************************************
  1074                                  ;* description	: sort faces by z-koord	       *
  1075                                  ;* parameter	: none		               *
  1076                                  ;* sideeffect	: ax,bx,cx,dx,si,di,es         *
  1077                                  ;* back		: none		               *
  1078                                  ;***********************************************
  1079                                  %macro		sortFaces 0
  1080                                  		; 26/07/2017
  1081                                  		mov	dword [_es], 0 ; es = ds
  1082                                  
  1083                                  		mov	edi, facei
  1084                                  		push	edi ; facei
  1085                                  		;mov	esi, o+object.f
  1086                                  		;;mov	si, o+object.f
  1087                                  		mov	esi, object.f
  1088                                  		mov	eax, esi ; pointer to faces
  1089                                  		;;mov	cx, [o+object.fanz]
  1090                                  		;movzx	ecx, word [o+object.fanz]
  1091                                  		movzx	ecx, word [object.fanz]
  1092                                  
  1093                                  		xor	ebx, ebx
  1094                                  sFmloop:
  1095                                  		fldz
  1096                                  		push	ecx
  1097                                  		mov	cx, 4
  1098                                  sFiloop:
  1099                                  		imul	bx, word [esi], 12 ; number of points (of face)
  1100                                  		inc	esi
  1101                                  		inc	esi
  1102                                  		fsub	dword [ebx+rp+vector.z]
  1103                                  		loop	sFiloop
  1104                                  		pop	ecx
  1105                                  		fistp	word [edi] ; z distance (face total) (29/01/2017) 
  1106                                  		inc	edi
  1107                                  		inc	edi
  1108                                  		;stosw		; face address (in 'o+object.f')
  1109                                  		stosw		; face address (in 'object.f')
  1110                                  		add	ax, 10
  1111                                  		inc	esi
  1112                                  		inc	esi
  1113                                  		loop	sFmloop
  1114                                  		;push	edi	; facei+4*(o+object.fanz-1)
  1115                                  		push	edi	; facei+4*(object.fanz-1)
  1116                                  		call	qsort
  1117                                  %endmacro
  1118                                  
  1119                                  ;***********************************************
  1120                                  ;* description	: animate the door  	       *
  1121                                  ;* parameter	: none		               *
  1122                                  ;* sideeffect	: ax,cx,si,di,es               *
  1123                                  ;* back		: none		               *
  1124                                  ;***********************************************
  1125                                  %macro		animDoor 0
  1126                                  		; 12/08/2017
  1127                                  		; 26/07/2017
  1128                                  		;mov	ax, [doortimer]
  1129                                  		movzx	eax, word [doortimer]
  1130                                  		or	ax, ax
  1131                                  		jns	short aDnounder
  1132                                  		xor	ax, ax
  1133                                  		jmp	short alreadydrawed
  1134                                  aDnounder:
  1135                                  		cmp	byte [once], 0
  1136                                  		jne	short alreadydrawed
  1137                                  		inc	byte [once]
  1138                                  		push	eax
  1139                                  		starbackground
  1140                                  		pop	eax
  1141                                  alreadydrawed:
  1142                                  		cmp	ax, 24
  1143                                  		jle	short aDnoover
  1144                                  		mov	ax, 24
  1145                                  aDnoover:
  1146                                  		shl	ax, 6
  1147                                  		; 26/07/2017
  1148                                  		;push	dword [_ds]
  1149                                  		movzx	ebp, word [tseg+26]
  1150                                  		shl	ebp, 4
  1151                                  		mov	[_es], ebp
  1152                                  		movzx	ebx, word [tseg+30]
  1153                                  		shl	ebx, 4
  1154                                  		mov	[_ds], ebx
  1155                                  		mov	esi, ebx
  1156                                  		;add	si, ax ; 16/01/2017
  1157                                  		add	esi, eax
  1158                                  		mov	edi, ebp
  1159                                  		;mov	cx, 1024
  1160                                  		mov	ecx, 1024
  1161                                  		rep movsw
  1162                                  		mov	esi, 2048
  1163                                  		sub	si, ax
  1164                                  		push	esi
  1165                                  		add	esi, ebx ; 12/08/2017 
  1166                                  		mov	ch, 4  ; cx = 1024
  1167                                  		rep movsw
  1168                                  		pop	edi
  1169                                  		add	edi, ebp
  1170                                  		mov	cx, ax
  1171                                  		xor	eax, eax ; 0
  1172                                  		rep stosw
  1173                                  		;pop	dword [_ds]
  1174                                  		mov	[_ds], eax ; ds = cs
  1175                                  %endmacro
  1176                                  
  1177                                  ;***********************************************
  1178                                  ;* description	: play a tick of the song      *
  1179                                  ;* parameter	: none                	       *
  1180                                  ;* sideeffect	: ax,bx,cx,dx,si	       *
  1181                                  ;* back		: none                	       *
  1182                                  ;***********************************************
  1183                                  %macro		playsong 0
  1184                                  		;mov	cx, [tracks]
  1185                                  		movzx	ecx, word [tracks] 
  1186                                  		;mov	si, channels
  1187                                  		mov	esi, channels
  1188                                  PSmloop:
  1189                                  		dec	word [esi+channel.del]
  1190                                  		jg	short PSdelayed
  1191                                  		mov	ax, [esi+channel.trk]
  1192                                  		add	al, CMD_NOTEOFF	; 80h
  1193                                  		call	setnote
  1194                                  		;mov	bx, [esi+channel.adr]
  1195                                  		movzx	ebx, word [esi+channel.adr]
  1196                                  		mov	ah, 127 	; 7Fh
  1197                                  		cmp	byte [ebx], 0
  1198                                  		jz	short PStrackend
  1199                                  		mov	ah, [ebx]
  1200                                  		mov	[esi+channel.ln], ah
  1201                                  		mov	al, [esi+channel.trk]
  1202                                  		add	al, CMD_NOTEON	; 90h
  1203                                  		call	setnote
  1204                                  		mov	al, [ebx+1]
  1205                                  		mov	bl, SONGSPEED	; 1Dh
  1206                                  		mul	bl
  1207                                  PStrackend:
  1208                                  		mov	[esi+channel.del], ax
  1209                                  		add	word [esi+channel.adr], 2
  1210                                  PSdelayed:
  1211                                  		add	si, 6
  1212                                  		loop	PSmloop
  1213                                  PSnosound:
  1214                                  %endmacro
  1215                                  
  1216                                  ;***********************************************
  1217                                  ;* description	: dump palette to CRT	       *
  1218                                  ;* parameter	: bl:intensity (0..255)	       *
  1219                                  ;* sideeffect	: ax,es,di,cx,dx               *
  1220                                  ;* back		: none		               *
  1221                                  ;***********************************************
  1222                                  %macro		setPalette2 0
  1223                                  		xor	al, al
  1224                                  		mov	dx, 3C8h
  1225                                  		;out	dx, al
  1226                                  		
  1227                                  		mov 	ah, 1 ; out (byte)
  1228                                  		int	34h ; TRDOS 386 - IOCTL interrupt
  1229                                  		
  1230                                  		inc	dx
  1231                                  		mov	esi, palette
  1232                                  		;mov	cx, 768 ; 300h
  1233                                  		mov	ecx, 768
  1234                                  _sp2loop:
  1235                                  		;rep outsb
  1236                                  		
  1237                                  		lodsb	
  1238                                  		;mov 	ah, 1 ; out (byte)
  1239                                  		;mov 	dx, 3C9h
  1240                                  		;out 	dx, al
  1241                                  		int	34h ; TRDOS 386 - IOCTL interrupt
  1242                                  		loop	_sp2loop
  1243                                  %endmacro
  1244                                  
  1245                                  ;***********************************************
  1246                                  ;* description	: clear starbackground         *
  1247                                  ;* parameter	: none		               *
  1248                                  ;* sideeffect	: ax,es,di,cx,dx               *
  1249                                  ;* back		: none		               *
  1250                                  ;***********************************************
  1251                                  %macro		cls 0
  1252                                  		; 26/07/2017
  1253                                  		movzx	edi, word [bseg]
  1254                                  		shl	edi, 4
  1255                                  		mov	[_es], edi 
  1256                                  		;
  1257                                  		mov	esi, 0A0000h + (320*5) ; 0A0640h
  1258                                  		;mov	cx, 32000 ; 7D00h
  1259                                  		mov	ecx, 32000 ;
  1260                                  clsloop:
  1261                                  		lodsb
  1262                                  		stosb
  1263                                  		stosb
  1264                                  		loop	clsloop
  1265                                  %endmacro
  1266                                  
  1267                                  ;***********************************************
  1268                                  ;* description	: draw starbackground	       *
  1269                                  ;* parameter	: none		               *
  1270                                  ;* sideeffect	: ax,es,di,cx,dx	       *
  1271                                  ;* back		: none		               *
  1272                                  ;***********************************************
  1273                                  %macro		starbackground 0
  1274                                  		; 26/07/2017
  1275                                  		movzx	ebp, word [bseg]
  1276                                  		shl	ebp, 4
  1277                                  		mov	[_es], ebp
  1278                                  
  1279                                  		;mov	cx, 100 ; 64h
  1280                                  		mov	ecx, 100
  1281                                  starbackloop:
  1282                                  		push	ecx
  1283                                  		mov	bx, 320*155 ; 0C1C0h
  1284                                  		;mov	ebx, 320*155
  1285                                  		call	rnd
  1286                                  		add	ax, 320*20  ; 1900h
  1287                                  		; 05/02/2017
  1288                                  		movzx	edi, ax
  1289                                  		and	ah, 7
  1290                                  		;mov	dx, 320-5   ; 13Bh
  1291                                  		mov	edx, 320-5 ; ?? 
  1292                                  		mov	cx, 2
  1293                                  		; 26/07/2017
  1294                                  		;ebp = [_es]
  1295                                  		call	setstarbob
  1296                                  		pop	ecx
  1297                                  		loop	starbackloop
  1298                                  %endmacro
  1299                                  
  1300                                  ;***********************************************
  1301                                  ;* description	: create identity matrix       *
  1302                                  ;* parameter	: ds:di address                *
  1303                                  ;* sideeffect	: cx,di		   	       *
  1304                                  ;* back		: none			       *
  1305                                  ;***********************************************
  1306                                  %macro		identityMat 0
  1307                                  		; 11/08/2017
  1308                                  		; nwmat:
  1309                                  		; dd 1,0,0,0,1,0,0,0,1 
  1310                                  		mov	ch, 2
  1311                                  iMolp:
  1312                                  		mov	cl, 2
  1313                                  iMilp:
  1314                                  		fldz
  1315                                  		cmp	ch, cl
  1316                                  		jne	short iMwritezero
  1317                                  		fstp	st0
  1318                                  		fld1
  1319                                  iMwritezero:
  1320                                  		fstp	dword [edi]
  1321                                  		;add	di, 4
  1322                                  		add	edi, 4 ; 26/07/2017
  1323                                  		dec	cl
  1324                                  		jns	short iMilp
  1325                                  		dec	ch
  1326                                  		jns	short iMolp
  1327                                  %endmacro
  1328                                  
  1329                                  ;=============================================================================
  1330                                  ;               entry point
  1331                                  ;=============================================================================
  1332                                  ;***********************************************
  1333                                  ;* description	: entry point		       *
  1334                                  ;* parameter	: none		               *
  1335                                  ;* sideeffect	: all		               *
  1336                                  ;* back		: none		               *
  1337                                  ;***********************************************
  1338                                  
  1339                                  [ORG 0] 
  1340                                  
  1341                                  start:
  1342                                  		; DIRECT VGA MEMORY ACCESS
  1343                                  		;xor	ebx, ebx
  1344 00000000 B705                    		mov	bh, 5 ; Direct access/map to VGA memory (0A0000h)
  1345                                  		;mov	eax, _video ; 1Fh
  1346 00000002 66B81F00                		mov	ax, 1Fh ; sys _video ; TRDOS 386 Video functions
  1347 00000006 CD40                    		int	40h   ; TRDOS 386 system call
  1348                                  
  1349                                  		; eax = 0A0000h
  1350 00000008 21C0                    		and	eax, eax
  1351 0000000A 0F84BE060000            		jz      terminate ; error (eax = 0)
  1352                                  
  1353                                  		; clear bss (18/12/2016)
  1354                                  		;mov	edi, bss_start ;
  1355 00000010 66BF[5A18]              		mov	di, bss_start
  1356 00000014 66B99332                		mov	cx, (bss_end - bss_start)/4
  1357                                  		;mov	ecx, (bss_end - bss_start)/4
  1358 00000018 31C0                    		xor	eax, eax
  1359 0000001A F3AB                    		rep	stosd
  1360                                  
  1361                                  			; 26/07/2017
  1362                                  		;mov	edi, vseg ;
  1363 0000001C 66BF[DC38]              		mov	di, vseg
  1364 00000020 66B80010                		mov	ax, 1000h
  1365 00000024 66AB                    		stosw	; vseg		; virtual screen address
  1366 00000026 66050010                		add	ax, 1000h
  1367 0000002A 66AB                    		stosw	; bseg		; star background address
  1368 0000002C 66050010                		add	ax, 1000h
  1369 00000030 66B91400                		mov	cx, 20
  1370                                  segloop:				; texture addresses
  1371 00000034 66AB                    		stosw	; tseg +
  1372                                  		;add	ax, 100h
  1373 00000036 FEC4                    		inc	ah
  1374 00000038 E2FA                    		loop	segloop
  1375                                  
  1376                                  		; 09/04/2017
  1377 0000003A 29C0                    		sub	eax, eax
  1378 0000003C BF00000100              		mov	edi, 10000h
  1379 00000041 B900D00000              		mov	ecx, (65536+65536+(20*4096))/4
  1380 00000046 F3AB                    		rep	stosd 
  1381                                  
  1382                                  		; 22/01/2017
  1383 00000048 DBE3                    		fninit
  1384                                  
  1385                                  		;nullData
  1386                                  		resetGM
  1387 0000004A 66BA3103            <1>  mov dx, GMPort
  1388 0000004E B0FF                <1>  mov al, 0FFh
  1389                              <1> 
  1390                              <1> 
  1391 00000050 B401                <1>  mov ah, 1
  1392 00000052 CD34                <1>  int 34h
  1393                              <1> 
  1394 00000054 FECC                <1>  dec ah
  1395                              <1> 
  1396                              <1> resGMbusy1:
  1397 00000056 FEC9                <1>  dec cl
  1398 00000058 741C                <1>  jz short rGMerror
  1399                              <1> 
  1400                              <1> 
  1401                              <1> 
  1402 0000005A CD34                <1>  int 34h
  1403                              <1> 
  1404 0000005C A880                <1>  test al, 80h
  1405 0000005E 75F6                <1>  jnz short resGMbusy1
  1406 00000060 664A                <1>  dec dx
  1407                              <1> 
  1408                              <1> 
  1409                              <1> 
  1410 00000062 CD34                <1>  int 34h
  1411                              <1> 
  1412 00000064 3CFE                <1>  cmp al, 0FEh
  1413 00000066 750E                <1>  jne short rGMerror
  1414 00000068 6642                <1>  inc dx
  1415                              <1> resGMbusy2:
  1416                              <1> 
  1417                              <1> 
  1418                              <1> 
  1419 0000006A CD34                <1>  int 34h
  1420                              <1> 
  1421 0000006C A840                <1>  test al, 40h
  1422 0000006E 75FA                <1>  jnz short resGMbusy2
  1423 00000070 B03F                <1>  mov al, 3Fh
  1424                              <1> 
  1425                              <1> 
  1426                              <1> 
  1427 00000072 FEC4                <1>  inc ah
  1428 00000074 CD34                <1>  int 34h
  1429                              <1> rGMerror:
  1430                                  		expandSong
  1431 00000076 BE[90120000]        <1>  mov esi, credits
  1432 0000007B BB[B61B0000]        <1>  mov ebx, channels
  1433 00000080 BF[90540000]        <1>  mov edi, songdata
  1434 00000085 66AD                <1> EPSwhile: lodsw
  1435 00000087 FEC8                <1>  dec al
  1436 00000089 7823                <1>  js short EPSendwhile
  1437 0000008B 884302              <1>  mov [ebx+channel.trk], al
  1438 0000008E 04C0                <1>  add al, CMD_CHANGEPRG
  1439 00000090 E811080000          <1>  call setinstr
  1440 00000095 66897B04            <1>  mov [ebx+channel.adr], di
  1441 00000099 E84B070000          <1>  call expand
  1442 0000009E 30C0                <1>  xor al, al
  1443 000000A0 AA                  <1>  stosb
  1444 000000A1 6683C306            <1>  add bx, 6
  1445 000000A5 66FF05[B4180000]    <1>  inc word [tracks]
  1446 000000AC EBD7                <1>  jmp short EPSwhile
  1447                              <1> EPSendwhile:
  1448                                  
  1449 000000AE E8DC0F0000              		call	createWorld
  1450                                  
  1451                                  		set320x200
  1452 000000B3 66B81300            <1>  mov ax, 13h
  1453                              <1> 
  1454                              <1> 
  1455 000000B7 CD31                <1>  int 31h
  1456                                  
  1457 000000B9 86E0                    		xchg	ah, al 		; ah = write string = 13h, 
  1458                                  					; al = write mode = 0
  1459 000000BB 66BB1C00                		mov	bx, 1Ch
  1460 000000BF BD[11180000]            		mov	ebp, omniscent
  1461 000000C4 66B90900                		mov	cx, omniend-omniscent ; 9
  1462 000000C8 66BA0601                		mov	dx, 106h
  1463                                  		;int	10h		; - VIDEO - WRITE STRING (AT,XT286,PS,EGA,VGA)
  1464                                  					; AL = mode, BL	= attribute if AL bit 1	clear, BH = display page number
  1465                                  					; DH,DL	= row,column of	starting cursor	position, CX = length of string
  1466                                  					; ES:BP	-> start of string
  1467 000000CC CD31                    		int	31h ; TRDOS 386 - Video interrupt
  1468                                  
  1469 000000CE 6601CD                  		add	bp, cx
  1470 000000D1 B110                    		mov	cl, sancend-sanction ; 11h
  1471 000000D3 66BA010C                		mov	dx, 0C01h
  1472                                  		;int	10h		; - VIDEO - WRITE STRING (AT,XT286,PS,EGA,VGA)
  1473                                  					; AL = mode, BL	= attribute if AL bit 1	clear, BH = display page number
  1474                                  					; DH,DL	= row,column of	starting cursor	position, CX = length of string
  1475                                  					; ES:BP	-> start of string
  1476 000000D7 CD31                    		int	31h ; TRDOS 386 - Video interrupt
  1477                                  
  1478                                  		makePalette
  1479                              <1> 
  1480 000000D9 BB03000000          <1>  mov ebx, 3
  1481                              <1> mPcolor:
  1482                              <1> 
  1483 000000DE BE[D5130000]        <1>  mov esi, colors
  1484 000000E3 BF[B6180000]        <1>  mov edi, palette
  1485 000000E8 30F6                <1>  xor dh, dh
  1486 000000EA AC                  <1>  lodsb
  1487                              <1> 
  1488 000000EB 0FB6C8              <1>  movzx ecx, al
  1489                              <1> mPouter:
  1490 000000EE 51                  <1>  push ecx
  1491 000000EF 8A0E                <1>  mov cl, [esi]
  1492 000000F1 8A2433              <1>  mov ah, [ebx+esi]
  1493 000000F4 6629D0              <1>  sub ax, dx
  1494 000000F7 52                  <1>  push edx
  1495 000000F8 6699                <1>  cwd
  1496 000000FA 66F7F9              <1>  idiv cx
  1497 000000FD 5A                  <1>  pop edx
  1498                              <1> mPinner:
  1499 000000FE 6601C2              <1>  add dx, ax
  1500 00000101 88741FFF            <1>  mov [edi+ebx-1], dh
  1501 00000105 6683C703            <1>  add di, 3
  1502 00000109 E2F3                <1>  loop mPinner
  1503 0000010B 6683C604            <1>  add si, 4
  1504 0000010F 59                  <1>  pop ecx
  1505 00000110 E2DC                <1>  loop mPouter
  1506 00000112 664B                <1>  dec bx
  1507 00000114 75C8                <1>  jnz short mPcolor
  1508                                  		
  1509                                  		initTextures
  1510                              <1> 
  1511                              <1> 
  1512 00000116 BB22000000          <1>  mov ebx, 34
  1513 0000011B 6820030000          <1>  push 800
  1514 00000120 6A05                <1>  push 5
  1515 00000122 E89C070000          <1>  call createFrac1
  1516                              <1> 
  1517 00000127 BB20000000          <1>  mov ebx, 32
  1518 0000012C 6A70                <1>  push 112
  1519 0000012E 6A0F                <1>  push 15
  1520 00000130 E88E070000          <1>  call createFrac1
  1521                              <1>  createFrac2
  1522                              <2> 
  1523                              <2> 
  1524 00000135 0FB72D[04390000]    <2>  movzx ebp, word [tseg+36]
  1525 0000013C C1E504              <2>  shl ebp, 4
  1526 0000013F 892D[EC530000]      <2>  mov [_es], ebp
  1527 00000145 B014                <2>  mov al, 20
  1528 00000147 E869070000          <2>  call setFrac
  1529 0000014C BF40000000          <2>  mov edi, 64
  1530                              <2> 
  1531 00000151 66B9C00F            <2>  mov cx, 4096-64
  1532 00000155 BB04000000          <2>  mov ebx, 4
  1533                              <2> cF1loop:
  1534                              <2> 
  1535 0000015A E8F1060000          <2>  call rnd
  1536                              <2> 
  1537                              <2> 
  1538                              <2> 
  1539                              <2> 
  1540 0000015F 02443DC0            <2>  add al, [ebp+edi-64]
  1541 00000163 02443DC1            <2>  add al, [ebp+edi-63]
  1542 00000167 6648                <2>  dec ax
  1543 00000169 66D1E8              <2>  shr ax, 1
  1544                              <2> 
  1545                              <2> 
  1546 0000016C 88443D00            <2>  mov [ebp+edi], al
  1547 00000170 47                  <2>  inc edi
  1548 00000171 E2E7                <2>  loop cF1loop
  1549                              <1>  createFrac3
  1550                              <2> 
  1551 00000173 0FB72D[06390000]    <2>  movzx ebp, word [tseg+38]
  1552 0000017A C1E504              <2>  shl ebp, 4
  1553 0000017D 892D[EC530000]      <2>  mov [_es], ebp
  1554 00000183 B003                <2>  mov al, 3
  1555 00000185 E82B070000          <2>  call setFrac
  1556                              <2> 
  1557 0000018A 66B90010            <2>  mov cx, 4096
  1558 0000018E 89CB                <2>  mov ebx, ecx
  1559                              <2> cF3loop:
  1560                              <2> 
  1561 00000190 E8BB060000          <2>  call rnd
  1562 00000195 0FB7F8              <2>  movzx edi, ax
  1563 00000198 FE443D00            <2>  inc byte [ebp+edi]
  1564 0000019C E2F2                <2>  loop cF3loop
  1565                              <1>  initStars
  1566                              <2> 
  1567                              <2> 
  1568                              <2> 
  1569 0000019E B11E                <2>  mov cl, 30
  1570 000001A0 BF[80380000]        <2>  mov edi, stars
  1571 000001A5 31DB                <2>  xor ebx, ebx
  1572 000001A7 891D[EC530000]      <2>  mov [_es], ebx
  1573                              <2> iSloop:
  1574 000001AD 66BB0001            <2>  mov bx, 256
  1575 000001B1 E89A060000          <2>  call rnd
  1576 000001B6 AA                  <2>  stosb
  1577 000001B7 66BBC00E            <2>  mov bx, 4096-(64*5)
  1578 000001BB 6681C38000          <2>  add bx, 128
  1579 000001C0 E88B060000          <2>  call rnd
  1580 000001C5 6683C040            <2>  add ax, 64
  1581 000001C9 66AB                <2>  stosw
  1582 000001CB E2E0                <2>  loop iSloop
  1583                              <1>  reactorWall
  1584                              <2> 
  1585 000001CD 0FB72D[E0380000]    <2>  movzx ebp, word [tseg]
  1586 000001D4 C1E504              <2>  shl ebp, 4
  1587 000001D7 892D[EC530000]      <2>  mov [_es], ebp
  1588 000001DD 31FF                <2>  xor edi, edi
  1589 000001DF B900100000          <2>  mov ecx, 4096
  1590                              <2> rsmloop:
  1591 000001E4 89F8                <2>  mov eax, edi
  1592 000001E6 A808                <2>  test al, 8
  1593 000001E8 7E02                <2>  jle short rsnonot1
  1594 000001EA F6D0                <2>  not al
  1595                              <2> rsnonot1:
  1596 000001EC 240F                <2>  and al, 15
  1597 000001EE 89C3                <2>  mov ebx, eax
  1598 000001F0 89F8                <2>  mov eax, edi
  1599 000001F2 66C1E806            <2>  shr ax, 6
  1600 000001F6 A808                <2>  test al, 8
  1601 000001F8 7E02                <2>  jle short rsnonot2
  1602 000001FA F6D0                <2>  not al
  1603                              <2> rsnonot2:
  1604 000001FC 240F                <2>  and al, 15
  1605 000001FE 38D8                <2>  cmp al, bl
  1606 00000200 7E02                <2>  jle short rstakeal
  1607 00000202 89D8                <2>  mov eax, ebx
  1608                              <2> rstakeal:
  1609 00000204 04E0                <2>  add al, 224
  1610 00000206 01EF                <2>  add edi, ebp
  1611 00000208 AA                  <2>  stosb
  1612 00000209 29EF                <2>  sub edi, ebp
  1613 0000020B E2D7                <2>  loop rsmloop
  1614                              <1>  addFractals
  1615                              <2> 
  1616                              <2> 
  1617 0000020D BE[B2140000]        <2>  mov esi, aF
  1618 00000212 B204                <2>  mov dl, 4
  1619                              <2> aFloop:
  1620 00000214 0FB6DA              <2>  movzx ebx, dl
  1621 00000217 0FB7AB[E0380000]    <2>  movzx ebp, word [ebx+tseg]
  1622 0000021E C1E504              <2>  shl ebp, 4
  1623 00000221 892D[EC530000]      <2>  mov [_es], ebp
  1624 00000227 31FF                <2>  xor edi, edi
  1625 00000229 66AD                <2>  lodsw
  1626 0000022B 88C3                <2>  mov bl, al
  1627                              <2> 
  1628 0000022D 0FB7AB[E0380000]    <2>  movzx ebp, word [ebx+tseg]
  1629 00000234 C1E504              <2>  shl ebp, 4
  1630 00000237 892D[F0530000]      <2>  mov [_fs], ebp
  1631                              <2> 
  1632 0000023D 66B90010            <2>  mov cx, 4096
  1633                              <2> 
  1634 00000241 8B1D[EC530000]      <2>  mov ebx, [_es]
  1635                              <2> aFiloop:
  1636 00000247 8A443D00            <2>  mov al, [ebp+edi]
  1637 0000024B 00E0                <2>  add al, ah
  1638                              <2> 
  1639 0000024D 88043B              <2>  mov [ebx+edi], al
  1640 00000250 47                  <2>  inc edi
  1641 00000251 E2F4                <2>  loop aFiloop
  1642                              <2> 
  1643 00000253 FEC2                <2>  inc dl
  1644 00000255 FEC2                <2>  inc dl
  1645 00000257 80FA1E              <2>  cmp dl, 30
  1646 0000025A 7EB8                <2>  jle short aFloop
  1647                              <1>  effects
  1648                              <2> 
  1649                              <2> 
  1650                              <2> 
  1651                              <2> 
  1652 0000025C B11A                <2>  mov cl, 26
  1653 0000025E BE[16140000]        <2>  mov esi, aE
  1654                              <2> 
  1655 00000263 31DB                <2>  xor ebx, ebx
  1656 00000265 31FF                <2>  xor edi, edi
  1657                              <2> effmloop:
  1658 00000267 51                  <2>  push ecx
  1659 00000268 8A1E                <2>  mov bl, [esi]
  1660 0000026A 88DA                <2>  mov dl, bl
  1661 0000026C C0EA04              <2>  shr dl, 4
  1662 0000026F 80E30F              <2>  and bl, 0Fh
  1663                              <2> 
  1664 00000272 D0E3                <2>  shl bl, 1
  1665                              <2> 
  1666 00000274 0FB7AB[E0380000]    <2>  movzx ebp, word [ebx+tseg]
  1667 0000027B C1E504              <2>  shl ebp, 4
  1668 0000027E 892D[EC530000]      <2>  mov [_es], ebp
  1669                              <2> 
  1670 00000284 0FB64E02            <2>  movzx ecx, byte [esi+2]
  1671                              <2> effyloop:
  1672 00000288 0FB65E01            <2>  movzx ebx, byte [esi+1]
  1673                              <2> effxloop:
  1674 0000028C 89CF                <2>  mov edi, ecx
  1675 0000028E 66C1E706            <2>  shl di, 6
  1676                              <2> 
  1677 00000292 01DF                <2>  add edi, ebx
  1678 00000294 88D0                <2>  mov al, dl
  1679 00000296 FEC8                <2>  dec al
  1680 00000298 7414                <2>  jz short effect1
  1681 0000029A FEC8                <2>  dec al
  1682 0000029C 740C                <2>  jz short effect2
  1683                              <2> 
  1684 0000029E 89D8                <2>  mov eax, ebx
  1685                              <2> 
  1686 000002A0 01C8                <2>  add eax, ecx
  1687 000002A2 2404                <2>  and al, 4
  1688                              <2> 
  1689 000002A4 7408                <2>  jz short effect1
  1690 000002A6 B098                <2>  mov al, 152
  1691                              <2> effdonot:
  1692 000002A8 EB04                <2>  jmp short effect1
  1693                              <2> effect2:
  1694 000002AA 8A443D00            <2>  mov al, [ebp+edi]
  1695                              <2> effect1:
  1696 000002AE 024605              <2>  add al, [esi+5]
  1697 000002B1 88443D00            <2>  mov [ebp+edi], al
  1698 000002B5 FEC3                <2>  inc bl
  1699 000002B7 3A5E03              <2>  cmp bl, [esi+3]
  1700 000002BA 7ED0                <2>  jle short effxloop
  1701                              <2> 
  1702 000002BC FEC1                <2>  inc cl
  1703 000002BE 3A4E04              <2>  cmp cl, [esi+4]
  1704 000002C1 7EC5                <2>  jle short effyloop
  1705 000002C3 6683C606            <2>  add si, 6
  1706 000002C7 59                  <2>  pop ecx
  1707 000002C8 E29D                <2>  loop effmloop
  1708                              <1>  addLava
  1709                              <2> 
  1710                              <2> 
  1711 000002CA 0FB72D[F6380000]    <2>  movzx ebp, word [tseg+22]
  1712 000002D1 C1E504              <2>  shl ebp, 4
  1713 000002D4 892D[EC530000]      <2>  mov [_es], ebp
  1714                              <2> 
  1715 000002DA BFFF0F0000          <2>  mov edi, 4095
  1716                              <2> 
  1717                              <2> 
  1718 000002DF B114                <2>  mov cl, 20
  1719                              <2> 
  1720 000002E1 B85E000000          <2>  mov eax, 94
  1721                              <2> aLyloop:
  1722 000002E6 51                  <2>  push ecx
  1723 000002E7 66C1E103            <2>  shl cx, 3
  1724                              <2> aLxloop:
  1725 000002EB 57                  <2>  push edi
  1726 000002EC 50                  <2>  push eax
  1727                              <2> 
  1728 000002ED BB40000000          <2>  mov ebx, 64
  1729 000002F2 E859050000          <2>  call rnd
  1730 000002F7 6629C7              <2>  sub di, ax
  1731                              <2> 
  1732 000002FA 58                  <2>  pop eax
  1733 000002FB 88443D00            <2>  mov [ebp+edi], al
  1734 000002FF 5F                  <2>  pop edi
  1735 00000300 E2E9                <2>  loop aLxloop
  1736 00000302 59                  <2>  pop ecx
  1737 00000303 FEC8                <2>  dec al
  1738 00000305 6683EF40            <2>  sub di, 64
  1739 00000309 E2DB                <2>  loop aLyloop
  1740                                  
  1741                                  		calcShadeTab
  1742                              <1> 
  1743 0000030B C705[EC530000]0000- <1>  mov dword [_es], 0
  1744 00000313 0000                <1>
  1745                              <1> 
  1746 00000315 BF[A8620000]        <1>  mov edi, shadetab
  1747 0000031A 30DB                <1>  xor bl, bl
  1748                              <1> cSolp:
  1749 0000031C FEC3                <1>  inc bl
  1750                              <1> 
  1751 0000031E 31C9                <1>  xor ecx, ecx
  1752                              <1> cSilp1:
  1753 00000320 88C8                <1>  mov al, cl
  1754 00000322 241F                <1>  and al, 31
  1755 00000324 F6E3                <1>  mul bl
  1756 00000326 6601C0              <1>  add ax, ax
  1757 00000329 88C8                <1>  mov al, cl
  1758 0000032B 24E0                <1>  and al, 224
  1759 0000032D 00E0                <1>  add al, ah
  1760 0000032F AA                  <1>  stosb
  1761 00000330 FEC1                <1>  inc cl
  1762 00000332 80F9C0              <1>  cmp cl, 192
  1763 00000335 75E9                <1>  jne short cSilp1
  1764                              <1> cSilp2:
  1765 00000337 88C8                <1>  mov al, cl
  1766 00000339 AA                  <1>  stosb
  1767 0000033A FEC1                <1>  inc cl
  1768 0000033C 75F9                <1>  jnz short cSilp2
  1769 0000033E 80FB80              <1>  cmp bl, 128
  1770 00000341 75D9                <1>  jne short cSolp
  1771                                  
  1772 00000343 8925[3C380000]          		mov	[oldstack], esp
  1773                                  
  1774                                  		startTimer
  1775                              <1> 
  1776                              <1> 
  1777                              <1> 
  1778                              <1> 
  1779                              <1> 
  1780                              <1> 
  1781                              <1> 
  1782                              <1> 
  1783 00000349 66BB510D            <1>  mov bx, 3409
  1784 0000034D E813050000          <1>  call setTimer
  1785                              <1> 
  1786                              <1> 
  1787 00000352 BB00840000          <1>  mov ebx, 8400h
  1788 00000357 B901000000          <1>  mov ecx, 1
  1789 0000035C BA[D7060000]        <1>  mov edx, timer_callback
  1790 00000361 B821000000          <1>  mov eax, 33
  1791 00000366 CD40                <1>  int 40h
  1792 00000368 0F8215030000        <1>  jc loc_err_exit
  1793                              <1> 
  1794 0000036E A2[DB380000]        <1>  mov [timer_event_number], al
  1795                                  		startKBDHandler
  1796                              <1> 
  1797                              <1> 
  1798                              <1> 
  1799                              <1> 
  1800                              <1> 
  1801                              <1> 
  1802                              <1> 
  1803                              <1> 
  1804                              <1> 
  1805                              <1> 
  1806                              <1> 
  1807                              <1> 
  1808 00000373 90                  <1>  nop
  1809                                  		cls
  1810                              <1> 
  1811 00000374 0FB73D[DE380000]    <1>  movzx edi, word [bseg]
  1812 0000037B C1E704              <1>  shl edi, 4
  1813 0000037E 893D[EC530000]      <1>  mov [_es], edi
  1814                              <1> 
  1815 00000384 BE40060A00          <1>  mov esi, 0A0000h + (320*5)
  1816                              <1> 
  1817 00000389 B9007D0000          <1>  mov ecx, 32000
  1818                              <1> clsloop:
  1819 0000038E AC                  <1>  lodsb
  1820 0000038F AA                  <1>  stosb
  1821 00000390 AA                  <1>  stosb
  1822 00000391 E2FB                <1>  loop clsloop
  1823                                  mainloop:
  1824                                  		; 12/08/2017
  1825 00000393 803D[A5620000]00        		cmp	byte [tstatus], 0
  1826 0000039A 0F87D9020000            		ja	_check_kbdb
  1827                                  
  1828 000003A0 C605[A5620000]01        		mov	byte [tstatus], 1
  1829                                  
  1830                                  		; 26/07/2017
  1831                                  		;mov	ah, 1	; Check keyboard buffer
  1832                                  		;;int	16h	; Keyboard interrupt
  1833                                  		;int	32h	; TRDOS 386 - Jeyboard interrupt
  1834                                  		;jnz	_exit_  ; exit
  1835                                  
  1836                                  		setPalette2
  1837 000003A7 30C0                <1>  xor al, al
  1838 000003A9 66BAC803            <1>  mov dx, 3C8h
  1839                              <1> 
  1840                              <1> 
  1841 000003AD B401                <1>  mov ah, 1
  1842 000003AF CD34                <1>  int 34h
  1843                              <1> 
  1844 000003B1 6642                <1>  inc dx
  1845 000003B3 BE[B6180000]        <1>  mov esi, palette
  1846                              <1> 
  1847 000003B8 B900030000          <1>  mov ecx, 768
  1848                              <1> _sp2loop:
  1849                              <1> 
  1850                              <1> 
  1851 000003BD AC                  <1>  lodsb
  1852                              <1> 
  1853                              <1> 
  1854                              <1> 
  1855 000003BE CD34                <1>  int 34h
  1856 000003C0 E2FB                <1>  loop _sp2loop
  1857                                  
  1858                                  		scriptIt
  1859                              <1> 
  1860                              <1> 
  1861                              <1> 
  1862                              <1> 
  1863 000003C2 0FB70D[B2180000]    <1>  movzx ecx, word [ticker]
  1864 000003C9 66C705[B2180000]00- <1>  mov word [ticker], 0
  1865 000003D1 00                  <1>
  1866 000003D2 6609C9              <1>  or cx, cx
  1867 000003D5 0F84D1000000        <1>  jz sItickerNull
  1868                              <1> sImloop:
  1869 000003DB 51                  <1>  push ecx
  1870 000003DC BE[A4180000]        <1>  mov esi, zspeed
  1871                              <1> 
  1872                              <1> 
  1873 000003E1 66FF0D[AE180000]    <1>  dec word [scriptanz]
  1874 000003E8 7940                <1>  jns short sIwaitTimer
  1875                              <1> 
  1876                              <1> 
  1877 000003EA 0FB71D[AC180000]    <1>  movzx ebx, word [scriptptr]
  1878 000003F1 8A83[90170000]      <1>  mov al, [ebx+script]
  1879 000003F7 08C0                <1>  or al, al
  1880 000003F9 0F8484020000        <1>  jz _exit_
  1881 000003FF 6689C3              <1>  mov bx, ax
  1882 00000402 80E307              <1>  and bl, 7
  1883                              <1> 
  1884 00000405 881D[B0180000]      <1>  mov [scriptins], bl
  1885 0000040B FECB                <1>  dec bl
  1886 0000040D 7507                <1>  jnz short sInegateTurn
  1887                              <1> 
  1888 0000040F 66F71D[0D180000]    <1>  neg word [zstep]
  1889                              <1> sInegateTurn:
  1890 00000416 6625F800            <1>  and ax, 0F8h
  1891 0000041A 6601C0              <1>  add ax, ax
  1892                              <1> 
  1893 0000041D 66A3[AE180000]      <1>  mov [scriptanz], ax
  1894                              <1> 
  1895 00000423 66FF05[AC180000]    <1>  inc word [scriptptr]
  1896                              <1> sIwaitTimer:
  1897                              <1> 
  1898 0000042A A0[B0180000]        <1>  mov al, [scriptins]
  1899 0000042F 6698                <1>  cbw
  1900 00000431 28ED                <1>  sub ch, ch
  1901 00000433 6648                <1>  dec ax
  1902 00000435 7510                <1>  jnz short sInoturn
  1903                              <1> 
  1904 00000437 668B1D[0D180000]    <1>  mov bx, [zstep]
  1905                              <1> 
  1906 0000043E 66011D[AA180000]    <1>  add [ozw], bx
  1907 00000445 EB18                <1>  jmp short sI_1
  1908                              <1> sInoturn:
  1909 00000447 B103                <1>  mov cl, 3
  1910                              <1> sIrotateLoop:
  1911 00000449 6648                <1>  dec ax
  1912 0000044B 7505                <1>  jnz short sInoIncrement
  1913                              <1> 
  1914 0000044D 66FF06              <1>  inc word [esi]
  1915 00000450 EB0D                <1>  jmp short sI_1
  1916                              <1> sInoIncrement:
  1917 00000452 6648                <1>  dec ax
  1918 00000454 7505                <1>  jnz short sInoDecrement
  1919                              <1> 
  1920 00000456 66FF0E              <1>  dec word [esi]
  1921 00000459 EB04                <1>  jmp short sI_1
  1922                              <1> sInoDecrement:
  1923 0000045B 46                  <1>  inc esi
  1924 0000045C 46                  <1>  inc esi
  1925 0000045D E2EA                <1>  loop sIrotateLoop
  1926                              <1> sI_1:
  1927                              <1> 
  1928 0000045F 66BE[A618]          <1>  mov si, oxw
  1929 00000463 B103                <1>  mov cl, 3
  1930                              <1> 
  1931                              <1> 
  1932                              <1> sIpushloop:
  1933 00000465 66AD                <1>  lodsw
  1934 00000467 66C1F802            <1>  sar ax, 2
  1935 0000046B 6650                <1>  push ax
  1936 0000046D E2F6                <1>  loop sIpushloop
  1937                              <1> 
  1938 0000046F 66676B44FC10        <1>  imul ax, word [si-4], 16
  1939                              <1> 
  1940 00000475 6650                <1>  push ax
  1941                              <1> 
  1942                              <1> 
  1943                              <1> 
  1944                              <1> 
  1945                              <1> 
  1946                              <1> 
  1947 00000477 E86C0B0000          <1>  call calcRotMat
  1948                              <1> 
  1949 0000047C B103                <1>  mov cl, 3
  1950 0000047E 31F6                <1>  xor esi, esi
  1951                              <1> sImoveLoop:
  1952 00000480 D986[4E180000]      <1>  fld dword [esi+owmat+24]
  1953 00000486 DE0D[A4180000]      <1>  fimul word [zspeed]
  1954 0000048C DE35[82120000]      <1>  fidiv word [CONST1792]
  1955 00000492 D886[2A180000]      <1>  fadd dword [esi+ob]
  1956 00000498 D99E[2A180000]      <1>  fstp dword [esi+ob]
  1957 0000049E 6683C604            <1>  add si, 4
  1958 000004A2 E2DC                <1>  loop sImoveLoop
  1959 000004A4 59                  <1>  pop ecx
  1960                              <1> 
  1961 000004A5 49                  <1>  dec ecx
  1962 000004A6 0F852FFFFFFF        <1>  jnz sImloop
  1963                              <1> sItickerNull:
  1964                                  	
  1965                                  		animDoor
  1966                              <1> 
  1967                              <1> 
  1968                              <1> 
  1969 000004AC 0FB705[0F180000]    <1>  movzx eax, word [doortimer]
  1970 000004B3 6609C0              <1>  or ax, ax
  1971 000004B6 7905                <1>  jns short aDnounder
  1972 000004B8 6631C0              <1>  xor ax, ax
  1973 000004BB EB4B                <1>  jmp short alreadydrawed
  1974                              <1> aDnounder:
  1975 000004BD 803D[B1180000]00    <1>  cmp byte [once], 0
  1976 000004C4 7542                <1>  jne short alreadydrawed
  1977 000004C6 FE05[B1180000]      <1>  inc byte [once]
  1978 000004CC 50                  <1>  push eax
  1979                              <1>  starbackground
  1980                              <2> 
  1981 000004CD 0FB72D[DE380000]    <2>  movzx ebp, word [bseg]
  1982 000004D4 C1E504              <2>  shl ebp, 4
  1983 000004D7 892D[EC530000]      <2>  mov [_es], ebp
  1984                              <2> 
  1985                              <2> 
  1986 000004DD B964000000          <2>  mov ecx, 100
  1987                              <2> starbackloop:
  1988 000004E2 51                  <2>  push ecx
  1989 000004E3 66BBC0C1            <2>  mov bx, 320*155
  1990                              <2> 
  1991 000004E7 E864030000          <2>  call rnd
  1992 000004EC 66050019            <2>  add ax, 320*20
  1993                              <2> 
  1994 000004F0 0FB7F8              <2>  movzx edi, ax
  1995 000004F3 80E407              <2>  and ah, 7
  1996                              <2> 
  1997 000004F6 BA3B010000          <2>  mov edx, 320-5
  1998 000004FB 66B90200            <2>  mov cx, 2
  1999                              <2> 
  2000                              <2> 
  2001 000004FF E8BA020000          <2>  call setstarbob
  2002 00000504 59                  <2>  pop ecx
  2003 00000505 E2DB                <2>  loop starbackloop
  2004 00000507 58                  <1>  pop eax
  2005                              <1> alreadydrawed:
  2006 00000508 6683F818            <1>  cmp ax, 24
  2007 0000050C 7E04                <1>  jle short aDnoover
  2008 0000050E 66B81800            <1>  mov ax, 24
  2009                              <1> aDnoover:
  2010 00000512 66C1E006            <1>  shl ax, 6
  2011                              <1> 
  2012                              <1> 
  2013 00000516 0FB72D[FA380000]    <1>  movzx ebp, word [tseg+26]
  2014 0000051D C1E504              <1>  shl ebp, 4
  2015 00000520 892D[EC530000]      <1>  mov [_es], ebp
  2016 00000526 0FB71D[FE380000]    <1>  movzx ebx, word [tseg+30]
  2017 0000052D C1E304              <1>  shl ebx, 4
  2018 00000530 891D[E8530000]      <1>  mov [_ds], ebx
  2019 00000536 89DE                <1>  mov esi, ebx
  2020                              <1> 
  2021 00000538 01C6                <1>  add esi, eax
  2022 0000053A 89EF                <1>  mov edi, ebp
  2023                              <1> 
  2024 0000053C B900040000          <1>  mov ecx, 1024
  2025 00000541 F366A5              <1>  rep movsw
  2026 00000544 BE00080000          <1>  mov esi, 2048
  2027 00000549 6629C6              <1>  sub si, ax
  2028 0000054C 56                  <1>  push esi
  2029 0000054D 01DE                <1>  add esi, ebx
  2030 0000054F B504                <1>  mov ch, 4
  2031 00000551 F366A5              <1>  rep movsw
  2032 00000554 5F                  <1>  pop edi
  2033 00000555 01EF                <1>  add edi, ebp
  2034 00000557 6689C1              <1>  mov cx, ax
  2035 0000055A 31C0                <1>  xor eax, eax
  2036 0000055C F366AB              <1>  rep stosw
  2037                              <1> 
  2038 0000055F A3[E8530000]        <1>  mov [_ds], eax
  2039                                  
  2040                                  		; 26/07/2017
  2041 00000564 0FB73D[DC380000]        		movzx	edi, word [vseg]  ; es = [vseg]
  2042 0000056B C1E704                  		shl	edi, 4
  2043 0000056E 893D[EC530000]          		mov	[_es], edi
  2044 00000574 0FB735[DE380000]        		movzx	esi, word [bseg]  ; ds = [bseg]
  2045 0000057B C1E604                  		shl	esi, 4
  2046 0000057E 8935[E8530000]          		mov	[_ds], esi
  2047 00000584 E858020000              		call	copyseg
  2048 00000589 C705[E8530000]0000-     		mov	dword [_ds], 0 ; ds = cs
  2049 00000591 0000               
  2050                                  
  2051                                  		rotation
  2052                              <1> 
  2053                              <1> 
  2054                              <1> 
  2055 00000593 0FB70D[161C0000]    <1>  movzx ecx, word [object.panz]
  2056                              <1> 
  2057 0000059A BE[1A1C0000]        <1>  mov esi, object.p
  2058 0000059F BF[E83A0000]        <1>  mov edi, rp
  2059                              <1> rotmlp:
  2060                              <1> 
  2061 000005A4 BB[5C180000]        <1>  mov ebx, wmat
  2062 000005A9 66BA0300            <1>  mov dx, 3
  2063                              <1> rotilp:
  2064 000005AD DF06                <1>  fild word [esi+0]
  2065 000005AF D825[2A180000]      <1>  fsub dword [ob+vector.x]
  2066 000005B5 D80B                <1>  fmul dword [ebx+0]
  2067 000005B7 DF4602              <1>  fild word [esi+2]
  2068 000005BA D825[2E180000]      <1>  fsub dword [ob+vector.y]
  2069 000005C0 D84B04              <1>  fmul dword [ebx+4]
  2070 000005C3 DF4604              <1>  fild word [esi+4]
  2071 000005C6 D825[32180000]      <1>  fsub dword [ob+vector.z]
  2072 000005CC D84B08              <1>  fmul dword [ebx+8]
  2073                              <1> 
  2074                              <1> 
  2075 000005CF DEC1                <1>  faddp
  2076 000005D1 DEC1                <1>  faddp
  2077 000005D3 D91F                <1>  fstp dword [edi]
  2078 000005D5 6683C704            <1>  add di, 4
  2079                              <1> 
  2080 000005D9 6683C30C            <1>  add bx, 12
  2081 000005DD 664A                <1>  dec dx
  2082 000005DF 75CC                <1>  jnz short rotilp
  2083 000005E1 6683C608            <1>  add si, 8
  2084                              <1> 
  2085 000005E5 E2BD                <1>  loop rotmlp
  2086                                  		sortFaces
  2087                              <1> 
  2088 000005E7 C705[EC530000]0000- <1>  mov dword [_es], 0
  2089 000005EF 0000                <1>
  2090                              <1> 
  2091 000005F1 BF[A84D0000]        <1>  mov edi, facei
  2092 000005F6 57                  <1>  push edi
  2093                              <1> 
  2094                              <1> 
  2095 000005F7 BE[9A280000]        <1>  mov esi, object.f
  2096 000005FC 89F0                <1>  mov eax, esi
  2097                              <1> 
  2098                              <1> 
  2099 000005FE 0FB70D[181C0000]    <1>  movzx ecx, word [object.fanz]
  2100                              <1> 
  2101 00000605 31DB                <1>  xor ebx, ebx
  2102                              <1> sFmloop:
  2103 00000607 D9EE                <1>  fldz
  2104 00000609 51                  <1>  push ecx
  2105 0000060A 66B90400            <1>  mov cx, 4
  2106                              <1> sFiloop:
  2107 0000060E 666B1E0C            <1>  imul bx, word [esi], 12
  2108 00000612 46                  <1>  inc esi
  2109 00000613 46                  <1>  inc esi
  2110 00000614 D8A3[F03A0000]      <1>  fsub dword [ebx+rp+vector.z]
  2111 0000061A E2F2                <1>  loop sFiloop
  2112 0000061C 59                  <1>  pop ecx
  2113 0000061D DF1F                <1>  fistp word [edi]
  2114 0000061F 47                  <1>  inc edi
  2115 00000620 47                  <1>  inc edi
  2116                              <1> 
  2117 00000621 66AB                <1>  stosw
  2118 00000623 6683C00A            <1>  add ax, 10
  2119 00000627 46                  <1>  inc esi
  2120 00000628 46                  <1>  inc esi
  2121 00000629 E2DC                <1>  loop sFmloop
  2122                              <1> 
  2123 0000062B 57                  <1>  push edi
  2124 0000062C E8DA010000          <1>  call qsort
  2125                                  
  2126                                  		;movzx	ecx, word [o+object.fanz]
  2127 00000631 0FB70D[181C0000]        		movzx	ecx, word [object.fanz]
  2128                                  
  2129 00000638 BE[A84D0000]            		mov	esi, facei
  2130                                  drawloop:
  2131                                  		; 27/07/2017
  2132 0000063D 66AD                    		lodsw
  2133 0000063F 66AD                    		lodsw
  2134                                  		;movzx	ebx, ax ; face address in 'o+object.f'
  2135 00000641 0FB7D8                  		movzx	ebx, ax ; face address in 'object.f'
  2136                                  		;pushad
  2137 00000644 56                      		push	esi
  2138 00000645 51                      		push	ecx
  2139 00000646 E817070000              		call	drawclippedface
  2140 0000064B 59                      		pop	ecx
  2141 0000064C 5E                      		pop	esi
  2142                                  		;popad
  2143 0000064D E2EE                    		loop	drawloop
  2144                                  
  2145 0000064F 0FB735[DC380000]        		movzx	esi, word [vseg] ; ds = [vseg]
  2146 00000656 C1E604                  		shl	esi, 4
  2147 00000659 8935[E8530000]          		mov	[_ds], esi
  2148                                  
  2149 0000065F BF00000A00              		mov	edi, 0A0000h
  2150 00000664 893D[EC530000]          		mov	[_es], edi ; es = 0A000h
  2151                                  
  2152 0000066A E872010000              		call	copyseg
  2153                                  
  2154 0000066F C705[E8530000]0000-     		mov	dword [_ds], 0 ; ds = cs ; 11/08/2017
  2155 00000677 0000               
  2156                                  
  2157                                  _check_kbdb:
  2158 00000679 B401                    		mov	ah, 1	; Check keyboard buffer
  2159 0000067B CD32                    		int	32h	; TRDOS 386 Keyboard interrupt
  2160                                  		;jnz	_exit_  ; exit
  2161                                  		;jmp	mainloop
  2162 0000067D 0F8410FDFFFF            		jz	mainloop ; 11/02/2017
  2163                                  loc_err_exit:
  2164                                  _exit_:
  2165                                  		; 26/07/2017
  2166 00000683 C705[E8530000]0000-     		mov	dword [_ds], 0  ; ds = cs
  2167 0000068B 0000               
  2168 0000068D 8B25[3C380000]          		mov	esp, [oldstack]
  2169                                  		silence
  2170 00000693 66B90F00            <1>  mov cx, 15
  2171                              <1> Siloop:
  2172 00000697 6689C8              <1>  mov ax, cx
  2173 0000069A 04B0                <1>  add al, CMD_CHANGEPARAM
  2174 0000069C E8DB010000          <1>  call writeGM
  2175 000006A1 B07B                <1>  mov al, MOD_ALLNOTESOFF
  2176 000006A3 E8D4010000          <1>  call writeGM
  2177 000006A8 30C0                <1>  xor al, al
  2178 000006AA E8CD010000          <1>  call writeGM
  2179 000006AF E2E6                <1>  loop Siloop
  2180                              <1> Sinosound:
  2181                                  		stopKBDHandler
  2182                              <1> 
  2183                              <1> 
  2184                              <1> 
  2185                              <1> 
  2186                              <1> 
  2187                              <1> 
  2188                              <1> 
  2189                              <1> 
  2190                              <1> 
  2191                              <1> 
  2192 000006B1 90                  <1>  nop
  2193                                  		stopTimer
  2194                              <1> 
  2195                              <1> 
  2196                              <1> 
  2197                              <1> 
  2198                              <1> 
  2199                              <1> 
  2200                              <1> 
  2201                              <1> 
  2202 000006B2 6631DB              <1>  xor bx, bx
  2203 000006B5 E8AB010000          <1>  call setTimer
  2204                              <1> 
  2205                              <1> 
  2206 000006BA 0FB61D[DB380000]    <1>  movzx ebx, byte [timer_event_number]
  2207                              <1> 
  2208                              <1> 
  2209                              <1> 
  2210 000006C1 B821000000          <1>  mov eax, 33
  2211 000006C6 CD40                <1>  int 40h
  2212                              <1> 
  2213                                  ;restore_text_mode:
  2214                                  		set80x25
  2215 000006C8 66B80300            <1>  mov ax, 3
  2216                              <1> 
  2217                              <1> 
  2218 000006CC CD31                <1>  int 31h
  2219                                  terminate:
  2220                                  		sys 	_exit   ; INT 40h
  2221                              <1> 
  2222                              <1> 
  2223                              <1> 
  2224                              <1> 
  2225                              <1>  %if %0 >= 2
  2226                              <1>  mov ebx, %2
  2227                              <1>  %if %0 >= 3
  2228                              <1>  mov ecx, %3
  2229                              <1>  %if %0 = 4
  2230                              <1>  mov edx, %4
  2231                              <1>  %endif
  2232                              <1>  %endif
  2233                              <1>  %endif
  2234 000006CE B801000000          <1>  mov eax, %1
  2235                              <1> 
  2236 000006D3 CD40                <1>  int 40h
  2237                                  here:
  2238 000006D5 EBFE                    		jmp	short here
  2239                                  
  2240                                  ;==============================================================================
  2241                                  ;		interrupt handler
  2242                                  ;==============================================================================
  2243                                  ;***********************************************
  2244                                  ;* description	: timer routine		       *
  2245                                  ;* parameter	: none		               *
  2246                                  ;* sideeffect	: none		               *
  2247                                  ;* back		: none		               *
  2248                                  ;***********************************************
  2249                                  
  2250                                  timer_callback:
  2251                                  		; 12/08/2017
  2252                                  		; 10/08/2017
  2253                                  		
  2254                                  		playsong
  2255                              <1> 
  2256 000006D7 0FB70D[B4180000]    <1>  movzx ecx, word [tracks]
  2257                              <1> 
  2258 000006DE BE[B61B0000]        <1>  mov esi, channels
  2259                              <1> PSmloop:
  2260 000006E3 66FF0E              <1>  dec word [esi+channel.del]
  2261 000006E6 7F34                <1>  jg short PSdelayed
  2262 000006E8 668B4602            <1>  mov ax, [esi+channel.trk]
  2263 000006EC 0480                <1>  add al, CMD_NOTEOFF
  2264 000006EE E8A6010000          <1>  call setnote
  2265                              <1> 
  2266 000006F3 0FB75E04            <1>  movzx ebx, word [esi+channel.adr]
  2267 000006F7 B47F                <1>  mov ah, 127
  2268 000006F9 803B00              <1>  cmp byte [ebx], 0
  2269 000006FC 7416                <1>  jz short PStrackend
  2270 000006FE 8A23                <1>  mov ah, [ebx]
  2271 00000700 886603              <1>  mov [esi+channel.ln], ah
  2272 00000703 8A4602              <1>  mov al, [esi+channel.trk]
  2273 00000706 0490                <1>  add al, CMD_NOTEON
  2274 00000708 E88C010000          <1>  call setnote
  2275 0000070D 8A4301              <1>  mov al, [ebx+1]
  2276 00000710 B31D                <1>  mov bl, SONGSPEED
  2277 00000712 F6E3                <1>  mul bl
  2278                              <1> PStrackend:
  2279 00000714 668906              <1>  mov [esi+channel.del], ax
  2280 00000717 6683460402          <1>  add word [esi+channel.adr], 2
  2281                              <1> PSdelayed:
  2282 0000071C 6683C606            <1>  add si, 6
  2283 00000720 E2C1                <1>  loop PSmloop
  2284                              <1> PSnosound:
  2285                                  
  2286 00000722 66FF05[B2180000]        		inc	word [ticker]
  2287 00000729 FE05[DA380000]          		inc	byte [twice]
  2288                                  		
  2289                                  		; 12/08/2017
  2290                                  		;and	byte [twice], 7
  2291                                  		;jnz	short tr_1
  2292                                  
  2293                                  		; 12/08/2017 
  2294                                  		; (25 Hz is necessary for proper rendering...)
  2295                                  		; (50 Hz was enough for DOS real mode
  2296                                  		; but not enough for TRDOS 386 protected
  2297                                  		; mode, for real computer and Virtual Box running.)
  2298                                  
  2299 0000072F 8025[DA380000]0F        		and	byte [twice], 15 ; 23.333 Hz  (350/15)
  2300 00000736 756F                    		jnz	short tr_1
  2301                                  
  2302 00000738 C605[A5620000]00        		mov	byte [tstatus], 0 ; screen update (50 Hz) flag
  2303                                  		
  2304                                  		colorCycle
  2305                              <1> 
  2306                              <1> 
  2307                              <1>  base equ 6*32
  2308                              <1>  range equ 32
  2309                              <1> 
  2310 0000073F C705[EC530000]0000- <1>  mov dword [_es], 0
  2311 00000747 0000                <1>
  2312                              <1> 
  2313 00000749 BF[F61A0000]        <1>  mov edi, palette+(base*3)
  2314 0000074E 89FE                <1>  mov esi, edi
  2315 00000750 66AD                <1>  lodsw
  2316                              <1> 
  2317 00000752 46                  <1>  inc esi
  2318                              <1> 
  2319 00000753 B95D000000          <1>  mov ecx, (range*3-3)
  2320 00000758 F3A4                <1>  rep movsb
  2321 0000075A 66AB                <1>  stosw
  2322                              <1> 
  2323                                  		animStars
  2324                              <1> 
  2325                              <1> 
  2326                              <1>  _base equ 7*32
  2327                              <1> 
  2328 0000075C 0FB72D[E2380000]    <1>  movzx ebp, word [tseg+2]
  2329 00000763 C1E504              <1>  shl ebp, 4
  2330 00000766 892D[EC530000]      <1>  mov [_es], ebp
  2331                              <1> 
  2332 0000076C E842010000          <1>  call clearFrac
  2333                              <1> 
  2334                              <1> 
  2335 00000771 B11E                <1>  mov cl, 30
  2336                              <1> 
  2337                              <1> 
  2338 00000773 BB[80380000]        <1>  mov ebx, stars
  2339                              <1> aSoloop:
  2340 00000778 FE0B                <1>  dec byte [ebx]
  2341 0000077A 8A23                <1>  mov ah, [ebx]
  2342 0000077C 80E43F              <1>  and ah, 63
  2343 0000077F 80FC1F              <1>  cmp ah, 31
  2344 00000782 7605                <1>  jbe short aSnonot
  2345 00000784 F6D4                <1>  not ah
  2346 00000786 80E41F              <1>  and ah, 31
  2347                              <1> aSnonot:
  2348 00000789 D0EC                <1>  shr ah, 1
  2349                              <1> 
  2350 0000078B 0FB77B01            <1>  movzx edi, word [ebx+1]
  2351                              <1> 
  2352 0000078F 51                  <1>  push ecx
  2353 00000790 53                  <1>  push ebx
  2354                              <1> 
  2355 00000791 BA3B000000          <1>  mov edx, 64-5
  2356 00000796 66B900E0            <1>  mov cx, _base*256+0
  2357                              <1> 
  2358                              <1> 
  2359 0000079A E81F000000          <1>  call setstarbob
  2360                              <1> 
  2361 0000079F 5B                  <1>  pop ebx
  2362 000007A0 59                  <1>  pop ecx
  2363                              <1> 
  2364 000007A1 6683C303            <1>  add bx, 3
  2365 000007A5 E2D1                <1>  loop aSoloop
  2366                                  
  2367                                  		;inc	word [doortimer]
  2368                                  tr_1:
  2369                                  		; 12/08/2017
  2370                                  		; (25 Hz is not ennough for final StarBackground)
  2371                                  		
  2372 000007A7 F605[DA380000]07        		test byte [twice], 7 ; 50 Hz
  2373 000007AE 7507                    		jnz	short tr_2
  2374                                  
  2375 000007B0 66FF05[0F180000]        		inc	word [doortimer] ; (animDoor, starbackground)
  2376                                  tr_2:
  2377 000007B7 B827000000              		mov	eax, 39	; 'sysrele'
  2378 000007BC CD40                    		int	40h	; TRDOS 386 system call
  2379                                  	
  2380                                  ;==============================================================================
  2381                                  ;		sub routines
  2382                                  ;==============================================================================
  2383                                  ;***********************************************
  2384                                  ;* description	: draw a the starbob	       *
  2385                                  ;* parameter	: ds,es: source seg,dest seg   *
  2386                                  ;* sideeffect	: ax,cx,si,di	               *
  2387                                  ;* back		: none		               *
  2388                                  ;***********************************************
  2389                                  
  2390                                  setstarbob:
  2391                                  		; 26/07/2017
  2392                                  		;mov	ebp, [_es]
  2393 000007BE BE[CE140000]            		mov	esi, bob
  2394 000007C3 B305                    		mov	bl, 5
  2395                                  yloop:
  2396 000007C5 B705                    		mov	bh, 5
  2397                                  xloop:
  2398 000007C7 AC                      		lodsb
  2399 000007C8 28E0                    		sub	al, ah
  2400 000007CA 7E08                    		jle	short aSnodraw
  2401 000007CC 00E8                    		add	al, ch
  2402 000007CE D2E0                    		shl	al, cl
  2403 000007D0 88443D00                		mov	[ebp+edi], al  ; mov [es:di], al
  2404                                  aSnodraw:
  2405                                  		;inc	di
  2406 000007D4 47                      		inc	edi
  2407 000007D5 FECF                    		dec	bh
  2408 000007D7 75EE                    		jnz	short xloop
  2409 000007D9 6601D7                  		add	di, dx
  2410 000007DC FECB                    		dec	bl
  2411 000007DE 75E5                    		jnz	short yloop
  2412 000007E0 C3                      		retn
  2413                                  
  2414                                  ;***********************************************
  2415                                  ;* description	: copy 16000 longs ds --> es   *
  2416                                  ;* parameter	: ds,es: source seg,dest seg   *
  2417                                  ;* sideeffect	: ax,cx,si,di	               *
  2418                                  ;* back		: none		               *
  2419                                  ;***********************************************
  2420                                  
  2421                                  copyseg:
  2422                                  		;mov	cx, 16000 ; 3E80h
  2423 000007E1 B9803E0000              		mov	ecx, 16000
  2424 000007E6 F3A5                    		rep movsd
  2425 000007E8 C3                      		retn
  2426                                  
  2427                                  ;***********************************************
  2428                                  ;* description	: expand a part of the song    *
  2429                                  ;* parameter	: si:base adress	       *
  2430                                  ;* sideeffect   : si,ax		               *
  2431                                  ;* back		: ax=si:new baseadress	       *
  2432                                  ;***********************************************
  2433                                  
  2434                                  expand:
  2435 000007E9 8A0E                    EPwhile: 	mov	cl, [esi]
  2436 000007EB 08C9                    		or	cl, cl
  2437 000007ED 7418                    		jz	short EPendwhile
  2438 000007EF 7912                    		jns	short EPnote
  2439                                  EPcall:
  2440 000007F1 51                      		push	ecx
  2441 000007F2 56                      		push	esi
  2442 000007F3 46                      		inc	esi
  2443 000007F4 E8F0FFFFFF              		call	expand
  2444 000007F9 5E                      		pop	esi
  2445 000007FA 59                      		pop	ecx
  2446 000007FB FEC1                    		inc	cl
  2447 000007FD 75F2                    		jnz	short EPcall
  2448 000007FF 89C6                    		mov	esi, eax
  2449 00000801 EBE6                    		jmp	short EPwhile 
  2450                                  EPnote:
  2451 00000803 66A5                    		movsw
  2452 00000805 EBE2                    		jmp	short EPwhile
  2453                                  EPendwhile:
  2454 00000807 46                      		inc	esi
  2455 00000808 89F0                    		mov	eax, esi
  2456 0000080A C3                      		retn
  2457                                  
  2458                                  ;**************************************************
  2459                                  ;* description	: recursive index quicksort       *
  2460                                  ;* parameter	: l,r:stack left and right border *
  2461                                  ;* sideeffect	: ax,bx,cx,dx,si,di               *
  2462                                  ;* back		: none		                  *
  2463                                  ;**************************************************
  2464                                  
  2465                                  qsort:		
  2466                                  		; 11/08/2017
  2467                                  		; 07/04/2017
  2468                                   		; 10/02/2017
  2469                                   		; 29/01/2017
  2470                                  
  2471 0000080B 58                      		pop	eax 	; get return address
  2472 0000080C 59                      		pop	ecx	; get 2. param r
  2473 0000080D 5B                      		pop	ebx	; get 1. param l
  2474 0000080E 50                      		push	eax	; store return address
  2475                                  
  2476 0000080F 39D9                    		cmp	ecx, ebx
  2477 00000811 7E3C                    		jle	short QSendrek
  2478 00000813 89DE                    		mov	esi, ebx
  2479 00000815 89CF                    		mov	edi, ecx  	
  2480 00000817 668B16                  		mov	dx, [esi]
  2481 0000081A EB0A                    		jmp	short QSwhile2
  2482                                  QSrepeat:
  2483 0000081C 663916                  QSwhile1:	cmp	[esi], dx
  2484 0000081F 7E05                    		jle	short QSwhile2
  2485 00000821 83C604                  		add	esi, 4
  2486 00000824 EBF6                    		jmp	short QSwhile1
  2487                                  QSwhile2:
  2488 00000826 663917                  		cmp	[edi], dx
  2489 00000829 7D05                    		jnl	short QSwhile2e
  2490 0000082B 83EF04                  		sub	edi, 4
  2491 0000082E EBF6                    		jmp	short QSwhile2
  2492                                  QSwhile2e:
  2493 00000830 39FE                    		cmp	esi, edi
  2494                                  		;jg	short QSnoswap
  2495 00000832 7F0D                    		jg	short _QSnoswap
  2496 00000834 AD                      		lodsd
  2497 00000835 8707                    		xchg	eax, [edi]
  2498 00000837 8946FC                  		mov	[esi-4], eax
  2499 0000083A 83EF04                  		sub	edi, 4
  2500                                  QSnoswap:
  2501 0000083D 39FE                    		cmp	esi, edi
  2502 0000083F 7EDB                    		jle	short QSrepeat
  2503                                  _QSnoswap:
  2504 00000841 56                      		push	esi 
  2505 00000842 51                      		push	ecx
  2506 00000843 53                      		push	ebx
  2507 00000844 57                      		push	edi
  2508 00000845 E8C1FFFFFF              		call	qsort
  2509 0000084A E8BCFFFFFF              		call	qsort
  2510                                  QSendrek:
  2511 0000084F C3                      		retn
  2512                                  
  2513                                  ;*************************************************
  2514                                  ;* description	: returns a pseudo random number *
  2515                                  ;* parameter	: bx=range		         *
  2516                                  ;* sideeffect	: eax,edx,si		         *
  2517                                  ;* back		: ax=rnd(range)                  *
  2518                                  ;*************************************************
  2519                                  
  2520                                  rnd:
  2521 00000850 BE[88120000]            		mov	esi, randommul
  2522                                  		;mov	si, randommul
  2523 00000855 AD                      		lodsd
  2524 00000856 F726                    		mul	dword [esi] ; randomseed
  2525 00000858 40                      		inc	eax
  2526 00000859 8906                    		mov	[esi], eax  ; randomseed
  2527 0000085B 66AD                    		lodsw
  2528 0000085D 66AD                    		lodsw
  2529 0000085F 66F7E3                  		mul	bx
  2530 00000862 6692                    		xchg	ax, dx
  2531 00000864 C3                      		retn
  2532                                  
  2533                                  ;************************************************
  2534                                  ;* description	: set timer speed to 1193180/AX *
  2535                                  ;*                interrupts per second         *
  2536                                  ;* parameter	: bx		                *
  2537                                  ;* sideeffect	: ax		                *
  2538                                  ;* back		: none		                *
  2539                                  ;************************************************
  2540                                  
  2541                                  setTimer:	; set timer speed to 1193180/BX (TRDOS 386)
  2542 00000865 B036                    		mov	al, 36h
  2543                                  		;out	43h, al		; Timer	8253-5 (AT: 8254.2).
  2544                                  
  2545 00000867 B401                    		mov	ah, 1 ; out (byte)
  2546 00000869 66BA4300                		mov	dx, 43h
  2547 0000086D CD34                    		int	34h ; TRDOS 386 - IOCTL interrupt
  2548                                  
  2549 0000086F 88D8                    		mov	al, bl
  2550                                  		;out	40h, al		; Timer	8253-5 (AT: 8254.2).
  2551                                  		
  2552 00000871 66BA4000                		mov	dx, 40h
  2553                                  		;mov	ah, 1 ; out (byte)
  2554 00000875 CD34                    		int	34h ; TRDOS 386 - IOCTL interrupt
  2555                                  
  2556 00000877 88F8                    		mov	al, bh
  2557                                  		;out	40h, al		; Timer	8253-5 (AT: 8254.2).
  2558                                  		
  2559                                  		;mov	ah, 1 ; out (byte)
  2560                                  		;mov	dx, 40h
  2561 00000879 CD34                    		int	34h ; TRDOS 386 - IOCTL interrupt
  2562                                  
  2563 0000087B C3                      		retn
  2564                                  
  2565                                  ;***********************************************
  2566                                  ;* description	: send a byte to the GM-Port   *
  2567                                  ;* parameter	: al:midi command              *
  2568                                  ;* sideeffect	: dx		               *
  2569                                  ;* back		: none		               *
  2570                                  ;***********************************************
  2571                                  
  2572                                  writeGM:
  2573 0000087C 66BA3103                		mov	dx, GMPort  ; 331h
  2574 00000880 51                      		push	ecx
  2575 00000881 50                      		push	eax
  2576 00000882 30C9                    		xor	cl, cl
  2577                                  busy:
  2578 00000884 FEC9                    		dec	cl
  2579 00000886 7408                    		jz	short timeOut
  2580                                  		;in	al, dx
  2581                                  
  2582 00000888 B400                    		mov	ah, 0	; in (byte)
  2583 0000088A CD34                      		int	34h	; TRDOS 386 - IOCTL interrupt
  2584                                  		
  2585 0000088C A840                    		test	al, 40h
  2586 0000088E 75F4                    		jnz	short busy
  2587                                  
  2588                                  timeOut:				; CODE XREF: writeGM+8j
  2589 00000890 58                      		pop	eax
  2590 00000891 59                      		pop	ecx
  2591 00000892 664A                    		dec	dx
  2592                                  		;out	dx, al
  2593                                  		
  2594 00000894 B401                    		mov	ah, 1	; out (byte)
  2595 00000896 CD34                      		int	34h	; TRDOS 386 - IOCTL interrupt
  2596                                  
  2597 00000898 C3                      		retn
  2598                                  
  2599                                  ;**************************************************
  2600                                  ;* description	: send NOTEON command, volume 127 *
  2601                                  ;* parameter	: al:channel;ah:note              *
  2602                                  ;* sideeffect	: dx,al		                  *
  2603                                  ;* back		: none		                  *
  2604                                  ;**************************************************
  2605                                  
  2606                                  setnote:
  2607 00000899 E808000000              		call	setinstr
  2608 0000089E B07F                    		mov	al, 127	; 7Fh
  2609 000008A0 E8D7FFFFFF              		call	writeGM
  2610 000008A5 C3                      		retn
  2611                                  
  2612                                  ;***********************************************
  2613                                  ;* description	: send CHANGEPRG command       *
  2614                                  ;* parameter	: al:channel;ah:instrument     *
  2615                                  ;* sideeffect	: dx,al		               *
  2616                                  ;* back		: none		               *
  2617                                  ;***********************************************
  2618                                  
  2619                                  setinstr:
  2620 000008A6 E8D1FFFFFF              		call	writeGM
  2621 000008AB 88E0                    		mov	al, ah
  2622 000008AD E8CAFFFFFF              		call	writeGM
  2623 000008B2 C3                      		retn
  2624                                  
  2625                                  ;**************************************************
  2626                                  ;* description	: clear/set the fractal es: to al *
  2627                                  ;* parameter	: al,es		                  *
  2628                                  ;* sideeffect	: ax,cx,di,es  	                  *
  2629                                  ;* back		: none			          *
  2630                                  ;**************************************************
  2631                                  
  2632                                  clearFrac:
  2633 000008B3 31C0                    		xor	eax, eax
  2634                                  setFrac:
  2635                                  		; 26/07/2017
  2636                                  		;xor	di, di
  2637 000008B5 8B3D[EC530000]          		mov	edi, [_es]
  2638                                  		;mov	cx, 4096 ; 1000h
  2639 000008BB B900100000              		mov	ecx, 4096
  2640 000008C0 F3AA                    		rep stosb
  2641 000008C2 C3                      		retn
  2642                                  
  2643                                  ;***********************************************
  2644                                  ;* description	: calc shade bob fractal       *
  2645                                  ;* parameter	: es:seg;num,rad:stack         *
  2646                                  ;* sideeffect	: all			       *
  2647                                  ;* back		: none			       *
  2648                                  ;***********************************************
  2649                                  
  2650                                  createFrac1:
  2651                                  		; 26/07/2017
  2652                                  
  2653                                  		;; *mov	 ebx, 34
  2654                                  		;; *push 800	 ; 320h ; arg 2
  2655                                  		;; *push 5		; arg 1 	
  2656                                  		;; *call createFrac1
  2657                                  		;; *mov	 ebx, 32 ; 20h
  2658                                  		;; *push 112	 ; 70h  ; arg 2
  2659                                  		;; *push 15	 ; 0Fh  ; arg 1
  2660                                  		;; *call createFrac1
  2661                                  
  2662                                  		rad	equ 8  ; arg 1 in [esp+4]
  2663                                  		num	equ 12 ; arg 2 in [esp+8]
  2664                                  
  2665 000008C3 55                      		push	ebp
  2666 000008C4 89E5                    		mov	ebp, esp
  2667                                  		;
  2668                                  		;movzx	ebx, word [ebx+tseg] ; es:
  2669 000008C6 668B9B[E0380000]        		mov	bx, [ebx+tseg]
  2670 000008CD C1E304                  		shl	ebx, 4
  2671 000008D0 891D[EC530000]          		mov	[_es], ebx
  2672 000008D6 E8D8FFFFFF              		call	clearFrac
  2673                                  		;mov	si, circletab
  2674 000008DB BE[40380000]            		mov	esi, circletab
  2675                                  		;mov	dx, [ebp+rad]
  2676 000008E0 8B5508                  		mov	edx, [ebp+rad]		
  2677                                  		;movzx	eax, dl
  2678                                  		;mov	eax, edx
  2679 000008E3 88D0                    		mov	al, dl
  2680 000008E5 F6EA                    		imul	dl
  2681                                  		;mov	di, ax
  2682                                  		;mov	bx, ax
  2683 000008E7 89C3                    		mov	ebx, eax
  2684                                  		;mov	cx, dx
  2685                                  		;add	cx, cx
  2686 000008E9 89D1                    		mov	ecx, edx
  2687 000008EB 01C9                    		add	ecx, ecx
  2688                                  CCTloop:
  2689 000008ED 88D0                    		mov	al, dl
  2690 000008EF F6EA                    		imul	dl
  2691 000008F1 66F7D8                  		neg	ax
  2692                                  		;add	ax, di
  2693 000008F4 6601D8                  		add	ax, bx ; 16/01/2017
  2694 000008F7 668906                  		mov	[esi], ax
  2695 000008FA DF06                    		fild	word [esi]
  2696 000008FC D9FA                    		fsqrt
  2697 000008FE DF1E                    		fistp	word [esi]
  2698 00000900 46                      		inc	esi
  2699 00000901 46                      		inc	esi
  2700 00000902 664A                    		dec	dx
  2701 00000904 E2E7                    		loop	CCTloop
  2702                                  
  2703 00000906 668B4D0C                		mov	cx, [ebp+num]
  2704                                  SBloop1:
  2705 0000090A 51                      		push	ecx
  2706                                  		;mov	ebx, 4096 ; 1000h
  2707 0000090B 66BB0010                		mov	bx, 4096
  2708 0000090F E83CFFFFFF              		call	rnd
  2709 00000914 0FB7F8                  		movzx	edi, ax ; 05/02/2017
  2710                                  		;mov	esi, circletab
  2711 00000917 66BE[4038]              		mov	si, circletab
  2712 0000091B 668B4D08                		mov	cx, [ebp+rad]
  2713                                  		;add	cx, cx
  2714 0000091F 01C9                    		add	ecx, ecx
  2715 00000921 8B1D[EC530000]          		mov	ebx, [_es]
  2716                                  SBloop2:
  2717 00000927 51                      		push	ecx
  2718 00000928 66AD                    		lodsw
  2719 0000092A 6689C1                  		mov	cx, ax
  2720                                  		;add	cx, cx
  2721 0000092D 01C9                    		add	ecx, ecx
  2722 0000092F 7410                    		jz	short SBskip
  2723 00000931 57                      		push	edi
  2724 00000932 6629C7                  		sub	di, ax
  2725                                  SBloop3:
  2726 00000935 6681E7FF0F              		and	di, 4095  ; 0FFFh
  2727 0000093A FE043B                  		inc	byte [ebx+edi] ; 17/01/2017
  2728                                  		;inc	di
  2729 0000093D 47                      		inc	edi
  2730 0000093E E2F5                    		loop	SBloop3
  2731 00000940 5F                      		pop	edi
  2732                                  SBskip:
  2733 00000941 6683C740                		add	di, 64 ; 40h
  2734 00000945 59                      		pop	ecx
  2735 00000946 E2DF                    		loop	SBloop2
  2736 00000948 59                      		pop	ecx
  2737 00000949 E2BF                    		loop	SBloop1
  2738 0000094B 5D                      		pop	ebp
  2739 0000094C C20800                  		ret	8
  2740                                  
  2741                                  ;**************************************************
  2742                                  ;* description	: draw a perpective-texturemapped *
  2743                                  ;* 		  and g.-shaded n-sided polygon   *
  2744                                  ;* parameter	: far ptr to poly, sides, textnum *
  2745                                  ;* sideeffect	: all			          *
  2746                                  ;* back		: none			          *
  2747                                  ;* length	: 700 bytes		          *
  2748                                  ;**************************************************
  2749                                  
  2750                                  scansubtextpoly:
  2751                                  		; 10/08/2017
  2752                                  		; 26/07/2017
  2753                                  		; 07/04/2017
  2754                                  		; 30/01/2017
  2755                                  
  2756                                  		;; *mov   edi, dcf.p2
  2757                                  		;; *push  edi		 ; arg 3 ; 32 bits push !
  2758                                  		;; *push  word [dcf.j]   ; arg 2 ; 16 bits push !!
  2759                                  		;; *push  word [dcf.col] ; arg 1 ; 16 bits push !!
  2760                                  		;; *call  scansubtextpoly
  2761                                  
  2762                                  		; 10/08/2017 (operand size bugfix, 8, 10, 12)
  2763                                  		col	equ 8   ; arg 1, [esp+4]  ; dcf.col value
  2764                                  		n	equ 10  ; arg 2, [esp+6]  ; dcf.j value
  2765                                  		pol	equ 12  ; arg 3, [esp+8]  ; dcf.p2 address
  2766                                  
  2767                                  		; 06/02/2017
  2768 0000094F 55                       		push	ebp
  2769 00000950 89E5                    		mov	ebp, esp
  2770                                  
  2771                                  		; 21/01/2017
  2772 00000952 B8FF7F0000              		mov	eax, 32767
  2773 00000957 89C2                    		mov	edx, eax
  2774 00000959 89C3                    		mov	ebx, eax
  2775 0000095B 66F7DB                  		neg	bx	 ; -32767 ; 8001h
  2776 0000095E 89DE                    		mov	esi, ebx ; -32767
  2777                                  		
  2778                                  		;e di = 32 bit address (in stack) /// 18/01/2017		
  2779 00000960 8B7D0C                  		mov	edi, [ebp+pol] ; [ebp+12] ; dcf.p2 ; face structure
  2780                                  
  2781 00000963 31C9                    		xor	ecx, ecx
  2782                                  minmax:
  2783 00000965 663B4712                		cmp	ax, [edi+2+edge.e+edges.x] ; [edi+12h]
  2784 00000969 7E04                    		jle	short noswap1
  2785 0000096B 668B4712                		mov	ax, [edi+2+edge.e+edges.x] ; [edi+12h]
  2786                                  noswap1:
  2787 0000096F 663B5F12                		cmp	bx, [edi+2+edge.e+edges.x] ; [edi+12h]
  2788 00000973 7D04                    		jge	short noswap2
  2789 00000975 668B5F12                		mov	bx, [edi+2+edge.e+edges.x] ; [edi+12h]
  2790                                  noswap2:
  2791 00000979 663B570C                		cmp	dx, [edi+edge.py]  ; [edi+0Ch]
  2792 0000097D 7E12                    		jle	short noswap3
  2793 0000097F 668B570C                		mov	dx, [edi+edge.py]  ; [edi+0Ch]
  2794 00000983 66890D[0A540000]        		mov	[sstp.l], cx
  2795 0000098A 66890D[08540000]        		mov	[sstp.r], cx
  2796                                  noswap3:
  2797 00000991 663B770C                		cmp	si, [edi+edge.py]  ; [edi+0Ch]
  2798 00000995 7D04                    		jge	short noswap4
  2799 00000997 668B770C                		mov	si, [edi+edge.py]  ; [edi+0Ch]
  2800                                  noswap4:
  2801 0000099B 6683C724                		add	di, 36 ; 24h
  2802                                  		;inc	cx
  2803                                  		; 10/08/2017
  2804 0000099F 41                      		inc	ecx
  2805 000009A0 663B4D0A                		cmp	cx, [ebp+n] ; [ebp+10]
  2806                                  				    ; dcf.j ; number of visible edges/points
  2807 000009A4 75BF                    		jne	short minmax
  2808                                  
  2809 000009A6 6683FB00                		cmp	bx, 0
  2810 000009AA 0F8C58030000            		jl	exitDraw
  2811 000009B0 663D4001                		cmp	ax, XMAX  ; 140h
  2812 000009B4 0F8F4E030000            		jg	exitDraw
  2813                                  
  2814 000009BA 6683FE15                		cmp	si, YMIN  ; 15h
  2815 000009BE 0F8C44030000            		jl	exitDraw
  2816 000009C4 6681FAB300              		cmp	dx, YMAX  ; 0B3h
  2817 000009C9 0F8F39030000            		jg	exitDraw
  2818 000009CF 668915[10540000]        		mov	[sstp.miny], dx
  2819 000009D6 668935[0E540000]        		mov	[sstp.maxy], si
  2820                                  
  2821                                  		;{ down clipping }
  2822 000009DD 66813D[0E540000]B3-     		cmp	word [sstp.maxy], YMAX ; 0B3h
  2823 000009E5 00                 
  2824 000009E6 7E09                    		jle	short noclipdown
  2825 000009E8 66C705[0E540000]B3-     		mov	word [sstp.maxy], YMAX ; 0B3h
  2826 000009F0 00                 
  2827                                  noclipdown:
  2828 000009F1 66A1[10540000]          		mov	ax, [sstp.miny]
  2829 000009F7 663B05[0E540000]        		cmp	ax, [sstp.maxy]
  2830 000009FE 0F8404030000            		je	exitDraw
  2831 00000A04 66A3[0C540000]          		mov	[sstp.y], ax
  2832                                  		; 05/02/2017
  2833                                  		;mov	ebx, [ebp+col]	; [ebp+8]
  2834                                  					 ; dcf.col ; shade/color index
  2835 00000A0A 668B5D08                		mov	bx, [ebp+col] ; 07/04/2017
  2836                                  		; 26/07/2017
  2837 00000A0E 6601DB                  		add	bx, bx ; shl bx, 1
  2838                                  		;movzx	eax, word [vseg]
  2839 00000A11 66A1[DC380000]          		mov	ax, [vseg] ; es = [vseg]
  2840 00000A17 C1E004                  		shl	eax, 4
  2841 00000A1A A3[EC530000]            		mov	[_es], eax
  2842 00000A1F 0FB783[E0380000]        		movzx	eax, word [ebx+tseg] ; fs = [ebx+tseg]
  2843 00000A26 C1E004                  		shl	eax, 4
  2844 00000A29 A3[F0530000]            		mov	[_fs], eax
  2845                                  for:
  2846 00000A2E 0FB705[0C540000]        		movzx	eax, word [sstp.y]
  2847 00000A35 663B05[0E540000]        		cmp	ax, word [sstp.maxy]
  2848 00000A3C 0F8FC6020000            		jg	exitDraw
  2849 00000A42 0F848B000000            		je	exitwhile2
  2850                                  while1:
  2851                                  		;mov	ax, [sstp.y]
  2852                                  		;cmp	ax, [sstp.maxy]
  2853                                  		;jge	short while2	
  2854                                  		; 05/02/2017
  2855 00000A48 666B1D[0A540000]24      		imul	bx, word [sstp.l], 36
  2856 00000A50 0FB7F3                  		movzx	esi, bx
  2857 00000A53 03750C                  		add	esi, [ebp+pol]	; [ebp+12]
  2858                                  
  2859 00000A56 663B460C                		cmp	ax, [esi+edge.py] ; [esi+0Ch]
  2860 00000A5A 7530                    		jne	short while2
  2861                                  
  2862 00000A5C 668B1D[0A540000]        		mov	bx, [sstp.l]
  2863 00000A63 664B                    		dec	bx
  2864 00000A65 7D06                    		jge	short nounder
  2865 00000A67 668B5D0A                		mov	bx, [ebp+n]	; [ebp+10]
  2866                                  				 	; dcf.j ; visible edges/points
  2867 00000A6B 664B                    		dec	bx
  2868                                  nounder:
  2869 00000A6D 66891D[0A540000]        		mov	[sstp.l], bx
  2870 00000A74 31FF                    		xor	edi, edi
  2871 00000A76 E891020000              		call	calcDeltas
  2872 00000A7B 66A1[0C540000]          		mov	ax, [sstp.y]
  2873 00000A81 663B05[0E540000]        		cmp	ax, [sstp.maxy]
  2874 00000A88 7D49                    		jge	short exitwhile2	
  2875 00000A8A EBBC                    		jmp	short while1
  2876                                  while2:
  2877                                  		;mov	ax, [sstp.y]
  2878 00000A8C 663B05[0E540000]        		cmp	ax, [sstp.maxy]
  2879 00000A93 7D3E                    		jge	short exitwhile2
  2880                                  		; 05/02/2017
  2881 00000A95 666B1D[08540000]24      		imul	bx, word [sstp.r], 36
  2882 00000A9D 0FB7F3                  		movzx	esi, bx
  2883 00000AA0 03750C                  		add	esi, [ebp+pol]	; [ebp+12]
  2884                                  
  2885 00000AA3 663B460C                		cmp	ax, [esi+edge.py] ; [esi+0Ch]
  2886 00000AA7 752A                    		jne	short exitwhile2
  2887                                  
  2888 00000AA9 668B1D[08540000]        		mov	bx, [sstp.r]
  2889 00000AB0 6643                    		inc	bx
  2890 00000AB2 663B5D0A                		cmp	bx, [ebp+n]	; [ebp+10]
  2891 00000AB6 7C02                    		jl	short noover
  2892                                  		;xor	bx, bx
  2893 00000AB8 31DB                    		xor	ebx, ebx
  2894                                  noover:
  2895 00000ABA 66891D[08540000]        		mov	[sstp.r], bx
  2896 00000AC1 BF14000000              		mov	edi, 20  ; 14h
  2897 00000AC6 E841020000              		call	calcDeltas
  2898                                  		;
  2899 00000ACB 66A1[0C540000]          		mov	ax, [sstp.y]
  2900 00000AD1 EBB9                    		jmp	short while2
  2901                                  exitwhile2:
  2902                                  		;{ up clipping }
  2903 00000AD3 66833D[0C540000]15      		cmp	word [sstp.y], YMIN	; 15h
  2904 00000ADB 0F8C04020000            		jl	clipup
  2905 00000AE1 0FB71D[56540000]        		movzx	ebx, word [sstp.edg+2+edges.x]
  2906 00000AE8 66891D[14540000]        		mov	[sstp.mx1], bx 
  2907 00000AEF 0FB70D[6A540000]        		movzx	ecx, word [sstp.edg+20+2+edges.x]
  2908 00000AF6 66890D[12540000]        		mov	[sstp.mx2], cx
  2909 00000AFD 6629D9                  		sub	cx, bx
  2910 00000B00 0F84DF010000            		jz	exitol
  2911 00000B06 66833D[12540000]00      		cmp	word [sstp.mx2], 0
  2912 00000B0E 0F8ED1010000            		jle	exitol
  2913 00000B14 66813D[14540000]40-     		cmp	word [sstp.mx1], XMAX ; 140h
  2914 00000B1C 01                 
  2915 00000B1D 0F8FC2010000            		jg	exitol
  2916                                  
  2917 00000B23 66F7DB                  		neg	bx
  2918 00000B26 790D                    		jns	short myelse
  2919 00000B28 6631DB                  		xor	bx, bx
  2920 00000B2B EB11                    		jmp	short myendif
  2921                                  _nodivbyzero:
  2922 00000B2D 8B87[40540000]          		mov	eax, [edi+sstp.del+40]
  2923 00000B33 EB26                    		jmp	short nodivbyzero
  2924                                  myelse:
  2925 00000B35 66C705[14540000]00-     		mov	word [sstp.mx1], 0
  2926 00000B3D 00                 
  2927                                  myendif:
  2928 00000B3E BF10000000              		mov	edi, 16 ; 10h
  2929                                  addloop1:
  2930                                  		;{ calculate deltas }
  2931 00000B43 8B87[68540000]          		mov	eax, [edi+sstp.edg+20]
  2932 00000B49 2B87[54540000]          		sub	eax, [edi+sstp.edg]
  2933 00000B4F 99                      		cdq
  2934                                  		;jcxz	nodivbyzero
  2935 00000B50 67E3DA                  		jcxz	_nodivbyzero
  2936 00000B53 F7F9                    		idiv	ecx
  2937 00000B55 8987[40540000]          		mov	[edi+sstp.del+40], eax
  2938                                  nodivbyzero:
  2939                                  		;{ left clipping }
  2940 00000B5B 8B87[40540000]          		mov	eax, [edi+sstp.del+40]
  2941 00000B61 F7EB                    		imul	ebx
  2942 00000B63 0387[54540000]          		add	eax, [edi+sstp.edg]
  2943 00000B69 8987[7C540000]          		mov	[edi+sstp.edg+40], eax
  2944 00000B6F 6683EF04                		sub	di, 4
  2945 00000B73 75CE                    		jnz	short addloop1
  2946                                  
  2947 00000B75 66A1[50540000]          		mov	ax, [sstp.del+40+16]
  2948 00000B7B 66A3[32120000]          		mov	[dels_pos_w], ax
  2949                                  
  2950                                  		;{ right clipping }
  2951 00000B81 66813D[12540000]40-     		cmp	word  [sstp.mx2], XMAX
  2952 00000B89 01                 
  2953 00000B8A 7E09                    		jle	short norightclip
  2954 00000B8C 66C705[12540000]40-     		mov	word  [sstp.mx2], XMAX
  2955 00000B94 01                 
  2956                                  norightclip:
  2957 00000B95 66693D[0C540000]40-     		imul	di, word [sstp.y], 320
  2958 00000B9D 01                 
  2959 00000B9E 66033D[14540000]        		add	di, [sstp.mx1]
  2960                                  		
  2961 00000BA5 66BB0001                		mov	bx, 256 ; 100h
  2962 00000BA9 A1[80540000]            		mov	eax, [sstp.edg+40+edges.u]
  2963 00000BAE F7EB                    		imul	ebx
  2964 00000BB0 F73D[88540000]          		idiv	dword [sstp.edg+40+edges.w]
  2965 00000BB6 66A3[02540000]          		mov	[sstp.uu2], ax
  2966 00000BBC A1[84540000]            		mov	eax, [sstp.edg+40+edges.v]
  2967 00000BC1 F7EB                    		imul	ebx
  2968 00000BC3 F73D[88540000]          		idiv	dword [sstp.edg+40+edges.w]
  2969 00000BC9 66A3[00540000]          		mov	[sstp.vv2], ax
  2970                                  outloop:
  2971 00000BCF 668B0D[12540000]        		mov	cx, [sstp.mx2]
  2972 00000BD6 662B0D[14540000]        		sub	cx, [sstp.mx1]
  2973 00000BDD 0F8E02010000            		jle	exitol
  2974 00000BE3 6683F910                		cmp	cx, SUBRANGE ; 10h
  2975 00000BE7 7E04                    		jle	short lastSeg
  2976 00000BE9 66B91000                		mov	cx, SUBRANGE ; 10h
  2977                                  lastSeg:
  2978                                  		;{ uu1:=uu2 }
  2979                                  		;{ vv1:=vv2 }
  2980 00000BED A1[00540000]            		mov	eax, [sstp.vv2]
  2981 00000BF2 A3[04540000]            		mov	[sstp.vv1], eax
  2982                                  
  2983 00000BF7 A1[44540000]            		mov	eax, [sstp.del+40+edges.u]
  2984 00000BFC F7E9                    		imul	ecx
  2985 00000BFE 0105[80540000]          		add	[sstp.edg+40+edges.u], eax
  2986 00000C04 A1[48540000]            		mov	eax, [sstp.del+40+edges.v]
  2987 00000C09 F7E9                    		imul	ecx
  2988 00000C0B 0105[84540000]          		add	[sstp.edg+40+edges.v], eax
  2989 00000C11 A1[4C540000]            		mov	eax, [sstp.del+40+edges.w]
  2990 00000C16 F7E9                    		imul	ecx
  2991 00000C18 0105[88540000]          		add	[sstp.edg+40+edges.w], eax
  2992                                  
  2993 00000C1E 66BB0001                		mov	bx, 256 ; 100h
  2994 00000C22 A1[80540000]            		mov	eax, [sstp.edg+40+edges.u]
  2995 00000C27 F7EB                    		imul	ebx
  2996 00000C29 F73D[88540000]          		idiv	dword [sstp.edg+40+edges.w]
  2997 00000C2F 66A3[02540000]          		mov	[sstp.uu2], ax
  2998 00000C35 A1[84540000]            		mov	eax, [sstp.edg+40+edges.v]
  2999 00000C3A F7EB                    		imul	ebx
  3000 00000C3C F73D[88540000]          		idiv	dword [sstp.edg+40+edges.w]
  3001 00000C42 66A3[00540000]          		mov	[sstp.vv2], ax
  3002                                  
  3003 00000C48 66A1[02540000]          		mov	ax, [sstp.uu2]
  3004 00000C4E 662B05[06540000]        		sub	ax, [sstp.uu1]
  3005 00000C55 6699                    		cwd
  3006 00000C57 66F7F9                  		idiv	cx
  3007 00000C5A 66A3[34120000]          		mov	[ddu_pos_w], ax
  3008                                  
  3009 00000C60 66A1[00540000]          		mov	ax, [sstp.vv2]
  3010 00000C66 662B05[04540000]        		sub	ax, [sstp.vv1]
  3011 00000C6D 6699                    		cwd
  3012 00000C6F 66F7F9                  		idiv	cx
  3013 00000C72 66A3[36120000]          		mov	[ddv_pos_w], ax
  3014                                  
  3015 00000C78 668B35[04540000]        		mov	si, [sstp.vv1]
  3016 00000C7F 668B15[06540000]        		mov	dx, [sstp.uu1]
  3017 00000C86 66A1[8C540000]          		mov	ax, [sstp.edg+40+16]
  3018                                  innerloop:
  3019                                   		; 05/02/2017
  3020 00000C8C 0FB7DE                  		movzx	ebx, si
  3021 00000C8F 30DB                    		xor	bl, bl
  3022 00000C91 66C1EB02                		shr	bx, 2
  3023 00000C95 00F3                    		add	bl, dh
  3024 00000C97 031D[F0530000]          		add	ebx, [_fs]
  3025 00000C9D 0FB61B                  		movzx	ebx, byte [ebx] ; [fs:bx]
  3026 00000CA0 08DB                    		or	bl, bl
  3027 00000CA2 7415                    		jz	short dels_pos
  3028 00000CA4 88E7                    		mov	bh, ah
  3029 00000CA6 8A9B[A8620000]          		mov	bl, [ebx+shadetab]
  3030                                  
  3031 00000CAC 56                      		push	esi
  3032 00000CAD 0FB7F7                  		movzx	esi, di
  3033 00000CB0 0335[EC530000]          		add	esi, [_es]
  3034 00000CB6 881E                    		mov	[esi], bl	; [es:di] 
  3035 00000CB8 5E                      		pop	esi
  3036                                  dels_pos:	
  3037 00000CB9 660305[32120000]        		add	ax, [dels_pos_w] ;{word ptr dels}
  3038                                  ddu_pos:	
  3039 00000CC0 660315[34120000]        		add	dx, [ddu_pos_w]  ;{word ptr ddu }
  3040                                  ddv_pos:	
  3041 00000CC7 660335[36120000]        		add	si, [ddv_pos_w]  ;{word ptr ddv }
  3042                                  
  3043 00000CCE 6647                    		inc	di	
  3044 00000CD0 E2BA                    		loop	innerloop
  3045                                  
  3046 00000CD2 66A3[8C540000]          		mov	[sstp.edg+40+16], ax
  3047 00000CD8 668305[14540000]10      		add	word [sstp.mx1], SUBRANGE
  3048 00000CE0 E9EAFEFFFF              		jmp	outloop
  3049                                  exitol:
  3050 00000CE5 BF24000000              clipup:		mov	edi, 36 ; 24h
  3051                                  addloop:
  3052 00000CEA 8B87[18540000]          		mov	eax, [edi+sstp.del]
  3053 00000CF0 0187[54540000]          		add	[edi+sstp.edg], eax
  3054 00000CF6 6683EF04                		sub	di, 4
  3055 00000CFA 79EE                    		jns	short addloop
  3056 00000CFC 66FF05[0C540000]        		inc	word [sstp.y]
  3057 00000D03 E926FDFFFF              		jmp	for
  3058                                  exitDraw:
  3059 00000D08 5D                      		pop	ebp
  3060                                  		; 10/08/2017
  3061 00000D09 C20800                  		ret	8 ; word, word, dword
  3062                                  
  3063                                  ;***************************************************
  3064                                  ;* description	: calc deltas for vertical interp. *
  3065                                  ;* parameter	: none			           *
  3066                                  ;* sideeffect	: all		 	           *
  3067                                  ;***************************************************
  3068                                  
  3069                                  calcDeltas:
  3070                                  		; 26/07/2017
  3071 00000D0C 666BD324                		imul	dx, bx,	36
  3072 00000D10 89F3                    		mov	ebx, esi
  3073 00000D12 0FB7F2                  		movzx	esi, dx
  3074 00000D15 03750C                  		add	esi, [ebp+pol]  ; [ebp+12]
  3075                                  		;
  3076 00000D18 668B460C                		mov	ax, [esi+12]
  3077 00000D1C 662B05[0C540000]        		sub	ax, [sstp.y]
  3078 00000D23 0FBFC0                  		movsx	eax, ax
  3079 00000D26 A3[F8530000]            		mov	[sstp.dy], eax
  3080                                  		;mov	ecx, 5
  3081 00000D2B 66B90500                		mov	cx, 5
  3082                                  cDloop:
  3083 00000D2F 8B5310                  		mov	edx, [ebx+16]
  3084 00000D32 8997[54540000]          		mov	[edi+sstp.edg], edx
  3085 00000D38 8B4610                  		mov	eax, [esi+16]
  3086 00000D3B 29D0                    		sub	eax, edx
  3087 00000D3D 99                      		cdq
  3088 00000D3E 66833D[F8530000]00      		cmp	word [sstp.dy], 0
  3089 00000D46 740C                    		je	short cDskip
  3090 00000D48 F73D[F8530000]          		idiv	dword [sstp.dy]
  3091 00000D4E 8987[18540000]          		mov	[edi+sstp.del], eax
  3092                                  cDskip:
  3093                                  		;mov	dx, 4
  3094                                  		;add	di, dx
  3095                                  		;add	si, dx
  3096                                  		;add	bx, dx
  3097                                  
  3098 00000D54 BA04000000              		mov	edx, 4
  3099 00000D59 01D7                    		add	edi, edx ; +4
  3100 00000D5B 01D6                    		add	esi, edx ; +4
  3101 00000D5D 01D3                    		add	ebx, edx ; +4
  3102                                  
  3103 00000D5F E2CE                    		loop	cDloop
  3104 00000D61 C3                      		retn
  3105                                  
  3106                                  ;************************************************
  3107                                  ;* description	: clip a poly at the viewplane, *
  3108                                  ;*                project and draw it	        *
  3109                                  ;* parameter	: bx:adress of the face	        *
  3110                                  ;* sideeffect	: all		 	        *
  3111                                  ;* back		: none			        *
  3112                                  ;************************************************
  3113                                  
  3114                                  drawclippedface:
  3115                                  		; 11/08/2017
  3116                                  		; 27/07/2017
  3117                                  		; 06/02/2017
  3118                                  
  3119                                  		dcf.d	equ -2	  ; word
  3120                                  		dcf.h	equ -4	  ; word	
  3121                                  		dcf.j	equ -6	  ; word
  3122                                  		dcf.col equ -8	  ; word
  3123                                  		dcf.is_in equ -10 ; byte
  3124                                  			
  3125                                  		dcf.p0	equ -192  ; poly (5*36 bytes)
  3126                                  		dcf.p2	equ -372  ; poly (5*36 bytes)
  3127                                  
  3128 00000D62 C8740100                		enter	372, 0  ; 174h
  3129                                   			; push ebp ; mov ebp, esp ; sub esp, 372
  3130                                  
  3131                                  		;mov	si, uvtab
  3132 00000D66 BE[EC140000]            		mov	esi, uvtab
  3133 00000D6B 31FF                    		xor	edi, edi
  3134                                  		;mov	ecx, 4
  3135 00000D6D 66B90400                		mov	cx, 4
  3136                                  dCFinitloop:
  3137                                  		;push	ebx	; face addr (in 'o+object.f')(29/01/2017)
  3138 00000D71 53                      		push	ebx	; face addr (in 'object.f')
  3139                                  		;movzx	ebx, word [ebx]
  3140 00000D72 668B1B                  		mov	bx, [ebx] ; point index into 'rp:' ? (29/01/2017)
  3141                                  
  3142 00000D75 53                      		push	ebx
  3143 00000D76 666BDB0C                		imul	bx, bx, 12 ; (point vector size = 12 bytes)
  3144 00000D7A 81C3[E83A0000]          		add	ebx, rp	  ; addr of rotated point vects (29/01/2017)
  3145 00000D80 8B03                    		mov	eax, [ebx]
  3146                                  		; vector(4-cx).x
  3147 00000D82 89843D40FFFFFF          		mov	[ebp+edi+dcf.p0+0], eax
  3148                                  		; vector(4-cx).y
  3149 00000D89 8B4304                  		mov	eax, [ebx+4]
  3150 00000D8C 89843D44FFFFFF          		mov	[ebp+edi+dcf.p0+4], eax
  3151                                  
  3152 00000D93 D94308                  		fld	dword [ebx+8]
  3153                                  		; vector(4-cx).z
  3154 00000D96 D9943D48FFFFFF          		fst	dword [ebp+edi+dcf.p0+8]
  3155 00000D9D DF5DFC                  		fistp	word [ebp+dcf.h]	; dcf.h = z distance
  3156 00000DA0 5B                      		pop	ebx
  3157                                  
  3158 00000DA1 668B45FC                		mov	ax, [ebp+dcf.h]
  3159 00000DA5 66050002                		add	ax, 512	; 200h
  3160 00000DA9 0F8874010000            		js	dCFbackclip   ; not visible ? (29/01/2017) 
  3161                                  
  3162 00000DAF 663DFF01                		cmp	ax, 511 ; 1FFh
  3163 00000DB3 7E04                    		jle	short intensityOK
  3164 00000DB5 66B8FF01                		mov	ax, 511 ; 1FFh	; maximum z distance (dept) ?
  3165                                  intensityOK:
  3166 00000DB9 66C1E303                		shl	bx, 3 ; point index * 8
  3167 00000DBD 31D2                    		xor	edx, edx
  3168 00000DBF 66C1E007                		shl	ax, 7
  3169                                  		;mul	word [ebx+o+6+object.p]	; [ebx+o+6+4]
  3170 00000DC3 66F7A3[201C0000]        		mul	word [ebx+6+object.p] ; 10/02/2017
  3171                                  		; edges(4-cx).s
  3172 00000DCA 89943D60FFFFFF          		mov	[ebp+edi+dcf.p0+32], edx
  3173                                  
  3174 00000DD1 30E4                    		xor	ah, ah
  3175 00000DD3 8A4604                  		mov	al, [esi+4]
  3176 00000DD6 C1E010                  		shl	eax, 16	; 10h
  3177                                  		; edges(4-cx).v
  3178 00000DD9 89843D58FFFFFF          		mov	[ebp+edi+dcf.p0+24], eax
  3179                                  
  3180 00000DE0 AC                      		lodsb
  3181 00000DE1 C1E010                  		shl	eax, 16	; 10h
  3182                                  		; edges(4-cx).u
  3183 00000DE4 89843D54FFFFFF          		mov	[ebp+edi+dcf.p0+20], eax
  3184                                  
  3185 00000DEB 5B                      		pop	ebx
  3186                                  		;inc	bx
  3187                                  		;inc	bx
  3188 00000DEC 43                      		inc	ebx
  3189 00000DED 43                      		inc	ebx
  3190 00000DEE 6683C724                		add	di, 36	; 24h  ; size of edge
  3191                                  		;loop	dCFinitloop
  3192                                  		;dec	cx
  3193 00000DF2 49                      		dec	ecx
  3194 00000DF3 0F8578FFFFFF            		jnz	dCFinitloop
  3195                                  
  3196                                  		; end of p1, p2, p3, p4 point dimensioning of face
  3197                                  		; 
  3198                                  		; p1 ...... p2
  3199                                  		;  .	    .	
  3200                                  		;  . shade  .
  3201                                  		;  .        .
  3202                                  		; p3 ...... p4
  3203                                  		;
  3204                                  		; p1 (x,y,z) ... p4 (x,y,z)
  3205                                  		;
  3206                                  
  3207 00000DF9 668B03                  		mov	ax, [ebx]		; shade
  3208 00000DFC 668945F8                		mov	[ebp+dcf.col], ax
  3209                                  
  3210 00000E00 31DB                    		xor	ebx, ebx
  3211 00000E02 66895DFA                		mov	[ebp+dcf.j], bx
  3212                                  
  3213                                  		; vector(3).z
  3214 00000E06 D945B4                  		fld	dword [ebp+dcf.p0+108+8]
  3215 00000E09 D9E4                    		ftst
  3216                                  		;fstsw	ax
  3217 00000E0B DFE0                    		fnstsw	ax
  3218 00000E0D DDD8                    		fstp	st0
  3219 00000E0F 9E                      		sahf
  3220 00000E10 7302                    		jae	short isFalse
  3221 00000E12 664B                    		dec	bx
  3222                                  isFalse:
  3223 00000E14 885DF6                  		mov	[ebp+dcf.is_in], bl
  3224 00000E17 31F6                    		xor	esi, esi
  3225 00000E19 31FF                    		xor	edi, edi 
  3226                                  forloop:
  3227                                  		; vector(0-3).z
  3228 00000E1B D9843548FFFFFF          		fld	dword [ebp+esi+dcf.p0+8]
  3229 00000E22 D9E4                    		ftst
  3230                                  		;fstsw	ax
  3231 00000E24 DFE0                    		fnstsw	ax
  3232 00000E26 DDD8                    		fstp	st0
  3233 00000E28 9E                      		sahf
  3234 00000E29 7331                    		jae	short elseFall
  3235                                  
  3236 00000E2B 807DF6FF                		cmp	byte [ebp+dcf.is_in], 0FFh ; -1 ; true
  3237 00000E2F 7408                    		je	short inside
  3238 00000E31 E8EF000000              		call	clipsub
  3239                                  		; { OUT / IN }
  3240 00000E36 F655F6                  		not	byte [ebp+dcf.is_in]
  3241                                  inside:
  3242 00000E39 57                      		push	edi
  3243 00000E3A 56                      		push	esi
  3244 00000E3B 8DBC3D8CFEFFFF          		lea	edi, [ebp+edi+dcf.p2]
  3245 00000E42 8DB43540FFFFFF          		lea	esi, [ebp+esi+dcf.p0]
  3246                                  		;add	edi, dcf.p2
  3247                                  		;add	esi, dcf.p0
  3248                                  
  3249 00000E49 66B91200                		mov	cx, 18	; 12h
  3250 00000E4D F366A5                  		rep movsw		; { IN / IN }
  3251                                  
  3252 00000E50 5E                      		pop	esi
  3253 00000E51 5F                      		pop	edi
  3254 00000E52 6683C724                		add	di, 36	; 24h
  3255 00000E56 66FF45FA                		inc	word [ebp+dcf.j]
  3256 00000E5A EB0E                    		jmp	short dCFendif
  3257                                  elseFall:
  3258 00000E5C 807DF6FF                		cmp	byte [ebp+dcf.is_in], 0FFh
  3259 00000E60 7508                    		jne	short outside
  3260 00000E62 E8BE000000              		call	clipsub
  3261                                  		; { IN / OUT }
  3262 00000E67 F655F6                  		not	byte [ebp+dcf.is_in]
  3263                                  outside:
  3264 00000E6A 6683C624                dCFendif:	add	si, 36 ; 24h
  3265 00000E6E 6681FE9000              		cmp	si, 4*36 ; 90h
  3266 00000E73 75A6                    		jne	short forloop
  3267                                  
  3268 00000E75 668B4DFA                		mov	cx, [ebp+dcf.j]
  3269 00000E79 6683F902                		cmp	cx, 2
  3270 00000E7D 0F8CA0000000            		jl	dCFnodraw
  3271 00000E83 31FF                    		xor	edi, edi
  3272                                  dCFloop:
  3273 00000E85 DF05[7C120000]          		fild	word [CONST13]
  3274 00000E8B D8A43D94FEFFFF          		fsub	dword [ebp+edi+dcf.p2+8]
  3275 00000E92 DE35[80120000]          		fidiv	word [CONST160]
  3276                                  		
  3277 00000E98 D9843D90FEFFFF          		fld	dword [ebp+edi+dcf.p2+4]
  3278 00000E9F D8F1                    		fdiv	st0, st1
  3279 00000EA1 DE05[7E120000]          		fiadd	word [CONST100]
  3280 00000EA7 DB9C3D98FEFFFF          		fistp	dword [ebp+edi+dcf.p2+12]
  3281                                  		
  3282 00000EAE D9843D8CFEFFFF          		fld	dword [ebp+edi+dcf.p2]
  3283 00000EB5 D80D[78120000]          		fmul	dword [ASPECT_PLACE]
  3284 00000EBB D8F1                    		fdiv	st0, st1
  3285 00000EBD DE05[80120000]          		fiadd	word [CONST160]
  3286 00000EC3 D9FC                    		frndint
  3287 00000EC5 DA0D[84120000]          		fimul	dword [CONST65536]
  3288 00000ECB DB9C3D9CFEFFFF          		fistp	dword [ebp+edi+dcf.p2+16]
  3289                                  
  3290 00000ED2 DB843DA0FEFFFF          		fild	dword [ebp+edi+dcf.p2+20]
  3291 00000ED9 D8F1                    		fdiv	st0, st1
  3292 00000EDB DB9C3DA0FEFFFF          		fistp	dword [ebp+edi+dcf.p2+20]
  3293                                  		
  3294 00000EE2 DB843DA4FEFFFF          		fild	dword [ebp+edi+dcf.p2+24]
  3295 00000EE9 D8F1                    		fdiv	st0, st1
  3296 00000EEB DB9C3DA4FEFFFF          		fistp	dword [ebp+edi+dcf.p2+24]
  3297                                  		
  3298 00000EF2 DB05[84120000]          		fild	dword [CONST65536]
  3299 00000EF8 D8F1                    		fdiv	st0, st1
  3300 00000EFA DB9C3DA8FEFFFF          		fistp	dword [ebp+edi+dcf.p2+28]
  3301                                  		
  3302 00000F01 DDD8                    		fstp	st0
  3303 00000F03 6683C724                		add	di, 36 ; 24h
  3304                                  		;loop	dCFloop
  3305 00000F07 6649                    		dec	cx
  3306 00000F09 0F8576FFFFFF            		jnz	dCFloop
  3307                                  
  3308 00000F0F 8DBD8CFEFFFF            		lea	edi, [ebp+dcf.p2]
  3309                                  		; 10/08/2017
  3310 00000F15 57                      		push	edi		; 32 bits push !
  3311 00000F16 66FF75FA                		push	word [ebp+dcf.j]    ; 16 bits push !!
  3312 00000F1A 66FF75F8                		push	word [ebp+dcf.col]  ; 16 bits push !!
  3313 00000F1E E82CFAFFFF              		call	scansubtextpoly
  3314                                  dCFnodraw:
  3315 00000F23 C9                      dCFbackclip:	leave
  3316                                  			; mov esp, ebp ; pop ebp
  3317 00000F24 C3                      		retn
  3318                                  
  3319                                  clipsub:
  3320                                  		; 06/04/2017
  3321                                  		; 05/02/2017
  3322 00000F25 56                      		push	esi
  3323 00000F26 57                      		push	edi
  3324                                  		;lea	ax, [esi-36]
  3325 00000F27 66678D44DC              		lea	ax, [si-36] ; 11/08/2017
  3326 00000F2C 6683F800                		cmp	ax, 0
  3327 00000F30 7D04                    		jge	short cSnounder
  3328                                  		;mov	eax, 108 ; 6Ch
  3329 00000F32 66B86C00                		mov	ax, 108
  3330                                  cSnounder:
  3331 00000F36 D9843548FFFFFF          		fld	dword [ebp+esi+dcf.p0+8]
  3332 00000F3D D9C0                    		fld	st0
  3333 00000F3F 6697                    		xchg	ax, di
  3334 00000F41 D8A43D48FFFFFF          		fsub	dword [ebp+edi+dcf.p0+8]
  3335 00000F48 6697                    		xchg	ax, di
  3336 00000F4A DEF9                    		fdivp	st1, st0
  3337                                  		;fdiv
  3338                                  
  3339 00000F4C BB[E7140000]            		mov	ebx, cliptab
  3340 00000F51 66B90600                		mov	cx, 6
  3341 00000F55 31D2                    		xor	edx, edx
  3342                                  dCFclipLoop2:
  3343 00000F57 6697                    		xchg	ax, di
  3344 00000F59 D9843D40FFFFFF          		fld	dword [ebp+edi+dcf.p0]
  3345 00000F60 6697                    		xchg	ax, di
  3346 00000F62 D8A43540FFFFFF          		fsub	dword [ebp+esi+dcf.p0]
  3347 00000F69 D8C9                    		fmul	st0, st1
  3348 00000F6B D8843540FFFFFF          		fadd	dword [ebp+esi+dcf.p0]
  3349 00000F72 D99C3D8CFEFFFF          		fstp	dword [ebp+edi+dcf.p2]
  3350                                  
  3351 00000F79 8A13                    		mov	dl, [ebx]
  3352 00000F7B 43                      		inc	ebx
  3353 00000F7C 01D7                    		add	edi, edx
  3354 00000F7E 01D6                    		add	esi, edx
  3355 00000F80 01D0                    		add	eax, edx
  3356 00000F82 E2D3                    		loop	dCFclipLoop2
  3357 00000F84 DDD8                    		fstp	st0
  3358 00000F86 5F                      		pop	edi
  3359 00000F87 5E                      		pop	esi
  3360 00000F88 66FF45FA                		inc	word [ebp+dcf.j]
  3361                                  		;add	edi, 36
  3362 00000F8C 6683C724                		add	di, 36 ; 24h
  3363 00000F90 C3                      		retn
  3364                                  
  3365                                  
  3366                                  ;***************************************************
  3367                                  ;* description	: rotate point over one axis       *
  3368                                  ;* parameter	: st(0):angle, [ds:si] ptr to	   *
  3369                                  ;*		  1.koord.,[ds:bx] ptr to 2.koord. *
  3370                                  ;* sideeffect	: empty copro-stack		   *
  3371                                  ;* back		: none			           *
  3372                                  ;***************************************************
  3373                                  
  3374                                  rotateAxis:
  3375 00000F91 D9EB                    		fldpi				;{ PI,a}
  3376 00000F93 DEC9                    		fmulp	st1, st0		;{ PI*a}	
  3377                                  		;fmul
  3378 00000F95 DA35[84120000]          		fidiv	dword [CONST65536]	;{ PI*a/65536}
  3379 00000F9B D9FB                    		fsincos				;{ cos,sin}
  3380 00000F9D D9C0                    		fld	st0			;{ cos,cos,sin}
  3381 00000F9F D80E                    		fmul	dword [esi] 		;{ y*cos,cos,sin}
  3382 00000FA1 D9C2                    		fld	st2			;{ sin,y*cos,cos,sin}
  3383 00000FA3 D80B                    		fmul	dword [ebx]		;{ z*sin,y*cos,cos,sin}
  3384 00000FA5 DEE9                    		fsubp	st1, st0		;{ y*cos-z*sin,cos,sin}
  3385 00000FA7 D9CA                    		fxch	st2			;{ sin,cos,y*cos-z*sin}
  3386 00000FA9 D80E                    		fmul	dword [esi]		;{ y*sin,cos,y*cos-z*sin}
  3387 00000FAB D9C9                    		fxch	st1			;{ cos,y*sin,y*cos-z*sin}
  3388 00000FAD D80B                    		fmul	dword [ebx]		;{ z*cos,y*sin,y*cos-z*sin}
  3389 00000FAF DEC1                    		faddp	st1, st0		;{ y*sin+z*cos,y*cos-z*sin}
  3390 00000FB1 D91B                    		fstp	dword [ebx]		;{ y*cos-z*sin}
  3391 00000FB3 D91E                    		fstp	dword [esi]		;{}
  3392 00000FB5 C3                      		retn
  3393                                  
  3394                                  ;***********************************************
  3395                                  ;* description	: rotate point		       *
  3396                                  ;* parameter	: a,b,c:angles,adr:address     *
  3397                                  ;* sideeffect	: all		 	       *
  3398                                  ;* back		: none			       *
  3399                                  ;***********************************************
  3400                                  
  3401                                  xyzRotate:
  3402                                  		; 11/08/2017
  3403                                  		;;push	word [ebp+xw] ; a ; 16 bits push !!
  3404                                  		;;push	word [ebp+yw] ; b ; 16 bits push !!
  3405                                  		;;push	word [ebp+zw] ; c ; 16 bits push !!
  3406                                  		;;add	di, nwmat
  3407                                  		;;push	edi	      ; adr ; 32 bits push !
  3408                                  		;;call	xyzRotate
  3409                                  		;;pop	edi
  3410                                  
  3411                                  		adr	equ 8   ; arg 1, [esp+4]
  3412                                  		c	equ 12	; arg 2, [esp+8]	
  3413                                  		b	equ 14  ; arg 3, [esp+10]
  3414                                  		a	equ 16  ; arg 4, [esp+12]
  3415                                  
  3416 00000FB6 55                      		push	ebp
  3417 00000FB7 89E5                    		mov	ebp, esp
  3418                                  	
  3419 00000FB9 8B7D08                  		mov	edi, [ebp+adr] ; nwmat+
  3420                                  
  3421                                  		; nwmat:	;;; edi +0 +4 +8	 	
  3422                                  		; loop 1 (nwmat)    : dd 1, 0, 0
  3423                                  		; loop 2 (nwmat+12) : dd 0, 1, 0
  3424                                  		; loop 3 (nwmat+24) : dd 0, 0, 1
  3425                                  
  3426 00000FBC DF4510                  		fild	word [ebp+a]   ; xw ; a (x angle)
  3427 00000FBF 8D5F08                  		lea	ebx, [edi+8]   ; z (2. coordinate)	
  3428 00000FC2 8D7704                  		lea	esi, [edi+4]   ; y (1. coordinate)
  3429 00000FC5 E8C7FFFFFF              		call	rotateAxis
  3430 00000FCA DF450E                  		fild	word [ebp+b]   ; yw ; a (y angle)
  3431 00000FCD 8D1F                    		lea	ebx, [edi]     ; z	
  3432 00000FCF 8D7708                  		lea	esi, [edi+8]   ; y	
  3433 00000FD2 E8BAFFFFFF              		call	rotateAxis
  3434 00000FD7 DF450C                  		fild	word [ebp+c]   ; zw ; a (z angle)	
  3435 00000FDA 8D5F04                  		lea	ebx, [edi+4]   ; z	
  3436 00000FDD 8D37                    		lea	esi, [edi]     ; y
  3437 00000FDF E8ADFFFFFF              		call	rotateAxis
  3438                                  
  3439 00000FE4 5D                      		pop	ebp
  3440                                  		; 11/08/2017 
  3441                                  		; (pop dw, pop w, pop w, pop w)
  3442 00000FE5 C20A00                  		ret	10
  3443                                  
  3444                                  ;***********************************************
  3445                                  ;* description	: calculate world matrix       *
  3446                                  ;* parameter	: x-,y-,z-angle,neig:stack     *
  3447                                  ;* sideeffect	: all		 	       *
  3448                                  ;* back		: none			       *
  3449                                  ;***********************************************
  3450                                  
  3451                                  calcRotMat:
  3452                                  		; 11/08/2017  (16 bits pushes)
  3453                                  
  3454                                  		; [esp] = [oyw]*16 ; angle or YSTEP * 16 ?		        	
  3455                                  		; [esp+2] = [ozw] ; ZSTEP
  3456                                  		; [esp+4] = [oyw] ; YSTEP
  3457                                  		; [esp+6] = [oxw] ; XSTEP
  3458                                  
  3459                                  		neig	equ 8   ; arg 1, [esp+4]
  3460                                  		zw	equ 10	; arg 2, [esp+6]	
  3461                                  		yw	equ 12  ; arg 3, [esp+8]
  3462                                  		xw	equ 14  ; arg 4, [esp+10]
  3463                                  
  3464 00000FE8 55                      		push	ebp
  3465 00000FE9 89E5                    		mov	ebp, esp
  3466                                  
  3467 00000FEB BF[80180000]            		mov	edi, nwmat
  3468                                  		
  3469                                  		identityMat
  3470                              <1> 
  3471                              <1> 
  3472                              <1> 
  3473 00000FF0 B502                <1>  mov ch, 2
  3474                              <1> iMolp:
  3475 00000FF2 B102                <1>  mov cl, 2
  3476                              <1> iMilp:
  3477 00000FF4 D9EE                <1>  fldz
  3478 00000FF6 38CD                <1>  cmp ch, cl
  3479 00000FF8 7504                <1>  jne short iMwritezero
  3480 00000FFA DDD8                <1>  fstp st0
  3481 00000FFC D9E8                <1>  fld1
  3482                              <1> iMwritezero:
  3483 00000FFE D91F                <1>  fstp dword [edi]
  3484                              <1> 
  3485 00001000 83C704              <1>  add edi, 4
  3486 00001003 FEC9                <1>  dec cl
  3487 00001005 79ED                <1>  jns short iMilp
  3488 00001007 FECD                <1>  dec ch
  3489 00001009 79E7                <1>  jns short iMolp
  3490                                  	
  3491                                  		; nwmat:
  3492                                  		; dd 1,0,0
  3493                                  		; dd 0,1,0
  3494                                  		; dd 0,0,1
  3495                                  		
  3496 0000100B 31FF                    		xor	edi, edi
  3497                                  cRMolp:
  3498 0000100D 57                      		push	edi
  3499                                  		; 11/07/2017 (16 bits pushes)
  3500 0000100E 66FF750E                		push	word [ebp+xw] ; a (x angle)
  3501 00001012 66FF750C                		push	word [ebp+yw] ; b (y angle)
  3502 00001016 66FF750A                		push	word [ebp+zw] ; c (z angle)
  3503                                  		;add	edi, nwmat
  3504 0000101A 6681C7[8018]            		add	di, nwmat
  3505 0000101F 57                      		push	edi  ; 32 bits push  ; adr
  3506 00001020 E891FFFFFF              		call	xyzRotate
  3507 00001025 5F                      		pop	edi
  3508 00001026 31DB                    		xor	ebx, ebx
  3509                                  cRMilp:
  3510 00001028 D987[80180000]          		fld	dword [edi+nwmat]
  3511 0000102E D88B[36180000]          		fmul	dword [ebx+owmat]
  3512 00001034 D987[84180000]          		fld	dword [edi+nwmat+4]
  3513 0000103A D88B[42180000]          		fmul	dword [ebx+owmat+12]
  3514 00001040 D987[88180000]          		fld	dword [edi+nwmat+8]
  3515 00001046 D88B[4E180000]          		fmul	dword [ebx+owmat+24]
  3516 0000104C DEC1                    		fadd
  3517 0000104E DEC1                    		fadd
  3518 00001050 D9943B[36180000]        		fst	dword [ebx+edi+owmat]
  3519 00001057 D99C3B[5C180000]        		fstp	dword [ebx+edi+wmat]
  3520 0000105E 6683C304                		add	bx, 4
  3521 00001062 80FB0C                  		cmp	bl, 12
  3522 00001065 75C1                    		jne	short cRMilp
  3523 00001067 6683C70C                		add	di, 12
  3524 0000106B 6683FF24                		cmp	di, 36
  3525 0000106F 759C                    		jne	short cRMolp
  3526                                  
  3527 00001071 BE[5C180000]            		mov	esi, wmat
  3528 00001076 66B90300                		mov	cx, 3
  3529                                  cRMneigloop:
  3530 0000107A DF4508                  		fild	word [ebp+neig]
  3531 0000107D 8D5E0C                  		lea	ebx, [esi+12]
  3532 00001080 E80CFFFFFF              		call	rotateAxis
  3533 00001085 6683C604                		add	si, 4
  3534 00001089 E2EF                    		loop	cRMneigloop
  3535                                  
  3536 0000108B 5D                      		pop	ebp
  3537                                  		; 11/08/2017 (16 bits pops)
  3538 0000108C C20800                  		ret	8
  3539                                  
  3540                                  ;***********************************************
  3541                                  ;* description	: create the world	       *
  3542                                  ;* parameter	: none			       *
  3543                                  ;* sideeffect	: all		               *
  3544                                  ;* back		: none			       *
  3545                                  ;***********************************************
  3546                                  
  3547                                  createWorld:
  3548                                  		; 11/08/2017
  3549                                  		; 10/08/2017
  3550                                  		; 27/07/2017
  3551                                  		; 06/02/2017
  3552 0000108F BE[39150000]            		mov	esi, world
  3553                                  		;mov	cx, 4
  3554 00001094 B904000000              		mov	ecx, 4 ;
  3555                                  cWworldLoop:
  3556 00001099 51                      		push	ecx
  3557 0000109A 56                      		push	esi
  3558 0000109B BF[08390000]            		mov	edi, p
  3559 000010A0 BB[80390000]            		mov	ebx, pr
  3560 000010A5 66BE[0C15]              		mov	si, print
  3561 000010A9 B10F                    		mov	cl, 15 ; 0Fh
  3562                                  cWinitStartRoom:
  3563 000010AB 51                      		push	ecx
  3564 000010AC B103                    		mov	cl, 3
  3565                                  cWinnerLoop:
  3566 000010AE AC                      		lodsb  ; byte data (to be converted to dword) from the 'print:'
  3567 000010AF 6698                    		cbw    ; convert byte to word with sign (0E0h -> FFE0h)	
  3568 000010B1 66AB                    		stosw  ; store world coordinate/dimension as integer (word), to 'p:' 
  3569 000010B3 DF47FE                  		fild	word [edi-2]
  3570 000010B6 D91B                    		fstp	dword [ebx] ; store coordinate as floatpoint (29/01/2017)
  3571 000010B8 6683C304                		add	bx, 4 ; next dimension (x,y,z) in 'pr:'
  3572 000010BC E2F0                    		loop	cWinnerLoop
  3573 000010BE 59                      		pop	ecx
  3574 000010BF 66B8007F                		mov	ax, 127*256 ; 7F00h ;  4th dimension in 'p:' (29/01/2017)
  3575 000010C3 66AB                    		stosw
  3576 000010C5 E2E4                    		loop	cWinitStartRoom
  3577 000010C7 5E                      		pop	esi
  3578                                  cWmainLoop:
  3579 000010C8 AC                      		lodsb	; the byte from 'world:' for shade and direction (29/01/2017)
  3580 000010C9 3CFF                    		cmp	al, 255 ; 0FFh
  3581 000010CB 0F8457010000            		je	cWexit  ; end of stage (1 to 4) (29/01/2017)
  3582                                  
  3583 000010D1 88C7                    		mov	bh, al  ; High 4 bits for shading (29/01/2017)
  3584 000010D3 6681E30070              		and	bx, 7000h
  3585 000010D8 80C70F                  		add	bh, 15 ; 0Fh
  3586 000010DB 66891D[F6530000]        		mov	[cw.shade], bx
  3587 000010E2 6683E00F                		and	ax, 0Fh ; 15   ; Low 4 bits for direction (29/01/2017)
  3588 000010E6 66A3[F4530000]          		mov	[cw.direc], ax
  3589                                  
  3590 000010EC 31DB                    		xor	ebx, ebx
  3591 000010EE EB0A                    		jmp	short cWfirstNibble ; 27/07/2017
  3592                                  cWsideLoop:
  3593 000010F0 F6C304                  		test	bl, 4
  3594 000010F3 7405                    		jz	short cWfirstNibble
  3595 000010F5 AC                      		lodsb
  3596 000010F6 240F                    		and	al, 0Fh ; 15
  3597 000010F8 EB05                    		jmp	short cWsecondNibble
  3598                                  cWfirstNibble:
  3599 000010FA 8A06                    		mov	al, [esi]
  3600 000010FC C0E804                  		shr	al, 4
  3601                                  cWsecondNibble:
  3602 000010FF 31FF                    		xor	edi, edi ; 10/02/2017 (is this necessary?)
  3603 00001101 30E4                    		xor	ah, ah
  3604 00001103 6648                    		dec	ax
  3605 00001105 7866                    		js	short cWnoWall ; ax = 0 -> ax = 0FFFFh (29/01/2017)
  3606                                  		;imul	di, word [o+object.fanz], 10 ; 0Ah
  3607 00001107 666B3D[181C0000]0A      		imul	di, word [object.fanz], 10 ; 10/02/2017
  3608                                  		;add	di, o+object.f ; base address + offset
  3609                                  		;add	di, object.f ; base address + offset		
  3610 0000110F 81C7[9A280000]          		add	edi, object.f ; 10/02/2017
  3611                                  		;inc	word [o+object.fanz] ; faces = faces + 1
  3612 00001115 66FF05[181C0000]        		inc	word [object.fanz] ; faces = faces + 1
  3613 0000111C 66894708                		mov	[edi+8], ax ; 4th word is shading value (29/01/2017)
  3614                                  
  3615 00001120 53                      		push	ebx
  3616 00001121 56                      		push	esi
  3617 00001122 B104                    		mov	cl, 4
  3618                                  cWaddPointloop:
  3619                                  		;movsx	esi, byte [ebx+cube] ; cube coordinate offset (29/01/207)
  3620                                  		;xor	esi, esi ; 10/02/2017
  3621                                  		;movsx	si, byte [ebx+cube]
  3622 00001124 0FB6B3[F4140000]        		movzx	esi, byte [ebx+cube] ; 11/02/2017
  3623 0000112B 81C6[08390000]          		add	esi, p ; + base address (p:) (29/01/2017)
  3624                                  
  3625 00001131 57                      		push	edi
  3626                                  		;mov	edi, o+object.p  ; p area of object structure (in o:)
  3627 00001132 BF[1A1C0000]            		mov	edi, object.p ; 10/02/2017
  3628 00001137 51                      		push	ecx
  3629                                  		;mov	cx, [o+object.panz] ; number of points (for object.p)
  3630 00001138 668B0D[161C0000]        		mov	cx, [object.panz] ; 10/02/2017
  3631                                  		;xor	ax, ax
  3632 0000113F 31C0                    		xor	eax, eax
  3633 00001141 67E317                  		jcxz	cWfirstPoint
  3634                                  cWsearchPointLoop: ; check point coordinates are same or not (29/01/2017)
  3635 00001144 8B16                    		mov	edx, [esi]
  3636 00001146 3B17                    		cmp	edx, [edi]
  3637 00001148 750A                    		jne	short cWdifferent
  3638 0000114A 668B5604                		mov	dx, [esi+4]
  3639 0000114E 663B5704                		cmp	dx, [edi+4]
  3640 00001152 7410                    		je	short cWpointExists
  3641                                  cWdifferent:
  3642                                  		;inc	ax ; number of different points (of object)
  3643 00001154 40                      		inc	eax
  3644 00001155 6683C708                		add	di, 8
  3645 00001159 E2E9                    		loop	cWsearchPointLoop
  3646                                  cWfirstPoint:
  3647 0000115B A5                      		movsd
  3648 0000115C A5                      		movsd
  3649                                  		;inc	word [o+object.panz] ; points = points + 1
  3650 0000115D 66FF05[161C0000]        		inc	word [object.panz] ; 10/02/2017
  3651                                  cWpointExists:
  3652 00001164 59                      		pop	ecx
  3653 00001165 5F                      		pop	edi
  3654 00001166 66AB                    		stosw   ; store number of different points (29/01/2017)
  3655                                  			; in the Xth word of face structure (5 words)
  3656                                  			; (Xth word of 'object.f', X = 4-CL)
  3657 00001168 43                      		inc	ebx
  3658 00001169 E2B9                    		loop	cWaddPointloop
  3659 0000116B 5E                      		pop	esi
  3660 0000116C 5B                      		pop	ebx
  3661                                  cWnoWall:
  3662                                  		; 27/07/2017
  3663                                  		;add	bx, 4
  3664 0000116D 80C304                  		add	bl, 4
  3665                                  		;cmp	bx, 24 ; 18h
  3666 00001170 80FB18                  		cmp	bl, 24
  3667                                  		;jne	cWsideLoop
  3668 00001173 0F8277FFFFFF            		jb	cWsideLoop ; 10/08/2017
  3669                                  
  3670                                  		;xor	edi, edi ; 10/02/2017
  3671 00001179 666B3D[F4530000]0C      		imul	di, word [cw.direc], 12
  3672                                  		;movsx	edi, di ; 05/02/2017
  3673 00001181 B103                    		mov	cl, 3
  3674                                  		;mov	ebx, pr+96
  3675 00001183 66BB[E039]              		mov	bx, pr+96 ; 24th dword of 'pr:'
  3676                                  cWaddStepLoop:
  3677 00001187 D94348                  		fld	dword [ebx+72] ; [ebx+48h]
  3678 0000118A D8043B                  		fadd	dword [ebx+edi]
  3679 0000118D D95B48                  		fstp	dword [ebx+72]
  3680 00001190 6683C304                		add	bx, 4
  3681 00001194 E2F1                    		loop	cWaddStepLoop
  3682                                  
  3683 00001196 807EFC00                		cmp	byte [esi-4], 0
  3684 0000119A 7D28                    		jge	short cWsimpleRoom
  3685                                  
  3686 0000119C 66BB[8039]              		mov	bx, pr
  3687 000011A0 B10E                    		mov	cl, 14 ; 0Eh
  3688                                  cWrotloop:
  3689 000011A2 60                      		pushad
  3690 000011A3 B103                    		mov	cl, 3
  3691 000011A5 8A16                    		mov	dl, [esi]
  3692                                  cWpushLoop:
  3693 000011A7 31C0                    		xor	eax, eax
  3694 000011A9 D0EA                    		shr	dl, 1
  3695 000011AB 7305                    		jnc	short cWnoRot
  3696 000011AD 8A26                    		mov	ah, [esi]
  3697                                  		;and	ax, 0F000h
  3698 000011AF 80E4F0                  		and	ah, 0F0h
  3699                                  		;push	ax
  3700                                  		;jmp	short cWendIf
  3701                                  cWnoRot:
  3702                                  		;push	0 ; arg 2 (c), arg 3 (b), arg 4 (a)
  3703                                  		; 11/08/2017
  3704 000011B2 6650                    		push	ax  ; 16 bits push !!
  3705                                  cWendIf:
  3706 000011B4 E2F1                    		loop	cWpushLoop
  3707                                  		; 11/08/2017
  3708 000011B6 53                      		push	ebx ; arg 1 (addr)  ; 32 bits push !
  3709 000011B7 E8FAFDFFFF              		call	xyzRotate
  3710 000011BC 61                      		popad
  3711 000011BD 6683C30C                		add	bx, 12 ; 0Ch
  3712 000011C1 E2DF                    		loop	cWrotloop
  3713 000011C3 46                      		inc	esi
  3714                                  cWsimpleRoom:
  3715 000011C4 668B1D[F4530000]        		mov	bx, [cw.direc]
  3716 000011CB 66C1E302                		shl	bx, 2
  3717 000011CF B104                    		mov	cl, 4
  3718                                  cWpointCopyLoop:
  3719 000011D1 60                      		pushad
  3720                                  		;movsx	esi, byte [ebx+cube]
  3721                                  		;xor	esi, esi ; 10/02/2017
  3722                                  		;movsx	si, byte [ebx+cube]
  3723 000011D2 0FB6B3[F4140000]        		movzx	esi, byte [ebx+cube] ; 11/02/2017
  3724 000011D9 89F0                    		mov	eax, esi
  3725 000011DB 81C6[08390000]          		add	esi, p ; + base address of 'p:'
  3726 000011E1 80F307                  		xor	bl, 7
  3727                                  		;movsx	edi, byte [ebx+cube]
  3728                                  		;xor	edi, edi ; 10/02/2017
  3729 000011E4 0FB6BB[F4140000]        		movzx	edi, byte [ebx+cube]
  3730 000011EB 81C7[08390000]          		add	edi, p ; + base address of 'p:'
  3731 000011F1 56                      		push	esi 
  3732 000011F2 A5                      		movsd
  3733 000011F3 A5                      		movsd
  3734 000011F4 5E                      		pop	esi
  3735                                  
  3736 000011F5 89C3                    		mov	ebx, eax
  3737                                  		;shr	ebx, 1
  3738 000011F7 66D1EB                  		shr	bx, 1
  3739 000011FA 01C3                    		add	ebx, eax
  3740 000011FC BF[80390000]            		mov	edi, pr ; + base address of 'pr:'
  3741 00001201 B103                    		mov	cl, 3
  3742                                  cWSround:
  3743 00001203 D9043B                  		fld	dword [ebx+edi]
  3744 00001206 D887A8000000            		fadd	dword [edi+168]  ; [edi+0A8h]
  3745 0000120C DF1E                    		fistp	word [esi] ; world coordinate/dimension
  3746 0000120E 6683C704                		add	di, 4
  3747 00001212 46                      		inc	esi
  3748 00001213 46                      		inc	esi
  3749 00001214 E2ED                    		loop	cWSround
  3750 00001216 66A1[F6530000]          		mov	ax, [cw.shade]
  3751 0000121C 668906                  		mov	[esi], ax ; 4th word
  3752 0000121F 61                      		popad
  3753 00001220 43                      		inc	ebx
  3754 00001221 E2AE                    		loop	cWpointCopyLoop
  3755 00001223 E9A0FEFFFF              		jmp	cWmainLoop
  3756                                  cWexit:
  3757 00001228 59                      		pop	ecx
  3758                                  		;dec	cx
  3759 00001229 FEC9                    		dec	cl ; 27/07/2017
  3760 0000122B 0F8568FEFFFF            		jnz	cWworldLoop
  3761 00001231 C3                      		retn
  3762                                  
  3763                                  ; 17/01/2017
  3764 00001232 1111                    dels_pos_w:	dw 1111h
  3765 00001234 1111                    ddu_pos_w:	dw 1111h
  3766 00001236 1111                    ddv_pos_w:	dw 1111h
  3767                                  
  3768                                  prg_msg:
  3769 00001238 4552444F47414E2054-     		db	'ERDOGAN TAN - TRDOS 386 VGA Test - SNCOMNI.PRG'
  3770 00001241 414E202D205452444F-
  3771 0000124A 532033383620564741-
  3772 00001253 2054657374202D2053-
  3773 0000125C 4E434F4D4E492E5052-
  3774 00001265 47                 
  3775 00001266 0D0A                    		db	0Dh, 0Ah
  3776 00001268 31322F30382F323031-     		db	'12/08/2017'
  3777 00001271 37                 
  3778 00001272 0D0A                    		db	0Dh, 0Ah
  3779 00001274 00                      		db	0 
  3780                                  
  3781 00001275 90<rept>                align 4
  3782                                  
  3783                                  ;=============================================================================
  3784                                  ;               preinitialized data
  3785                                  ;=============================================================================
  3786                                  
  3787 00001278 9A99993F                ASPECT_PLACE:	dd ASPECT_RATIO		; 1.2
  3788 0000127C 0D00                    CONST13:	dw 13			; 000Dh			
  3789 0000127E 6400                    CONST100:	dw CENTERY		; 0064h
  3790 00001280 A000                    CONST160:	dw CENTERX		; 00A0h
  3791 00001282 0007                    CONST1792:	dw 1792			; 0700h
  3792 00001284 00000100                CONST65536:	dd 65536		; 00010000h
  3793 00001288 05840808                randommul:	dd 134775813		; 08088405h
  3794 0000128C FB100000                randomseed:	dd 4347			; 000010FBh
  3795                                  credits:
  3796 00001290 0250FB                  		db	 2, 80,-5
  3797 00001293 FE320445023E024502-     		db      -2,50,4,69,2,62,2,69,2,81,2,62,2,69,2,79,2,62,2,69,2
  3798 0000129C 51023E0245024F023E-
  3799 000012A5 024502             
  3800 000012A8 51023E0245024F0251-     		db	81,2,62,2,69,2,79,2,81,2,0	; { pat 0,2,4,6,8 }
  3801 000012B1 0200               
  3802 000012B3 FE320446023E024602-     		db      -2,50,4,70,2,62,2,70,2,81,2,62,2,70,2,79,2,62,2,70,2
  3803 000012BC 51023E0246024F023E-
  3804 000012C5 024602             
  3805 000012C8 52023E0246024F0252-     		db	82,2,62,2,70,2,79,2,82,2,0	; { pat 1,3,5,7,9 }
  3806 000012D1 0200               
  3807 000012D3 00                      		db       0
  3808 000012D4 37203820                		db      55,32,56,32			; { pat 10 }
  3809 000012D8 332035183708            		db      51,32,53,24,55,8                ; { pat 11 }
  3810 000012DE 39203220                		db      57,32,50,32		 	; { pat 12 }
  3811 000012E2 3C303A083908            		db      60,48,58,8,57,8                 ; { pat 13 }
  3812 000012E8 3740                    		db      55,64		   		; { pat 14 }
  3813 000012EA FE43103E1045104610-     		db      -2,67,16,62,16,69,16,70,16,0	; { pat 15 }
  3814 000012F3 00                 
  3815 000012F4 FE461045103E104110-     		db      -2,70,16,69,16,62,16,65,16,0    ; { pat 16 }
  3816 000012FD 00                 
  3817 000012FE 00                      		db       0
  3818 000012FF 043201800180            		db       4, 50,1,128,1,128              ;{ pat 0-3 }
  3819 00001305 411C4002410240103E-     		db      65,28,64,2,65,2,64,16,62,8,60,8 ;{ pat 4 }
  3820 0000130E 083C08             
  3821 00001311 431C41043C10410840-     		db      67,28,65,4,60,16,65,8,64,8      ;{ pat 5 }
  3822 0000131A 08                 
  3823 0000131B 3E20321040084108        		db      62,32,50,16,64,8,65,8           ;{ pat 6 }
  3824 00001323 43203C103E084008        		db      67,32,60,16,62,8,64,8           ;{ pat 7 }
  3825 0000132B 3E80                    		db      62,128		  		;{ pat 8,9 }
  3826 0000132D 4380                    		db      67,128		  		;{ pat 10,11 }
  3827 0000132F 431040104210400842-     		db     	67,16,64,16,66,16,64,8,66,8	;{ pat 12 }
  3828 00001338 08                 
  3829 00001339 48304610                		db     	72,48,70,16                 	;{ pat 13 }
  3830 0000133D 43203720                		db     	67,32,55,32                 	;{ pat 14 }
  3831 00001341 FE1F20372000            		db     	-2,31,32,55,32,0                ;{ pat 15 }
  3832 00001347 FE1A20322000            		db      -2,26,32,50,32,0                ;{ pat 16 }
  3833 0000134D 00                      		db       0
  3834 0000134E 0559FB018000            		db       5, 89,-5,1,128,0		;{ pat 0-9 }
  3835 00001354 43084A1844084B18        		db      67,8,74,24,68,8,75,24           ;{ pat 10 }
  3836 0000135C 3F0846183C08451043-     		db      63,8,70,24,60,8,69,16,67,8      ;{ pat 11 }
  3837 00001365 08                 
  3838 00001366 3E08451043083E0842-     		db      62,8,69,16,67,8,62,8,66,24	;{ pat 12 }
  3839 0000136F 18                 
  3840 00001370 3F0843183C08431045-     		db      63,8,67,24,60,8,67,16,69,8	;{ pat 13 }
  3841 00001379 08                 
  3842 0000137A 370843182B083218        		db      55,8,67,24,43,8,50,24           ;{ pat 14 }
  3843 00001382 FE1F01263F00            		db      -2,31,1,38,63,0                	;{ pat 15 }
  3844 00001388 FE1A01213F00            		db      -2,26,1,33,63,0                	;{ pat 16 }
  3845 0000138E 00                      		db       0
  3846 0000138F 0A00F02A022A022A02-     		db	10,  0,-16,42,2,42,2,42,2,42,1,42,1,0 ;{ pat 0,1 }
  3847 00001398 2A012A0100         
  3848 0000139D F024022A022A022A01-     		db     -16,36,2,42,2,42,2,42,1,42,1,0   ;{ pat 2,3 }
  3849 000013A6 2A0100             
  3850 000013A9 E224022A022E022401-     		db     -30,36,2,42,2,46,2,36,1,42,1,38,2
  3851 000013B2 2A012602           
  3852 000013B6 2A022E0226012A01        		db	42,2,46,2,38,1,42,1     	;{ pat 4-16 }
  3853 000013BE 2402260224022A012A-     		db      36,2,38,2,36,2,42,1,42,1,38,2,42,2,46,2,38,1,42,1,0
  3854 000013C7 0126022A022E022601-
  3855 000013D0 2A0100             
  3856 000013D3 00                      		db     	 0
  3857 000013D4 00                      		db	 0
  3858                                  
  3859                                  ; colortable 65 bytes
  3860 000013D5 10                      colors 		db	16
  3861 000013D6 1F3F3F3F                                db      31,63,63,63
  3862 000013DA 01000000                                db	 1, 0, 0, 0
  3863 000013DE 1F28203F                                db      31,40,32,63
  3864 000013E2 01000000                                db	 1, 0, 0, 0
  3865 000013E6 1F3F0000                                db      31,63, 0, 0
  3866 000013EA 01060100                                db	 1, 6, 1, 0
  3867 000013EE 1F3F2914                                db      31,63,41,20
  3868 000013F2 01000000                                db	 1, 0, 0, 0
  3869 000013F6 1F3F3F08                                db      31,63,63, 8
  3870 000013FA 01000000                                db	 1, 0, 0, 0
  3871 000013FE 1F38383F                                db	31,56,56,63
  3872 00001402 013F0000                                db	 1,63, 0, 0
  3873 00001406 103F3F00                                db      16,63,63, 0
  3874 0000140A 103F0000                                db      16,63, 0, 0
  3875 0000140E 01160500                                db	 1,22, 5, 0
  3876 00001412 073F3811                                db       7,63,56,17
  3877                                  
  3878                                  ; parameter for the texture effects 156 bytes
  3879 00001416 130F0F31310A            aE              db	013h,15,15,49,49,10
  3880 0000141C 131010303011                            db      013h,16,16,48,48,17
  3881 00001422 1311112F2F18                            db      013h,17,17,47,47,24
  3882 00001428 1312122E2EBE                            db      013h,18,18,46,46,190
  3883 0000142E 1315152B2B1E                            db      013h,21,21,43,43,30
  3884 00001434 2500003E1E03                            db      025h,0,0,62,30,3
  3885 0000143A 2503033E1E07                            db      025h,3,3,62,30,7
  3886 00001440 2503033B1BFC                            db      025h,3,3,59,27,0FCh
  3887 00001446 2500203E3E03                            db      025h,0,32,62,62,3
  3888 0000144C 2503233E3E07                            db      025h,3,35,62,62,7
  3889 00001452 2503233B3BFC                            db      025h,3,35,59,59,0FCh
  3890 00001458 2500003F3FFE                            db      025h,0,0,63,63,0FEh
  3891 0000145E 2C000A3F0FF6                            db      02Ch,0,10,63,15,0F6h
  3892 00001464 2C000B3F1004                            db      02Ch,0,11,63,16,4
  3893 0000146A 2C002F3F34F6                            db      02Ch,0,47,63,52,0F6h
  3894 00001470 2C00303F3504                            db      02Ch,0,48,63,53,4
  3895 00001476 2E13182C2705                            db      02Eh,19,24,44,39,5
  3896 0000147C 2E14192C27F4                            db      02Eh,20,25,44,39,0F4h
  3897 00001482 2E14192B2607                            db      02Eh,20,25,43,38,7
  3898 00001488 3E14192B2606                            db      03Eh,20,25,43,38,6
  3899 0000148E 2F00183F1E06                            db      02Fh,0,24,63,30,6
  3900 00001494 2F00193F1FFA                            db      02Fh,0,25,63,31,0FAh
  3901 0000149A 3F00193F1E06                            db      03Fh,0,25,63,30,6
  3902 000014A0 2F00203F2606                            db      02Fh,0,32,63,38,6
  3903 000014A6 2F00213F27FA                            db      02Fh,0,33,63,39,0FAh
  3904 000014AC 3F00213F2606                            db      03Fh,0,33,63,38,6
  3905                                  
  3906                                  ; parameter for fractaladd 28 bytes
  3907 000014B2 22C026012601260020-     aF:             db      34,192,38,1,38,1,38,0,32,0,32,32,32,64
  3908 000014BB 0020202040         
  3909 000014C0 226024002260240024-                     db	34,96,36,0,34,96,36,0,36,0,36,0,36,0
  3910 000014C9 0024002400         
  3911                                  
  3912                                  ; star bob for the sparcling stars texture 25 bytes
  3913 000014CE 0000030000              bob:            db	0,0,3,0,0
  3914 000014D3 0002050200                              db	0,2,5,2,0
  3915 000014D8 0305070503                              db	3,5,7,5,3
  3916 000014DD 0002050200                              db	0,2,5,2,0
  3917 000014E2 0000030000                              db	0,0,3,0,0
  3918                                  
  3919 000014E7 04040C0408              cliptab:	db	4,4,12,4,8
  3920                                  
  3921 000014EC 00003F3F3F00003F        uvtab:		db	0,0,63,63,63,0,0,63
  3922                                  
  3923 000014F4 08283010                cube:		db	1*8,5*8,6*8,2*8
  3924 000014F8 18382000                                db      3*8,7*8,4*8,0*8
  3925 000014FC 10303818                                db      2*8,6*8,7*8,3*8
  3926 00001500 00202808                                db      0*8,4*8,5*8,1*8
  3927 00001504 38302820                        	db	7*8,6*8,5*8,4*8
  3928 00001508 00081018                                db      0*8,1*8,2*8,3*8
  3929                                  
  3930 0000150C E0E0E0                  print:		db	-32,-32,-32
  3931 0000150F 20E0E0                                  db       32,-32,-32
  3932 00001512 2020E0                                  db   	 32, 32,-32
  3933 00001515 E020E0                                  db  	-32, 32,-32
  3934 00001518 E0E020                                  db  	-32,-32, 32
  3935 0000151B 20E020                                  db       32,-32, 32
  3936 0000151E 202020                                  db   	 32, 32, 32
  3937 00001521 E02020                                  db  	-32, 32, 32
  3938 00001524 400000                                  db       64,  0,  0
  3939 00001527 C00000                                  db      -64,  0,  0
  3940 0000152A 004000                                  db        0, 64,  0
  3941 0000152D 00C000                                  db        0,-64,  0
  3942 00001530 000040                                  db        0,  0, 64
  3943 00001533 0000C0                                  db        0,  0,-64
  3944 00001536 000000                                  db	  0,  0,  0
  3945                                  
  3946                                  ; world contruction data 599 bytes
  3947 00001539 71700006                world:		db	071h,070h,000h,006h
  3948 0000153D 72000006                                db	072h,000h,000h,006h
  3949 00001541 71007006                                db	071h,000h,070h,006h
  3950 00001545 73077006                                db	073h,007h,070h,006h
  3951 00001549 73070006                                db	073h,007h,000h,006h
  3952 0000154D 70070706                                db	070h,007h,007h,006h
  3953 00001551 74000706                                db	074h,000h,007h,006h
  3954 00001555 70000740                                db	070h,000h,007h,040h
  3955 00001559 72700750                                db	072h,070h,007h,050h
  3956 0000155D 72700050                                db	072h,070h,000h,050h
  3957 00001561 71707050                                db	071h,070h,070h,050h
  3958 00001565 73007040                                db	073h,000h,070h,040h
  3959 00001569 71000040                                db	071h,000h,000h,040h
  3960 0000156D 72000050                                db	072h,000h,000h,050h
  3961 00001571 71007050                                db	071h,000h,070h,050h
  3962 00001575 73077046                                db	073h,007h,070h,046h
  3963 00001579 73000046                                db	073h,000h,000h,046h
  3964 0000157D 70070746                                db	070h,007h,007h,046h
  3965 00001581 72000750                                db	072h,000h,007h,050h
  3966 00001585 71000000                                db	071h,000h,000h,000h
  3967 00001589 71000000                                db	071h,000h,000h,000h
  3968 0000158D 7100BB56                                db	071h,000h,0BBh,056h
  3969 00001591 700FBB46                                db	070h,00Fh,0BBh,046h
  3970 00001595 FF                                      db	0FFh
  3971 00001596 33000000                                db	033h,000h,000h,000h
  3972 0000159A F0000706E4                              db	0F0h,000h,007h,006h,0E4h
  3973 0000159F B000BB46E4                              db	0B0h,000h,0BBh,046h,0E4h
  3974 000015A4 9000BB56E4                              db	090h,000h,0BBh,056h,0E4h
  3975 000015A9 9000BB56E4                              db	090h,000h,0BBh,056h,0E4h
  3976 000015AE 3000BB56                                db	030h,000h,0BBh,056h
  3977 000015B2 F000BB5611                              db	0F0h,000h,0BBh,056h,011h
  3978 000015B7 F000BB4611                              db	0F0h,000h,0BBh,046h,011h
  3979 000015BC B000BB5611                              db	0B0h,000h,0BBh,056h,011h
  3980 000015C1 9000BB5611                              db	090h,000h,0BBh,056h,011h
  3981 000015C6 B000BB5611                              db	0B0h,000h,0BBh,056h,011h
  3982 000015CB F000BB5611                              db	0F0h,000h,0BBh,056h,011h
  3983 000015D0 F000BB4611                              db	0F0h,000h,0BBh,046h,011h
  3984 000015D5 B000BB5611                              db	0B0h,000h,0BBh,056h,011h
  3985 000015DA 3000BB56                                db	030h,000h,0BBh,056h
  3986 000015DE 1000BB56                                db	010h,000h,0BBh,056h
  3987                                  
  3988 000015E2 34000000                                db	034h,000h,000h,000h
  3989 000015E6 32050080                                db	032h,005h,000h,080h
  3990 000015EA 35058080                                db	035h,005h,080h,080h
  3991 000015EE 35058000                                db	035h,005h,080h,000h
  3992 000015F2 33058008                                db	033h,005h,080h,008h
  3993 000015F6 33050008                                db	033h,005h,000h,008h
  3994 000015FA 74050808                                db	074h,005h,008h,008h
  3995 000015FE 74050000                                db	074h,005h,000h,000h
  3996 00001602 73050880                                db	073h,005h,008h,080h
  3997 00001606 75000000                                db	075h,000h,000h,000h
  3998 0000160A 75050888                                db	075h,005h,008h,088h
  3999 0000160E 70000000                                db	070h,000h,000h,000h
  4000 00001612 74640808                                db	074h,064h,008h,008h
  4001 00001616 74600800                                db	074h,060h,008h,000h
  4002 0000161A 72640880                                db	072h,064h,008h,080h
  4003 0000161E 05600080                                db	005h,060h,000h,080h
  4004 00001622 05600000                                db	005h,060h,000h,000h
  4005 00001626 02600008                                db	002h,060h,000h,008h
  4006 0000162A 34600008                                db	034h,060h,000h,008h
  4007 0000162E 34600000                                db	034h,060h,000h,000h
  4008 00001632 32600080                                db	032h,060h,000h,080h
  4009 00001636 35600080                                db	035h,060h,000h,080h
  4010 0000163A 35600000                                db	035h,060h,000h,000h
  4011 0000163E 32600008                                db	032h,060h,000h,008h
  4012 00001642 34350008                                db	034h,035h,000h,008h
  4013 00001646 14650000                                db      014h,065h,000h,000h
  4014 0000164A 32350080                                db      032h,035h,000h,080h
  4015 0000164E 35350080                               	db      035h,035h,000h,080h
  4016 00001652 15650000                               	db      015h,065h,000h,000h
  4017 00001656 32350008                                db	032h,035h,000h,008h
  4018 0000165A 34358008                                db	034h,035h,080h,008h
  4019 0000165E 14650000                               	db      014h,065h,000h,000h
  4020 00001662 32358080                               	db      032h,035h,080h,080h
  4021 00001666 75000000                		db	075h,000h,000h,000h
  4022 0000166A 5265E077                		db	052h,065h,0E0h,077h
  4023 0000166E 32640E77                		db	032h,064h,00Eh,077h
  4024 00001672 12650077                		db	012h,065h,000h,077h
  4025 00001676 00650077                		db	000h,065h,000h,077h
  4026 0000167A FF                      		db	0FFh
  4027 0000167B 32000000                		db	032h,000h,000h,000h
  4028 0000167F F000000014              		db	0F0h,000h,000h,000h,014h
  4029 00001684 B000000014              		db	0B0h,000h,000h,000h,014h
  4030 00001689 30000000                		db	030h,000h,000h,000h
  4031 0000168D F0000000F4              		db	0F0h,000h,000h,000h,0F4h
  4032 00001692 F000DD56F4              		db	0F0h,000h,0DDh,056h,0F4h
  4033 00001697 3000DD46                		db	030h,000h,0DDh,046h
  4034 0000169B 3000DD56                		db	030h,000h,0DDh,056h
  4035 0000169F 3000DD56                		db	030h,000h,0DDh,056h
  4036 000016A3 32000050                		db	032h,000h,000h,050h
  4037 000016A7 300AA050                		db	030h,00Ah,0A0h,050h
  4038 000016AB 3300A050                		db	033h,000h,0A0h,050h
  4039 000016AF 30000050                		db	030h,000h,000h,050h
  4040 000016B3 32700050                		db	032h,070h,000h,050h
  4041 000016B7 3000A050                		db	030h,000h,0A0h,050h
  4042 000016BB 33A0A750                		db	033h,0A0h,0A7h,050h
  4043 000016BF 33000000                		db	033h,000h,000h,000h
  4044 000016C3 31A07A50                		db	031h,0A0h,07Ah,050h
  4045 000016C7 31000A50                		db	031h,000h,00Ah,050h
  4046 000016CB 31000A50                		db	031h,000h,00Ah,050h
  4047 000016CF 320A0A50                		db	032h,00Ah,00Ah,050h
  4048 000016D3 35000000                		db	035h,000h,000h,000h
  4049 000016D7 720A0000                		db	072h,00Ah,000h,000h
  4050 000016DB 700AA000                		db	070h,00Ah,0A0h,000h
  4051 000016DF 7300A000                		db	073h,000h,0A0h,000h
  4052 000016E3 70000000                		db	070h,000h,000h,000h
  4053 000016E7 72000000                		db	072h,000h,000h,000h
  4054 000016EB 7000A000                		db	070h,000h,0A0h,000h
  4055 000016EF 73A0A000                		db	073h,0A0h,0A0h,000h
  4056 000016F3 73A00099                		db	073h,0A0h,000h,099h
  4057 000016F7 71A00A00                		db	071h,0A0h,00Ah,000h
  4058 000016FB 71000A00                		db	071h,000h,00Ah,000h
  4059 000016FF 71000A00                                db	071h,000h,00Ah,000h
  4060 00001703 750A0A00                                db	075h,00Ah,00Ah,000h
  4061 00001707 700C0C03                                db	070h,00Ch,00Ch,003h
  4062 0000170B 70000C03                                db	070h,000h,00Ch,003h
  4063 0000170F 70000C03                                db	070h,000h,00Ch,003h
  4064 00001713 72C07C03                                db	072h,0C0h,07Ch,003h
  4065 00001717 72000000                                db	072h,000h,000h,000h
  4066 0000171B 71C0C703                                db	071h,0C0h,0C7h,003h
  4067 0000171F 7300C003                                db	073h,000h,0C0h,003h
  4068 00001723 71700003                                db	071h,070h,000h,003h
  4069 00001727 72000003                                db	072h,000h,000h,003h
  4070 0000172B 7100C003                                db	071h,000h,0C0h,003h
  4071 0000172F 730CC003                                db	073h,00Ch,0C0h,003h
  4072 00001733 71000003                                db	071h,000h,000h,003h
  4073 00001737 310CCCA3                                db	031h,00Ch,0CCh,0A3h
  4074 0000173B FF                                      db	0FFh
  4075 0000173C 32000000                                db	032h,000h,000h,000h
  4076 00001740 F000700614                              db	0F0h,000h,070h,006h,014h
  4077 00001745 B000DD4614                              db	0B0h,000h,0DDh,046h,014h
  4078 0000174A 3000DD56                                db	030h,000h,0DDh,056h
  4079 0000174E B2000D56C4                              db	0B2h,000h,00Dh,056h,0C4h
  4080 00001753 32DD0056                                db	032h,0DDh,000h,056h
  4081 00001757 32DD0056                                db	032h,0DDh,000h,056h
  4082 0000175B 32DD0056                                db	032h,0DDh,000h,056h
  4083 0000175F 7000F056                                db	070h,000h,0F0h,056h
  4084 00001763 7000BB56                                db	070h,000h,0BBh,056h
  4085 00001767 32B00B46                                db	032h,0B0h,00Bh,046h
  4086 0000176B 72BB0056                                db	072h,0BBh,000h,056h
  4087 0000176F 71B0B056                                db	071h,0B0h,0B0h,056h
  4088 00001773 71021156                                db	071h,002h,011h,056h
  4089 00001777 71221156                                db	071h,022h,011h,056h
  4090 0000177B 31201156                                db	031h,020h,011h,056h
  4091 0000177F 730BB056                                db	073h,00Bh,0B0h,056h
  4092 00001783 73BB0056                                db	073h,0BBh,000h,056h
  4093 00001787 300B0B46                                db	030h,00Bh,00Bh,046h
  4094 0000178B 3000BB56                                db	030h,000h,0BBh,056h
  4095 0000178F FF                                      db	0FFh
  4096                                  
  4097                                  ; flying script	126 bytes
  4098                                  script:
  4099                                  ;     7 6 5 4 3 2 1 0
  4100                                  ;	  v v v v v c c c
  4101                                  ;
  4102                                  ;	  v = VALUE
  4103                                  ;	  c = COMMAND
  4104                                  ;
  4105                                  ;	  0 = NOP
  4106                                  ;	  1 = NEG ZSTEP
  4107                                  ;	  2 = INC SPEED
  4108                                  ;	  3 = DEC SPEED
  4109                                  ;	  4 = INC XSTEP
  4110                                  ;	  5 = DEC XSTEP
  4111                                  ;	  6 = INC YSTEP
  4112                                  ;	  7 = INC YSTEP
  4113                                  
  4114 00001790 A1F8F898A1A6                            db      0A1h,0f8h,0f8h,098h,0a1h,0A6h
  4115 00001796 F0A7B3371036                            db      0F0h,0A7h,0B3h,037h,010h,036h
  4116 0000179C 5084858584F0                            db      050h,084h,085h,085h,084h,0F0h
  4117 000017A2 F0B2A7A6A6A7                            db      0F0h,0B2h,0A7h,0A6h,0A6h,0A7h
  4118 000017A8 F32670278044                            db      0f3h,026h,070h,027h,080h,044h
  4119 000017AE 457776A6B061                            db      045h,077h,076h,0a6h,0b0h,061h
  4120 000017B4 6152A7773076                            db      061h,052h,0a7h,077h,030h,076h
  4121 000017BA 80A201414101                            db      080h,0a2H,001h,041h,041h,001h
  4122 000017C0 F530F4B3A4F8            		db	0f5h,030h,0f4h,0b3h,0a4h,0f8h
  4123 000017C6 A5D04746F0A6            		db	0a5h,0D0h,047h,046h,0F0h,0A6h
  4124 000017CC 80A770A710A6                            db      080h,0A7h,070h,0A7h,010h,0A6h
  4125 000017D2 8EF0508FB2F8                            db      08eh,0f0h,050h,08fh,0b2h,0f8h
  4126 000017D8 A3808EF0508F                            db      0a3h,080h,08eh,0f0h,050h,08fh
  4127 000017DE B710B6F080A6                            db      0b7h,010h,0b6h,0f0h,080h,0a6h
  4128 000017E4 A7F087F07086            		db      0a7h,0f0h,087h,0F0h,070h,086h
  4129 000017EA 36F0F0903783            		db      036h,0f0h,0f0h,090h,037h,083h
  4130 000017F0 2CF0F0F0302D                            db      02ch,0f0h,0f0h,0f0h,030h,02dh
  4131 000017F6 8230B5B4F2A6            		db	082h,030h,0b5h,0b4h,0f2h,0a6h
  4132 000017FC 30A78383A6F0            		db	030h,0a7h,083h,083h,0a6h,0f0h
  4133 00001802 58A77776F0F0            		db	058h,0a7h,077h,076h,0f0h,0f0h
  4134 00001808 F0F0F8F800                              db	0f0h,0f0h,0f8h,0f8h,000h
  4135                                  
  4136 0000180D 0100                    zstep:		dw	1			
  4137 0000180F 66EF                    doortimer	dw 	-4250	; 0EF66h
  4138 00001811 4F4D4E495343454E54      omniscent	db	"OMNISCENT"
  4139                                  omniend:
  4140 0000181A 284329204449524B20-     sanction        db      "(C) DIRK KPPERS"
  4141 00001823 4B9A5050455253     
  4142                                  sancend:
  4143 0000182A 0000A5C3                ob:		dd 	-330.0	; vector.x
  4144 0000182E 00000000                		dd 	   0.0	; vector.y	
  4145 00001832 00008042                		dd	  64.0	; vector.z	
  4146                                  owmat:
  4147 00001836 00000000                		dd 	   0.0	; vector.x
  4148 0000183A 000080BF                		dd 	  -1.0	; vector.y
  4149 0000183E 00000000                		dd	   0.0  ; vector.z
  4150                                  ;owmat+12:
  4151 00001842 00000000                		dd 	   0.0	; vector.x
  4152 00001846 00000000                		dd 	   0.0	; vector.y
  4153 0000184A 000080BF                		dd	  -1.0  ; vector.z
  4154                                  ;owmat+24:
  4155 0000184E 0000803F                		dd 	   1.0	; vector.x
  4156 00001852 00000000                		dd 	   0.0	; vector.y
  4157 00001856 00000000                		dd	   0.0  ; vector.z
  4158                                  
  4159                                  bss_start:
  4160                                  
  4161                                  ABSOLUTE bss_start
  4162                                  
  4163 0000185A <res 00000002>          alignb 4
  4164                                  
  4165                                  ; 05/02/2017 (32 bit -> 16 bit)
  4166                                  
  4167                                  ;=============================================================================
  4168                                  ;        	null-initialized data
  4169                                  ;=============================================================================
  4170                                  
  4171                                  nullstart:
  4172 0000185C <res 00000024>          wmat:           resb	matrix.size  ; 36
  4173 00001880 <res 00000024>          nwmat:		resb	matrix.size  ; 36
  4174 000018A4 <res 00000002>          zspeed:		resw	1
  4175 000018A6 <res 00000002>          oxw:		resw	1
  4176 000018A8 <res 00000002>          oyw:		resw	1
  4177 000018AA <res 00000002>          ozw:		resw	1
  4178 000018AC <res 00000002>          scriptptr:	resw	1
  4179 000018AE <res 00000002>          scriptanz:	resw	1
  4180 000018B0 <res 00000001>          scriptins:	resb	1
  4181 000018B1 <res 00000001>          once:		resb	1
  4182 000018B2 <res 00000002>          ticker:		resw	1
  4183 000018B4 <res 00000002>          tracks:		resw	1
  4184 000018B6 <res 00000300>          palette:        resb 	768
  4185 00001BB6 <res 00000060>          channels:       resb	16*6
  4186                                  ;o:		resb	object.size ; 7204
  4187                                  ; 10/02/2017
  4188 00001C16 <res 00000002>          object.panz:	resw 1
  4189 00001C18 <res 00000002>          object.fanz:	resw 1
  4190 00001C1A <res 00000C80>          object.p:	resb point.size*MAXPOINTS
  4191 0000289A <res 00000FA0>          object.f:	resb face.size*MAXFACES
  4192                                  nullend:
  4193                                  
  4194                                  ;=============================================================================
  4195                                  ;       	uninitialized data
  4196                                  ;=============================================================================
  4197                                  
  4198 0000383A <res 00000002>          alignb 4	; 10/08/2017
  4199                                  
  4200 0000383C <res 00000002>          oldstack:	resw	1
  4201                                  ;Old08IrqPtr:
  4202                                  ;Old08Irqofs:	resw	1
  4203                                  ;Old08Irqseg:	resw	1
  4204                                  ;Old09IrqPtr:
  4205                                  ;Old09Irqofs:	resw	1
  4206                                  ;Old09Irqseg:	resw	1
  4207                                  ;songdata:	resb	3605
  4208                                  ;		resb	1 
  4209 0000383E <res 00000002>          root:   	resw	1
  4210 00003840 <res 00000040>          circletab:	resw	32
  4211 00003880 <res 0000005A>          stars:		resb	90
  4212 000038DA <res 00000001>          twice:		resb	1
  4213 000038DB <res 00000001>          timer_event_number:	resb 1 ; 06/02/2017
  4214                                  ; 25/07/2017
  4215                                  ; 11/02/2017
  4216 000038DC <res 00000002>          vseg:		resw	1
  4217 000038DE <res 00000002>          bseg:		resw    1
  4218 000038E0 <res 00000028>          tseg:   	resw	20
  4219                                  ;
  4220                                  ;shadetab:	resb	256*128
  4221 00003908 <res 00000078>          p:		resw	4*15
  4222 00003980 <res 000000B4>          pr:		resd	3*15
  4223 00003A34 <res 000000B4>          po:		resb	poly.size ; 5*36
  4224 00003AE8 <res 000012C0>          rp:		resd	3*MAXPOINTS ; 3*400
  4225 00004DA8 <res 00000640>          facei:		resd    MAXFACES ; 400
  4226                                  
  4227                                  alignb 4
  4228                                  ; 26/07/2017
  4229 000053E8 <res 00000004>          _ds:		resd	1
  4230 000053EC <res 00000004>          _es:		resd    1
  4231 000053F0 <res 00000004>          _fs:		resd	1
  4232                                  
  4233                                  ; 11/08/2017
  4234                                  ; 06/02/2017
  4235 000053F4 <res 00000002>          cw.direc:	resw	1 ; word
  4236 000053F6 <res 00000002>          cw.shade:	resw	1 ; word
  4237                                  ;
  4238 000053F8 <res 00000004>          sstp.dy:	resd	1 ; dword
  4239 000053FC <res 00000002>          sstp.ddv:	resw	1 ; word
  4240 000053FE <res 00000002>          sstp.ddu:	resw	1 ; word
  4241 00005400 <res 00000002>          sstp.vv2:	resw	1 ; word
  4242 00005402 <res 00000002>          sstp.uu2:	resw	1 ; word
  4243 00005404 <res 00000002>          sstp.vv1:	resw	1 ; word
  4244 00005406 <res 00000002>          sstp.uu1:	resw	1 ; word
  4245 00005408 <res 00000002>          sstp.r:		resw	1 ; word
  4246 0000540A <res 00000002>          sstp.l:		resw	1 ; word
  4247 0000540C <res 00000002>          sstp.y:		resw	1 ; word
  4248 0000540E <res 00000002>          sstp.maxy:	resw	1 ; word
  4249 00005410 <res 00000002>          sstp.miny:	resw	1 ; word
  4250 00005412 <res 00000002>          sstp.mx2:	resw	1 ; word
  4251 00005414 <res 00000002>          sstp.mx1:	resw	1 ; word
  4252 00005416 <res 00000002>          		resw	1
  4253 00005418 <res 0000003C>          sstp.del:	resb	edges.size * 3 ; 60 bytes 
  4254 00005454 <res 0000003C>          sstp.edg:	resb	edges.size * 3 ; 60 bytes
  4255                                  
  4256                                  ; 12/08/2017
  4257 00005490 <res 00000E15>          songdata:	resb	3605
  4258 000062A5 <res 00000001>          tstatus:	resb	1  ; timer (screen update) flag
  4259                                  
  4260 000062A6 <res 00000002>          alignb 4
  4261                                  
  4262                                  ; 12/08/2017
  4263 000062A8 <res 00008000>          shadetab:	resb	256*128
  4264                                  
  4265                                  bss_end:
