home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best Objectech Shareware Selections
/
UNTITLED.iso
/
boss
/
grap
/
util
/
010
/
calmanfp.asm
< prev
next >
Wrap
Assembly Source File
|
1992-02-26
|
43KB
|
1,125 lines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; calmanfp.asm - floating point version of the calcmand.asm file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The following code was adapted from a little program called "Mandelbrot
; Sets by Wesley Loewer" which had a very limited distribution (my
; Algebra II class). It didn't have any of the fancy integer math, but it
; did run floating point stuff pretty fast.
;
; The code was originally optimized for a 287 ('cuz that's what I've got)
; and for a large maxit (ie: use of generous overhead outside the loop to get
; slightly faster code inside the loop), which is generally the case when
; Fractint chooses to use floating point math. This code also has the
; advantage that once the initial parameters are loaded into the fpu
; register, no transfers of fp values to/from memory are needed except to
; check periodicity and to show orbits and the like. Thus, values keep all
; the significant digits of the full 10 byte real number format internal to
; the fpu. Intermediate results are not rounded to the normal IEEE 8 byte
; format (double) at any time.
;
; The non fpu specific stuff, such as periodicity checking and orbits,
; was adapted from CALCFRAC.C and CALCMAND.ASM.
;
; This file must be assembled with floating point emulation turned on. I
; suppose there could be some compiler differences in the emulation
; libraries, but this code has been successfully tested with the MSQC 2.51
; and MSC 5.1 emulation libraries.
;
; Wes Loewer
;
; and now for some REAL fractal calculations...
; (get it, real, floating point..., never mind)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; required for compatibility if Turbo ASM
IFDEF ??version
MASM51
QUIRKS
ENDIF
.8086
.8087
.MODEL medium,c
; external functions
EXTRN keypressed:FAR ; this routine is in 'general.asm'
EXTRN getakey:FAR ; this routine is in 'general.asm'
EXTRN plot_orbit:FAR ; this routine is in 'fracsubr.c'
EXTRN scrub_orbit:FAR ; this routine is in 'fracsubr.c'
; external data
EXTRN init:WORD ; declared as type complex
EXTRN parm:WORD ; declared as type complex
EXTRN new:WORD ; declared as type complex
EXTRN maxit:WORD
EXTRN inside:WORD
EXTRN outside:WORD
EXTRN fpu:WORD ; fpu type: 87, 287, or 387
EXTRN rqlim:QWORD ; bailout (I never did figure out
; what "rqlim" stands for. -Wes)
EXTRN color:WORD
EXTRN oldcolor:WORD
EXTRN realcolor:WORD
EXTRN periodicitycheck:WORD
EXTRN reset_periodicity:WORD
EXTRN closenuff:QWORD
EXTRN fractype:WORD ; Mandelbrot or Julia
EXTRN kbdcount:WORD ; keyboard counter
EXTRN dotmode:WORD
EXTRN show_orbit:WORD ; "show-orbit" flag
EXTRN orbit_ptr:WORD ; "orbit pointer" flag
EXTRN potflag:WORD ; potential flag
EXTRN magnitude:QWORD ; when using potential
JULIAFP EQU 6 ; from FRACTYPE.H
MANDELFP EQU 4
GREEN EQU 2 ; near y-axis
YELLOW EQU 6 ; near x-axis
initx EQU <qword ptr init> ; just to make life easier
inity EQU <qword ptr init+8>
parmx EQU <qword ptr parm>
parmy EQU <qword ptr parm+8>
newx EQU <qword ptr new>
newy EQU <qword ptr new+8>
; Apparently, these might be needed for TC++ overlays. I don't know if
; these are really needed here since I am not familiar with TC++. -Wes
FRAME MACRO regs
push bp
mov bp, sp
IRP reg, <regs>
push reg
ENDM
ENDM
UNFRAME MACRO regs
IRP reg, <regs>
pop reg
ENDM
pop bp
ENDM
.DATA
align 2
savedx DQ ?
savedy DQ ?
orbit_real DQ ?
orbit_imag DQ ?
close DD 0.01
round_down_half DD 0.5
tmp_word DW ?
inside_color DW ?
periodicity_color DW ?
;savedand DW ?
;savedincr DW ?
savedand EQU SI ; this doesn't save much time or
savedincr EQU DI ; space, but it doesn't hurt either
.CODE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This routine is called once per image.
; Put things here that won't change from one pixel to the next.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC calcmandfpasmstart
calcmandfpasmstart PROC
; not sure if needed here
FRAME <di,si> ; std frame, for TC++ overlays
mov ax,inside
cmp ax,0 ; if (inside color == maxiter)
jnl non_neg_inside
mov ax,maxit ; use maxit as inside_color
non_neg_inside: ; else
mov inside_color,ax ; use inside as inside_color
cmp periodicitycheck,0 ; if periodicitycheck < 0
jnl non_neg_periodicitycheck
mov ax,7 ; use color 7 (default white)
non_neg_periodicitycheck: ; else
mov periodicity_color,ax ; use inside_color still in ax
mov oldcolor,0 ; no periodicity checking on 1st pixel
sub ax,ax ; ax=0
UNFRAME <si,di> ; pop stack frame
ret
calcmandfpasmstart ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; floating point version of calcmandasm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC calcmandfpasm
calcmandfpasm PROC
FRAME <di,si> ; std frame, for TC++ overlays
; initialization stuff
sub ax,ax ; clear ax
cmp periodicitycheck,ax ; periodicity checking?
je initoldcolor ; no, set oldcolor 0 to disable it
cmp inside,-59 ; zmag?
je initoldcolor ; set oldcolor to 0
cmp reset_periodicity,ax ; periodicity reset?
je short initparms ; no, inherit oldcolor from prior invocation
mov ax,maxit ; yup. reset oldcolor to maxit-250
sub ax,250 ; (avoids slowness at high maxits)
initoldcolor:
mov oldcolor,ax ; reset oldcolor
initparms:
sub ax,ax ; clear ax
mov word ptr savedx,ax ; savedx = 0.0
mov word ptr savedx+2,ax ; needed since savedx is a QWORD
mov word ptr savedx+4,ax
mov word ptr savedx+6,ax
mov word ptr savedy,ax ; savedy = 0.0
mov word ptr savedy+2,ax ; needed since savedy is a QWORD
mov word ptr savedy+4,ax
mov word ptr savedy+6,ax
inc ax ; ax = 1
mov savedand,ax ; savedand = 1
mov savedincr,ax ; savedincr = 1
mov orbit_ptr,0 ; clear orbits
dec kbdcount ; decrement the keyboard counter
jns short nokey ; skip keyboard test if still positive
mov kbdcount,10 ; stuff in a low kbd count
cmp show_orbit,0 ; are we showing orbits?
jne quickkbd ; yup. leave it that way.
;this may need to be adjusted, I'm guessing at the "appropriate" values -Wes
mov kbdcount,5000 ; else, stuff an appropriate count val
cmp fpu,387 ; ("appropriate" to the FPU)
je short kbddiskadj ; ...
mov kbdcount,3000 ; ...
cmp fpu,287 ; ...
je short kbddiskadj ; ...
mov kbdcount,1000 ; ...
cmp fpu,87 ; ...
je short kbddiskadj ; ...
mov kbdcount,500 ; emulation
kbddiskadj:
cmp dotmode,11 ; disk video?
jne quickkbd ; no, leave as is
mov cl,2 ; yes, reduce count
shr kbdcount,cl ; ..