annotate 3rdparty/utils/view/view_setsave.a @ 1797:3084051a2863

Updated
author boisy
date Mon, 11 Apr 2005 15:42:16 +0000
parents b7fb6a9aead4
children 37fd74e6fad8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1706
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
1 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
2 * Save current picture to a file
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
3 * SetSave: - Expects Picture format code in A, X points to filename.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
4 * Opens save file, prompts for overwrite, sets up save variables.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
5
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
6 ifp1
1777
b7fb6a9aead4 Removed /dd/defs so that rma could assemble
boisy
parents: 1706
diff changeset
7 use os9defs.a
1706
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
8 endc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
9
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
10 check macro
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
11 pshs b,cc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
12 ldb #\1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
13 os9 F$PErr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
14 puls b,cc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
15 endm
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
16
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
17 StdIn equ 0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
18 StdOut equ 1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
19 StdErr equ 2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
20
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
21 psect view_setsave_a,0,0,0,0,0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
22
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
23 * vsect dp
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
24 *SaveFormat rmb 1 These are all declared in view_save.a
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
25 *SavePath rmb 1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
26 * endsect
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
27
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
28
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
29 SetSave:
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
30 pshs a,b,y,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
31 sta <SaveFormat Set picture format for save.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
32 clr <SavePath SavePath = 0 will flag no save.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
33
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
34 * Try to Create the file specified.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
35 lda #WRITE.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
36 ldb #READ.+WRITE.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
37 pshs x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
38 os9 I$Create Create the file for Write.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
39 puls x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
40 bcc SetSaveOK
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
41
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
42 * We got an error.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
43 cmpb #E$CEF File already exist?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
44 lbne _error
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
45
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
46 * The error was "file already exists", so ask if the user wants to overwrite.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
47 lda #StdErr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
48 pshs y,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
49 leax overwrite,pcr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
50 ldy #owlength
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
51 os9 I$Write Output the prompt.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
52 puls y,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
53 lbcs _error
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
54 lda #StdErr Read from StdErr, in case StdIn is busy....
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
55 pshs x,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
56 leax altbuff,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
57 ldy #2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
58 os9 I$ReadLn Read the response.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
59 puls x,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
60 lbcs _error
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
61 lda altbuff,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
62 cmpa #'y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
63 beq SetSave5
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
64 cmpa #'Y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
65 bne SetSaveEnd It wasn't "y" or "Y", so just quit.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
66 SetSave5
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
67 lda #WRITE.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
68 pshs x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
69 os9 I$Open Try to open in write mode.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
70 puls x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
71 lbcs _error
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
72
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
73 * Exit here after successfully opening the file.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
74 SetSaveOK
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
75 sta <SavePath
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
76
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
77 * Move X past the end of the filename.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
78 SetSaveEnd
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
79
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
80 SetSave11
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
81 lda ,x+ Skip any leading whitespace.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
82 cmpa #$20 Space?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
83 beq SetSave11
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
84 cmpa #$09 Tab?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
85 beq SetSave11
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
86 cmpa #$0d
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
87 beq SetSave14
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
88
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
89 SetSave12
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
90 lda ,x+ Now skip until we find whitespace.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
91 cmpa #$20
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
92 beq SetSave14
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
93 cmpa #$09
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
94 beq SetSave14
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
95 cmpa #$0d
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
96 beq SetSave14
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
97 bra SetSave12
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
98
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
99 SetSave14
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
100 leax -1,x Backup to last character.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
101
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
102 puls a,b,y,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
103
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
104 overwrite fcc "Save file already exists. Overwrite (y/n)? "
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
105 owlength equ *-overwrite
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
106
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
107
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
108 endsect