Adding game history
[beyond-the-titanic.git] / src / SPECIAL.PAS
1 {//-------------------------------------------------------------------------}\r
2 {/*                                                                         }\r
3 {Copyright (C) 2014 Jason Self <j@jxself.org>                               }\r
4 {                                                                           }\r
5 {This file is free software: you may copy, redistribute and/or modify it    }\r
6 {under the terms of the GNU Affero General Public License as published by   }\r
7 {the Free Software Foundation, either version 3 of the License, or (at your }\r
8 {option) any later version.                                                 }\r
9 {                                                                           }\r
10 {This file is distributed in the hope that it will be useful, but WITHOUT   }\r
11 {ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      }\r
12 {FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License}\r
13 {for more details.                                                          }\r
14 {                                                                           }\r
15 {You should have received a copy of the GNU Affero General Public License   }\r
16 {along with this program; if not, see https://gnu.org/licenses or write to: }\r
17 {  Free Software Foundation, Inc.                                           }\r
18 {  51 Franklin Street, Fifth Floor                                          }\r
19 {  Boston, MA 02110-1301                                                    }\r
20 {  USA                                                                      }\r
21 {                                                                           }\r
22 {This file incorporates work covered by the following copyright and         }\r
23 {permission notice:                                                         }\r
24 {                                                                           }\r
25 {Copyright (C) 1990, 2009 - Apogee Software, Ltd.                           }\r
26 {                                                                           }\r
27 {This file is part of Beyond The Titanic. Beyond The Titanic is free        }\r
28 {software; you can redistribute it and/or modify it under the terms of the  }\r
29 {GNU General Public License as published by the Free Software Foundation;   }\r
30 {either version 3 of the License, or (at your option) any later version.    }\r
31 {                                                                           }\r
32 {This program is distributed in the hope that it will be useful, but WITHOUT}\r
33 {ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      }\r
34 {FITNESS FOR A PARTICULAR PURPOSE.                                          }\r
35 {                                                                           }\r
36 {See the GNU General Public License for more details.                       }\r
37 {                                                                           }\r
38 {You should have received a copy of the GNU General Public License          }\r
39 {along with this program; if not, write to:                                 }\r
40 {  Free Software Foundation, Inc.                                           }\r
41 {  51 Franklin Street, Fifth Floor                                          }\r
42 {  Boston, MA 02110-1301                                                    }\r
43 {  USA                                                                      }\r
44 {                                                                           }\r
45 {Original Source: 1990 Scott Miller                                         }\r
46 {Prepared for public release: 03/19/09 - Joe Siegler, Apogee Software, Ltd. }\r
47 {*/                                                                         }\r
48 {//-------------------------------------------------------------------------}\r
49 program\r
50   Special_Responce_Writer;\r
51 \r
52          {This program WRITES and READS from the two text files:\r
53     'special1' and 'special2'.  If a description exceeds 240 letters (Max),\r
54        then the file 'special2' is used.  Otherwise 'special2' = ''.}\r
55                {This program has the line edit feature!}\r
56 \r
57 uses Crt, Printer;\r
58 \r
59 const\r
60   Max = 240;\r
61 \r
62 type\r
63   DescriptionLength = string[Max];\r
64   OneChar = string[1];\r
65 \r
66 var\r
67   Special1, Special2 : file of descriptionlength;\r
68   Position,Counter,Start,Stop : integer;\r
69   Text1, Text2 : descriptionlength;\r
70   Answer : char;\r
71   Letter : onechar;\r
72   List   : boolean;\r
73 \r
74 procedure Diskwrite(text1,text2: Descriptionlength; pointer: integer);\r
75   begin\r
76     seek(special1,pointer); seek(special2,pointer);\r
77     WRITE(special1,text1); WRITE(special2,text2);\r
78     writeln('Special responce ',pointer,\r
79             ' is written!  Size = ',filesize(special1));\r
80     close(special1); close(special2);\r
81   end; {End of Diskwrite.}\r
82 \r
83 procedure Diskread(start,stop: integer);\r
84 var\r
85 counter : integer;\r
86 text1, text2 : descriptionlength;\r
87   begin\r
88    assign(special1,'special1'); assign(special2,'special2');\r
89    reset(special1); reset(special2);\r
90    seek(special1,start); seek(special2,start);\r
91     for counter:= start to stop do\r
92       begin\r
93         highvideo;\r
94         READ(special1,text1); READ(special2,text2);\r
95         if list then\r
96           begin\r
97             writeln(lst,'Special # ',counter);\r
98             writeln(lst,text1,text2);\r
99           end\r
100         else\r
101           begin\r
102             writeln('Here is special responce # ',counter);\r
103             lowvideo;\r
104             writeln(text1,text2);\r
105             highvideo;\r
106           end;\r
107       end;\r
108 \r
109     write('The file contains ',filesize(special1),' special responces.');\r
110     close(special1); close(special2);\r
111   end;  {End of Diskread.}\r
112 \r
113 procedure Beep;\r
114 begin\r
115  if(length(text1)in[70,150,230])or(length(text2)in[70,150,230])then write(^g);\r
116 end;\r
117 \r
118 BEGIN\r
119 repeat          {Main loop.}\r
120   text1:='';\r
121   text2:='';\r
122 \r
123 writeln;\r
124 writeln('Do you want to R)ead or W)rite?');\r
125 readln(answer);\r
126 if upcase(answer) <> 'R' then       {Write to 'Special' files.}\r
127     begin\r
128       writeln;writeln;\r
129       assign(special1,'special1'); assign(special2,'special2');\r
130       writeln('Now RESETing Special files.');\r
131             RESET(special1); RESET(special2);\r
132       writeln;\r
133       writeln('Input a string not more than ',2*Max,' characters.',\r
134               '  ''\''-Ends string.');\r
135       lowvideo;\r
136         repeat\r
137           letter := ReadKey;\r
138           write(letter);\r
139           if letter = ^h then\r
140             begin\r
141               write(' ',^h);\r
142               delete(text1,length(text1),1);\r
143             end;\r
144           beep;\r
145           if (letter <> '\') and (letter <> ^h) then text1:=text1+letter\r
146         until (length(text1)=Max) or (letter='\');\r
147         writeln;\r
148         if letter = '\' then\r
149           begin\r
150             highvideo;\r
151             writeln('Total of ',length(text1),' characters.');\r
152             text2:='';\r
153           end\r
154         else\r
155           begin\r
156             writeln;\r
157             highvideo;\r
158             writeln('String #1 is full!  Now writing to string #2.',^g);\r
159             lowvideo;\r
160               repeat\r
161                 letter := ReadKey;\r
162                 write(letter);\r
163                 if letter = ^h then\r
164                   begin\r
165                     write(' ',^h);\r
166                     delete(text2,length(text2),1);\r
167                   end;\r
168                 beep;\r
169                 if (letter <> '\') and (letter <> ^h) then text2:=text2+letter\r
170               until (length(text2)=Max) or (letter='\');\r
171             writeln; highvideo;\r
172             writeln('Total description length = ',\r
173                      length(text1)+length(text2),' characters.');\r
174           end;\r
175       writeln('Now WRITING string to disk.');\r
176       writeln('  At what position?  (Next open is # ',filesize(special1),')');\r
177       readln(position);\r
178       Diskwrite(text1,text2,position);\r
179     end\r
180 else                      {Read from 'Rooms'.}\r
181   begin\r
182     writeln;writeln;\r
183     writeln('To the S)creen or the P)rinter?');\r
184     readln(answer);\r
185     if(upcase(answer)='P')then List:=True else List:=False;\r
186     assign(special1,'special1');\r
187     reset(special1);\r
188     writeln('Filesize = ',filesize(special1),\r
189             '  (From 0 to ',filesize(special1)-1,')');\r
190 \r
191     writeln('Enter starting position:');\r
192     readln(start);\r
193     if(start > filesize(special1)-5)then stop:=(filesize(special1)-1) else\r
194       begin\r
195         writeln('Enter final position:');\r
196         readln(stop);\r
197       end;\r
198     Diskread(start,stop);\r
199 \r
200   end;  {End of else clause.}\r
201 writeln;writeln('Another special responce?  Y)es or N)o');\r
202 readln(answer);\r
203 until upcase(answer) = 'N';     {End of Main loop.}\r
204 writeln; writeln(^g,'You are now out of the program.')\r
205 END.\r