接上篇文章《Turbo C使用的汇编函数 -- VGA 12H模式图形函数(一)》,继续粘贴代码文件:
;grimage.asm
includegraph.inc
DATASEG
bufsegdw 0
bufoffdw 0
linebytesdw 0
tmpbufdb 80 dup( 0 )
CODESEG
PUBLIC_ImageSize
PUBLIC_GetImage
PUBLIC_PutImage
;
; long ImageSize( int x1, int y1, int x2, int y2)
;
PROC_ImageSize
ARGx1:word,y1:word,x2:word,y2:word
USESsi,di
movax,[x1]
movbx,[y1]
movsi,[x2]
movdi,[y2]
movcx,MAXX
movdx,MAXY
callTestPoint
jnc@@ 1
xorax,ax
xordx,dx
jmp short @@ 2
@@ 1 :
xchgax,si
subax,si
subdi,bx
incdi
andax,0fff8h
shrax, 1
addax, 4
muldi
addax, 4
adcdx, 0
@@ 2 :
ret
ENDP
;
PROCPackLine
USESbx,ds,es
pushes
popds
moves,[bufseg]
movdi,[bufoff]
movsi,offsettmpbuf
@@ 1 :
xorbh,bh
@@ 2 :
orbl,bl
jz@@ 3
lodsb
decbl
incbh
cmpal,[si]
je@@ 2
@@ 3 :
cmpbh, 1
ja@@ 4
testal,80h
jz@@ 5
@@ 4 :
xchgal,bh
oral,80h
stosb
moval,bh
@@ 5 :
stosb
orbl,bl
jnz@@ 1
mov[bufoff],di
ret
ENDP
;
PROCUnPackLine
USESbx,cx,di,es
pushds
popes
movdi,offsettmpbuf
pushdi
pushds
movsi,[bufoff]
movbx,[linebytes]
movax,[bufseg]
movds,ax
@@ 1 :
lodsb
movcx, 1
testal,80h
jz@@ 2
andax,7fh
movcx,ax
lodsb
@@ 2 :
subbx,cx
@@ 3 :
stosb
loop@@ 3
cmpbx, 0
jne@@ 1
popds
mov[bufoff],si
popsi
ret
ENDP
;
;unsignedGetImage( int x1, int y1, int x2, int y2, void far * buf)
;
PROC_GetImage
ARGx1:word,y1:word,x2:word,y2:word,buf:farptr
USESsi,di
movax,[x1]
movbx,[y1]
movsi,[x2]
movdi,[y2]
movcx,MAXX
movdx,MAXY
callTestPoint
jnc@@ 5
xorax,ax
jmp@@ 4
@@ 5 :
pushds
movcx,ax
andcl, 7
movdl,cl
movcx,si
notcl
addcl,dl
andcl, 7
movdh,0ffh
shldh,cl
mov[x1],dx
subsi,ax
subdi,bx
movcx,di
lesdi,[dwordbuf]
mov[wordes:di],si
mov[wordes:di + 2 ],cx
pushdi
adddi, 4
mov[bufseg],es
mov[bufoff],di
shrsi, 3
callGetDspMemOff
xchgsi,bx
incbx
inccx
pushds
popes
movdi,offsettmpbuf
pushDSPMEMSEG
popds
movdx,3ceh
cld
@@ 1 :
pushcx
pushsi
movcx,[x1]
movax,304h
@@ 2 :
out dx,ax
pushax
pushsi
pushdi
pushbx
lodsb
@@ 3 :
movah,al
lodsb
pushax
shlax,cl
moval,ah
stosb
popax
decbx
jnz@@ 3
and[ byte es:di - 1 ],ch
popbx
callPackLine
popdi
popsi
popax
decah
jns@@ 2
popsi
popcx
addsi,DMWIDTH
loop@@ 1
popdi
popds
movax,[bufoff]
subax,di
@@ 4 :
ret
ENDP
;
; void PutImage( int x, int y, void far * buf, int mod)
;
PROC_PutImage
ARGx:word,y:word,buf:farptr,mod:word
USESsi,di
lesbx,[dwordbuf]
movdi,[wordes:bx + 2 ]
movsi,[wordes:bx]
mov[bufseg],es
addbx, 4
mov[bufoff],bx
movax,si
shrax, 3
incax
mov[linebytes],ax
movax,[x]
movbx,[y]
addsi,ax
adddi,bx
movcx,MAXX
movdx,MAXY
callTestPoint
jc@@ 7
push[wordDrMode]
movcx,si
notcl
andcl, 7
movch,0ffh
shlch,cl
movcl,al
andcl, 7
mov[x],cx
pushax
shrsi, 3
shrax, 3
subsi,ax
pushsi
push[wordmod]
call_SetDrMode
xorah,ah
callSetWrMode
popax
cld
movcx,di
subcx,bx
inccx
popdi
popax
callGetDspMem
@@ 2 :
pushbx
pushcx
movax,802h
movcx,[x]
@@ 3 :
movdx,3c4h
out dx,ax
movdx,3cfh
pushax
pushbx
pushdi
callUnPackLine
movax,0ffh
shral,cl
decdi
js@@ 6
out dx,al
lodsb
rorax,cl
xchgal,[ byte es:bx]
incbx
moval,0ffh
out dx,al
@@ 4 :
decdi
js@@ 5
movch,ah
lodsb
xorah,ah
rorax,cl
oral,ch
xchgal,[ byte es:bx]
incbx
jmp short @@ 4
@@ 5 :
moval,0ffh
@@ 6 :
andal,[ byte x + 1 ]
out dx,al
lodsb
shral,cl
oral,ah
xchgal,[ byte es:bx]
popdi
popbx
popax
shrah, 1
jnz@@ 3
popcx
popbx
addbx,DMWIDTH
loop@@ 2
pop[wordDrMode]
callRestReg
movdx,3c4h
movax,0f02h
out dx,ax
@@ 7 :
ret
ENDP
END
includegraph.inc
DATASEG
bufsegdw 0
bufoffdw 0
linebytesdw 0
tmpbufdb 80 dup( 0 )
CODESEG
PUBLIC_ImageSize
PUBLIC_GetImage
PUBLIC_PutImage
;
; long ImageSize( int x1, int y1, int x2, int y2)
;
PROC_ImageSize
ARGx1:word,y1:word,x2:word,y2:word
USESsi,di
movax,[x1]
movbx,[y1]
movsi,[x2]
movdi,[y2]
movcx,MAXX
movdx,MAXY
callTestPoint
jnc@@ 1
xorax,ax
xordx,dx
jmp short @@ 2
@@ 1 :
xchgax,si
subax,si
subdi,bx
incdi
andax,0fff8h
shrax, 1
addax, 4
muldi
addax, 4
adcdx, 0
@@ 2 :
ret
ENDP
;
PROCPackLine
USESbx,ds,es
pushes
popds
moves,[bufseg]
movdi,[bufoff]
movsi,offsettmpbuf
@@ 1 :
xorbh,bh
@@ 2 :
orbl,bl
jz@@ 3
lodsb
decbl
incbh
cmpal,[si]
je@@ 2
@@ 3 :
cmpbh, 1
ja@@ 4
testal,80h
jz@@ 5
@@ 4 :
xchgal,bh
oral,80h
stosb
moval,bh
@@ 5 :
stosb
orbl,bl
jnz@@ 1
mov[bufoff],di
ret
ENDP
;
PROCUnPackLine
USESbx,cx,di,es
pushds
popes
movdi,offsettmpbuf
pushdi
pushds
movsi,[bufoff]
movbx,[linebytes]
movax,[bufseg]
movds,ax
@@ 1 :
lodsb
movcx, 1
testal,80h
jz@@ 2
andax,7fh
movcx,ax
lodsb
@@ 2 :
subbx,cx
@@ 3 :
stosb
loop@@ 3
cmpbx, 0
jne@@ 1
popds
mov[bufoff],si
popsi
ret
ENDP
;
;unsignedGetImage( int x1, int y1, int x2, int y2, void far * buf)
;
PROC_GetImage
ARGx1:word,y1:word,x2:word,y2:word,buf:farptr
USESsi,di
movax,[x1]
movbx,[y1]
movsi,[x2]
movdi,[y2]
movcx,MAXX
movdx,MAXY
callTestPoint
jnc@@ 5
xorax,ax
jmp@@ 4
@@ 5 :
pushds
movcx,ax
andcl, 7
movdl,cl
movcx,si
notcl
addcl,dl
andcl, 7
movdh,0ffh
shldh,cl
mov[x1],dx
subsi,ax
subdi,bx
movcx,di
lesdi,[dwordbuf]
mov[wordes:di],si
mov[wordes:di + 2 ],cx
pushdi
adddi, 4
mov[bufseg],es
mov[bufoff],di
shrsi, 3
callGetDspMemOff
xchgsi,bx
incbx
inccx
pushds
popes
movdi,offsettmpbuf
pushDSPMEMSEG
popds
movdx,3ceh
cld
@@ 1 :
pushcx
pushsi
movcx,[x1]
movax,304h
@@ 2 :
out dx,ax
pushax
pushsi
pushdi
pushbx
lodsb
@@ 3 :
movah,al
lodsb
pushax
shlax,cl
moval,ah
stosb
popax
decbx
jnz@@ 3
and[ byte es:di - 1 ],ch
popbx
callPackLine
popdi
popsi
popax
decah
jns@@ 2
popsi
popcx
addsi,DMWIDTH
loop@@ 1
popdi
popds
movax,[bufoff]
subax,di
@@ 4 :
ret
ENDP
;
; void PutImage( int x, int y, void far * buf, int mod)
;
PROC_PutImage
ARGx:word,y:word,buf:farptr,mod:word
USESsi,di
lesbx,[dwordbuf]
movdi,[wordes:bx + 2 ]
movsi,[wordes:bx]
mov[bufseg],es
addbx, 4
mov[bufoff],bx
movax,si
shrax, 3
incax
mov[linebytes],ax
movax,[x]
movbx,[y]
addsi,ax
adddi,bx
movcx,MAXX
movdx,MAXY
callTestPoint
jc@@ 7
push[wordDrMode]
movcx,si
notcl
andcl, 7
movch,0ffh
shlch,cl
movcl,al
andcl, 7
mov[x],cx
pushax
shrsi, 3
shrax, 3
subsi,ax
pushsi
push[wordmod]
call_SetDrMode
xorah,ah
callSetWrMode
popax
cld
movcx,di
subcx,bx
inccx
popdi
popax
callGetDspMem
@@ 2 :
pushbx
pushcx
movax,802h
movcx,[x]
@@ 3 :
movdx,3c4h
out dx,ax
movdx,3cfh
pushax
pushbx
pushdi
callUnPackLine
movax,0ffh
shral,cl
decdi
js@@ 6
out dx,al
lodsb
rorax,cl
xchgal,[ byte es:bx]
incbx
moval,0ffh
out dx,al
@@ 4 :
decdi
js@@ 5
movch,ah
lodsb
xorah,ah
rorax,cl
oral,ch
xchgal,[ byte es:bx]
incbx
jmp short @@ 4
@@ 5 :
moval,0ffh
@@ 6 :
andal,[ byte x + 1 ]
out dx,al
lodsb
shral,cl
oral,ah
xchgal,[ byte es:bx]
popdi
popbx
popax
shrah, 1
jnz@@ 3
popcx
popbx
addbx,DMWIDTH
loop@@ 2
pop[wordDrMode]
callRestReg
movdx,3c4h
movax,0f02h
out dx,ax
@@ 7 :
ret
ENDP
END
;GRFILL.ASM
includegraph.inc
BLOCKEDequ 1
UNBLOCKEDequ 2
DATASEG
BorderValuedw 0
FillColordw 0
FillBufPtrdw 0
BufStartOfsdw 0
BufEndOfsdw 0
Ddw 0
PrevDdw 0
PrevVdw 0
TmpXdw 0
TmpYdw 0
TmpFlagdb 0
CODESEG
PUBLIC_Fill
;
;ax = x,bx = y return ax = xr,bx = y
;
PROCScanRight
USESes,di,si,bx
movsi,ax
callGetDspMem
movdi,bx
movcx,si
shrsi, 3
andcl, 7
movch,0ffh
shrch,cl
movdx,3ceh
movah,[ byte BorderValue]
moval, 2
out dx,ax
movax,805h
out dx,ax
movax,0f07h
out dx,ax
moval,[es:di]
incdi
notal
andal,ch
jnz@@ 1
movcx,[MaxX]
shrcx, 3
subcx,si
moval,0ffh
cld
repescasb
moval,[es:di - 1 ]
notal
cmpcx, 0
jne@@ 1
movcx,[MaxX]
andcl, 7
movch,40h
shrch,cl
oral,ch
@@ 1 :
subdi,bx
adddi,si
shldi, 3
movcx, 8
@@ 2 :
shlal, 1
jc@@ 3
loop@@ 2
@@ 3 :
subdi,cx
movax, 2
out dx,ax
movax, 5
out dx,ax
movax,di
ret
ENDP
;
; return ax = x,bx = y
;
PROCScanRegion
USESdi
movdi,[BufStartOfs];i = bufstart
@@ 1 :
cmpdi,si; while (i < bufend)
jae@@ 5 ;{
cmp[ byte es:di + 4 ],BLOCKED; if (buf[i].flag == BLOCKED
je@@ 2
movbx,[es:di + 2 ]; || buf[i].y != buf[i + 1 ].y)
cmpbx,[es:di + 7 ]
je@@ 3
@@ 2 :
adddi, 5 ;i ++
jmp short @@ 1 ;}
@@ 3 :; else {
movax,[es:di]; if (buf[i].x + 1 < buf[i + 1 ].x)
incax;{
cmpax,[es:di + 5 ]
jge@@ 4
callScanRight;xr = ScanRight(buf[i].x + 1 ,buf[i].y)
cmpax,[es:di + 5 ]; if (xr < buf[i + 1 ].x){
jl@@ 5 ;ax = xr;bx = buf[i].y
@@ 4 :;}
adddi, 10 ;i += 2
jmp short @@ 1 ;}
@@ 5 :;}
mov[BufStartOfs],di;bufstart = i
ret
ENDP
;
;
PROCFillRegion
USESdi
push[wordColor]
movax,[FillColor]
mov[Color],ax
movdi,[FillBufPtr]
callSetWrMode0
@@ 1 :
cmpdi,[BufEndOfs]
jae@@ 5
cmp[ byte es:di + 4 ],BLOCKED
je@@ 2
movbx,[es:di + 2 ]
cmpbx,[es:di + 7 ]
je@@ 3
@@ 2 :
adddi, 5
jmp short @@ 1
@@ 3 :
movsi,[es:di + 5 ]
decsi
cmpsi,[es:di]
jle@@ 4
pushes
pushdi
movax,[es:di]
incax
movdi,bx
callBar
popdi
popes
@@ 4 :
adddi, 10
jmp short @@ 1
@@ 5 :
callRestReg0
pop[wordColor]
ret
ENDP
;
;
PROCAppendBPList
mov[ byte es:si + 4 ],bl
movebx,[dwordTmpX]
mov[dwordes:si],ebx
addsi, 5
ret
ENDP
;
;
PROCFindBP
USESbx
movcx,[TmpX]
movdx,[TmpY]
cmpax, 1 ; 1 , 2 , 3 ,y --
jl@@ 5
cmpax, 3
jg@@ 1
decdx
jmp short @@ 2
@@ 1 :
cmpax, 5 ; 5 , 6 , 7 ,y ++
jl@@ 3
incdx
@@ 2 :
cmpax, 3 ; 3 , 4 , 5 ,x --
jl@@ 4
cmpax, 5
jg@@ 4
@@ 3 :
deccx
jmp short @@ 6
@@ 4 :
cmpax, 7 ; 0 , 1 , 7 ,x ++
je@@ 5
cmpax, 1
jg@@ 6
@@ 5 :
inccx
@@ 6 :
cmpcx,[MinX]
jl@@ 18
cmpcx,[MaxX]
jg@@ 18
cmpdx,[MinY]
jl@@ 18
cmpdx,[MaxY]
jg@@ 18
pushes
pushax
pushcx
pushdx
movax,cx
movbx,dx
callGetPixel
movbx,ax
popdx
popcx
popax
popes
cmpbx,[BorderValue]
je@@ 16
@@ 18 :
cmpax,[PrevD]
jne@@ 8
cmp[wordPrevD], 4
je@@ 15
cmp[wordPrevD], 0
jne@@ 7
mov[ byte es:si - 1 ],BLOCKED
jmp@@ 15
@@ 7 :
movbl,UNBLOCKED
callAppendBPList
jmp@@ 15
@@ 8 :
movbl,BLOCKED
cmp[wordPrevD], 4
jne@@ 10
cmp[wordPrevV], 5
jne@@ 13
mov[ byte es:si - 1 ],BLOCKED
jmp short @@ 13
@@ 10 :
cmp[wordPrevD], 0
jne@@ 11
mov[ byte es:si - 1 ],BLOCKED
cmpax, 7
je@@ 13
movbl,UNBLOCKED
jmp short @@ 13
@@ 11 :
movbl,UNBLOCKED
callAppendBPList
cmpax, 1
jl@@ 14
movbl,UNBLOCKED
cmpax, 3
jg@@ 12
cmp[wordPrevD], 5
jl@@ 14
cmp[wordPrevD], 7
jg@@ 14
jmp short @@ 13
@@ 12 :
cmpax, 5
jl@@ 14
cmp[wordPrevD], 1
jl@@ 14
cmp[wordPrevD], 3
jg@@ 14
@@ 13 :
callAppendBPList
@@ 14 :
push[wordPrevD]
pop[wordPrevV]
@@ 15 :
mov[PrevD],ax
mov[TmpX],cx
mov[TmpY],dx
movax, 1
jmp short @@ 17
@@ 16 :
xorax,ax
@@ 17 :
ret
ENDP
;
;
PROCFindNextPixel
movbx, - 2
@@ 1 :
incbx
cmpbx, 5
jg@@ 2
movax,bx
addax,[D]
andax, 7
callFindBP
cmpax, 0
je@@ 1
add[wordD],bx
and[wordD], 6
@@ 2 :
ret
ENDP
;
;TraceBorder( int startx, int starty)
;
PROCTraceBorder
ARGstartx:word,starty:word
mov[wordD], 6
mov[wordPrevD], 8
mov[wordPrevV], 2
push[wordstartx]
pop[wordTmpX]
push[wordstarty]
pop[wordTmpY]
@@ 1 :
callFindNextPixel
cmpax, 0
je@@ 2
movbx,[startx]
cmpbx,[TmpX]
jne@@ 1
movbx,[starty]
cmpbx,[TmpY]
jne@@ 1
@@ 2 :
movcx,[startx]
movdx,[starty]
cmpax, 0
jne@@ 3
mov[es:si],cx
mov[es:si + 2 ],dx
mov[ byte es:si + 4 ],UNBLOCKED
addsi, 5
jmp short @@ 4
@@ 3 :
cmp[wordPrevD], 3
jg@@ 5
cmp[wordPrevD], 1
jl@@ 5
@@ 4 :
mov[es:si],cx
mov[es:si + 2 ],dx
mov[ byte es:si + 4 ],UNBLOCKED
addsi, 5
@@ 5 :
ret
ENDP
;
PROC_CompBP
movax,[es:di + 2 ]
subax,[TmpY]
jne@@ 1
movax,[es:di]
subax,[TmpX]
jne@@ 1
moval,[es:di + 4 ]
subal,[TmpFlag]
cbw
@@ 1 :
ret
ENDP
;
PROCBorSort
movax,cx
subax,bx
cmpax, 10
jl@@ 8
xordx,dx
movdi, 5
divdi
shrax, 1
muldi
addax,bx
movdi,ax
moveax,[dwordes:di]
mov[dwordTmpX],eax
moval,[es:di + 4 ]
mov[TmpFlag],al
movsi,bx
movdx,cx
subsi, 5
pushdi
@@ 0 :
movdi,si
@@ 1 :
adddi, 5
call_CompBP
jl@@ 1
@@ 2 :
movsi,di
movdi,dx
@@ 3 :
subdi, 5
call_CompBP
jg@@ 3
@@ 4 :
movdx,di
cmpsi,di
jae@@ 7
@@ 6 :
moveax,[dwordes:si]
xchgeax,[dwordes:di]
mov[dwordes:si],eax
moval,[es:si + 4 ]
xchgal,[es:di + 4 ]
mov[es:si + 4 ],al
jmp short @@ 0
@@ 7 :
popdi
cmpsi,di
jae@@ 5
pushcx
pushsi
movcx,si
callBorSort
popbx
popcx
callBorSort
jmp short @@ 8
@@ 5 :
pushbx
pushsi
movbx,si
callBorSort
popcx
popbx
callBorSort
@@ 8 :
ret
ENDP
;
; void Fill( int x, int y, int fillcolor)
;
PROC_Fill
ARGx:word,y:word,fillcolor:word
USESsi
movax,[x]
movbx,[y]
cmpax,[WidthX]
ja@@ 2
cmpbx,[WidthY]
ja@@ 2
addax,[MinX]
addbx,[MinY]
mov[x],ax
mov[y],bx
callGetPixel
mov[BorderValue],ax
movax,[fillcolor]
mov[FillColor],ax
push 0
push 15000
call_farmalloc
addsp, 4
cmpdx, 0
je@@ 2
moves,dx
mov[FillBufPtr],ax
mov[BufStartOfs],ax
movsi,ax
movax,[x]
movbx,[y]
callScanRight
@@ 1 :
pushbx
pushax
callTraceBorder
addsp, 4
pushsi
movcx,si
movbx,[BufStartOfs]
callBorSort
popsi
callScanRegion
cmpsi,[BufStartOfs]
ja@@ 1
mov[BufEndOfs],si
callFillRegion
pushes
push[wordFillBufPtr]
call_farfree
addsp, 4
@@ 2 :
ret
ENDP
;
END
includegraph.inc
BLOCKEDequ 1
UNBLOCKEDequ 2
DATASEG
BorderValuedw 0
FillColordw 0
FillBufPtrdw 0
BufStartOfsdw 0
BufEndOfsdw 0
Ddw 0
PrevDdw 0
PrevVdw 0
TmpXdw 0
TmpYdw 0
TmpFlagdb 0
CODESEG
PUBLIC_Fill
;
;ax = x,bx = y return ax = xr,bx = y
;
PROCScanRight
USESes,di,si,bx
movsi,ax
callGetDspMem
movdi,bx
movcx,si
shrsi, 3
andcl, 7
movch,0ffh
shrch,cl
movdx,3ceh
movah,[ byte BorderValue]
moval, 2
out dx,ax
movax,805h
out dx,ax
movax,0f07h
out dx,ax
moval,[es:di]
incdi
notal
andal,ch
jnz@@ 1
movcx,[MaxX]
shrcx, 3
subcx,si
moval,0ffh
cld
repescasb
moval,[es:di - 1 ]
notal
cmpcx, 0
jne@@ 1
movcx,[MaxX]
andcl, 7
movch,40h
shrch,cl
oral,ch
@@ 1 :
subdi,bx
adddi,si
shldi, 3
movcx, 8
@@ 2 :
shlal, 1
jc@@ 3
loop@@ 2
@@ 3 :
subdi,cx
movax, 2
out dx,ax
movax, 5
out dx,ax
movax,di
ret
ENDP
;
; return ax = x,bx = y
;
PROCScanRegion
USESdi
movdi,[BufStartOfs];i = bufstart
@@ 1 :
cmpdi,si; while (i < bufend)
jae@@ 5 ;{
cmp[ byte es:di + 4 ],BLOCKED; if (buf[i].flag == BLOCKED
je@@ 2
movbx,[es:di + 2 ]; || buf[i].y != buf[i + 1 ].y)
cmpbx,[es:di + 7 ]
je@@ 3
@@ 2 :
adddi, 5 ;i ++
jmp short @@ 1 ;}
@@ 3 :; else {
movax,[es:di]; if (buf[i].x + 1 < buf[i + 1 ].x)
incax;{
cmpax,[es:di + 5 ]
jge@@ 4
callScanRight;xr = ScanRight(buf[i].x + 1 ,buf[i].y)
cmpax,[es:di + 5 ]; if (xr < buf[i + 1 ].x){
jl@@ 5 ;ax = xr;bx = buf[i].y
@@ 4 :;}
adddi, 10 ;i += 2
jmp short @@ 1 ;}
@@ 5 :;}
mov[BufStartOfs],di;bufstart = i
ret
ENDP
;
;
PROCFillRegion
USESdi
push[wordColor]
movax,[FillColor]
mov[Color],ax
movdi,[FillBufPtr]
callSetWrMode0
@@ 1 :
cmpdi,[BufEndOfs]
jae@@ 5
cmp[ byte es:di + 4 ],BLOCKED
je@@ 2
movbx,[es:di + 2 ]
cmpbx,[es:di + 7 ]
je@@ 3
@@ 2 :
adddi, 5
jmp short @@ 1
@@ 3 :
movsi,[es:di + 5 ]
decsi
cmpsi,[es:di]
jle@@ 4
pushes
pushdi
movax,[es:di]
incax
movdi,bx
callBar
popdi
popes
@@ 4 :
adddi, 10
jmp short @@ 1
@@ 5 :
callRestReg0
pop[wordColor]
ret
ENDP
;
;
PROCAppendBPList
mov[ byte es:si + 4 ],bl
movebx,[dwordTmpX]
mov[dwordes:si],ebx
addsi, 5
ret
ENDP
;
;
PROCFindBP
USESbx
movcx,[TmpX]
movdx,[TmpY]
cmpax, 1 ; 1 , 2 , 3 ,y --
jl@@ 5
cmpax, 3
jg@@ 1
decdx
jmp short @@ 2
@@ 1 :
cmpax, 5 ; 5 , 6 , 7 ,y ++
jl@@ 3
incdx
@@ 2 :
cmpax, 3 ; 3 , 4 , 5 ,x --
jl@@ 4
cmpax, 5
jg@@ 4
@@ 3 :
deccx
jmp short @@ 6
@@ 4 :
cmpax, 7 ; 0 , 1 , 7 ,x ++
je@@ 5
cmpax, 1
jg@@ 6
@@ 5 :
inccx
@@ 6 :
cmpcx,[MinX]
jl@@ 18
cmpcx,[MaxX]
jg@@ 18
cmpdx,[MinY]
jl@@ 18
cmpdx,[MaxY]
jg@@ 18
pushes
pushax
pushcx
pushdx
movax,cx
movbx,dx
callGetPixel
movbx,ax
popdx
popcx
popax
popes
cmpbx,[BorderValue]
je@@ 16
@@ 18 :
cmpax,[PrevD]
jne@@ 8
cmp[wordPrevD], 4
je@@ 15
cmp[wordPrevD], 0
jne@@ 7
mov[ byte es:si - 1 ],BLOCKED
jmp@@ 15
@@ 7 :
movbl,UNBLOCKED
callAppendBPList
jmp@@ 15
@@ 8 :
movbl,BLOCKED
cmp[wordPrevD], 4
jne@@ 10
cmp[wordPrevV], 5
jne@@ 13
mov[ byte es:si - 1 ],BLOCKED
jmp short @@ 13
@@ 10 :
cmp[wordPrevD], 0
jne@@ 11
mov[ byte es:si - 1 ],BLOCKED
cmpax, 7
je@@ 13
movbl,UNBLOCKED
jmp short @@ 13
@@ 11 :
movbl,UNBLOCKED
callAppendBPList
cmpax, 1
jl@@ 14
movbl,UNBLOCKED
cmpax, 3
jg@@ 12
cmp[wordPrevD], 5
jl@@ 14
cmp[wordPrevD], 7
jg@@ 14
jmp short @@ 13
@@ 12 :
cmpax, 5
jl@@ 14
cmp[wordPrevD], 1
jl@@ 14
cmp[wordPrevD], 3
jg@@ 14
@@ 13 :
callAppendBPList
@@ 14 :
push[wordPrevD]
pop[wordPrevV]
@@ 15 :
mov[PrevD],ax
mov[TmpX],cx
mov[TmpY],dx
movax, 1
jmp short @@ 17
@@ 16 :
xorax,ax
@@ 17 :
ret
ENDP
;
;
PROCFindNextPixel
movbx, - 2
@@ 1 :
incbx
cmpbx, 5
jg@@ 2
movax,bx
addax,[D]
andax, 7
callFindBP
cmpax, 0
je@@ 1
add[wordD],bx
and[wordD], 6
@@ 2 :
ret
ENDP
;
;TraceBorder( int startx, int starty)
;
PROCTraceBorder
ARGstartx:word,starty:word
mov[wordD], 6
mov[wordPrevD], 8
mov[wordPrevV], 2
push[wordstartx]
pop[wordTmpX]
push[wordstarty]
pop[wordTmpY]
@@ 1 :
callFindNextPixel
cmpax, 0
je@@ 2
movbx,[startx]
cmpbx,[TmpX]
jne@@ 1
movbx,[starty]
cmpbx,[TmpY]
jne@@ 1
@@ 2 :
movcx,[startx]
movdx,[starty]
cmpax, 0
jne@@ 3
mov[es:si],cx
mov[es:si + 2 ],dx
mov[ byte es:si + 4 ],UNBLOCKED
addsi, 5
jmp short @@ 4
@@ 3 :
cmp[wordPrevD], 3
jg@@ 5
cmp[wordPrevD], 1
jl@@ 5
@@ 4 :
mov[es:si],cx
mov[es:si + 2 ],dx
mov[ byte es:si + 4 ],UNBLOCKED
addsi, 5
@@ 5 :
ret
ENDP
;
PROC_CompBP
movax,[es:di + 2 ]
subax,[TmpY]
jne@@ 1
movax,[es:di]
subax,[TmpX]
jne@@ 1
moval,[es:di + 4 ]
subal,[TmpFlag]
cbw
@@ 1 :
ret
ENDP
;
PROCBorSort
movax,cx
subax,bx
cmpax, 10
jl@@ 8
xordx,dx
movdi, 5
divdi
shrax, 1
muldi
addax,bx
movdi,ax
moveax,[dwordes:di]
mov[dwordTmpX],eax
moval,[es:di + 4 ]
mov[TmpFlag],al
movsi,bx
movdx,cx
subsi, 5
pushdi
@@ 0 :
movdi,si
@@ 1 :
adddi, 5
call_CompBP
jl@@ 1
@@ 2 :
movsi,di
movdi,dx
@@ 3 :
subdi, 5
call_CompBP
jg@@ 3
@@ 4 :
movdx,di
cmpsi,di
jae@@ 7
@@ 6 :
moveax,[dwordes:si]
xchgeax,[dwordes:di]
mov[dwordes:si],eax
moval,[es:si + 4 ]
xchgal,[es:di + 4 ]
mov[es:si + 4 ],al
jmp short @@ 0
@@ 7 :
popdi
cmpsi,di
jae@@ 5
pushcx
pushsi
movcx,si
callBorSort
popbx
popcx
callBorSort
jmp short @@ 8
@@ 5 :
pushbx
pushsi
movbx,si
callBorSort
popcx
popbx
callBorSort
@@ 8 :
ret
ENDP
;
; void Fill( int x, int y, int fillcolor)
;
PROC_Fill
ARGx:word,y:word,fillcolor:word
USESsi
movax,[x]
movbx,[y]
cmpax,[WidthX]
ja@@ 2
cmpbx,[WidthY]
ja@@ 2
addax,[MinX]
addbx,[MinY]
mov[x],ax
mov[y],bx
callGetPixel
mov[BorderValue],ax
movax,[fillcolor]
mov[FillColor],ax
push 0
push 15000
call_farmalloc
addsp, 4
cmpdx, 0
je@@ 2
moves,dx
mov[FillBufPtr],ax
mov[BufStartOfs],ax
movsi,ax
movax,[x]
movbx,[y]
callScanRight
@@ 1 :
pushbx
pushax
callTraceBorder
addsp, 4
pushsi
movcx,si
movbx,[BufStartOfs]
callBorSort
popsi
callScanRegion
cmpsi,[BufStartOfs]
ja@@ 1
mov[BufEndOfs],si
callFillRegion
pushes
push[wordFillBufPtr]
call_farfree
addsp, 4
@@ 2 :
ret
ENDP
;
END
;grroll.asm
includegraph.inc
CODESEG
PUBLIC_Roll
;
; void Roll( int n, int x1, int y1, int x2, int y2)
;
PROC_Roll
ARGn:word,x1:word,y1:word,x2:word,y2:word
USESsi,di,ds
cmp[wordn], 0
je@@ 4
movax,[x1]
movbx,[y1]
movsi,[x2]
movdi,[y2]
movcx,MAXX
movdx,MAXY
callTestPoint
jc@@ 4
movdx,0ffffh
movcx,ax
andcl, 7
shrdh,cl
movcx,si
andcl, 7
notcl
shldl,cl
pushdx
pushax
shrax, 3
shrsi, 3
subsi,ax
mov[x2],si
movcx,[n]
movax,DMWIDTH
mov[y2],ax
imulcx
movsi,ax
movcx,di
subcx,bx
inccx
cmpsi, 0
jg@@ 1
xchgbx,di
neg[wordn]
neg[wordy2]
@@ 1 :
popax
callGetDspMem
movdi,bx
addsi,di
popbx
subcx,[n]
jle@@ 4
movah, 1
callSetWrMode
pushes
popds
cld
@@ 2 :
pushcx
pushsi
pushdi
movcx,[x2]
moval,bh
jcxz@@ 3
out dx,al
movsb
moval,0ffh
deccx
jz@@ 3
out dx,ax
repzmovsb
moval,0ffh
@@ 3 :
andal,bl
out dx,ax
movsb
popdi
popsi
popcx
adddi,[y2]
addsi,[y2]
loop@@ 2
callRestReg
@@ 4 :
ret
ENDP
end
includegraph.inc
CODESEG
PUBLIC_Roll
;
; void Roll( int n, int x1, int y1, int x2, int y2)
;
PROC_Roll
ARGn:word,x1:word,y1:word,x2:word,y2:word
USESsi,di,ds
cmp[wordn], 0
je@@ 4
movax,[x1]
movbx,[y1]
movsi,[x2]
movdi,[y2]
movcx,MAXX
movdx,MAXY
callTestPoint
jc@@ 4
movdx,0ffffh
movcx,ax
andcl, 7
shrdh,cl
movcx,si
andcl, 7
notcl
shldl,cl
pushdx
pushax
shrax, 3
shrsi, 3
subsi,ax
mov[x2],si
movcx,[n]
movax,DMWIDTH
mov[y2],ax
imulcx
movsi,ax
movcx,di
subcx,bx
inccx
cmpsi, 0
jg@@ 1
xchgbx,di
neg[wordn]
neg[wordy2]
@@ 1 :
popax
callGetDspMem
movdi,bx
addsi,di
popbx
subcx,[n]
jle@@ 4
movah, 1
callSetWrMode
pushes
popds
cld
@@ 2 :
pushcx
pushsi
pushdi
movcx,[x2]
moval,bh
jcxz@@ 3
out dx,al
movsb
moval,0ffh
deccx
jz@@ 3
out dx,ax
repzmovsb
moval,0ffh
@@ 3 :
andal,bl
out dx,ax
movsb
popdi
popsi
popcx
adddi,[y2]
addsi,[y2]
loop@@ 2
callRestReg
@@ 4 :
ret
ENDP
end
;GRARC.ASM
P386N
includegraph.inc
DATASEG
Sindw0000h,00afh,015dh,020bh,02bah,0368h,0415h,04c3h
dw0570h,061ch,06c8h,0774h,081fh,08cah,0973h,0a1ch
dw0ac4h,0b6ch,0c12h,0cb8h,0d5ch,0e00h,0ea2h,0f43h
dw0fe3h,1082h,1120h,11bch,1257h,12f0h,1388h,141eh
dw14b3h,1546h,15d8h,1668h,16f6h,1782h,180dh,1895h
dw191ch,19a1h,1a23h,1aa4h,1b23h,1b9fh,1c19h,1c92h
dw1d07h,1d7bh,1dech,1e5bh,1ec8h,1f32h,1f9ah,2000h
dw2062h,20c3h,2120h,217ch,21d4h,222ah,227dh,22ceh
dw231ch,2367h,23afh,23f5h,2438h,2478h,24b5h,24efh
dw2527h,255bh,258dh,25bbh,25e7h,2610h,2635h,2658h
dw2678h,2695h,26afh,26c5h,26d9h,26eah,26f8h,2702h
dw270ah,270eh,2710h
StartQdw 0
EndQdw 0
StartXdw 0
StartYdw 0
EndXdw 0
EndYdw 0
;
EXTRNCirX0:word
EXTRNCirY0:word
;
CODESEG
PUBLIC_Arc
PUBLIC_Slice
PUBLIC_Pie
EXTRNEllipse:proc
EXTRNPlotCirPix:proc
;
;
PROCSumArcXY
ARGx:word,y:word
movax,[CirX0]
movbx,[CirY0]
andcx, 3
jnz@@ 1
addax,[x]
subbx,[y]
jmp short @@ 4
@@ 1 :
cmpcx, 1
jne@@ 2
subax,[x]
subbx,[y]
jmp short @@ 4
@@ 2 :
addbx,[y]
cmpcx, 2
jne@@ 3
subax,[x]
jmp short @@ 4
@@ 3 :
addax,[x]
@@ 4 :
ret
ENDP
;
;
PROCArcjs
USESdi
@@ 1 :
cmpdi,bp
je@@ 5
cmpax,[es:di]
jne@@ 2
cmpbx,[es:di + 2 ]
je@@ 5
cmpbx,[es:di + 6 ]
je@@ 5
@@ 2 :
cmpbx,[es:di + 2 ]
jne@@ 3
cmpax,[es:di + 4 ]
je@@ 5
@@ 3 :
adddi,cx
jmp short @@ 1
@@ 5 :
movax,di
ret
ENDP
;
;ax = jd,dx = r, return ax = sq,di = x,dx = y
;
PROCArcSum
movsxecx,dx
xordx,dx
movsi, 90
divsi
pushax
movdi,dx
subsi,dx
shldi, 1
shlsi, 1
movsxeax,[wordSin + di]
imulecx
addeax, 5000
movebx, 10000
divebx
movdi,ax
movsxeax,[wordSin + si]
imulecx
addeax, 5000
divebx
movdx,ax
popax
testax, 1
jnz@@ 1
xchgdx,di
@@ 1 :
ret
ENDP
;
; void Arc( int x, int y, int start, int end, int radius)
;
PROC_Arc
ARGx:word,y:word,start:word,end:word,radius:word
USESsi,di
movax,[end]
orax,ax
js@@ 2
movbx,[start]
orbx,bx
js@@ 2
cmpax,bx
jge@@ 3
xchgax,bx
@@ 3 :
pushbx
movdx,[radius]
callArcSum
mov[EndQ],ax
mov[EndX],di
mov[EndY],dx
popax
movdx,[radius]
callArcSum
mov[StartQ],ax
mov[StartX],di
mov[StartY],dx
push 0
push 12000
call_farmalloc
addsp, 4
cmpdx, 0
je@@ 2
moves,dx
pushdx
pushax
push[wordx]
push[wordy]
pop[wordCirY0]
pop[wordCirX0]
movsi,[radius]
movdi,si
pushbp
movbp,ax
pushax
callEllipse
movah, 2
callSetWrMode
popdi
movcx, 4
movsi,[StartQ]
testsi, 1
jnz@@ 4
@@ 1 :
negcx
xchgdi,bp
@@ 4 :
pushsi
pushdi
cmpsi,[StartQ]
jne@@ 5
movbx,[StartY]
movax,[StartX]
callArcjs
movdi,ax
moveax,[dwordes:di]
mov[dwordStartX],eax
@@ 5 :
cmpsi,[EndQ]
jne@@ 6
movbx,[EndY]
movax,[EndX]
callArcjs
movbp,ax
moveax,[dwordes:bp]
mov[dwordEndX],eax
or[wordEndQ],8000h
@@ 6 :
andsi, 3
callPlotCirPix
popdi
popsi
incsi
test[wordEndQ],8000h
jz@@ 1
popbp
call_farfree
addsp, 4
callRestReg
@@ 2 :
ret
ENDP
;
; void Slice( int x, int y, int start, int end, int radius)
;
PROC_Slice
ARGx:word,y:word,start:word,end:word,radius:word
push[wordradius]
push[wordend]
push[wordstart]
push[wordy]
push[wordx]
call_Arc
addsp, 10
push[wordStartY]
push[wordStartX]
movcx,[StartQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_PutPixel
push[wordCirY0]
push[wordCirX0]
call_Line
addsp, 8
movax,[CirX0]
movbx,[CirY0]
pushbx
pushax
call_PutPixel
push[wordEndY]
push[wordEndX]
movcx,[EndQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_Line
ret
ENDP
;
; void Pie( int x, int y, int start, int end, int radius)
;
PROC_Pie
ARGx:word,y:word,start:word,end:word,radius:word
push[wordradius]
push[wordend]
push[wordstart]
push[wordy]
push[wordx]
call_Arc
addsp, 10
push[wordStartY]
push[wordStartX]
movcx,[StartQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_PutPixel
push[wordEndY]
push[wordEndX]
movcx,[EndQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_Line
ret
ENDP
END
P386N
includegraph.inc
DATASEG
Sindw0000h,00afh,015dh,020bh,02bah,0368h,0415h,04c3h
dw0570h,061ch,06c8h,0774h,081fh,08cah,0973h,0a1ch
dw0ac4h,0b6ch,0c12h,0cb8h,0d5ch,0e00h,0ea2h,0f43h
dw0fe3h,1082h,1120h,11bch,1257h,12f0h,1388h,141eh
dw14b3h,1546h,15d8h,1668h,16f6h,1782h,180dh,1895h
dw191ch,19a1h,1a23h,1aa4h,1b23h,1b9fh,1c19h,1c92h
dw1d07h,1d7bh,1dech,1e5bh,1ec8h,1f32h,1f9ah,2000h
dw2062h,20c3h,2120h,217ch,21d4h,222ah,227dh,22ceh
dw231ch,2367h,23afh,23f5h,2438h,2478h,24b5h,24efh
dw2527h,255bh,258dh,25bbh,25e7h,2610h,2635h,2658h
dw2678h,2695h,26afh,26c5h,26d9h,26eah,26f8h,2702h
dw270ah,270eh,2710h
StartQdw 0
EndQdw 0
StartXdw 0
StartYdw 0
EndXdw 0
EndYdw 0
;
EXTRNCirX0:word
EXTRNCirY0:word
;
CODESEG
PUBLIC_Arc
PUBLIC_Slice
PUBLIC_Pie
EXTRNEllipse:proc
EXTRNPlotCirPix:proc
;
;
PROCSumArcXY
ARGx:word,y:word
movax,[CirX0]
movbx,[CirY0]
andcx, 3
jnz@@ 1
addax,[x]
subbx,[y]
jmp short @@ 4
@@ 1 :
cmpcx, 1
jne@@ 2
subax,[x]
subbx,[y]
jmp short @@ 4
@@ 2 :
addbx,[y]
cmpcx, 2
jne@@ 3
subax,[x]
jmp short @@ 4
@@ 3 :
addax,[x]
@@ 4 :
ret
ENDP
;
;
PROCArcjs
USESdi
@@ 1 :
cmpdi,bp
je@@ 5
cmpax,[es:di]
jne@@ 2
cmpbx,[es:di + 2 ]
je@@ 5
cmpbx,[es:di + 6 ]
je@@ 5
@@ 2 :
cmpbx,[es:di + 2 ]
jne@@ 3
cmpax,[es:di + 4 ]
je@@ 5
@@ 3 :
adddi,cx
jmp short @@ 1
@@ 5 :
movax,di
ret
ENDP
;
;ax = jd,dx = r, return ax = sq,di = x,dx = y
;
PROCArcSum
movsxecx,dx
xordx,dx
movsi, 90
divsi
pushax
movdi,dx
subsi,dx
shldi, 1
shlsi, 1
movsxeax,[wordSin + di]
imulecx
addeax, 5000
movebx, 10000
divebx
movdi,ax
movsxeax,[wordSin + si]
imulecx
addeax, 5000
divebx
movdx,ax
popax
testax, 1
jnz@@ 1
xchgdx,di
@@ 1 :
ret
ENDP
;
; void Arc( int x, int y, int start, int end, int radius)
;
PROC_Arc
ARGx:word,y:word,start:word,end:word,radius:word
USESsi,di
movax,[end]
orax,ax
js@@ 2
movbx,[start]
orbx,bx
js@@ 2
cmpax,bx
jge@@ 3
xchgax,bx
@@ 3 :
pushbx
movdx,[radius]
callArcSum
mov[EndQ],ax
mov[EndX],di
mov[EndY],dx
popax
movdx,[radius]
callArcSum
mov[StartQ],ax
mov[StartX],di
mov[StartY],dx
push 0
push 12000
call_farmalloc
addsp, 4
cmpdx, 0
je@@ 2
moves,dx
pushdx
pushax
push[wordx]
push[wordy]
pop[wordCirY0]
pop[wordCirX0]
movsi,[radius]
movdi,si
pushbp
movbp,ax
pushax
callEllipse
movah, 2
callSetWrMode
popdi
movcx, 4
movsi,[StartQ]
testsi, 1
jnz@@ 4
@@ 1 :
negcx
xchgdi,bp
@@ 4 :
pushsi
pushdi
cmpsi,[StartQ]
jne@@ 5
movbx,[StartY]
movax,[StartX]
callArcjs
movdi,ax
moveax,[dwordes:di]
mov[dwordStartX],eax
@@ 5 :
cmpsi,[EndQ]
jne@@ 6
movbx,[EndY]
movax,[EndX]
callArcjs
movbp,ax
moveax,[dwordes:bp]
mov[dwordEndX],eax
or[wordEndQ],8000h
@@ 6 :
andsi, 3
callPlotCirPix
popdi
popsi
incsi
test[wordEndQ],8000h
jz@@ 1
popbp
call_farfree
addsp, 4
callRestReg
@@ 2 :
ret
ENDP
;
; void Slice( int x, int y, int start, int end, int radius)
;
PROC_Slice
ARGx:word,y:word,start:word,end:word,radius:word
push[wordradius]
push[wordend]
push[wordstart]
push[wordy]
push[wordx]
call_Arc
addsp, 10
push[wordStartY]
push[wordStartX]
movcx,[StartQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_PutPixel
push[wordCirY0]
push[wordCirX0]
call_Line
addsp, 8
movax,[CirX0]
movbx,[CirY0]
pushbx
pushax
call_PutPixel
push[wordEndY]
push[wordEndX]
movcx,[EndQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_Line
ret
ENDP
;
; void Pie( int x, int y, int start, int end, int radius)
;
PROC_Pie
ARGx:word,y:word,start:word,end:word,radius:word
push[wordradius]
push[wordend]
push[wordstart]
push[wordy]
push[wordx]
call_Arc
addsp, 10
push[wordStartY]
push[wordStartX]
movcx,[StartQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_PutPixel
push[wordEndY]
push[wordEndX]
movcx,[EndQ]
callSumArcXY
addsp, 4
pushbx
pushax
call_Line
ret
ENDP
END
;GRELLIP.ASM
P386N
includegraph.inc
DATASEG
PUBLICCirX0,CirY0
Aspdd 0
Bspdd 0
TowAdd 0
TowBdd 0
CirX0dw 0
CirY0dw 0
;
CODESEG
PUBLIC_Circle
PUBLIC_Ellipse
PUBLICEllipse
PUBLICPlotCirPix
;
;si = a(xr),di = b(yr),bp = BufPtr
;
PROCEllipse
movsxeax,di
imuleax
mov[Bsp],eax;Bsp = b * b
shleax, 1
mov[TowB],eax;TowB = b * b * 2
movsxeax,si
imuleax
mov[Asp],eax;Asp = a * a
pusheax
shleax, 1
mov[TowA],eax;TowA = a * a * 2
movsxedx,di
imuledx
movebx,eax;Cirdy = TowA * b
popeax
movecx,eax
sarecx, 2
addecx,[Bsp]
movsxedx,di
imuledx
subecx,eax;Cird = Bsp - Asp * b + Asp / 4
xorsi,si;x = 0
xoredx,edx;Cirdx = 0
@@ 1 :
cmpedx,ebx; while (dx < dy)
jge@@ 5
mov[es:bp],si
mov[es:bp + 2 ],di
addbp, 4
cmpecx, 0 ; if (d > 0 )
jle@@ 4
subebx,[TowA];dy -= TowA
subecx,ebx;d -= dy
decdi;y --
@@ 4 :
incsi;x ++
addedx,[TowB];dx += TowB
addecx,[Bsp];d += Bsp + dx
addecx,edx
jmp short @@ 1
@@ 5 :
moveax,[Asp];d += ( 3 * (Asp - Bsp) / 2 - (dx + dy)) / 2
subeax,[Bsp]
pushebx
movebx,eax
sareax, 1
addeax,ebx
popebx
subeax,edx
subeax,ebx
sareax, 1
addecx,eax
@@ 6 :
ordi,di; if (y >= 0 )
js@@ 9
mov[es:bp],si
mov[es:bp + 2 ],di
addbp, 4
cmpecx, 0 ; if (d < 0 )
jge@@ 8
P386N
includegraph.inc
DATASEG
PUBLICCirX0,CirY0
Aspdd 0
Bspdd 0
TowAdd 0
TowBdd 0
CirX0dw 0
CirY0dw 0
;
CODESEG
PUBLIC_Circle
PUBLIC_Ellipse
PUBLICEllipse
PUBLICPlotCirPix
;
;si = a(xr),di = b(yr),bp = BufPtr
;
PROCEllipse
movsxeax,di
imuleax
mov[Bsp],eax;Bsp = b * b
shleax, 1
mov[TowB],eax;TowB = b * b * 2
movsxeax,si
imuleax
mov[Asp],eax;Asp = a * a
pusheax
shleax, 1
mov[TowA],eax;TowA = a * a * 2
movsxedx,di
imuledx
movebx,eax;Cirdy = TowA * b
popeax
movecx,eax
sarecx, 2
addecx,[Bsp]
movsxedx,di
imuledx
subecx,eax;Cird = Bsp - Asp * b + Asp / 4
xorsi,si;x = 0
xoredx,edx;Cirdx = 0
@@ 1 :
cmpedx,ebx; while (dx < dy)
jge@@ 5
mov[es:bp],si
mov[es:bp + 2 ],di
addbp, 4
cmpecx, 0 ; if (d > 0 )
jle@@ 4
subebx,[TowA];dy -= TowA
subecx,ebx;d -= dy
decdi;y --
@@ 4 :
incsi;x ++
addedx,[TowB];dx += TowB
addecx,[Bsp];d += Bsp + dx
addecx,edx
jmp short @@ 1
@@ 5 :
moveax,[Asp];d += ( 3 * (Asp - Bsp) / 2 - (dx + dy)) / 2
subeax,[Bsp]
pushebx
movebx,eax
sareax, 1
addeax,ebx
popebx
subeax,edx
subeax,ebx
sareax, 1
addecx,eax
@@ 6 :
ordi,di; if (y >= 0 )
js@@ 9
mov[es:bp],si
mov[es:bp + 2 ],di
addbp, 4
cmpecx, 0 ; if (d < 0 )
jge@@ 8