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