a2-chemi-gs-1993/draw.asm

1 line
6.5 KiB
NASM

keep DRAW
****************************************************************
* ChemiGS *
****************************************************************
* A Drawing Program for Chemical Structures *
* (c) 1992-93 by Urs Hochstrasser *
* Buendtenweg 6 *
* 5105 AUENSTEIN (SWITZERLAND) *
****************************************************************
* Module DRAW
****************************************************************
*
* USES ...
*
mcopy draw.macros
copy equates.asm
DisplayData start
using Globals
~StartDrawing gDataWin
jsr displayIt
~SetOrigin #0,#0
rts
displayIt entry
ph4 #0
~GetPort
pl4 theWindow
~GetPortRect #dPortRect
ph4 #0
~GetWRefCon theWindow
pl4 theHandle
~HandToPtr theHandle,#theData,#miniFInfo
************************ CONTROL POSITIONING STUFF *********************
lda dPortRect+6 Stuff to position the ctls...
sec
sbc dPortRect+2
sta winW
lda dPortRect+4
sec
sbc dPortRect
sta winH
sec winH still in A-reg
lda winH
sbc #12 heigth of size box -1
sta myY
sta gViewH
lda winW
sec
sbc #24 width of size box -2
sta myX
sta gViewW
~MoveControl myX,myY,sizeBox
~MoveControl #0,myY,Mountn
lda myX
sta vsRect+2 ctlRect.left
lda myY
inc a
sta vsRect+4
lda winW
inc a
inc a
sta vsRect+6
~DisposeControl vScroll
ph4 #0
~NewControl2 theWindow,#0,#vScrollBar
pl4 vScroll
~SetCtlParams docH,myY,vScroll
lda myY
sta hsRect
lda winH
inc a
sta hsRect+4
lda myX
inc a
inc a
sta hsRect+6
~DisposeControl hScroll
ph4 #0
~NewControl2 theWindow,#0,#hScrollBar
pl4 hScroll
~SetCtlParams docW,myX,hScroll
lda myY
dec a
sta contRect+4
lda myX
sta contRect+6
cmp4 theWindow,gDataWin
bne pass
move4 contRect+4,gContentRect+4
pass anop
lda theWindow
ldx theWindow+2
jsr GrowClip
***************************** ToolBar redraw
lda fTextFlag
beq noText
~HideControl TBarH
ph4 #0
~LoadResource #kPicResID,#kToolPicID
pl4 toolBar
~DrawPicture toolBar,#destRect
brl isText
noText ~ShowControl TBarH
isText anop
****************************END ToolBar Stuff
~DrawControls theWindow
~PenNormal
~MoveTo #0,#17 draw ruler's border line
~LineTo #640,#17
lda theWindow
ldx theWindow+2
jsr ShrinkClip
lda fcacheWins
beq noOff
************************ IF YOU GET HERE, WIN CACHING IS ON ************
~PPToPort pixImage,#srcRect,#0,#18,modeCopy
brl exit
************************ CONTENT DRAW STUFF ****************************
* new stuff here:
noOff ph4 #0
~GetVisHandle
pl4 visHandle
loop ~HandToPtr theData,#TheSegment,#segSize
* new stuff continued tests if part of rect built
sub2 yy,yOffset *** even more recent!
sub2 yy2,yOffset *** Doc -> Window
sub2 xx,xOffset ***
sub2 xx2,xOffset ***
move4 yy,myRect with the two endpoints has
move4 yy2,myRect+4 any points in common with
lda yy the visrgn.
cmp yy2 Result: Same problem as
bcc yOK testing the individual points
sta myRect+4 last chance to speed things up:
lda yy2 test against the hit region of
sta myRect the line segment!!!!
yOK lda xx (pretty cool, eh?)
cmp xx2
bcc xOK here's how:
sta myRect+6 SectRgn rg1Hndl,rg2Hndl,destRHndl
lda xx2 bool:=EmptyRgn rgnHndl
sta myRect+2
xOK inc myRect+4 Problem with RectInVisRgn: h+v
inc myRect+6 Problem with PtInPortRect: v
stz fSkip ***
pha
~RectInRgn #myRect,visHandle
pla
bne doit
* brl l4 skip this line segment
inc fSkip **
* end new stuff
************************ ACTUAL CONTENT DRAW ROUTINE *******************
doit ~SetPenSize sPenSize+2,sPenSize
lda sCMD
bne l7
brl exit
l7 cmp #6
bcs l1
asl a
tax
lda fSkip ***
bne l4 ***
jsr (toolTable,x)
brl l4
l1 cmp #11
bcs l2
bra exit
l2 cmp #17
bcc l3
bra exit
l3 sec
sbc #11
asl a
tax
lda fSkip ***
bne l4 ***
jsr (toolTable2,x)
l4 move4 sLink,theData
lda theData
ora theData+2
beq exit
brl loop
exit anop
lda theWindow *** TEST...
ldx theWindow+2
jsr GrowClip *** TEST ...
lda
rts
************************** MINI FILE INFO: 52 BYTES ***************************
theData ds 4 Handle to linked segment list
theText ds 4 Handle to linked AtomText list
theObj ds 4 Handle to linked object list
hScroll ds 4 handle to hor. scroll bar (ID 5)
vScroll ds 4 handle to vert. scroll bar (ID 6)
Mountn ds 4 handle to display size control (ID 8)
SizeBox ds 4 handle to size box control (ID 9)
contRect entry
dc i2'18,0,156,531' Window's Content Rect (own terminology)
pixImage ds 4
xOffset ds 2 x offset into document
yOffset ds 2 y " " "
docW ds 2
docH ds 2
*******************************************************************************
srcRect dc i2'0,0,200,640' muss noch automatisiert werden
* evt sogar into mini file info!!!
theWindow ds 4
theHandle ds 4
visHandle ds 4
myRect ds 8
dPortRect entry
ds 8
fSkip dc i2'0' *
toolBar ds 4
*btnRect entry
destRect dc i2'0,0,17,640'
myX entry
ds 2 \ most recent -18,0,-1,550
myY entry
ds 2
winH entry
ds 2
winW entry
ds 2
myPtr ds 4
fWindow ds 4
vScrollBar anop
dc i2'10' pCount
dc i4'6' ID
vsRect dc i2'17,532,158,558' rect
dc i4'$86000000' ScrollBar defProc
dc i2'3' flag
dc i2'$1002' moreFlags
dc i4'0' refCon
dc i2'0' maxSize
dc i2'50' viewSize
dc i2'0' initialValue
dc i4'0' colorTableRef
hScrollBar anop
dc i2'10' pCount
dc i4'5' ID
hsRect dc i2'157,104,170,534' rect
dc i4'$86000000' ScrollBar defProc
dc i2'$1C' flag
dc i2'$1002' moreFlags
dc i4'0' refCon
dc i2'0' maxSize
dc i2'50' viewSize
dc i2'0' initialValue
dc i4'0' colorTableRef
end
************************ CLIP REGION MANIPULATING SUBROUTINES ************
shrinkClip start
using Globals
sta parmWin parameter: AX=windowPtr
stx parmWin+2
ph4 #0
~GetPort
pl4 theWindow
~SetPort parmWin
~GetPortRect #portRect
lda portRect+6 Stuff to position the ctls...
sec
sbc portRect+2
sta winW
lda portRect+4
sec
sbc portRect
sta winH
sec winH still in A-reg
lda winH
sbc #11 heigth of size box -1
sta myY
lda winW
sec
sbc #24 width of size box -2
sta myX
lda myY
dec a
sta contRect+4
lda myX
sta contRect+6
ph4 #0
~NewRgn
pl4 theRgn
~rectRgn theRgn,#contRect
~SetClip theRgn
~SetPort theWindow
rts
theWindow ds 4
parmWin ds 4
portRect ds 8
theRgn ds 4
contRect anop
topLeft dc i2'18,0'
myY ds 2
myX ds 2
winH ds 2
winW ds 2
end
GrowClip start
using Globals
sta parmWin parameter: AX=windowPtr
stx parmWin+2
ph4 #0
~GetPort
pl4 theWindow
~SetPort parmWin
~GetPortRect #portRect
ph4 #0
~NewRgn
pl4 theRgn
~rectRgn theRgn,#portRect
~SetClip theRgn
~SetPort theWindow
rts
theWindow ds 4
parmWin ds 4
theRgn ds 4
portRect ds 8
end