     1                                  ; NASM Version: Erdogan Tan (22/08/2016)
     2                                  
     3                                  ; 4ge's Xmas 94 Intro fractalzoom source
     4                                  ; ======================================
     5                                  
     6                                  ; Copyright (C) 1994/5 Samuel Marshall. All rights reserved. 
     7                                  
     8                                  ; Text and program code by Samuel Marshall, a.k.a. CuteElf / 4ge.
     9                                  
    10                                  ; Contact me at the following email address:
    11                                  
    12                                  ; Samuel.Marshall@durham.ac.uk
    13                                  
    14                                  ; and if you don't get a response, probably it's not during termtime, and
    15                                  ; I am at home - in which case, I check email here only about once a month
    16                                  ; (if that). You will get a reply eventually.
    17                                  
    18                                  ; My WWW homepage is
    19                                  
    20                                  ; http://www.dur.ac.uk/~d405ua/
    21                                  
    22                                  ; Enjoy the program... hope it helps you. Don't expect a wonderfully-
    23                                  ; optimised piece of code, because 1) the zoom routine wasn't really time-
    24                                  ; critical, and 2) this is the first time I ever wrote a fractal program,
    25                                  ; in my entire life, and 3) I didn't know how to do fixed-point numbers
    26                                  ; properly when I wrote this ;)
    27                                  
    28                                  ; General Principles for a real-time fractalzoom using this method
    29                                  ; ================================================================
    30                                  ;
    31                                  ; First, we calculate a fractal at twice the size, each way (i.e. 4 times
    32                                  ; the area) as the screen display area.
    33                                  ;
    34                                  ; We then display that fractal, zoomed-out to half size each way, so that
    35                                  ; it will exactly fill the screen display area.
    36                                  ;
    37                                  ; Then, we calculate another fractal twice the size of the display area,
    38                                  ; but this one is calculated "zoomed in" so that this fractal is a more
    39                                  ; detailed view of one-quarter of the area of the fractal just calculated.
    40                                  ;
    41                                  ; While we are calculating this, which takes a few seconds, we gradually
    42                                  ; zoom in the fractal we already have - using standard bitmap-zoom 
    43                                  ; techniques - until eventually by the time the new fractal is finished,
    44                                  ; the old fractal will be showing at 1:1 size, and will can then be 
    45                                  ; seamlessly replaced on the display by the new fractal at 1:2. Then
    46                                  ; repeat.
    47                                  ;
    48                                  ; Note: the fractal being DISPLAYED, i.e. the one that's already been
    49                                  ; calculated, can be zoomed to any point at all within the region, but
    50                                  ; this decision must be known in advance so that the next fractal is
    51                                  ; calculated from the right point. That's why you can't change the direction
    52                                  ; "realtime", only every so often.
    53                                  
    54                                  ; I would include references here but I worked the method out myself with
    55                                  ; no help from anything or anyone, so there aren't any... (oh, by the
    56                                  ; way, I assume this is the standard method everyone else uses too, it's
    57                                  ; nothing special or anything, just that I reinvented the wheel one more
    58                                  ; time ;)
    59                                  
    60                                  ; More details are included in the individual function descriptions.
    61                                  
    62                                  [ORG 100h]
    63                                  
    64 00000000 E93408                  jmp Start
    65                                  
    66                                  Getch:
    67 00000003 B80000                  mov ax, 0
    68 00000006 CD16                    int 16h
    69 00000008 C3                      retn
    70                                  
    71                                  ; You can probably change height without messing things up, but
    72                                  ; changing the width will I think need some work.
    73                                  
    74                                  FRACWIDTH equ 256
    75                                  FRACHEIGHT equ 128
    76                                  
    77                                  ; Fractal parameter
    78 00000009 03000000                frac:    dd 3
    79                                  
    80                                  ; Memory
    81 0000000D 0000                    enlargebufferseg:        dw 0    ; segment address of the 64*32 enlarge buf.
    82 0000000F 0000                    textureseg:              dw 0    ; the segment address of texture to display.
    83 00000011 0000                    fractalseg:              dw 0    ; the segment address of texture to create
    84                                  
    85                                  ;====================================================================
    86                                  ;ZOOMTEXTURE - display picture at given zoom fraction
    87                                  ;--------------------------------------------------------------------
    88                                  
    89                                  ; This is pretty obvious; just a standard, fixed-point bitmap
    90                                  ; display routine. The only extra bit you might notice is that
    91                                  ; it doubles each pixel, so as to get a larger screen display without
    92                                  ; taking too long to calculate the fractals.
    93                                  
    94                                  ; Data_______________________________________________________________
    95                                  
    96 00000013 0000                    lfrac:   dw 0    
    97 00000015 0000                    hfrac:   dw 0    ; texture pixels per real pixel
    98 00000017 00                      hfracb:  db 0    ; same but a byte
    99                                  
   100 00000018 00                      ystart:  db 0
   101 00000019 00                      xstart:  db 0    ; where to start, in texturemap
   102                                  
   103 0000001A 0000                    oldbx:   dw 0
   104 0000001C 0000                    oldss:   dw 0
   105                                  
   106 0000001E 0000                    yfracpos: dw 0   ; fractional y-position
   107                                  
   108 00000020 0000                    stopat:  dw 0    ; where to stop in screen ram
   109                                  
   110                                  ; Source_____________________________________________________________
   111                                  
   112                                  ZoomTexture:
   113 00000022 50                      push ax
   114 00000023 53                      push bx
   115 00000024 51                      push cx
   116 00000025 52                      push dx
   117 00000026 56                      push si
   118 00000027 57                      push di
   119                                  
   120 00000028 8B3E[3C03]              mov di, [screenstart]      ; start position on display memory
   121 0000002C 893E[2000]              mov [stopat], di
   122 00000030 8106[2000]00A0          add word [stopat], FRACHEIGHT*320 ; stop position on display memory
   123 00000036 8A3E[1800]              mov bh, [ystart]
   124 0000003A 8A1E[1900]              mov bl, [xstart]           ; start position on texture memory
   125                                  
   126 0000003E A1[1500]                mov ax, [hfrac]
   127 00000041 A2[1700]                mov [hfracb], al
   128 00000044 8B16[1300]              mov dx, [lfrac]
   129                                  
   130 00000048 8CD0                    mov ax, ss
   131 0000004A A3[1C00]                mov [oldss], ax
   132 0000004D A1[0F00]                mov ax, [textureseg]
   133 00000050 8ED0                    mov ss, ax
   134                                  
   135                                    ZoomYLoop:
   136                                  
   137 00000052 BE8000                    mov si, FRACWIDTH/2
   138 00000055 891E[1A00]                mov [oldbx], bx
   139 00000059 B90000                    mov cx, 0
   140                                  
   141                                      ZoomXLoop:
   142                                  
   143 0000005C 368A07                      mov al, [ss:bx]
   144 0000005F 88C4                        mov ah, al
   145 00000061 268905                      mov [es:di], ax
   146 00000064 2689854001                  mov [es:di+320], ax
   147 00000069 83C702                      add di, 2
   148 0000006C 030E[1300]                  add cx, [lfrac]
   149 00000070 131E[1500]                  adc bx, [hfrac]
   150                                  
   151 00000074 4E                          dec si
   152 00000075 75E5                        jnz short ZoomXLoop
   153                                  
   154 00000077 8B1E[1A00]                mov bx, [oldbx]
   155                                  
   156 0000007B 0116[1E00]                add [yfracpos], dx
   157 0000007F 123E[1700]                adc bh, [hfracb]
   158                                  
   159 00000083 81C78001                  add di, 640-FRACWIDTH
   160 00000087 3B3E[2000]                cmp di, [stopat]
   161 0000008B 72C5                      jb short ZoomYLoop
   162                                  
   163 0000008D A1[1C00]                mov ax, [oldss]
   164 00000090 8ED0                    mov ss, ax
   165                                  
   166                                  ; Check for keypress
   167 00000092 B401                    mov ah,1
   168 00000094 CD16                    int 16h
   169 00000096 7403                    jz short zt_afterkeyhit  
   170                                  
   171 00000098 E94F06                  jmp dfs_keyhit
   172                                  
   173                                  zt_afterkeyhit:
   174                                  
   175 0000009B 5F                      pop di
   176 0000009C 5E                      pop si
   177 0000009D 5A                      pop dx
   178 0000009E 59                      pop cx
   179 0000009F 5B                      pop bx
   180 000000A0 58                      pop ax
   181 000000A1 C3                      retn
   182                                  
   183                                  ;====================================================================
   184                                  ;CALCULATE - work out one pixel of Mandelbrot fractal
   185                                  ;--------------------------------------------------------------------
   186                                  
   187                                  ; The fractal formula used, with coordinates x,y, is:
   188                                  ; A = B = 0. Colour=starting colour.
   189                                  ;
   190                                  ; new A = a squared - b squared - x
   191                                  ; new B = 2 * a * b - y
   192                                  ;
   193                                  ; If A squared + B squared > some number frac, then stop.
   194                                  ; If been round loop more than colour limit (64) times, then stop too.
   195                                  ;
   196                                  ; Otherwise, work out next A and B, and increment the colour we're going
   197                                  ; to use for the pixel.
   198                                  ;
   199                                  ; When we get out of the loop, that colour value is the one to draw at
   200                                  ; this pixel.
   201                                  
   202                                  ; Note:
   203                                  ; The fixed point sections of this are pretty crap; there are proper ways
   204                                  ; to do fixed point (I think...) so for god's sake don't copy those
   205                                  ; bits for your own fixed point code.
   206                                  
   207                                  ; Data_______________________________________________________________
   208                                  
   209 000000A2 00                      colour:  db 0    ; colour to plot the pixel
   210                                  
   211 000000A3 00                      esign:    db 0    ; esign of multiplication result
   212                                  
   213 000000A4 00000000                la:      dd 0
   214 000000A8 00000000                ha:      dd 0    
   215 000000AC 00000000                lb:      dd 0
   216 000000B0 00000000                hb:      dd 0    ; a,b from a+bi. Low and high words thereof.
   217                                  
   218 000000B4 00000000                lasq:    dd 0
   219 000000B8 00000000                hasq:    dd 0
   220 000000BC 00000000                lbsq:    dd 0
   221 000000C0 00000000                hbsq:    dd 0    ; a squared, b squared, low and high words.
   222                                  
   223 000000C4 00000000                lnewa:   dd 0
   224 000000C8 00000000                hnewa:   dd 0    ; temporary storage for `new' veresion of `a'.
   225                                  
   226 000000CC 00000000                lx:      dd 0
   227 000000D0 00000000                hx:      dd 0
   228 000000D4 00000000                ly:      dd 0
   229 000000D8 00000000                hy:      dd 0    ; co-oredinates in complex plane of this point
   230                                  
   231                                  ; Source_____________________________________________________________
   232                                  
   233                                  Calculate:
   234 000000DC 6650                      push eax
   235 000000DE 6653                      push ebx
   236 000000E0 6651                      push ecx
   237 000000E2 6652                      push edx
   238 000000E4 6656                      push esi
   239 000000E6 6657                      push edi
   240                                  
   241                                  ; 0) Fix up the x,y data to specific point
   242                                  ;  mov dword [lx], 2621
   243                                  ;  mov dword [hx], 1
   244                                  ;  mov dword [ly], 11107
   245                                  ;  mov dword [hy], 1
   246                                  
   247                                  ; 1) setup colour
   248 000000E8 C606[A200]20              mov byte  [colour], 32
   249                                  
   250                                  ; 2) clear the a,b and squared variables,
   251 000000ED 6631C0                    xor eax, eax ; 0
   252 000000F0 66A3[A400]                mov [la], eax
   253 000000F4 66A3[A800]                mov [ha], eax
   254 000000F8 66A3[AC00]                mov [lb], eax
   255 000000FC 66A3[B000]                mov [hb], eax
   256 00000100 66A3[B400]                mov [lasq], eax
   257 00000104 66A3[B800]                mov [hasq], eax
   258 00000108 66A3[BC00]                mov [lbsq], eax
   259 0000010C 66A3[C000]                mov [hbsq], eax
   260                                  
   261                                    CalcLoop:
   262                                  
   263                                    ; 3) increment colour
   264 00000110 FE06[A200]                inc byte [colour]
   265                                  
   266                                    ; 4) set up a-squared
   267                                  asquared:  
   268 00000114 66A1[B400]                mov eax, [lasq]
   269 00000118 668B16[B800]              mov edx, [hasq]
   270                                  
   271                                  minusbsquared:
   272                                    ; 5) subtract b-squared
   273 0000011D 662B06[BC00]              sub eax, [lbsq]
   274 00000122 661B16[C000]              sbb edx, [hbsq]
   275                                  
   276                                  minusx:  
   277                                    ; 6) subtract x and store result in new-a
   278 00000127 662B06[CC00]              sub eax, [lx]
   279 0000012C 661B16[D000]              sbb edx, [hx]
   280 00000131 66A3[C400]                mov [lnewa], eax
   281 00000135 668916[C800]              mov [hnewa], edx
   282                                  
   283                                    ; 7) multiply a and b
   284                                    
   285                                  atimesb:
   286                                    ; a. setup variables
   287 0000013A 668B1E[A400]              mov ebx, [la]
   288 0000013F 668B0E[A800]              mov ecx, [ha]
   289 00000144 668B36[AC00]              mov esi, [lb]
   290 00000149 668B3E[B000]              mov edi, [hb]
   291                                  
   292                                  fixesigns:  
   293                                    ; b. sort out esigns to be poesitive
   294 0000014E C606[A300]00              mov byte [esign], 0
   295 00000153 6683F900                  cmp ecx, 0
   296 00000157 7D14                      jge short ecxok_1
   297 00000159 6683F1FF                    xor ecx, 0ffffffffh
   298 0000015D 6683F3FF                    xor ebx, 0ffffffffh
   299 00000161 6683C301                    add ebx, 1
   300 00000165 6683D100                    adc ecx, 0
   301 00000169 FE06[A300]                  inc byte [esign]
   302                                    ecxok_1:
   303 0000016D 6683FF00                  cmp edi, 0
   304 00000171 7D14                      jge short ediok_1
   305 00000173 6683F7FF                    xor edi, 0ffffffffh
   306 00000177 6683F6FF                    xor esi, 0ffffffffh
   307 0000017B 6683C601                    add esi, 1
   308 0000017F 6683D700                    adc edi, 0
   309 00000183 FE06[A300]                  inc byte [esign]
   310                                    ediok_1:
   311                                  
   312                                  multiply:
   313                                    ; c. multiply the two numbers
   314 00000187 66C706[B000]000000-       mov dword [hb], 0
   315 0000018F 00                 
   316 00000190 6689D8                    mov eax, ebx
   317 00000193 6689F2                    mov edx, esi
   318 00000196 66F7E2                    mul edx
   319 00000199 668916[AC00]              mov [lb], edx
   320 0000019E 6689D8                    mov eax, ebx
   321 000001A1 6689FA                    mov edx, edi
   322 000001A4 66F7E2                    mul edx
   323 000001A7 660106[AC00]              add [lb], eax
   324 000001AC 661116[B000]              adc [hb], edx
   325 000001B1 6689C8                    mov eax, ecx
   326 000001B4 6689F2                    mov edx, esi
   327 000001B7 66F7E2                    mul edx
   328 000001BA 660106[AC00]              add [lb], eax
   329 000001BF 661116[B000]              adc [hb], edx
   330 000001C4 6689C8                    mov eax, ecx
   331 000001C7 6689FA                    mov edx, edi
   332 000001CA 66F7E2                    mul edx
   333 000001CD 660106[B000]              add [hb], eax
   334                                  
   335                                  fixresultesign:
   336                                    ; d. fix the esign of the result
   337 000001D2 F606[A300]01              test byte [esign], 1
   338 000001D7 7418                      jz short esignok_1
   339 000001D9 668336[B000]FF              xor dword [hb], 0ffffffffh
   340 000001DF 668336[AC00]FF              xor dword [lb], 0ffffffffh
   341 000001E5 668306[CC00]01              add dword [lx], 1
   342 000001EB 668316[B000]00              adc dword [hb], 0
   343                                    esignok_1:
   344                                  
   345                                  doublenumber:
   346                                    ; 8) Add this to itself, (with carry)
   347 000001F1 66A1[AC00]                mov eax, [lb]
   348 000001F5 668B16[B000]              mov edx, [hb]
   349 000001FA 6601C0                    add eax, eax
   350 000001FD 6611D2                    adc edx, edx
   351                                  
   352                                  subtracty:
   353                                    ; 9) Subtract y and store in b
   354 00000200 662B06[D400]              sub eax, [ly]
   355 00000205 661B16[D800]              sbb edx, [hy]
   356 0000020A 66A3[AC00]                mov [lb], eax
   357 0000020E 668916[B000]              mov [hb], edx
   358                                  
   359                                    ; 10) Update a from new-a : combined with
   360                                    ; 11) Square a and store in a-squared
   361                                    ; a. setup variable
   362                                  starttosquare:  
   363 00000213 668B1E[C400]              mov ebx, [lnewa]
   364 00000218 668B0E[C800]              mov ecx, [hnewa]
   365 0000021D 66891E[A400]              mov [la], ebx
   366 00000222 66890E[A800]              mov [ha], ecx
   367                                  
   368                                  fixesign:
   369                                    ; b. sort out esign to be poesitive
   370 00000227 6683F900                  cmp ecx, 0
   371 0000022B 7D10                      jge short ecxok_2
   372 0000022D 6683F1FF                    xor ecx, 0ffffffffh
   373 00000231 6683F3FF                    xor ebx, 0ffffffffh
   374 00000235 6683C301                    add ebx, 1
   375 00000239 6683D100                    adc ecx, 0
   376                                    ecxok_2:
   377                                  
   378                                  squareit:
   379                                    ; c. square data
   380 0000023D 66C706[B800]000000-       mov dword [hasq], 0
   381 00000245 00                 
   382 00000246 6689D8                    mov eax, ebx
   383 00000249 66F7E0                    mul eax
   384 0000024C 668916[B400]              mov [lasq], edx
   385 00000251 6689D8                    mov eax, ebx
   386 00000254 66F7E1                    mul ecx
   387 00000257 660106[B400]              add [lasq], eax
   388 0000025C 661116[B800]              adc [hasq], edx
   389 00000261 660106[B400]              add [lasq], eax
   390 00000266 661116[B800]              adc [hasq], edx
   391 0000026B 6689C8                    mov eax, ecx
   392 0000026E 66F7E0                    mul eax
   393 00000271 660106[B800]              add [hasq], eax
   394                                  
   395                                  sametosquareb:
   396                                    ; 12) Square b and store in b-squared
   397                                    ; a. setup variable
   398 00000276 668B1E[AC00]              mov ebx, [lb]
   399 0000027B 668B0E[B000]              mov ecx, [hb]
   400                                  
   401                                    ; b. sort out esign to be poesitive
   402 00000280 6683F900                  cmp ecx, 0
   403 00000284 7D10                      jge short ecxok_3
   404 00000286 6683F1FF                    xor ecx, 0ffffffffh
   405 0000028A 6683F3FF                    xor ebx, 0ffffffffh
   406 0000028E 6683C301                    add ebx, 1
   407 00000292 6683D100                    adc ecx, 0
   408                                    ecxok_3:
   409                                  
   410                                    ; c. square data
   411 00000296 66C706[C000]000000-       mov dword [hbsq], 0
   412 0000029E 00                 
   413 0000029F 6689D8                    mov eax, ebx
   414 000002A2 66F7E0                    mul eax
   415 000002A5 668916[BC00]              mov [lbsq], edx
   416 000002AA 6689D8                    mov eax, ebx
   417 000002AD 66F7E1                    mul ecx
   418 000002B0 660106[BC00]              add [lbsq], eax
   419 000002B5 661116[C000]              adc [hbsq], edx
   420 000002BA 660106[BC00]              add [lbsq], eax
   421 000002BF 661116[C000]              adc [hbsq], edx
   422 000002C4 6689C8                    mov eax, ecx
   423 000002C7 66F7E0                    mul eax
   424 000002CA 660106[C000]              add [hbsq], eax
   425                                  
   426                                  asquaredaddbsquared:  
   427                                    ; 13) Setup a-squared
   428 000002CF 66A1[B400]                mov eax, [lasq]
   429 000002D3 668B16[B800]              mov edx, [hasq]
   430                                  
   431                                    ; 14) Add b-squared
   432 000002D8 660306[BC00]              add eax, [lbsq]
   433 000002DD 661316[C000]              adc edx, [hbsq]
   434                                  
   435                                    ; 15) Compare with *n*, stop if >
   436 000002E2 663B16[0900]              cmp edx, [frac]
   437 000002E7 7F0A                      jg short CalcFinish
   438                                  
   439                                    ; 16) If colour > *c*, stop
   440 000002E9 803E[A200]3F              cmp byte [colour], 63
   441 000002EE 7F03                      jg short CalcFinish
   442                                  
   443 000002F0 E91DFE                  jmp CalcLoop
   444                                  
   445                                  CalcFinish:
   446                                  ; 17) Return pixel colour
   447 000002F3 665F                    pop edi
   448 000002F5 665E                    pop esi
   449 000002F7 665A                    pop edx
   450 000002F9 6659                    pop ecx
   451 000002FB 665B                    pop ebx
   452 000002FD 6658                    pop eax
   453 000002FF A0[A200]                mov al, [colour]
   454 00000302 C3                      retn
   455                                  
   456                                  ;====================================================================
   457                                  ;FRACTAL - loop round to draw a 256x256 fractal using Calculate
   458                                  ;--------------------------------------------------------------------
   459                                  
   460                                  ; Basically, this just uses fixed-point to go through all the 
   461                                  ; x and y coordinates corresponding to SCREEN x and y.
   462                                  ; If you're confused about the "normaltime", "othertime", etc crap
   463                                  ; in the zooming-in section, well, I *think* this is because the
   464                                  ; Y-position sometimes needs to start at a half-pixel (i.e. "othertime")
   465                                  ; but usually ("normaltime") starts on a whole pixel.
   466                                  
   467                                  ; Note, it would be possible to speed this up by 1/4, simply by re-using
   468                                  ; the relevant pixels from the fractal calculated last: see this diagram
   469                                  
   470                                  ; We're zooming in to top left corner.
   471                                  
   472                                  ; Original fractal      Fractal needs calculating next
   473                                  ;
   474                                  ; abcd....              a?b?c?d?
   475                                  ; efgh....              ????????
   476                                  ; ijkl....              e?f?g?h?
   477                                  ; mnop....              ????????
   478                                  ; ........              i?j?k?l?
   479                                  ; ........              ????????
   480                                  ; ........              m?n?o?p?
   481                                  ; ........              ????????
   482                                  ;
   483                                  ; where "." has been calculated on original fractal, but will not be used
   484                                  ; for the new one, and ? represents what actually needs to be calculated
   485                                  ; in the new one. (a,b,c,... could be copied from the old one).
   486                                  ;
   487                                  ; Actually, this routine doesn't copy over a,b,c,..., they are recalculated.
   488                                  
   489                                  ; Data_______________________________________________________________
   490                                  
   491 00000303 00000000                lxcentre:    dd 0
   492 00000307 00000000                hxcentre:    dd 0
   493 0000030B 00000000                lycentre:    dd 0
   494 0000030F 00000000                hycentre:    dd 0    ; co-ordinates of the window's centre, not used here
   495                                                       ; (they are used in the main loop...)
   496 00000313 00000000                lxs:     dd 0
   497 00000317 00000000                hxs:     dd 0
   498 0000031B 00000000                lys:     dd 0
   499 0000031F 00000000                hys:     dd 0    ; co-oredinates of the window's top left corner
   500                                  
   501 00000323 00000000                lxi:     dd 0
   502 00000327 00000000                hxi:     dd 0
   503 0000032B 00000000                lyi:     dd 0
   504 0000032F 00000000                hyi:     dd 0    ; amount to increment fractal parameter per pixel
   505                                  
   506 00000333 0000                    ycount:  dw 0
   507 00000335 0000                    xcount:  dw 0    ; loop counters
   508                                  
   509 00000337 01                      nodraw:  db 1    ; whether or not to draw the last one
   510                                  
   511 00000338 01                      ydirection: db 1
   512 00000339 01                      xdirection: db 1 ; direction of the zoom (0 = left/up, 1=centre, 2=rt/down)
   513 0000033A 01                      newxdirection: db 1
   514 0000033B 01                      newydirection: db 1
   515                                  
   516 0000033C 0000                    screenstart:   dw 0    ; screen edisplay offset
   517                                  
   518                                  ; Source_____________________________________________________________
   519                                  
   520                                  Fractal:
   521 0000033E 6650                    push eax
   522 00000340 6653                    push ebx
   523 00000342 6651                    push ecx
   524 00000344 6652                    push edx
   525 00000346 6656                    push esi
   526 00000348 6657                    push edi
   527                                  
   528                                  ; 1) Initialise x and y parameters of fractal to xstart,ystart
   529 0000034A 66A1[1303]              mov eax, [lxs]
   530 0000034E 668B16[1703]            mov edx, [hxs]
   531 00000353 66A3[CC00]              mov [lx], eax
   532 00000357 668916[D000]            mov [hx], edx
   533 0000035C 66A1[1B03]              mov eax, [lys]
   534 00000360 668B16[1F03]            mov edx, [hys]
   535 00000365 66A3[D400]              mov [ly], eax
   536 00000369 668916[D800]            mov [hy], edx
   537                                  
   538                                  ; 1.5) Initialise zoom parameters
   539 0000036E C706[1300]00FC          mov word [lfrac], 1024*63
   540 00000374 C706[1500]0100          mov word [hfrac], 1
   541 0000037A C606[1800]00            mov byte [ystart], 0
   542 0000037F C606[1900]00            mov byte [xstart], 0
   543                                  
   544                                  ; 2) Set up screen pointer
   545 00000384 06                      push es
   546 00000385 A1[1100]                mov ax, [fractalseg]
   547 00000388 8EC0                    mov es, ax
   548 0000038A 66BF00000000            mov edi, 0
   549                                  
   550 00000390 C706[3303]8000          mov word [ycount], FRACHEIGHT
   551                                    FracYLoop:
   552                                  
   553 00000396 C706[3503]0001            mov word [xcount], FRACWIDTH
   554                                      FracXLoop:
   555                                      
   556                                      ; 3) Calculate pixel
   557 0000039C E83DFD                      call Calculate
   558                                  
   559                                      ; 4) Draw pixel
   560 0000039F 26678807                    mov [es:edi], al
   561                                  
   562                                      ; 5) Add X increment to X
   563 000003A3 66A1[2303]                  mov eax, [lxi]
   564 000003A7 668B16[2703]                mov edx, [hxi]
   565 000003AC 660106[CC00]                add [lx], eax
   566 000003B1 661116[D000]                adc [hx], edx
   567                                  
   568                                      ; 6) Increment screen poesition
   569 000003B6 6647                        inc edi
   570                                      
   571                                      ; 7) If count >127, stop
   572 000003B8 FF0E[3503]                  dec word [xcount]
   573 000003BC 75DE                        jnz short FracXLoop
   574                                  
   575                                    ; 8) Set X to xstart
   576 000003BE 66A1[1303]                mov eax, [lxs]
   577 000003C2 668B16[1703]              mov edx, [hxs]
   578 000003C7 66A3[CC00]                mov [lx], eax
   579 000003CB 668916[D000]              mov [hx], edx
   580                                  
   581                                    ; 10) Add Y increment to Y
   582 000003D0 66A1[2303]                mov eax, [lxi]
   583 000003D4 668B16[2703]              mov edx, [hxi]
   584 000003D9 660106[D400]              add [ly], eax
   585 000003DE 661116[D800]              adc [hy], edx
   586                                  
   587                                    ; 10.5) Draw zoomed last fractal if count%2==0
   588 000003E3 A1[3303]                  mov ax, [ycount]
   589 000003E6 2401                      and al, 1
   590 000003E8 754C                      jnz short notthistime
   591 000003EA 06                          push es
   592 000003EB B800A0                      mov ax, 0a000h
   593 000003EE 8EC0                        mov es, ax
   594                                    ; Update zoom position
   595 000003F0 C706[1E00]0000              mov word [yfracpos], 0
   596 000003F6 A0[3903]                    mov al, [xdirection]
   597 000003F9 0006[1900]                  add [xstart], al
   598 000003FD 803E[3803]00                cmp byte [ydirection], 0
   599 00000402 7421                        je short normaltime
   600 00000404 803E[3803]02                cmp byte [ydirection], 2
   601 00000409 7506                        jne short ydirection1
   602 0000040B FE06[1800]                  inc byte [ystart]
   603 0000040F EB14                        jmp short normaltime
   604                                      ydirection1:
   605 00000411 F706[3303]0200              test word [ycount], 2
   606 00000417 7406                        jz short othertime
   607 00000419 FE06[1800]                  inc byte [ystart]
   608 0000041D EB06                        jmp short normaltime
   609                                    
   610                                    othertime:
   611 0000041F C706[1E00]0080              mov word [yfracpos], 8000h
   612                                  
   613                                    normaltime:
   614 00000425 803E[3703]00                cmp byte [nodraw], 0
   615 0000042A 7503                        jne short dontdraw
   616 0000042C E8F3FB                      call ZoomTexture
   617                                      dontdraw:
   618 0000042F 07                          pop es
   619 00000430 812E[1300]0004              sub word [lfrac], 1024
   620                                  
   621                                    notthistime:
   622                                  
   623                                    ; 11) If count>127, stop
   624 00000436 FF0E[3303]                dec word [ycount]
   625 0000043A 0F8558FF                  jnz FracYLoop
   626                                  
   627 0000043E 07                      pop es
   628                                  
   629 0000043F 665F                    pop edi
   630 00000441 665E                    pop esi
   631 00000443 665A                    pop edx
   632 00000445 6659                    pop ecx
   633 00000447 665B                    pop ebx
   634 00000449 6658                    pop eax
   635 0000044B C3                      retn
   636                                  
   637                                  ;====================================================================
   638                                  ; SWITCHTEXTURES - switch around the two buffers
   639                                  ;--------------------------------------------------------------------
   640                                  
   641                                  ; This just changes the two buffers when one has been finished; so
   642                                  ; that the new fractal becomes the one that gets drawn to screen, and 
   643                                  ; the old fractal will get written over by the one newly being
   644                                  ; calculated.
   645                                  
   646                                  ; This is a separate function, because if you decide to implement
   647                                  ; the 25% saving described above, you'll need to copy over those
   648                                  ; re-cycled pixels at some point, and this is a good time to do that.
   649                                  
   650                                  ; Source_____________________________________________________________
   651                                  
   652                                  SwitchTextures:
   653 0000044C 50                      push ax
   654 0000044D 53                      push bx
   655                                  
   656 0000044E A1[1100]                mov ax, [fractalseg]
   657 00000451 8B1E[0F00]              mov bx, [textureseg]
   658 00000455 891E[1100]              mov [fractalseg], bx
   659 00000459 A3[0F00]                mov [textureseg], ax
   660                                  
   661 0000045C 5B                      pop bx
   662 0000045D 58                      pop ax
   663 0000045E C3                      retn
   664                                  
   665                                  ;====================================================================
   666                                  ;DOBACKGROUND - the background for lo-res part of demo
   667                                  ;--------------------------------------------------------------------
   668                                  
   669                                  ; Just draws the swirly background things, very simple.
   670                                  
   671                                  DoBackground:
   672 0000045F 50                      push ax
   673 00000460 53                      push bx
   674 00000461 51                      push cx
   675 00000462 57                      push di
   676                                  
   677 00000463 06                      push es
   678                                  
   679 00000464 B800A0                  mov ax, 0a000h
   680 00000467 8EC0                    mov es, ax
   681                                  
   682 00000469 BB0000                  mov bx, 0        ; bh=y, bl=x
   683                                  
   684 0000046C 89DF                    mov di, bx ;0
   685 0000046E B900FA                  mov cx, 64000
   686 00000471 88D8                    mov al, bl ;0
   687 00000473 F3AA                    rep stosb
   688                                  
   689 00000475 89DF                    mov di, bx ; 0
   690                                  
   691                                  db_loop:
   692 00000477 88F8                      mov al, bh
   693 00000479 F6E3                      mul bl
   694 0000047B 240F                      and al, 0fh
   695 0000047D 0410                      add al, 16
   696 0000047F 268805                    mov [es:di], al
   697 00000482 47                        inc di
   698 00000483 43                        inc bx
   699 00000484 80FB00                    cmp bl, 0
   700 00000487 7503                      jne short notnextline
   701 00000489 83C740                    add di, 320-256
   702                                  notnextline:
   703 0000048C 81FB00C1                  cmp bx, 256*193
   704 00000490 72E5                      jb short db_loop
   705                                  
   706 00000492 BE0000                  mov si, 0
   707 00000495 BF0001                  mov di, 256
   708 00000498 1E                      push ds
   709 00000499 06                      push es
   710 0000049A 1F                      pop ds
   711 0000049B BAC000                  mov dx, 192
   712                                  
   713                                  copy_loop:
   714 0000049E B92000                    mov cx, 32
   715 000004A1 F3A5                      rep movsw
   716 000004A3 81C60001                  add si, 320-64
   717 000004A7 81C70001                  add di, 320-64
   718 000004AB 4A                        dec dx
   719 000004AC 75F0                      jnz short copy_loop
   720                                  
   721 000004AE 1F                      pop ds
   722                                  
   723                                  ;mov di, 256*193
   724                                  ;mov cx, 8*320
   725                                  ;mov al, 0
   726                                  ;rep stosb
   727                                  
   728 000004AF 07                      pop es
   729                                  
   730 000004B0 5F                      pop di
   731 000004B1 59                      pop cx
   732 000004B2 5B                      pop bx
   733 000004B3 58                      pop ax
   734                                  
   735 000004B4 C3                      retn
   736                                  
   737                                  ;====================================================================
   738                                  ;DRAWSQUARE - fills a square, for showing which way things are going
   739                                  ;--------------------------------------------------------------------
   740                                  
   741                                  ; I won't bother explaining this, you can all manage to draw a square
   742                                  ; by now...
   743                                  
   744                                  DrawSquare:
   745 000004B5 50                      push ax
   746 000004B6 52                      push dx
   747 000004B7 56                      push si
   748 000004B8 57                      push di
   749 000004B9 06                      push es
   750                                  
   751 000004BA 89C6                    mov si, ax
   752 000004BC B800A0                  mov ax, 0a000h
   753 000004BF 8EC0                    mov es, ax
   754                                  
   755                                  ; bh=starty, ax(now si)=startx
   756                                  ; dx=width and height
   757                                  ; cl=colour
   758 000004C1 52                      push dx
   759 000004C2 89DF                    mov di, bx
   760 000004C4 C1EF08                  shr di, 8
   761 000004C7 B84001                  mov ax, 320
   762 000004CA F7E7                    mul di
   763 000004CC 01F0                    add ax, si
   764 000004CE 89C7                    mov di, ax
   765 000004D0 5A                      pop dx
   766                                  
   767 000004D1 88C8                    mov al, cl
   768                                  
   769 000004D3 89D6                    mov si, dx
   770                                  ds_yloop:
   771 000004D5 89D1                      mov cx, dx
   772 000004D7 F3AA                      rep stosb
   773 000004D9 81C74001                  add di, 320
   774 000004DD 29D7                      sub di, dx
   775 000004DF 4E                        dec si
   776 000004E0 75F3                      jnz short ds_yloop
   777                                  
   778 000004E2 07                      pop es
   779 000004E3 5F                      pop di
   780 000004E4 5E                      pop si
   781 000004E5 5A                      pop dx
   782 000004E6 58                      pop ax
   783 000004E7 C3                      retn
   784                                  
   785                                  ;====================================================================
   786                                  ;DRAWDIRECTIONSQUARES - draw the motion direction indicators
   787                                  ;--------------------------------------------------------------------
   788                                  
   789                                  ; this is pretty trivial too.
   790                                  
   791                                  DrawDirectionSquares:
   792 000004E8 50                      push ax
   793 000004E9 53                      push bx
   794 000004EA 51                      push cx
   795 000004EB 52                      push dx
   796 000004EC 56                      push si
   797 000004ED 57                      push di
   798                                  
   799                                  ; Clear all squares
   800 000004EE B700                    mov bh, 0        ; was 16
   801 000004F0 B80000                  mov ax, 0        ; was 16
   802 000004F3 B100                    mov cl, 0
   803 000004F5 BA2000                  mov dx, 32
   804                                  
   805 000004F8 BE0300                  mov si, 3
   806                                  dds_yloop:
   807 000004FB BF0300                    mov di, 3
   808                                    dds_xloop:
   809 000004FE 83FF02                      cmp di, 2
   810 00000501 7505                        jne short dds_drawit
   811 00000503 83FE02                      cmp si, 2
   812 00000506 7403                        je short dds_skipit
   813                                  
   814                                      dds_drawit:
   815 00000508 E8AAFF                      call DrawSquare
   816                                  
   817                                      dds_skipit:
   818 0000050B 059000                      add ax, 9*16
   819 0000050E 4F                          dec di
   820 0000050F 75ED                        jnz short dds_xloop
   821 00000511 B80000                    mov ax, 0      
   822 00000514 80C750                    add bh, 5*16   
   823 00000517 4E                        dec si
   824 00000518 75E1                      jnz short dds_yloop
   825                                  
   826                                  ; Draw chosen square
   827 0000051A 803E[3B03]01            cmp byte [newydirection], 1
   828 0000051F 7507                    jne short drawchosen
   829 00000521 803E[3A03]01            cmp byte [newxdirection], 1 
   830 00000526 742B                    je short afterchosen
   831                                  
   832                                  drawchosen:
   833 00000528 B400                    mov ah, 0
   834 0000052A A0[3B03]                mov al, [newydirection]
   835 0000052D 6BC050                  imul ax, 5*16    
   836 00000530 88C7                    mov bh, al
   837                                  ;mov eax, 0
   838                                  ;mov al, [newxdirection]
   839 00000532 660FB606[3A03]          movzx eax, byte [newxdirection]
   840 00000538 BE9000                  mov si, 9*16
   841 0000053B F7E6                    mul si
   842 0000053D BA2000                  mov dx, 32               ; square side length
   843 00000540 B101                    mov cl, 1
   844 00000542 E870FF                  call DrawSquare
   845 00000545 80C704                  add bh, 4
   846 00000548 83C004                  add ax, 4
   847 0000054B 83EA08                  sub dx, 8
   848 0000054E B100                    mov cl, 0
   849 00000550 E862FF                  call DrawSquare         ; clear the inside
   850                                  
   851                                  afterchosen:
   852                                  ; Draw actual (current) square
   853 00000553 803E[3803]01            cmp byte [ydirection], 1
   854 00000558 7507                    jne short drawcurrent
   855 0000055A 803E[3903]01            cmp byte [xdirection], 1
   856 0000055F 7425                    je short aftercurrent
   857                                  
   858                                  drawcurrent:
   859 00000561 B400                    mov ah, 0
   860 00000563 A0[3803]                mov al, [ydirection]
   861 00000566 6BC050                  imul ax ,5*16  
   862 00000569 83C000                  add ax, 0        
   863 0000056C 88C7                    mov bh, al
   864 0000056E B400                    mov ah, 0
   865 00000570 A0[3903]                mov al, [xdirection]
   866 00000573 BE9000                  mov si, 9*16
   867 00000576 F7E6                    mul si
   868 00000578 80C704                  add bh, 4
   869 0000057B 83C004                  add ax, 4                ; current square start now in bx.
   870 0000057E BA1800                  mov dx, 24               ; square side length
   871 00000581 B102                    mov cl, 2
   872 00000583 E82FFF                  call DrawSquare
   873                                  
   874                                  aftercurrent:
   875 00000586 5F                      pop di
   876 00000587 5E                      pop si
   877 00000588 5A                      pop dx
   878 00000589 59                      pop cx
   879 0000058A 5B                      pop bx
   880 0000058B 58                      pop ax
   881 0000058C C3                      retn
   882                                  
   883                                  ;====================================================================
   884                                  ;DOFRACTALSECTION - the controllable fractals part of the demo
   885                                  ;--------------------------------------------------------------------
   886                                  
   887                                  ; hopefully what with the background you have already read, this
   888                                  ; routine is self-explanatory.
   889                                  
   890                                  DoFractalSection:
   891                                  ; Now setup fractal parameters
   892                                  ; Start at preplanned position
   893 0000058D 66C706[0703]000000-     mov dword [hxcentre], 000000000h
   894 00000595 00                 
   895 00000596 66C706[0303]FFDFFA-     mov dword [lxcentre], 04afadfffh
   896 0000059E 4A                 
   897 0000059F 66C706[0F03]FEFFFF-     mov dword [hycentre], 0fffffffeh
   898 000005A7 FF                 
   899 000005A8 66C706[0B03]FFBF71-     mov dword [lycentre], 08f71bfffh
   900 000005B0 8F                 
   901                                  
   902                                  ; and increment by 1/64 per pixel
   903 000005B1 66C706[2703]000000-     mov dword [hxi], 0
   904 000005B9 00                 
   905 000005BA 66C706[2303]000000-     mov dword [lxi], 1024*65536
   906 000005C2 04                 
   907 000005C3 66C706[2F03]000000-     mov dword [hyi], 0
   908 000005CB 00                 
   909 000005CC 66C706[2B03]000000-     mov dword [lyi], 1024*65536
   910 000005D4 04                 
   911                                  
   912 000005D5 C706[3C03]6029          mov word [screenstart], 33*320+32
   913                                  
   914                                  dfs_fracloop:
   915                                  
   916                                  ; Calculate new hxcentre etc depending on xdirection,ydirection
   917                                  ; (new position = FW/4*(xdirection+1),FH/4*(ydirection+1) on the display)
   918                                  
   919                                  ; xcentre=xcentre+fw/4*(xdirection-1)*xi 
   920 000005DB 803E[3903]01            cmp byte [xdirection], 1
   921 000005E0 742A                    je short xchangedone
   922 000005E2 66BA80000000            mov edx, FRACWIDTH/2
   923 000005E8 66A1[2303]              mov eax, [lxi]
   924 000005EC 66F7E2                  mul edx
   925 000005EF 803E[3903]02            cmp byte [xdirection], 2
   926 000005F4 750C                    jne short xchangeminus
   927 000005F6 660106[0303]              add [lxcentre], eax
   928 000005FB 661116[0703]              adc [hxcentre], edx
   929 00000600 EB0A                      jmp short xchangedone
   930                                  xchangeminus:
   931 00000602 662906[0303]              sub [lxcentre], eax
   932 00000607 661916[0703]              sbb [hxcentre], edx
   933                                  xchangedone:
   934                                  
   935                                  ; Same for Y:
   936 0000060C 803E[3803]01            cmp byte [ydirection], 1
   937 00000611 742A                    je short ychangedone
   938 00000613 66BA40000000            mov edx, FRACHEIGHT/2
   939 00000619 66A1[2B03]              mov eax, [lyi]
   940 0000061D 66F7E2                  mul edx
   941 00000620 803E[3803]02            cmp byte [ydirection], 2
   942 00000625 750C                    jne short ychangeminus
   943 00000627 660106[0B03]              add [lycentre], eax
   944 0000062C 661116[0F03]              adc [hycentre], edx
   945 00000631 EB0A                      jmp short ychangedone
   946                                  ychangeminus:
   947 00000633 662906[0B03]              sub [lycentre], eax
   948 00000638 661916[0F03]              sbb [hycentre], edx
   949                                  ychangedone:
   950                                  
   951                                  ; Calculate start hxs,lxs hys,lys to keep hxcentre in middle (at 128,128)
   952                                  
   953                                  ; xs=xcentre-128*xi ys=ycentre-128*yi
   954 0000063D 66A1[2303]              mov eax, [lxi]
   955 00000641 66BA80000000            mov edx, FRACWIDTH/2
   956 00000647 66F7E2                  mul edx
   957 0000064A 6689C3                  mov ebx, eax     ; bx is l(xi*128)
   958 0000064D 6689D1                  mov ecx, edx     ; cx is h(xi*128)
   959 00000650 6683F3FF                xor ebx, 0ffffffffh
   960 00000654 6683F1FF                xor ecx, 0ffffffffh
   961 00000658 6641                    inc ecx         ; cx:bx now negative'd
   962 0000065A 66031E[0303]            add ebx, [lxcentre]
   963 0000065F 66130E[0703]            adc ecx, [hxcentre]
   964 00000664 66891E[1303]            mov [lxs], ebx
   965 00000669 66890E[1703]            mov [hxs], ecx
   966                                  
   967                                  ; Same for Y:
   968 0000066E 66A1[2B03]              mov eax, [lyi]
   969 00000672 66BA40000000            mov edx, FRACHEIGHT/2
   970 00000678 66F7E2                  mul edx
   971 0000067B 6689C3                  mov ebx, eax     ; bx is l(xi*128)
   972 0000067E 6689D1                  mov ecx, edx     ; cx is h(xi*128)
   973 00000681 6683F3FF                xor ebx, 0ffffffffh
   974 00000685 6683F1FF                xor ecx, 0ffffffffh
   975 00000689 6641                    inc ecx         ; cx:bx now negative'd
   976 0000068B 66031E[0B03]            add ebx, [lycentre]
   977 00000690 66130E[0F03]            adc ecx, [hycentre]
   978 00000695 66891E[1B03]            mov [lys], ebx
   979 0000069A 66890E[1F03]            mov [hys], ecx
   980                                  
   981                                  ; Calculate next fractal while we zoom the last one
   982 0000069F E89CFC                  call Fractal
   983                                  
   984                                  ; Switch the texture buffers, including copying 1/4 of the pixels
   985 000006A2 E8A7FD                  call SwitchTextures
   986                                  
   987 000006A5 803E[3703]01            cmp byte [nodraw], 1
   988 000006AA 750B                    jne alreadydrawing
   989 000006AC C606[3703]00            mov byte [nodraw], 0
   990 000006B1 E8ABFD                  call DoBackground
   991 000006B4 B90000                  mov cx, 0
   992                                  alreadydrawing:
   993                                  
   994                                  ; Double magnification
   995 000006B7 66A1[2303]              mov eax, [lxi]
   996 000006BB 668B16[2703]            mov edx, [hxi]
   997 000006C0 66D1E8                  shr eax, 1
   998 000006C3 66D1EA                  shr edx, 1
   999 000006C6 66A3[2303]              mov [lxi], eax
  1000 000006CA 668916[2703]            mov [hxi], edx
  1001 000006CF 66A3[2B03]              mov [lyi], eax
  1002 000006D3 668916[2F03]            mov [hyi], edx
  1003                                  
  1004                                  ; Update direction
  1005 000006D8 A0[3A03]                mov al, [newxdirection]
  1006 000006DB A2[3903]                mov [xdirection], al
  1007 000006DE A0[3B03]                mov al, [newydirection]
  1008 000006E1 A2[3803]                mov [ydirection], al
  1009                                  
  1010 000006E4 E801FE                  call DrawDirectionSquares
  1011                                  
  1012 000006E7 E9F1FE                  jmp dfs_fracloop
  1013                                  
  1014                                  dfs_keyhit:
  1015                                  
  1016 000006EA E816F9                  call Getch
  1017                                  
  1018 000006ED 3C37                    cmp al,'7'
  1019 000006EF 750A                    jne short not7
  1020 000006F1 C606[3A03]00            mov byte [newxdirection], 0
  1021 000006F6 C606[3B03]00            mov byte [newydirection], 0
  1022                                  not7:
  1023                                  
  1024 000006FB 3C34                    cmp al,'4'
  1025 000006FD 750A                    jne short not4
  1026 000006FF C606[3A03]00            mov byte [newxdirection], 0
  1027 00000704 C606[3B03]01            mov byte [newydirection], 1
  1028                                  not4:
  1029                                  
  1030 00000709 3C31                    cmp al,'1'
  1031 0000070B 750A                    jne short not1
  1032 0000070D C606[3A03]00            mov byte [newxdirection], 0
  1033 00000712 C606[3B03]02            mov byte [newydirection], 2
  1034                                  not1:
  1035                                  
  1036 00000717 3C38                    cmp al,'8'
  1037 00000719 750A                    jne short not8
  1038 0000071B C606[3A03]01            mov byte [newxdirection], 1
  1039 00000720 C606[3B03]00            mov byte [newydirection], 0
  1040                                  not8:
  1041                                  
  1042 00000725 3C35                    cmp al,'5'
  1043 00000727 750A                    jne short not5
  1044 00000729 C606[3A03]01            mov byte [newxdirection], 1
  1045 0000072E C606[3B03]01            mov byte [newydirection], 1
  1046                                  not5:
  1047                                  
  1048 00000733 3C32                    cmp al,'2'
  1049 00000735 750A                    jne short not2
  1050 00000737 C606[3A03]01            mov byte [newxdirection], 1
  1051 0000073C C606[3B03]02            mov byte [newydirection], 2
  1052                                  not2:
  1053                                  
  1054 00000741 3C39                    cmp al, '9'
  1055 00000743 750A                    jne short not9
  1056 00000745 C606[3A03]02            mov byte [newxdirection], 2
  1057 0000074A C606[3B03]00            mov byte [newydirection], 0
  1058                                  not9:
  1059                                  
  1060 0000074F 3C36                    cmp al, '6'
  1061 00000751 750A                    jne short not6
  1062 00000753 C606[3A03]02            mov byte [newxdirection], 2
  1063 00000758 C606[3B03]01            mov byte [newydirection], 1
  1064                                  not6:
  1065                                  
  1066 0000075D 3C33                    cmp al,'3'
  1067 0000075F 750A                    jne not3
  1068 00000761 C606[3A03]02            mov byte [newxdirection],2
  1069 00000766 C606[3B03]02            mov byte [newydirection],2
  1070                                  not3:
  1071                                  
  1072 0000076B 3C1B                    cmp al, 27
  1073 0000076D 0F84CC00                je breakout
  1074                                  
  1075 00000771 E874FD                  call DrawDirectionSquares
  1076                                  
  1077                                  donethecentrechange:
  1078 00000774 E924F9                  jmp zt_afterkeyhit    
  1079                                  
  1080                                  ;====================================================================
  1081                                  ;MAIN SECTION & MISC
  1082                                  ;--------------------------------------------------------------------
  1083                                  
  1084                                  Init:
  1085 00000777 50                      push ax
  1086 00000778 53                      push bx
  1087                                  ; 1) Setup ES segment
  1088 00000779 B800A0                  mov ax, 0a000h
  1089 0000077C 8EC0                    mov es, ax
  1090                                  ; 2) Allocate RAM
  1091                                  ; This is a COM program, so we just set the segments to spare
  1092                                  ; space in memory. (well, hopefully spare space :) 
  1093 0000077E 0E                      push cs
  1094 0000077F 58                      pop ax
  1095 00000780 050010                  add ax, 4096     ; textureseg is 64k above our segment
  1096 00000783 A3[0F00]                mov [textureseg], ax
  1097 00000786 050010                  add ax, 4096     ; and fractalseg is 128k above
  1098 00000789 A3[1100]                mov [fractalseg], ax
  1099 0000078C 2D0010                  sub ax, 4096
  1100 0000078F 2D0008                  sub ax, 2048     ; enlargebuffer is 1/2 way through our segment.
  1101 00000792 A3[0D00]                mov [enlargebufferseg], ax
  1102                                  ; 3) Do graphics mode
  1103 00000795 B81300                  mov ax, 0013h
  1104 00000798 CD10                    int 10h
  1105 0000079A 5B                      pop bx
  1106 0000079B 58                      pop ax
  1107 0000079C C3                      retn
  1108                                  
  1109                                  Shutdown:
  1110 0000079D 50                      push ax
  1111 0000079E B80300                  mov ax, 0003h
  1112 000007A1 CD10                    int 10h
  1113 000007A3 58                      pop ax
  1114 000007A4 C3                      retn
  1115                                  
  1116 000007A5 5468616E6B7320666F-     message db 'Thanks for watching the modified version of 4ge',39,'S XMaS 94 iNTRo.'
  1117 000007AE 72207761746368696E-
  1118 000007B7 6720746865206D6F64-
  1119 000007C0 696669656420766572-
  1120 000007C9 73696F6E206F662034-
  1121 000007D2 6765275320584D6153-
  1122 000007DB 20393420694E54526F-
  1123 000007E4 2E                 
  1124 000007E5 0D0A0D0A                db 13,10,13,10
  1125 000007E9 476574203467652D78-     db 'Get 4ge-xmas.zip from ftp.cdrom.com for the full version, Tseng gfx only.',13,10,13,10,'$'
  1126 000007F2 6D61732E7A69702066-
  1127 000007FB 726F6D206674702E63-
  1128 00000804 64726F6D2E636F6D20-
  1129 0000080D 666F72207468652066-
  1130 00000816 756C6C207665727369-
  1131 0000081F 6F6E2C205473656E67-
  1132 00000828 20676678206F6E6C79-
  1133 00000831 2E0D0A0D0A24       
  1134                                  
  1135                                  Start:
  1136 00000837 E83DFF                  call Init
  1137 0000083A E850FD                  call DoFractalSection
  1138                                  breakout:
  1139 0000083D E85DFF                  call Shutdown
  1140 00000840 B409                    mov ah, 09h
  1141 00000842 BA[A507]                mov dx, message
  1142 00000845 CD21                    int 21h
  1143                                  
  1144 00000847 CD20                    int 20h
  1145                                  
  1146                                  _end:
  1147                                  
