-
Notifications
You must be signed in to change notification settings - Fork 2
/
keyWindowsOnly.h
343 lines (240 loc) · 8.82 KB
/
keyWindowsOnly.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
// Bahasa Anak Indonesia untuk Komputer - BAIK
// Copyright Haris Hasanudin - 2005 - 2011
//
// Kupersembahkan untuk istriku tercinta Masako, anakku tersayang Takumi
// dan Tomoki serta seluruh putra putri Indonesia
#include <pthread.h>
typedef struct {
char myfile[256];
int num;
} TH_BOX;
#ifdef WINDOWS
#include "hariswav.h"
#else
#ifdef USE_MIKMOD
#include <unistd.h>
#include <mikmod.h>
#include "mikmod_playwav.h"
#elif USE_ALSA
#include "alsa_play_sound.h"
#else
#include "ux_hariswav.h"
#endif
#endif
void keyMusikBGM ()
{
char tmpMsg[MAX_STRING_LEN * 2];
VAL_LABEL valdat;
pthread_t pt;
TH_BOX * arg_bgm=NULL;
char get_name[MAX_STRING_LEN];
// var list for class params
struct node_list tmpnode;
char class_tmpvar[MAX_STRING_LEN];
memset(&valdat, '\0', sizeof(valdat));
memset(&get_name, '\0', sizeof(get_name));
memset(&tmpMsg, '\0', sizeof(tmpMsg));
memset(&tmpnode, '\0', sizeof(tmpnode));
memset(&class_tmpvar, '\0', sizeof(class_tmpvar));
memset(tmpMsg, '\0', sizeof(tmpMsg));
arg_bgm = malloc(sizeof(TH_BOX));
getlex();
switch( lex.type )
{
case TYPE_STR:
strcpy(arg_bgm->myfile, lex.detail.string);
arg_bgm->num = 1;
#ifdef WINDOWS
pthread_create( &pt, NULL, &play_BGM, arg_bgm);
#else
#ifdef USE_MIKMOD
pthread_create( &pt, NULL, &mikmod_play_BGM, arg_bgm);
#elif USE_ALSA
pthread_create( &pt, NULL, &alsa_play_BGM, arg_bgm);
#else
// printf ("before: %s\n", arg_bgm->myfile);
pthread_create( &pt, NULL, &ux_play_BGM, arg_bgm);
#endif
#endif
break;
case TYPE_OBJECT:
checkObjectValidation(lex.detail.object_str);
case TYPE_IDENT:
case TYPE_NUM:
//printf("curr class : %s\n", currentClass);
//printf("datatype : %d\n", valdat.datatype);
//printf("\nval : %d\n", valdat.val);
//printf("str : %s\n", valdat.str);
if(currentClass != NULL && strlen(currentClass) > 0) {
sprintf(class_tmpvar, "%s->%s", currentClass, lex.detail.string);
//printf("construct class var: %s\n", class_tmpvar);
valdat = ValLabel( class_tmpvar, class_sub_deep, valdat, VAL_FLAG_SEARCH_R );
} else {
valdat = ValLabel(lex.detail.string, sub_deep, valdat, VAL_FLAG_SEARCH_R );
}
if(valdat.str != '\0' && strlen(valdat.str) > 0) {
strcpy(arg_bgm->myfile, valdat.str);
arg_bgm->num = 1;
#ifdef WINDOWS
pthread_create( &pt, NULL, &play_BGM, arg_bgm);
#else
#ifdef USE_MIKMOD
pthread_create( &pt, NULL, &mikmod_play_BGM, arg_bgm);
#elif USE_ALSA
pthread_create( &pt, NULL, &alsa_play_BGM, arg_bgm);
#else
pthread_create( &pt, NULL, &ux_play_BGM, arg_bgm);
#endif
#endif
}
break;
default:
Error("kode perintah MUSIK salah");
}
getlex();
ungetlex();
}
/////////////////////////////////////////////////////////
void keyMusik ()
{
char tmpMsg[MAX_STRING_LEN * 2];
VAL_LABEL valdat;
char get_name[MAX_STRING_LEN];
// var list for class params
struct node_list tmpnode;
char class_tmpvar[MAX_STRING_LEN];
memset(&valdat, '\0', sizeof(valdat));
memset(&get_name, '\0', sizeof(get_name));
memset(&tmpMsg, '\0', sizeof(tmpMsg));
memset(&tmpnode, '\0', sizeof(tmpnode));
memset(&class_tmpvar, '\0', sizeof(class_tmpvar));
memset(tmpMsg, '\0', sizeof(tmpMsg));
getlex();
switch( lex.type )
{
case TYPE_STR:
#ifdef WINDOWS
playWave( lex.detail.string );
#else
#if USE_MIKMOD
printf("use mikmod\n");
mymikmod_play( lex.detail.string );
#elif USE_ALSA
printf("use alsa\n");
alsa_play_son( lex.detail.string );
#else
printf("use dsp\n");
ux_play_wave( lex.detail.string );
#endif
#endif
break;
case TYPE_OBJECT:
checkObjectValidation(lex.detail.object_str);
case TYPE_IDENT:
case TYPE_NUM:
//printf("curr class : %s\n", currentClass);
//printf("datatype : %d\n", valdat.datatype);
//printf("\nval : %d\n", valdat.val);
//printf("str : %s\n", valdat.str);
if(currentClass != NULL && strlen(currentClass) > 0) {
sprintf(class_tmpvar, "%s->%s", currentClass, lex.detail.string);
//printf("construct class var: %s\n", class_tmpvar);
valdat = ValLabel( class_tmpvar, class_sub_deep, valdat, VAL_FLAG_SEARCH_R );
} else {
valdat = ValLabel(lex.detail.string, sub_deep, valdat, VAL_FLAG_SEARCH_R );
}
if(valdat.str != '\0' && strlen(valdat.str) > 0) {
#ifdef WINDOWS
playWave( valdat.str );
#else
#if USE_MIKMOD
mymikmod_play( valdat.str );
#elif USE_ALSA
alsa_play_son( valdat.str );
#else
ux_play_wave (valdat.str );
#endif
#endif
}
break;
default:
Error("kode perintah MUSIK salah");
}
getlex();
ungetlex();
}
void keyJendela ()
{
char tmpMsg[MAX_STRING_LEN * 2];
int n=0, i=0;
char popupmsg[1024],
poptitle[1024];
VAL_LABEL valdat,tmpdat;
int idx=0; // array index
int isArrDummy=0;
int size = 0;
char get_name[MAX_STRING_LEN];
// var list for class params
struct node_list tmpnode;
char class_tmpvar[MAX_STRING_LEN];
memset(&valdat, '\0', sizeof(valdat));
memset(&tmpdat, '\0', sizeof(tmpdat));
memset(&get_name, '\0', sizeof(get_name));
memset(&tmpnode, '\0', sizeof(tmpnode));
memset(&class_tmpvar, '\0', sizeof(class_tmpvar));
memset(tmpMsg, '\0', sizeof(tmpMsg));
memset(popupmsg, '\0', sizeof(popupmsg));
memset(poptitle, '\0', sizeof(poptitle));
n = 0;
do{
memset(tmpMsg, '\0', sizeof(tmpMsg));
getlex();
switch( lex.type )
{
case TYPE_STR:
if(n == 0) {
strcpy(popupmsg, lex.detail.string );
} else if(n == 1) {
strcpy(poptitle, lex.detail.string );
}
break;
case TYPE_OBJECT:
checkObjectValidation(lex.detail.object_str);
case TYPE_IDENT:
//printf("curr class : %s\n", currentClass);
//printf("datatype : %d\n", valdat.datatype);
//printf("\nval : %d\n", valdat.val);
//printf("str : %s\n", valdat.str);
if(currentClass != NULL && strlen(currentClass) > 0) {
sprintf(class_tmpvar, "%s->%s", currentClass, lex.detail.string);
//printf("construct class var: %s\n", class_tmpvar);
valdat = ValLabel( class_tmpvar, class_sub_deep, valdat, VAL_FLAG_SEARCH_R );
} else {
valdat = ValLabel(lex.detail.string, sub_deep, valdat, VAL_FLAG_SEARCH_R );
}
// printf("type %d\n", valdat.datatype);
if(valdat.str != '\0' && strlen(valdat.str) > 0) {
sprintf(tmpMsg, "%s" , valdat.str );
if(n == 0) {
strcpy(popupmsg, tmpMsg );
} else if(n == 1) {
strcpy(poptitle, tmpMsg );
}
}
break;
default:
Error("bentuk perintah JENDELA salah");
}
n++;
getlex();
}while( lex.type == TYPE_SYM && lex.detail.symbol == ',');
if(n != 2) {
Error("parameter JENDELA tidak lengkap");
} else {
#ifdef WINDOWS
showDialog(popupmsg, poptitle);
#else
#endif
}
ungetlex();
}