mirror of
https://github.com/codebur/a2-chemi-gs-1993.git
synced 2025-04-22 22:37:45 +00:00
1 line
11 KiB
NASM
1 line
11 KiB
NASM
|
keep FILE
****************************************************************
* ChemiGS *
****************************************************************
* A Drawing Program for Chemical Structures *
* (c) 1992-93 by Urs Hochstrasser *
* Buendtenweg 6 *
* 5105 AUENSTEIN (SWITZERLAND) *
****************************************************************
* Module FILE
****************************************************************
*
* USES ...
*
mcopy File.macros
copy equates.asm
****************************************************************
*
* File Stuff
*
OpenDlog start
using Globals
using Parms
~SFGetFile2 #120,#40,#RefIsPointer,#prompt,#0,#typeList,#gReplyRec
lda gReplyRec
rts
prompt dw 'Open Chemix File:'
typeList dc i2'1' numEntries
dc i2'$8000' flags cf.p. 48-10 TB III
dc i2'$00F4' fileType
dc i4'$00005548' auxType; ='UH'
end
DoOpen start
using Globals
using Parms
jsr OpenDlog
bne l1 user cancelled the open dlog
brl exit
l1 anop
lda gRRpath
ldx gRRPath+2
jsr Deref
sta Opath
stx Opath+2
~HUnlock gRRpath
inc4 Opath convert Cl1output to Cl1InputString
inc4 Opath
Open2 entry
inc fFullAccess assume full R/W access allowed
lda #3 try R/W access
sta OreqAcc
OpenGS OpenParm
bcc opened no Error --> OK
sta gToolErr
stz fFullAccess sorry, no full R/W access...
cmp #invalidAccess (R/O)
bne exit2
jsr alertRO inform user of read only access
beq exit User cancelled OPEN
lda #1 try read only
sta OreqAcc
OpenGS OpenParm
sta gToolErr
bcs exit2
opened anop
~WaitCursor
lda OpenParm+2
sta CloseParm+2
sta ReadParm+2
sta RSegRec+2
jsr DoNew2
jsr OpenWindow
inc gDataWNum
jsr NewData
lda OpenParm+2 ... *
sta gRefNum besser hier... *
jsr ReadFile
bcs exit4 close window if READ fails
lda fFirstFile
bne l2
jsr NewTitle
l2 stz fFirstFile
inc fSaved
inc fNamed
lda fFullAccess
beq exit3
brl exit
exit4 jsr DoClose
bra exit2
exit3 CloseGS CloseParm close if R/O
exit2 jsr Error
exit ~InitCursor
rts
alertRO anop inform user that file is read only
pha
~AlertWindow #4,#0,#kAlertRO refIsResource,no SubstStrings,ResID
pla
rts
NewTitle entry
inc fNamed set 'named' flag
move4 gRRname,gTitleH
lda gTitleH
ldx gTitleH+2
jsr Deref
sta 0
stx 2
ldy #2 Convert Cl2 Output to...
lda [0],y
xba
sta [0],y
move4 0,gTitlePtr
inc4 gTitlePtr
inc4 gTitlePtr
inc4 gTitlePtr ...Pascal string
~SetWTitle gTitlePtr,gDataWin
rts
end
ReadFile start
using Globals
using Parms
move4 #FileHeader,RdBuf
ReadGS ReadParm
sta gToolErr
bcs rdExit
jsr ReadData
rdExit rts check for errors in calling pgm only
ReadData anop
ph4 #0
~NewHandle #segSize,gMyID,#0,#0
pl4 gNewLink
ReadGS RSegRec
sta gToolErr
bcs exit
lda sLink
ora sLink+2
beq exit
move4 gNewLink,sLink
~PtrToHand #TheSegment,gLink,#segSize *
move4 gNewLink,gLink
bra ReadData
exit brl exit3
lda fCacheWins
bne drawOff
brl exit3
******************* NEW: DRAW INTO OFFSCREEN PORT ***********************
drawOff ~PtrToHand #TheSegment,gLink,#4 ****
ph4 #0
~GetPort
pl4 thePort
ph4 #0
~GetWRefCon gDataWin
pl4 theHandle
~HandToPtr theHandle,#theData,#40
~SetPort offPort
loop ~HandToPtr theData,#TheSegment,#segSize
~SetPenSize sPenSize+2,sPenSize
lda sCMD
bne l7
brl exit2
l7 cmp #6
bcs l1
asl a
tax
jsr (toolTable,x)
brl l4
l1 cmp #11
bcs l2
bra exit2
l2 cmp #17
bcc l3
bra exit2
l3 sec
sbc #11
asl a
tax
jsr (toolTable2,x)
l4 move4 sLink,theData
lda theData
ora theData+2
beq exit2
brl loop
exit2 anop
~SetPort thePort
exit3 rts
theData ds 4 Handle to linked segment list
theText ds 4 Handle to linked AtomText list
theObj ds 4 Handle to linked object list
ds 4 handle to hor. scroll bar (ID 5)
ds 4 handle to vert. scroll bar (ID 6)
ds 4 handle to display size control (ID 8)
ds 4 handle to size box control (ID 9)
dc i2'18,0,156,531' Window's Content Rect (own terminology)
offPort ds 4
theWindow ds 4
thePort ds 4
theHandle ds 4
end
DoNew start
using Globals
ph4 #0 cr
|