OSDN Git Service

最初のコミット
[winaudioj/stedx.git] / basic.cpp
1 /* basic.c
2
3    some of X-BASIC compatible functions
4
5    Made by Studio Breeze. 1998, 2002
6
7
8   Permission is hereby granted, free of charge, to any person obtaining a copy
9   of this software and associated documentation files (the "Software"), to deal
10   in the Software without restriction, including without limitation the rights
11   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12   copies of the Software, and to permit persons to whom the Software is
13   furnished to do so, subject to the following conditions:
14
15   The above copyright notice and this permission notice shall be included in
16   all copies or substantial portions of the Software.
17
18   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
21   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24   THE SOFTWARE.
25 */
26 #include "sted.h"
27 #include "sted_screen.h"
28
29 /* graphic functions */
30
31 void
32 fill( int in_x0, int in_y0, int in_x1, int in_y1, unsigned int in_col )
33 {
34   CSTedScreenBase* scr;
35
36   scr = GetDriver();
37   if (!scr) return;
38
39   scr->GraphicsFill(in_x0, in_y0, in_x1, in_y1, in_col);
40   return;
41 }
42
43 void
44 box( int in_x0, int in_y0, int in_x1, int in_y1, unsigned int in_col, unsigned int in_ls )
45 {
46   CSTedScreenBase* scr;
47
48   scr = GetDriver();
49   if (!scr) return;
50
51   scr->GraphicsBox(in_x0, in_y0, in_x1, in_y1, in_col, in_ls);
52   return;
53 }
54
55 int
56 point( int in_x, int in_y )
57 {
58   CSTedScreenBase* scr;
59
60   scr = GetDriver();
61   if (!scr) return 0;
62
63   return scr->GraphicsPoint(in_x, in_y);
64 }
65
66 void
67 line( int in_x0, int in_y0, int in_x1, int in_y1, int in_col, int in_ls )
68 {
69   CSTedScreenBase* scr;
70
71   scr = GetDriver();
72   if (!scr) return;
73
74   scr->GraphicsLine(in_x0, in_y0, in_x1, in_y1, in_col, in_ls);
75   return;
76 }
77
78 void
79 symbol( int in_x, int in_y, char *in_st, char in_h, char in_v, char in_mo, int in_p, char in_an )
80 {
81   CSTedScreenBase* scr;
82
83   scr = GetDriver();
84   if (!scr) return;
85
86   scr->SetGraphicsColor(in_p);
87   scr->GraphicsPuts(in_x, in_y, in_st);
88   return;
89 }
90
91
92 /* other functions */
93
94 /* returns string describing current day(?) */
95 char *dtasc( unsigned int j ) {
96
97   static char dtasc_name[10];
98   int y,a,b;
99
100   a=(j>>9)&0x7f;
101   b=a%10;
102   a=a%100-b;
103   y=a+b;
104   
105   snprintf(dtasc_name, 10, "%02d-%02d-%02d", y, ((j>>5)&0x0f)+1, j&0x1f );
106
107   return dtasc_name;
108 }
109
110 /* returns string describing current time(?) */
111 char *tmasc( unsigned int j ) {
112
113   static char tmasc_name[10];
114
115   snprintf(tmasc_name, 10, "%02d:%02d:%02d", (j>>11)&0x1f, (j>>5)&0x3f, (j&0x1f)*2 );
116   return tmasc_name;
117 }
118
119 /* returns mouse positions */
120 int 
121 mspos( int *out_x, int *out_y )
122 {
123   CSTedScreenBase* scr;
124
125   scr = GetDriver();
126   if (!scr) return 0;
127   return scr->GetMousePos(out_x, out_y);
128 }
129
130 /* returns someting B-) */
131 void b_striS ( char * buf, int bufSize, int num ) {
132   int r;
133
134   r=snprintf( buf, bufSize, "%d", num );
135   if ( r < 0 ) {
136     buf[0]='\0';
137   }
138   return;
139 }
140
141 /* set current Kanji mode */
142 void KNJCTRL( int i, int j ) {
143
144   /* not implemented */
145   return;
146 }
147