OSDN Git Service

最初のコミット
[winaudioj/stedx.git] / dos.cpp
1 /*
2   dos.c
3
4   functions for compatibility to doslib
5
6   ( mainly contains file-oriented functions )
7
8   Made by Studio Breeze. 1998, 2002
9
10
11   Permission is hereby granted, free of charge, to any person obtaining a copy
12   of this software and associated documentation files (the "Software"), to deal
13   in the Software without restriction, including without limitation the rights
14   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15   copies of the Software, and to permit persons to whom the Software is
16   furnished to do so, subject to the following conditions:
17
18   The above copyright notice and this permission notice shall be included in
19   all copies or substantial portions of the Software.
20
21   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
24   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27   THE SOFTWARE.
28  */
29
30 #include "sted.h"
31 #include "sted_screen.h"
32
33
34 /* variables */
35
36 //char fnc_func[10][32];
37 //char fnc_sfunc[10][32];
38 //char fnc_key[12][6];
39
40 /* ROLL UP, ROLL DOWN, INS, DEL,
41    UP, LEFT, RIGHT, DOWN,
42    CLR, HELP, HOME, UNDO */
43
44 /* console-oriented functions */
45
46 int
47 _dos_c_cls_al ( void )
48 {
49   _iocs_b_clr_al();
50   return 0;
51 }
52
53 int
54 _dos_c_cls_ed( void )
55 {
56   _iocs_b_clr_ed();
57   return 0;
58 }
59
60 int
61 _dos_c_curoff( void )
62 {
63   CSTedScreenBase* scr;
64
65   scr = GetDriver();
66   if (!scr) return 0;
67   scr->SetCursor(EButtonOff);
68   return 0;
69 }
70
71 int
72 _dos_c_curon( void )
73 {
74   CSTedScreenBase* scr;
75
76   scr = GetDriver();
77   if (!scr) return 0;
78   scr->SetCursor(EButtonOn);
79   return 0;
80 }
81
82 int
83 _dos_c_fnkmod( int in_mode )
84 {
85   /* not implemented */
86   return 0;
87 }
88
89 int
90 _dos_c_window( int in_x, int in_y )
91 {
92   CSTedScreenBase* scr;
93
94   scr = GetDriver();
95   if (!scr) return 0;
96   scr->SetTextWindow(in_x, in_y);
97   scr->Locate(0, 0);
98   return 0;
99 }
100
101 int
102 _dos_fnckeygt( int in_fno, char *in_buff )
103 {
104   /* not implemented */
105   return 0;
106 }
107
108 int
109 _dos_fnckeyst( int fno, const char *buff )
110 {
111   int i,j;
112   const char *p;
113
114   CSTedScreenBase* scr;
115
116   scr = GetDriver();
117   if (!scr) return 0;
118
119   p=buff;
120
121   if (fno==0) {
122     for ( i=0 ; i<10 ; i++ ) {
123       for ( j=0 ; j<32 ; j++ ) {
124         fnc_func[i][j]=*p++;
125       }
126     }
127     for ( i=0 ; i<10 ; i++ ) {
128       for ( j=0 ; j<32 ; j++ ) {
129         fnc_sfunc[i][j]=*p++;
130       }
131     }
132     for ( i=0 ; i<12 ; i++ ) {
133       for ( j=0 ; j<6 ; j++ ) {
134         fnc_key[i][j]=*p++;
135       }
136     }
137   } else if ( fno<=10 ) {
138     for ( j=0 ; j<32 ; j++ ) {
139       fnc_func[fno-1][j]=*p++;
140     }
141   } else if ( fno<=20 ) {
142     for ( j=0 ; j<32 ; j++ ) {
143       fnc_sfunc[fno-11][j]=*p++;
144     }
145   } else if ( fno<=32 ) {
146     for ( j=0 ; j<6 ; j++ ) {
147       fnc_key[fno-21][j]=*p++;
148     }
149   }
150
151   scr->SetFncKey(fnc_key);
152   return 0;
153 }
154
155 int
156 _dos_inpout( int in_code )
157 {
158   CSTedScreenBase* scr;
159
160   scr = GetDriver();
161   if (!scr) return 0;
162
163   if ( (in_code==0xfe) || (in_code==0xff) ) {
164     return scr->KeyIn(in_code);
165   }
166 }
167
168 /* functions */
169
170 void *
171 _dos_malloc(int in_size)
172 {
173   void *tmp;
174
175   tmp = (void *)malloc(in_size);
176   if ( tmp == NULL ) tmp = (void *)0x82000000;
177
178   return tmp;
179   
180 }
181
182
183 /* file related */
184
185 dosmode_t
186 _dos_chmod( const char *in_name, dosmode_t in_atr )
187 {
188   /* returns only one flag : is the file "name" directory? */
189
190   CSTedScreenBase* scr;
191
192   scr = GetDriver();
193   if (!scr) return 0;
194
195   return scr->FileChmod(in_name, in_atr);
196 }
197
198 int
199 _dos_chdir( const char *in_name )
200 {
201   CSTedScreenBase* scr;
202
203   scr = GetDriver();
204   if (!scr) return 0;
205
206   return scr->FileChdir(in_name);
207 }
208
209 int
210 _dos_curdir( int in_drive, char *out_buff )
211 {
212   CSTedScreenBase* scr;
213
214   scr = GetDriver();
215   if (!scr) return 0;
216
217   return scr->FileCurdir(in_drive, out_buff);
218 }
219
220 int
221 _dos_curdrv( void )
222 {
223   CSTedScreenBase* scr;
224
225   scr = GetDriver();
226   if (!scr) return 0;
227
228   return scr->FileCurdrv();
229 }
230
231 int
232 _dos_delete( const char *in_name )
233 {
234   CSTedScreenBase* scr;
235
236   scr = GetDriver();
237   if (!scr) return 0;
238
239   return scr->FileDelete(in_name);
240 }
241
242 int _dos_drvctrl( int mode, int drive ) {
243
244   return 2; /* media inserted, ready, not protected, enable eject by user,
245                no buffer, enable eject, not blink LED */
246 }
247
248 int
249 _dos_rename( const char *in_name, const char *in_nname )
250 {
251   CSTedScreenBase* scr;
252
253   scr = GetDriver();
254   if (!scr) return 0;
255
256   return scr->FileRename(in_name, in_nname);
257 }
258
259 int _dos_super( int stack ) {
260
261   return 1; /* ignore */
262 }
263
264 int
265 _dos_files (struct _x68_filbuf *in_buff, const char *in_name, int in_atr )
266 {
267   CSTedScreenBase* scr;
268
269   scr = GetDriver();
270   if (!scr) return 0;
271
272   return scr->FileFiles(in_buff, in_name, in_atr);
273 }
274
275 int
276 _dos_nfiles( struct _x68_filbuf *in_buff )
277 {
278   CSTedScreenBase* scr;
279
280   scr = GetDriver();
281   if (!scr) return 0;
282
283   return scr->FileNfiles(in_buff);
284 }
285
286 int _dos_setblock( void *memptr, int newsize ) {
287
288   /* not implemented */
289   return -1;  
290 }
291
292 int dskf( char drive_number ) {
293
294   /* max 8 keta */
295   return 58371500;
296 }
297
298 FILE
299 *fopen2( char *in_name, char *in_mode)
300 {
301   CSTedScreenBase* scr;
302
303   scr = GetDriver();
304   if (!scr) return NULL;
305
306   return scr->FileFopen(in_name, in_mode);
307 }