Rev 4583 | Rev 7174 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4583 | Rev 5485 | ||
---|---|---|---|
1 | // |
1 | // |
2 | // This file is part of the AC97 mp3 player. |
2 | // This file is part of the AC97 mp3 player. |
3 | // (C) copyright Serge 2006-2007 infinity_sound@mail.ru |
3 | // (C) copyright Serge 2006-2007 infinity_sound@mail.ru |
4 | // (C) copyright Quantum 2007 ufmod@users.sf.net |
4 | // (C) copyright Quantum 2007 ufmod@users.sf.net |
5 | // |
5 | // |
6 | // This program is free software; you can redistribute it and/or modify |
6 | // This program is free software; you can redistribute it and/or modify |
7 | // it under the terms of the GNU General Public License as published by |
7 | // it under the terms of the GNU General Public License as published by |
8 | // the Free Software Foundation; either version 2 of the License, or |
8 | // the Free Software Foundation; either version 2 of the License, or |
9 | // (at your option) any later version. |
9 | // (at your option) any later version. |
10 | // |
10 | // |
11 | // This program is distributed in the hope that it will be useful, |
11 | // This program is distributed in the hope that it will be useful, |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | // GNU General Public License for more details. |
14 | // GNU General Public License for more details. |
15 | 15 | ||
16 | #include "../kolibri.h" |
16 | #include "../kolibri.h" |
17 | #include "string.h" |
17 | #include "string.h" |
18 | #include "ac97wav.h" |
18 | #include "ac97wav.h" |
19 | #include "../mpg/mpg123.h" |
19 | #include "../mpg/mpg123.h" |
20 | #include "../sound.h" |
20 | #include "../sound.h" |
21 | #include "../ufmod-codec.h" /* uFMOD integration */ |
21 | #include "../ufmod-codec.h" /* uFMOD integration */ |
22 | void exit(); /* uFMOD integration */ |
22 | void exit(); /* uFMOD integration */ |
23 | 23 | ||
24 | #define DOCKABLE_WINDOW |
24 | #define DOCKABLE_WINDOW |
25 | #define MP3_ERROR_OUT_OF_BUFFER 5 |
25 | #define MP3_ERROR_OUT_OF_BUFFER 5 |
26 | int m_last_error; |
26 | int m_last_error; |
27 | 27 | ||
28 | void _stdcall thread_proc(void *param); |
28 | void _stdcall thread_proc(void *param); |
29 | int _stdcall create_thread(void *proc, void *param, int stack_size); |
29 | int _stdcall create_thread(void *proc, void *param, int stack_size); |
30 | 30 | ||
31 | #ifdef DOCKABLE_WINDOW |
31 | #ifdef DOCKABLE_WINDOW |
32 | void GetThreadInfo (char *info, int slot); //Asper+ |
32 | void GetThreadInfo (char *info, int slot); //Asper+ |
33 | #endif |
33 | #endif |
34 | 34 | ||
35 | void touch(char *buf, int size); |
35 | void touch(char *buf, int size); |
36 | int mp3FindSync(byte* buf, int size, int* sync); |
36 | int mp3FindSync(byte* buf, int size, int* sync); |
37 | int stream_read_raw(struct reader *rd,unsigned char *buf, int size); |
37 | int stream_read_raw(struct reader *rd,unsigned char *buf, int size); |
38 | 38 | ||
39 | int __cdecl _stricmp (const char * dst, const char * src); |
39 | int __cdecl _stricmp (const char * dst, const char * src); |
40 | char *__cdecl strrchr (const char * string,int ch); |
40 | char *__cdecl strrchr (const char * string,int ch); |
41 | int _strncmp(char *src, char *dst, DWORD n); //Asper+ |
41 | int _strncmp(char *src, char *dst, DWORD n); //Asper+ |
42 | int _strncpy (char *dst, char *src, int n); //Asper+ |
42 | int _strncpy (char *dst, char *src, int n); //Asper+ |
43 | void uint2str(unsigned int value, char *string); //Asper+ |
43 | void uint2str(unsigned int value, char *string); //Asper+ |
44 | 44 | ||
45 | struct reader rd; |
45 | struct reader rd; |
46 | struct frame fr; |
46 | struct frame fr; |
47 | 47 | ||
48 | DWORD hDrv; |
48 | DWORD hDrv; |
49 | DWORD hSound; |
49 | DWORD hSound; |
50 | SNDBUF hBuff; |
50 | SNDBUF hBuff; |
51 | 51 | ||
52 | CTRL_INFO info; |
52 | CTRL_INFO info; |
53 | 53 | ||
54 | FILEINFO fileinfo; |
54 | FILEINFO fileinfo; |
55 | const char filename[256]; |
55 | const char filename[256]; |
56 | const char *fileext; |
56 | const char *fileext; |
57 | char full_filename[4096]; |
57 | char full_filename[4096]; |
58 | 58 | ||
59 | int m_vol; |
59 | int m_vol; |
60 | int l_vol=-700; //-7db |
60 | int l_vol=-700; //-7db |
61 | int r_vol=-700; |
61 | int r_vol=-700; |
62 | int pan =0; |
62 | int pan =0; |
63 | 63 | ||
64 | DWORD status; |
64 | DWORD status; |
65 | DWORD first_sync; |
65 | DWORD first_sync; |
66 | DWORD PLStatus=0; //Asper+ |
66 | DWORD PLStatus=0; //Asper+ |
67 | byte replay=0; |
67 | byte replay=0; |
68 | byte hidden=0; |
68 | byte hidden=0; |
69 | 69 | ||
70 | #ifdef DOCKABLE_WINDOW |
70 | #ifdef DOCKABLE_WINDOW |
71 | byte thread_info[1024]; //Asper+ |
71 | byte thread_info[1024]; //Asper+ |
72 | #endif |
72 | #endif |
73 | 73 | ||
74 | int tid, pl_tid; |
74 | int tid, pl_tid; |
75 | const DWORD main_wh=92, pl_ww=300, pl_wh=382; //Asper+ |
75 | const DWORD main_wh=92, pl_ww=300, pl_wh=382; //Asper+ |
76 | DWORD pl_wx=100, pl_wy=101+92; //Asper+ |
76 | DWORD pl_wx=100, pl_wy=101+92; //Asper+ |
77 | //DWORD main_wc=0x404040, main_bc=0x808080; //Asper+ ac97snd Classic style |
77 | //DWORD main_wc=0x404040, main_bc=0x808080; //Asper+ ac97snd Classic style |
78 | //DWORD main_wc=0x002040, main_bc=0x008080, main_ic=0x002040, selected_ic=0x1010F0; //Asper+ |
78 | //DWORD main_wc=0x002040, main_bc=0x008080, main_ic=0x002040, selected_ic=0x1010F0; //Asper+ |
79 | DWORD main_wc=0x101030, main_bc=0x008080, main_ic=0x000000, selected_ic=0x1010F0; //Asper+ |
79 | DWORD main_wc=0x101030, main_bc=0x008080, main_ic=0x000000, selected_ic=0x1010F0; //Asper+ |
80 | 80 | ||
81 | unsigned char *testbuff; |
81 | unsigned char *testbuff; |
82 | unsigned char *outbuf; |
82 | unsigned char *outbuf; |
83 | unsigned char *inpbuf; |
83 | unsigned char *inpbuf; |
84 | unsigned char *outPtr; |
84 | unsigned char *outPtr; |
85 | 85 | ||
86 | int inpsize; |
86 | int inpsize; |
87 | int outsize; |
87 | int outsize; |
88 | int outremain; |
88 | int outremain; |
89 | int totalout; |
89 | int totalout; |
90 | int done; |
90 | int done; |
91 | 91 | ||
92 | char header[] = "AC97 MP3 player"; |
92 | char header[] = "AC97 MP3 player"; |
93 | char header_PL[] = "PLAYLIST"; |
93 | char header_PL[] = "PLAYLIST"; |
94 | char buttons_xm[] = " Play Stop Vol- Vol+"; /* uFMOD integration */ |
94 | char buttons_xm[] = " Play Stop Vol- Vol+"; /* uFMOD integration */ |
95 | char buttons_wav[] = " Play Stop << >> Vol- Vol+"; /* uFMOD integration */ |
95 | char buttons_wav[] = " Play Stop << >> Vol- Vol+"; /* uFMOD integration */ |
96 | char button_PL[] = "PL"; //Asper+ |
96 | char button_PL[] = "PL"; //Asper+ |
97 | char button_R[] = "R"; //Asper+ |
97 | char button_R[] = "R"; //Asper+ |
98 | char *buttons_text = buttons_wav; /* uFMOD integration */ |
98 | char *buttons_text = buttons_wav; /* uFMOD integration */ |
99 | 99 | ||
100 | void play_xm(); /* uFMOD integration */ |
100 | void play_xm(); /* uFMOD integration */ |
101 | void (*snd_play)(); |
101 | void (*snd_play)(); |
102 | 102 | ||
103 | 103 | ||
104 | //Asper_____________________Play List code start_____________________________ |
104 | //Asper_____________________Play List code start_____________________________ |
105 | #define PLI_BUTTON_HEIGHT 13 |
105 | #define PLI_BUTTON_HEIGHT 13 |
106 | #define PL_MAX_SHOWN_ITEMS (pl_wh-PLI_BUTTON_HEIGHT-40)/PLI_BUTTON_HEIGHT |
106 | #define PL_MAX_SHOWN_ITEMS (pl_wh-PLI_BUTTON_HEIGHT-40)/PLI_BUTTON_HEIGHT |
107 | #define MAX_TEXT_WIDTH 46 |
107 | #define MAX_TEXT_WIDTH 46 |
108 | #define MAX_PATH_LEN 1024 |
108 | #define MAX_PATH_LEN 1024 |
109 | 109 | ||
110 | int currSelected, currActive, currFirstShowed; |
110 | int currSelected, currActive, currFirstShowed; |
111 | unsigned char *pl_buff; |
111 | unsigned char *pl_buff; |
112 | char pl_path[4096]; |
112 | char pl_path[4096]; |
113 | int pl_items_number; |
113 | int pl_items_number; |
114 | 114 | ||
115 | int ShowPLContent(char *filebuffer); |
115 | int ShowPLContent(char *filebuffer); |
116 | int GetFileNameFromPL(const char *fbuff, int index, char *name); |
116 | int GetFileNameFromPL(const char *fbuff, int index, char *name); |
117 | void Win2Dos (char *st, int len); |
117 | void Win2Dos (char *st, int len); |
118 | 118 | ||
119 | void HidePLWindow() |
119 | void HidePLWindow() |
120 | { |
120 | { |
121 | BeginDraw(); |
121 | BeginDraw(); |
122 | ResizeReplaceWindow(pl_wx,pl_wy,0,0); |
122 | ResizeReplaceWindow(pl_wx,pl_wy,0,0); |
123 | EndDraw(); |
123 | EndDraw(); |
124 | } |
124 | } |
125 | 125 | ||
126 | void ShowPLWindow() |
126 | void ShowPLWindow() |
127 | { |
127 | { |
128 | unsigned int i; |
128 | unsigned int i; |
129 | 129 | ||
130 | BeginDraw(); |
130 | BeginDraw(); |
131 | DrawWindow(pl_wx,pl_wy,pl_ww,pl_wh,main_ic,4,0,0,0); |
131 | DrawWindow(pl_wx,pl_wy,pl_ww,pl_wh,main_ic,4,0,0,0); |
132 | 132 | ||
133 | for (i=0; i |
133 | for (i=0; i |
134 | make_button(7,24+i*(PLI_BUTTON_HEIGHT+1),285,PLI_BUTTON_HEIGHT, (0x10+i)|BT_NORMAL|BT_NOFRAME, main_ic); |
134 | make_button(7,24+i*(PLI_BUTTON_HEIGHT+1),285,PLI_BUTTON_HEIGHT, (0x10+i)|BT_NORMAL|BT_NOFRAME, main_ic); |
135 | 135 | ||
136 | write_text(8,8,FONT0, header_PL, sizeof(header_PL)-1); |
136 | write_text(8,8,FONT0, header_PL, sizeof(header_PL)-1); |
137 | ShowPLContent(pl_buff); |
137 | ShowPLContent(pl_buff); |
138 | EndDraw(); |
138 | EndDraw(); |
139 | } |
139 | } |
140 | 140 | ||
141 | int LoadTrack(int i) |
141 | int LoadTrack(int i) |
142 | { |
142 | { |
143 | if (GetFileNameFromPL(pl_buff, i, filename)) |
143 | if (GetFileNameFromPL(pl_buff, i, filename)) |
144 | { |
144 | { |
145 | strcpy (full_filename, pl_path); |
145 | strcpy (full_filename, pl_path); |
146 | strcat (full_filename, filename); |
146 | strcat (full_filename, filename); |
147 | return 1; |
147 | return 1; |
148 | } |
148 | } |
149 | return 0; |
149 | return 0; |
150 | } |
150 | } |
151 | 151 | ||
152 | void _stdcall pl_thread_proc(void *param) |
152 | void _stdcall pl_thread_proc(void *param) |
153 | { int evnt; |
153 | { int evnt; |
154 | int key, button; |
154 | int key, button; |
155 | DWORD tmp_x, tmp_y, i; //Asper+ |
155 | DWORD tmp_x, tmp_y, i; //Asper+ |
156 | char ipc_buff[16]=""; |
156 | char ipc_buff[16]=""; |
157 | 157 | ||
158 | set_event_mask(0x47); //Asper + IPC event |
158 | set_event_mask(0x47); //Asper + IPC event |
159 | ipc_init(ipc_buff, 16); |
159 | ipc_init(ipc_buff, 16); |
160 | 160 | ||
161 | _asm |
161 | _asm |
162 | { |
162 | { |
163 | mov eax, 66 |
163 | mov eax, 66 |
164 | mov ebx, 1 |
164 | mov ebx, 1 |
165 | mov ecx, 1 |
165 | mov ecx, 1 |
166 | int 0x40 |
166 | int 0x40 |
167 | }; |
167 | }; |
168 | 168 | ||
169 | ShowPLWindow(); |
169 | ShowPLWindow(); |
170 | 170 | ||
171 | while(1) |
171 | while(1) |
172 | { |
172 | { |
173 | if (PLStatus&0xF0) |
173 | if (PLStatus&0xF0) |
174 | { |
174 | { |
175 | switch(PLStatus) |
175 | switch(PLStatus) |
176 | { |
176 | { |
177 | case 0x11: |
177 | case 0x11: |
178 | HidePLWindow(); |
178 | HidePLWindow(); |
179 | break; |
179 | break; |
180 | case 0x12: |
180 | case 0x12: |
181 | ResizeReplaceWindow(pl_wx,pl_wy,pl_ww,pl_wh); |
181 | ResizeReplaceWindow(pl_wx,pl_wy,pl_ww,pl_wh); |
182 | break; |
182 | break; |
183 | } |
183 | } |
184 | PLStatus&=0x0F; |
184 | PLStatus&=0x0F; |
185 | } |
185 | } |
186 | switch (status) |
186 | switch (status) |
187 | { |
187 | { |
188 | case ST_TRACK: |
188 | case ST_TRACK: |
189 | break; |
189 | break; |
190 | case ST_EXIT: |
190 | case ST_EXIT: |
191 | PLStatus=0x00; |
191 | PLStatus=0x00; |
192 | exit(); |
192 | exit(); |
193 | } |
193 | } |
194 | 194 | ||
195 | #ifdef DOCKABLE_WINDOW |
195 | #ifdef DOCKABLE_WINDOW |
196 | tmp_x = (DWORD)thread_info[35]*0x100+(DWORD)thread_info[34]; |
196 | tmp_x = (DWORD)thread_info[35]*0x100+(DWORD)thread_info[34]; |
197 | tmp_y = (DWORD)thread_info[38]+main_wh+1; |
197 | tmp_y = (DWORD)thread_info[38]+main_wh+1; |
198 | if (pl_wx!= tmp_x || pl_wy!=tmp_y) |
198 | if (pl_wx!= tmp_x || pl_wy!=tmp_y) |
199 | { |
199 | { |
200 | pl_wx=tmp_x; |
200 | pl_wx=tmp_x; |
201 | pl_wy=tmp_y; |
201 | pl_wy=tmp_y; |
202 | ResizeReplaceWindow(pl_wx,pl_wy,-1,-1); |
202 | ResizeReplaceWindow(pl_wx,pl_wy,-1,-1); |
203 | } |
203 | } |
204 | #endif |
204 | #endif |
205 | 205 | ||
206 | evnt = wait_for_event(20); |
206 | evnt = wait_for_event(20); |
207 | 207 | ||
208 | switch(evnt) |
208 | switch(evnt) |
209 | { |
209 | { |
210 | case EV_REDRAW: |
210 | case EV_REDRAW: |
211 | ShowPLWindow(); |
211 | ShowPLWindow(); |
212 | break; |
212 | break; |
213 | 213 | ||
214 | case EV_KEY: |
214 | case EV_KEY: |
215 | if(!get_key(&key)) |
215 | if(!get_key(&key)) |
216 | { |
216 | { |
217 | 217 | ||
218 | switch(key) |
218 | switch(key) |
219 | { case 0xE0: |
219 | { case 0xE0: |
220 | case 0xE1: |
220 | case 0xE1: |
221 | break; |
221 | break; |
222 | default: |
222 | default: |
223 | switch (key) |
223 | switch (key) |
224 | { |
224 | { |
225 | case 0x01: //Esc |
225 | case 0x01: //Esc |
226 | PLStatus=0x00; |
226 | PLStatus=0x00; |
227 | exit(); |
227 | exit(); |
228 | break; |
228 | break; |
229 | 229 | ||
230 | case 0x19: //P - playlist |
230 | case 0x19: //P - playlist |
231 | switch (PLStatus) |
231 | switch (PLStatus) |
232 | { case 0x00: //PL not started. |
232 | { case 0x00: //PL not started. |
233 | pl_tid=create_thread(pl_thread_proc, 0, 4096); |
233 | pl_tid=create_thread(pl_thread_proc, 0, 4096); |
234 | PLStatus=0x12; |
234 | PLStatus=0x12; |
235 | break; |
235 | break; |
236 | case 0x01: //PL started, but hidden. |
236 | case 0x01: //PL started, but hidden. |
237 | PLStatus=0x12; |
237 | PLStatus=0x12; |
238 | break; |
238 | break; |
239 | case 0x02: //PL started and showed. |
239 | case 0x02: //PL started and showed. |
240 | PLStatus=0x11; |
240 | PLStatus=0x11; |
241 | break; |
241 | break; |
242 | } |
242 | } |
243 | break; |
243 | break; |
244 | 244 | ||
245 | case 0x1C: //Enter |
245 | case 0x1C: //Enter |
246 | currActive=currFirstShowed+currSelected-1; |
246 | currActive=currFirstShowed+currSelected-1; |
247 | status = ST_TRACK; |
247 | status = ST_TRACK; |
248 | break; |
248 | break; |
249 | 249 | ||
250 | case 0x2C: //Z - previous |
250 | case 0x2C: //Z - previous |
251 | currActive-=2; |
251 | currActive-=2; |
252 | status = ST_TRACK; |
252 | status = ST_TRACK; |
253 | break; |
253 | break; |
254 | 254 | ||
255 | case 0x2D: //X - play |
255 | case 0x2D: //X - play |
256 | status = ST_PLAY; |
256 | status = ST_PLAY; |
257 | break; |
257 | break; |
258 | 258 | ||
259 | case 0x2E: //C - pause |
259 | case 0x2E: //C - pause |
260 | break; |
260 | break; |
261 | 261 | ||
262 | case 0x2F: //V - stop |
262 | case 0x2F: //V - stop |
263 | status = ST_STOP; |
263 | status = ST_STOP; |
264 | break; |
264 | break; |
265 | 265 | ||
266 | case 0x30: //B - next |
266 | case 0x30: //B - next |
267 | status = ST_TRACK; |
267 | status = ST_TRACK; |
268 | break; |
268 | break; |
269 | 269 | ||
270 | case 0x47: //Home |
270 | case 0x47: //Home |
271 | if(l_vol < 0) |
271 | if(l_vol < 0) |
272 | { l_vol+=100; |
272 | { l_vol+=100; |
273 | r_vol+=100; |
273 | r_vol+=100; |
274 | SetVolume(hBuff,l_vol,r_vol); |
274 | SetVolume(hBuff,l_vol,r_vol); |
275 | }; |
275 | }; |
276 | break; |
276 | break; |
277 | case 0x48: //Up |
277 | case 0x48: //Up |
278 | if (currSelected==0) |
278 | if (currSelected==0) |
279 | { |
279 | { |
280 | if (currFirstShowed>0) |
280 | if (currFirstShowed>0) |
281 | currFirstShowed--; |
281 | currFirstShowed--; |
282 | else break; |
282 | else break; |
283 | ShowPLContent(pl_buff); |
283 | ShowPLContent(pl_buff); |
284 | break; |
284 | break; |
285 | } |
285 | } |
286 | currSelected--; |
286 | currSelected--; |
287 | ShowPLContent(pl_buff); |
287 | ShowPLContent(pl_buff); |
288 | break; |
288 | break; |
289 | case 0x50: //Down |
289 | case 0x50: //Down |
290 | if (currSelected+currFirstShowed > pl_items_number-2) break; |
290 | if (currSelected+currFirstShowed > pl_items_number-2) break; |
291 | if (currSelected==PL_MAX_SHOWN_ITEMS-1) |
291 | if (currSelected==PL_MAX_SHOWN_ITEMS-1) |
292 | { |
292 | { |
293 | //if (currFirstShowed |
293 | //if (currFirstShowed |
294 | currFirstShowed++; |
294 | currFirstShowed++; |
295 | ShowPLContent(pl_buff); |
295 | ShowPLContent(pl_buff); |
296 | break; |
296 | break; |
297 | } |
297 | } |
298 | //if (currSelected |
298 | //if (currSelected |
299 | currSelected++; |
299 | currSelected++; |
300 | ShowPLContent(pl_buff); |
300 | ShowPLContent(pl_buff); |
301 | break; |
301 | break; |
302 | case 0x4F: //End |
302 | case 0x4F: //End |
303 | if(l_vol > -10000) |
303 | if(l_vol > -10000) |
304 | { l_vol-=100; |
304 | { l_vol-=100; |
305 | r_vol-=100; |
305 | r_vol-=100; |
306 | SetVolume(hBuff,l_vol,r_vol); |
306 | SetVolume(hBuff,l_vol,r_vol); |
307 | }; |
307 | }; |
308 | break; |
308 | break; |
309 | case 0x53: |
309 | case 0x53: |
310 | if(pan > -10000) |
310 | if(pan > -10000) |
311 | { pan -=100; |
311 | { pan -=100; |
312 | SetPan(hBuff,pan); |
312 | SetPan(hBuff,pan); |
313 | }; |
313 | }; |
314 | break; |
314 | break; |
315 | case 0x51: |
315 | case 0x51: |
316 | if(pan < 10000) |
316 | if(pan < 10000) |
317 | { pan +=100; |
317 | { pan +=100; |
318 | SetPan(hBuff,pan); |
318 | SetPan(hBuff,pan); |
319 | }; |
319 | }; |
320 | break; |
320 | break; |
321 | } |
321 | } |
322 | }; |
322 | }; |
323 | }; |
323 | }; |
324 | break; |
324 | break; |
325 | 325 | ||
326 | case EV_BUTTON: |
326 | case EV_BUTTON: |
327 | button=get_button_id(); |
327 | button=get_button_id(); |
328 | if (button==1) |
328 | if (button==1) |
329 | { |
329 | { |
330 | PLStatus=0x00; |
330 | PLStatus=0x00; |
331 | exit(); |
331 | exit(); |
332 | } |
332 | } |
333 | currActive=currFirstShowed+button-0x10-1; |
333 | currActive=currFirstShowed+button-0x10-1; |
334 | status = ST_TRACK; |
334 | status = ST_TRACK; |
335 | break; |
335 | break; |
336 | case EV_IPC: |
336 | case EV_IPC: |
337 | *ipc_buff='\0'; |
337 | *ipc_buff='\0'; |
338 | ShowPLContent(pl_buff); |
338 | ShowPLContent(pl_buff); |
339 | break; |
339 | break; |
340 | 340 | ||
341 | } |
341 | } |
342 | } |
342 | } |
343 | } |
343 | } |
344 | 344 | ||
345 | void Win2Dos (char *st, int len) |
345 | void Win2Dos (char *st, int len) |
346 | { |
346 | { |
347 | int i; |
347 | int i; |
348 | unsigned char ch; |
348 | unsigned char ch; |
349 | 349 | ||
350 | for (i=0; i |
350 | for (i=0; i |
351 | { |
351 | { |
352 | ch = st[i]; |
352 | ch = st[i]; |
353 | if (ch>=192) |
353 | if (ch>=192) |
354 | { |
354 | { |
355 | if (ch>=240) ch-=16; |
355 | if (ch>=240) ch-=16; |
356 | else ch-=64; |
356 | else ch-=64; |
357 | } |
357 | } |
358 | else |
358 | else |
359 | { |
359 | { |
360 | if (ch==168) ch = 240; |
360 | if (ch==168) ch = 240; |
361 | if (ch==184) ch = 241; |
361 | if (ch==184) ch = 241; |
362 | if (ch==185) ch = 252; |
362 | if (ch==185) ch = 252; |
363 | if ((ch==147) || (ch==148) || (ch==171) || (ch==187)) ch = 34; |
363 | if ((ch==147) || (ch==148) || (ch==171) || (ch==187)) ch = 34; |
364 | if ((ch==150) || (ch==151)) ch = 45; |
364 | if ((ch==150) || (ch==151)) ch = 45; |
365 | } |
365 | } |
366 | st[i]=ch; |
366 | st[i]=ch; |
367 | } |
367 | } |
368 | } |
368 | } |
369 | 369 | ||
370 | int GetFileNameFromPL(const char *plbuff, int index, char *name) |
370 | int GetFileNameFromPL(const char *plbuff, int index, char *name) |
371 | { |
371 | { |
372 | int count=0,i=0,j=0; |
372 | int count=0,i=0,j=0; |
373 | char ch; |
373 | char ch; |
374 | 374 | ||
375 | do{ |
375 | do{ |
376 | ch=plbuff[i]; |
376 | ch=plbuff[i]; |
377 | if (ch!='#' && i && plbuff[i-1]=='\n') |
377 | if (ch!='#' && i && plbuff[i-1]=='\n') |
378 | count++; |
378 | count++; |
379 | if (count-1==index) |
379 | if (count-1==index) |
380 | { |
380 | { |
381 | if (j>MAX_PATH_LEN || ch=='\r' || ch=='\n') |
381 | if (j>MAX_PATH_LEN || ch=='\r' || ch=='\n') |
382 | { |
382 | { |
383 | name[j]='\0'; |
383 | name[j]='\0'; |
384 | break; |
384 | break; |
385 | } |
385 | } |
386 | if (ch=='\\') ch='/'; |
386 | if (ch=='\\') ch='/'; |
387 | name[j++]=ch; |
387 | name[j++]=ch; |
388 | } |
388 | } |
389 | else if (count-1>index) break; |
389 | else if (count-1>index) break; |
390 | i++; |
390 | i++; |
391 | }while (ch); |
391 | }while (ch); |
392 | if (!ch) return 0; |
392 | if (!ch) return 0; |
393 | return j; |
393 | return j; |
394 | } |
394 | } |
395 | 395 | ||
396 | int CountFileNamesInPL(const char *plbuff) |
396 | int CountFileNamesInPL(const char *plbuff) |
397 | { |
397 | { |
398 | int count=0,i=0; |
398 | int count=0,i=0; |
399 | char ch; |
399 | char ch; |
400 | 400 | ||
401 | do{ |
401 | do{ |
402 | ch=plbuff[i]; |
402 | ch=plbuff[i]; |
403 | if (ch!='#' && i && plbuff[i-1]=='\n') |
403 | if (ch!='#' && i && plbuff[i-1]=='\n') |
404 | count++; |
404 | count++; |
405 | i++; |
405 | i++; |
406 | }while (ch); |
406 | }while (ch); |
407 | if (count) count--; |
407 | if (count) count--; |
408 | return count; |
408 | return count; |
409 | } |
409 | } |
410 | 410 | ||
411 | int ShowPLContent(char *filebuffer) |
411 | int ShowPLContent(char *filebuffer) |
412 | { |
412 | { |
413 | char st[MAX_PATH_LEN+10]="", tmp[MAX_PATH_LEN+1]=""; |
413 | char st[MAX_PATH_LEN+10]="", tmp[MAX_PATH_LEN+1]=""; |
414 | unsigned int len=8,i; |
414 | unsigned int len=8,i; |
415 | DWORD text_color; |
415 | DWORD text_color; |
416 | 416 | ||
417 | draw_bar(7,24,285,PLI_BUTTON_HEIGHT*(PL_MAX_SHOWN_ITEMS+2), main_ic); |
417 | draw_bar(7,24,285,PLI_BUTTON_HEIGHT*(PL_MAX_SHOWN_ITEMS+2), main_ic); |
418 | draw_bar(7,24+currSelected*(PLI_BUTTON_HEIGHT+1),285,PLI_BUTTON_HEIGHT, selected_ic); |
418 | draw_bar(7,24+currSelected*(PLI_BUTTON_HEIGHT+1),285,PLI_BUTTON_HEIGHT, selected_ic); |
419 | for (i=0; i |
419 | for (i=0; i |
420 | { |
420 | { |
421 | text_color = (currFirstShowed+i==currActive?0xFFFFFF|FONT0:0x00FF20|FONT0); |
421 | text_color = (currFirstShowed+i==currActive?0xFFFFFF|FONT0:0x00FF20|FONT0); |
422 | if (!GetFileNameFromPL(filebuffer, i+currFirstShowed, tmp)) break; |
422 | if (!GetFileNameFromPL(filebuffer, i+currFirstShowed, tmp)) break; |
423 | uint2str(currFirstShowed+i+1, st); |
423 | uint2str(currFirstShowed+i+1, st); |
424 | strcat(st, ". "); |
424 | strcat(st, ". "); |
425 | strcat(st, tmp); |
425 | strcat(st, tmp); |
426 | len = strlen(st); |
426 | len = strlen(st); |
427 | if (len > MAX_TEXT_WIDTH) |
427 | if (len > MAX_TEXT_WIDTH) |
428 | len = MAX_TEXT_WIDTH; |
428 | len = MAX_TEXT_WIDTH; |
429 | write_text(11,i*(PLI_BUTTON_HEIGHT+1)+27,text_color, st, len); |
429 | write_text(11,i*(PLI_BUTTON_HEIGHT+1)+27,text_color, st, len); |
430 | } |
430 | } |
431 | return 1; |
431 | return 1; |
432 | } |
432 | } |
433 | //Asper_____________________Play List code end_____________________________ |
433 | //Asper_____________________Play List code end_____________________________ |
434 | void redraw_R_button() //Asper + |
434 | void redraw_R_button() //Asper + |
435 | { |
435 | { |
436 | DWORD rc = 0xA0FFA0; //R button text color |
436 | DWORD rc = 0xA0FFA0; //R button text color |
437 | if (!replay) rc = 0x404040; |
437 | if (!replay) rc = 0x404040; |
438 | write_text(14,74,rc|FONT0,button_R,sizeof(button_R)-1); |
438 | write_text(14,74,rc|FONT0,button_R,sizeof(button_R)-1); |
439 | } |
439 | } |
440 | 440 | ||
441 | void update_dynamic_content() //Asper + |
441 | void update_dynamic_content() //Asper + |
442 | { |
442 | { |
443 | int len = strlen(filename); |
443 | int len = strlen(filename); |
444 | if (len > 47) len = 47; |
444 | if (len > 47) len = 47; |
445 | draw_bar(7,41,286,11,main_wc); |
445 | draw_bar(7,41,286,11,main_wc); |
446 | draw_bar(7,55,286,11,main_wc); |
446 | draw_bar(7,55,286,11,main_wc); |
447 | write_text(11,57,0x00FF20|FONT0, filename, len); |
447 | write_text(11,57,0x00FF20|FONT0, filename, len); |
448 | } |
448 | } |
449 | 449 | ||
450 | void draw_window() |
450 | void draw_window() |
451 | { |
451 | { |
452 | BeginDraw(); |
452 | BeginDraw(); |
453 | if (!hidden) |
453 | if (!hidden) |
454 | { |
454 | { |
455 | DrawWindow(100,100,299,main_wh,main_wc,4,0,0,0); //Asper+ |
455 | DrawWindow(100,100,299,main_wh,main_wc,4,0,0,0); //Asper+ |
456 | 456 | ||
457 | make_button(7,24,45,13, 0x10|BT_NORMAL,main_bc); |
457 | make_button(7,24,45,13, 0x10|BT_NORMAL,main_bc); |
458 | make_button(56,24,45,13, 0x11|BT_NORMAL,main_bc); |
458 | make_button(56,24,45,13, 0x11|BT_NORMAL,main_bc); |
459 | make_button(104,24,45,13, 0x12|BT_NORMAL,main_bc); |
459 | make_button(104,24,45,13, 0x12|BT_NORMAL,main_bc); |
460 | make_button(152,24,45,13, 0x13|BT_NORMAL,main_bc); |
460 | make_button(152,24,45,13, 0x13|BT_NORMAL,main_bc); |
461 | make_button(200,24,45,13, 0x14|BT_NORMAL,main_bc); |
461 | make_button(200,24,45,13, 0x14|BT_NORMAL,main_bc); |
462 | make_button(248,24,45,13, 0x15|BT_NORMAL,main_bc); |
462 | make_button(248,24,45,13, 0x15|BT_NORMAL,main_bc); |
463 | 463 | ||
464 | make_button(268,70,25,13, 0x16|BT_NORMAL,main_bc); //Asper+ PL button |
464 | make_button(268,70,25,13, 0x16|BT_NORMAL,main_bc); //Asper+ PL button |
465 | make_button(10,70,12,13, 0x17|BT_NORMAL,main_wc); //Asper+ R button |
465 | make_button(10,70,12,13, 0x17|BT_NORMAL,main_wc); //Asper+ R button |
466 | 466 | ||
467 | make_button(7,41,286,11, 0x30|BT_HIDE|BT_NOFRAME,main_wc); |
467 | make_button(7,41,286,11, 0x30|BT_HIDE|BT_NOFRAME,main_wc); |
468 | 468 | ||
469 | update_dynamic_content(); |
469 | update_dynamic_content(); |
470 | write_text(8,8,FONT0, header, sizeof(header)-1); /* uFMOD integration */ |
470 | write_text(8,8,FONT0, header, sizeof(header)-1); /* uFMOD integration */ |
471 | write_text(12,28,main_wc|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */ |
471 | write_text(12,28,main_wc|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */ |
472 | write_text(11,27,0xA0FFA0|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */ |
472 | write_text(11,27,0xA0FFA0|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */ |
473 | 473 | ||
474 | write_text(276,74,main_wc|FONT0,button_PL,sizeof(button_PL)-1); //Asper+ PL button text |
474 | write_text(276,74,main_wc|FONT0,button_PL,sizeof(button_PL)-1); //Asper+ PL button text |
475 | write_text(275,73,0xA0FFA0|FONT0,button_PL,sizeof(button_PL)-1); //Asper+ |
475 | write_text(275,73,0xA0FFA0|FONT0,button_PL,sizeof(button_PL)-1); //Asper+ |
476 | redraw_R_button(); |
476 | redraw_R_button(); |
477 | } |
477 | } |
478 | EndDraw(); |
478 | EndDraw(); |
479 | }; |
479 | }; |
480 | 480 | ||
481 | void draw_progress_bar() |
481 | void draw_progress_bar() |
482 | { DWORD x; |
482 | { DWORD x; |
483 | x = (DWORD)(287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size); /* uFMOD integration */ |
483 | x = (DWORD)(287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size); /* uFMOD integration */ |
484 | if(x==0) return; |
484 | if(x==0) return; |
485 | draw_bar(7,41,x,11,0xA0A0A0); |
485 | draw_bar(7,41,x,11,0xA0A0A0); |
486 | draw_bar(x+7,41,287-x,11,main_wc); |
486 | draw_bar(x+7,41,287-x,11,main_wc); |
487 | }; |
487 | }; |
488 | 488 | ||
489 | void debug_out_str(const char* str) |
489 | void debug_out_str(const char* str) |
490 | { |
490 | { |
491 | while (*str != 0) |
491 | while (*str != 0) |
492 | { |
492 | { |
493 | debug_out(*str); |
493 | debug_out(*str); |
494 | str++; |
494 | str++; |
495 | } |
495 | } |
496 | } |
496 | } |
497 | 497 | ||
498 | int LoadPL(char *fname) |
498 | int LoadPL(char *fname) |
499 | { |
499 | { |
500 | DWORD fmt; |
500 | DWORD fmt; |
501 | DWORD r_bytes; |
501 | DWORD r_bytes; |
502 | int retval; |
502 | int retval; |
503 | int i; |
503 | int i; |
504 | // char st[100]=""; |
504 | // char st[100]=""; |
505 | 505 | ||
506 | char *pch; |
506 | char *pch; |
507 | 507 | ||
508 | r_bytes=0; |
508 | r_bytes=0; |
509 | pch=strrchr(fname, '/'); |
509 | pch=strrchr(fname, '/'); |
510 | if (pch) |
510 | if (pch) |
511 | i=pch-fname+1; |
511 | i=pch-fname+1; |
512 | else |
512 | else |
513 | i=strlen(fname); |
513 | i=strlen(fname); |
514 | 514 | ||
515 | _strncpy (pl_path, fname, i); |
515 | _strncpy (pl_path, fname, i); |
516 | pl_path[i]='\0'; |
516 | pl_path[i]='\0'; |
517 | 517 | ||
518 | if (!pl_buff) |
518 | if (!pl_buff) |
519 | pl_buff = UserAlloc(0x40000); |
519 | pl_buff = UserAlloc(0x40000); |
520 | retval=read_file (fname,pl_buff,0,0x40000,&r_bytes); |
520 | retval=read_file (fname,pl_buff,0,0x40000,&r_bytes); |
521 | 521 | ||
522 | if ( retval && (r_bytes==0)) |
522 | if ( retval && (r_bytes==0)) |
523 | return 0; |
523 | return 0; |
524 | 524 | ||
525 | Win2Dos(pl_buff, r_bytes); |
525 | Win2Dos(pl_buff, r_bytes); |
526 | pl_items_number=CountFileNamesInPL(pl_buff); |
526 | pl_items_number=CountFileNamesInPL(pl_buff); |
527 | /* |
527 | /* |
528 | debug_out_str("\n\rPlay List files number = "); |
528 | debug_out_str("\n\rPlay List files number = "); |
529 | itoa(pl_items_number, st, 10); |
529 | itoa(pl_items_number, st, 10); |
530 | debug_out_str(st); |
530 | debug_out_str(st); |
531 | */ |
531 | */ |
532 | fmt = test_m3u(pl_buff); |
532 | fmt = test_m3u(pl_buff); |
533 | 533 | ||
534 | if(!fmt) |
534 | if(!fmt) |
535 | { |
535 | { |
536 | debug_out_str("\n\rInvalid M3U file"); |
536 | debug_out_str("\n\rInvalid M3U file"); |
537 | return 0; |
537 | return 0; |
538 | } |
538 | } |
539 | debug_out_str("\n\rValid M3U file"); |
539 | debug_out_str("\n\rValid M3U file"); |
540 | currSelected=currFirstShowed=0; |
540 | currSelected=currFirstShowed=0; |
541 | currActive=-1; |
541 | currActive=-1; |
542 | return 1; |
542 | return 1; |
543 | } |
543 | } |
544 | 544 | ||
545 | int LoadFile(char *fname) |
545 | int LoadFile(char *fname) |
546 | { |
546 | { |
547 | DWORD fmt; |
547 | DWORD fmt; |
548 | DWORD r_bytes; |
548 | DWORD r_bytes; |
549 | int retval; |
549 | int retval; |
550 | int err; |
550 | int err; |
551 | unsigned char *ttl, *cur; /* uFMOD integration */ |
551 | unsigned char *ttl, *cur; /* uFMOD integration */ |
552 | 552 | ||
553 | debug_out_str("\n\rPlay file "); |
553 | debug_out_str("\n\rPlay file "); |
554 | debug_out_str(fname); |
554 | debug_out_str(fname); |
555 | debug_out_str("\n\r"); |
555 | debug_out_str("\n\r"); |
556 | 556 | ||
557 | if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND) |
557 | if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND) |
558 | { debug_out_str("\n\rfile not found\n\r"); |
558 | { debug_out_str("\n\rfile not found\n\r"); |
559 | return 0; |
559 | return 0; |
560 | } |
560 | } |
561 | 561 | ||
562 | r_bytes=0; |
562 | r_bytes=0; |
563 | strcpy(filename, strrchr(fname,'/')+1); |
563 | strcpy(filename, strrchr(fname,'/')+1); |
564 | if( !(fileext = strrchr(filename,'.'))) |
564 | if( !(fileext = strrchr(filename,'.'))) |
565 | return 0; |
565 | return 0; |
566 | 566 | ||
567 | if(!_stricmp(fileext,".m3u")) |
567 | if(!_stricmp(fileext,".m3u")) |
568 | { |
568 | { |
569 | LoadPL(fname); |
569 | LoadPL(fname); |
570 | status=ST_TRACK; |
570 | status=ST_TRACK; |
571 | return 1; |
571 | return 1; |
572 | } |
572 | } |
573 | 573 | ||
574 | if (!testbuff) |
574 | if (!testbuff) |
575 | testbuff = UserAlloc(4096); |
575 | testbuff = UserAlloc(4096); |
576 | 576 | ||
577 | retval=read_file (fname,testbuff,0,2048,&r_bytes); |
577 | retval=read_file (fname,testbuff,0,2048,&r_bytes); |
578 | if ( retval && (r_bytes==0)) |
578 | if ( retval && (r_bytes==0)) |
579 | return 0; |
579 | return 0; |
580 | 580 | ||
581 | if (!inpbuf) |
581 | if (!inpbuf) |
582 | { |
582 | { |
583 | inpbuf = UserAlloc(0x10000); |
583 | inpbuf = UserAlloc(0x10000); |
584 | touch(inpbuf, 0x10000); |
584 | touch(inpbuf, 0x10000); |
585 | } |
585 | } |
586 | create_reader(&rd, inpbuf, 0x10000); |
586 | create_reader(&rd, inpbuf, 0x10000); |
587 | init_reader(&rd,fname); |
587 | init_reader(&rd,fname); |
588 | 588 | ||
589 | if(!_stricmp(fileext,".mp3")) |
589 | if(!_stricmp(fileext,".mp3")) |
590 | { |
590 | { |
591 | fmt = test_mp3(testbuff); |
591 | fmt = test_mp3(testbuff); |
592 | if(!fmt) |
592 | if(!fmt) |
593 | { |
593 | { |
594 | debug_out_str("\n\rInvalid MP3 file"); |
594 | debug_out_str("\n\rInvalid MP3 file"); |
595 | return 0; |
595 | return 0; |
596 | }; |
596 | }; |
597 | snd_play = &play_mp3; |
597 | snd_play = &play_mp3; |
598 | outremain = 0x40000; |
598 | outremain = 0x40000; |
599 | if (!outbuf) |
599 | if (!outbuf) |
600 | { |
600 | { |
601 | outbuf = UserAlloc(outremain); |
601 | outbuf = UserAlloc(outremain); |
602 | touch(outbuf, outremain); |
602 | touch(outbuf, outremain); |
603 | } |
603 | } |
604 | make_decode_tables(32767); |
604 | make_decode_tables(32767); |
605 | init_layer2(); |
605 | init_layer2(); |
606 | init_layer3(32); |
606 | init_layer3(32); |
607 | fr.single = -1; |
607 | fr.single = -1; |
608 | goto play; |
608 | goto play; |
609 | }; |
609 | }; |
610 | 610 | ||
611 | if(!_stricmp(fileext,".xm")) |
611 | if(!_stricmp(fileext,".xm")) |
612 | { |
612 | { |
613 | if(uFMOD_LoadSong(fname)) |
613 | if(uFMOD_LoadSong(fname)) |
614 | { |
614 | { |
615 | buttons_text = buttons_xm; /* uFMOD integration */ |
615 | buttons_text = buttons_xm; /* uFMOD integration */ |
616 | fmt = PCM_2_16_48; /* uFMOD integration */ |
616 | fmt = PCM_2_16_48; /* uFMOD integration */ |
617 | snd_play = &play_xm; /* uFMOD integration */ |
617 | snd_play = &play_xm; /* uFMOD integration */ |
618 | ttl = uFMOD_GetTitle(); /* uFMOD integration */ |
618 | ttl = uFMOD_GetTitle(); /* uFMOD integration */ |
619 | cur = ttl; /* uFMOD integration */ |
619 | cur = ttl; /* uFMOD integration */ |
620 | err = 0; /* uFMOD integration */ |
620 | err = 0; /* uFMOD integration */ |
621 | while(*cur && *cur++ != ' ') err++; /* uFMOD integration */ |
621 | while(*cur && *cur++ != ' ') err++; /* uFMOD integration */ |
622 | if(err){ /* uFMOD integration */ |
622 | if(err){ /* uFMOD integration */ |
623 | cur = fname; /* uFMOD integration */ |
623 | cur = fname; /* uFMOD integration */ |
624 | while(*cur) cur++; /* uFMOD integration */ |
624 | while(*cur) cur++; /* uFMOD integration */ |
625 | *cur++ = ' '; /* uFMOD integration */ |
625 | *cur++ = ' '; /* uFMOD integration */ |
626 | *cur++ = '|'; /* uFMOD integration */ |
626 | *cur++ = '|'; /* uFMOD integration */ |
627 | *cur++ = ' '; /* uFMOD integration */ |
627 | *cur++ = ' '; /* uFMOD integration */ |
628 | while(*ttl) *cur++ = *ttl++; /* uFMOD integration */ |
628 | while(*ttl) *cur++ = *ttl++; /* uFMOD integration */ |
629 | } |
629 | } |
630 | goto play; |
630 | goto play; |
631 | } |
631 | } |
632 | debug_out_str("\n\rInvalid XM file"); |
632 | debug_out_str("\n\rInvalid XM file"); |
633 | return 0; |
633 | return 0; |
634 | }; |
634 | }; |
635 | 635 | ||
636 | if(!_stricmp(fileext, ".wav")) |
636 | if(!_stricmp(fileext, ".wav")) |
637 | { |
637 | { |
638 | fmt = test_wav((WAVEHEADER*)testbuff); |
638 | fmt = test_wav((WAVEHEADER*)testbuff); |
639 | if(fmt) |
639 | if(fmt) |
640 | { |
640 | { |
641 | snd_play = &play_wave; |
641 | snd_play = &play_wave; |
642 | set_reader(&rd, 44); |
642 | set_reader(&rd, 44); |
643 | outbuf = UserAlloc(32*1024); |
643 | outbuf = UserAlloc(32*1024); |
644 | touch(outbuf, 32768); |
644 | touch(outbuf, 32768); |
645 | goto play; |
645 | goto play; |
646 | } |
646 | } |
647 | debug_out_str("\n\rInvalid WAV file"); |
647 | debug_out_str("\n\rInvalid WAV file"); |
648 | return 0; |
648 | return 0; |
649 | }; |
649 | }; |
650 | 650 | ||
651 | debug_out_str("\n\rUnsupported file"); |
651 | debug_out_str("\n\rUnsupported file"); |
652 | return 0; |
652 | return 0; |
653 | 653 | ||
654 | play: |
654 | play: |
655 | 655 | ||
656 | status = ST_PLAY; |
656 | status = ST_PLAY; |
657 | SetFormat(hBuff, fmt); |
657 | SetFormat(hBuff, fmt); |
658 | SetVolume(hBuff,l_vol,r_vol); |
658 | SetVolume(hBuff,l_vol,r_vol); |
659 | GetVolume(hBuff,&l_vol,&r_vol); |
659 | GetVolume(hBuff,&l_vol,&r_vol); |
660 | 660 | ||
661 | return 1; |
661 | return 1; |
662 | } |
662 | } |
663 | 663 | ||
664 | int main(int argc, char *argv[]) |
664 | int main(int argc, char *argv[]) |
665 | { |
665 | { |
666 | int err, ver; |
666 | int err, ver; |
667 | int i; |
667 | int i; |
668 | char ipc_msg[2]="\0\0"; |
668 | char ipc_msg[2]="\0\0"; |
669 | pl_items_number=0; |
669 | pl_items_number=0; |
670 | 670 | ||
671 | if (argv[1][0]=='-' && argv[1][1]=='h') |
671 | if (argv[1][0]=='-' && argv[1][1]=='h') |
672 | { |
672 | { |
673 | hidden = 1; |
673 | hidden = 1; |
674 | argv[1]+=3; |
674 | argv[1]+=3; |
675 | } |
675 | } |
676 | strcpy (full_filename, argv[1]); |
676 | strcpy (full_filename, argv[1]); |
677 | 677 | ||
678 | InitHeap(1024*1024); |
678 | InitHeap(1024*1024); |
679 | 679 | ||
680 | if(err = InitSound(&ver)) |
680 | if(err = InitSound(&ver)) |
681 | { |
681 | { |
682 | debug_out_str("Sound service not installed\n\r"); |
682 | debug_out_str("Sound service not installed\n\r"); |
683 | return 0; |
683 | return 0; |
684 | } |
684 | } |
685 | 685 | ||
686 | if( (SOUND_VERSION>(ver&0xFFFF)) || |
686 | if( (SOUND_VERSION>(ver&0xFFFF)) || |
687 | (SOUND_VERSION<(ver >> 16))) |
687 | (SOUND_VERSION<(ver >> 16))) |
688 | { |
688 | { |
689 | debug_out_str("Sound service version mismatch\n\r"); |
689 | debug_out_str("Sound service version mismatch\n\r"); |
690 | return 0; |
690 | return 0; |
691 | } |
691 | } |
692 | 692 | ||
693 | if (err = CreateBuffer(PCM_2_16_48, 0, &hBuff)) |
693 | if (err = CreateBuffer(PCM_2_16_48, 0, &hBuff)) |
694 | { |
694 | { |
695 | debug_out_str("create buffer return error\n\r"); |
695 | debug_out_str("create buffer return error\n\r"); |
696 | return 0; |
696 | return 0; |
697 | } |
697 | } |
698 | 698 | ||
699 | if (!LoadFile(full_filename)) |
699 | if (!LoadFile(full_filename)) |
700 | return 0; |
700 | return 0; |
701 | tid=create_thread(thread_proc, 0, 4096); |
701 | tid=create_thread(thread_proc, 0, 4096); |
702 | 702 | ||
703 | while(1) |
703 | while(1) |
704 | { delay(10); |
704 | { delay(10); |
705 | switch(status) |
705 | switch(status) |
706 | { case ST_TRACK: |
706 | { case ST_TRACK: |
707 | StopBuffer(hBuff); |
707 | StopBuffer(hBuff); |
708 | if (LoadTrack(++currActive)) |
708 | if (LoadTrack(++currActive)) |
709 | { |
709 | { |
710 | if (LoadFile(full_filename)) |
710 | if (LoadFile(full_filename)) |
711 | status = ST_PLAY; |
711 | status = ST_PLAY; |
712 | } |
712 | } |
713 | else |
713 | else |
714 | { |
714 | { |
715 | currSelected=currFirstShowed=0; |
715 | currSelected=currFirstShowed=0; |
716 | currActive=-1; |
716 | currActive=-1; |
717 | if (!replay) status = ST_STOP; |
717 | if (!replay) status = ST_STOP; |
718 | continue; |
718 | continue; |
719 | } |
719 | } |
720 | 720 | ||
721 | //Update ac97snd and PL windows |
721 | //Update ac97snd and PL windows |
722 | i=currActive-currFirstShowed; |
722 | i=currActive-currFirstShowed; |
723 | if (i>PL_MAX_SHOWN_ITEMS-1) |
723 | if (i>PL_MAX_SHOWN_ITEMS-1) |
724 | currFirstShowed = currActive - PL_MAX_SHOWN_ITEMS/2; |
724 | currFirstShowed = currActive - PL_MAX_SHOWN_ITEMS/2; |
725 | ipc_send_msg(tid, ipc_msg); |
725 | ipc_send_msg(tid, ipc_msg); |
726 | ipc_send_msg(pl_tid, ipc_msg); |
726 | ipc_send_msg(pl_tid, ipc_msg); |
727 | continue; |
727 | continue; |
728 | 728 | ||
729 | case ST_PLAY: |
729 | case ST_PLAY: |
730 | snd_play(); |
730 | snd_play(); |
731 | continue; |
731 | continue; |
732 | 732 | ||
733 | case ST_STOP: |
733 | case ST_STOP: |
734 | StopBuffer(hBuff); |
734 | StopBuffer(hBuff); |
735 | status = ST_DONE; |
735 | status = ST_DONE; |
736 | continue; |
736 | continue; |
737 | 737 | ||
738 | case ST_EXIT: |
738 | case ST_EXIT: |
739 | uFMOD_StopSong(); /* uFMOD integration */ |
739 | uFMOD_StopSong(); /* uFMOD integration */ |
740 | StopBuffer(hBuff); |
740 | StopBuffer(hBuff); |
741 | DestroyBuffer(hBuff); |
741 | DestroyBuffer(hBuff); |
742 | return 0; |
742 | return 0; |
743 | }; |
743 | }; |
744 | }; |
744 | }; |
745 | return 0; |
745 | return 0; |
746 | }; |
746 | }; |
747 | 747 | ||
748 | void touch(char *buf, int size) |
748 | void touch(char *buf, int size) |
749 | { int i; |
749 | { int i; |
750 | char a; |
750 | char a; |
751 | for ( i = 0;i < size; i+=4096) //alloc all pages |
751 | for ( i = 0;i < size; i+=4096) //alloc all pages |
752 | a = buf[i]; |
752 | a = buf[i]; |
753 | }; |
753 | }; |
754 | 754 | ||
755 | DWORD test_m3u(char *buf) //Asper+ |
755 | DWORD test_m3u(char *buf) //Asper+ |
756 | { |
756 | { |
757 | char *sign="#EXTM3U"; |
757 | char *sign="#EXTM3U"; |
758 | return _strncmp(buf, sign, 7); |
758 | return _strncmp(buf, sign, 7); |
759 | } |
759 | } |
760 | 760 | ||
761 | DWORD test_mp3(char *buf) |
761 | DWORD test_mp3(char *buf) |
762 | { unsigned long hdr; |
762 | { unsigned long hdr; |
763 | WAVEHEADER whdr; |
763 | WAVEHEADER whdr; |
- | 764 | int attempts = 0; |
|
764 | 765 | ||
765 | while (1) |
766 | for (;;attempts++) |
766 | { if(rd.filepos > 102400) |
767 | { if(attempts > 1000) |
767 | return 0; |
768 | return 0; |
768 | if(!rd.head_read(&rd,&hdr)) |
769 | if(!rd.head_read(&rd,&hdr)) |
769 | return 0; |
770 | return 0; |
770 | if(!decode_header(&fr,hdr)) |
771 | if(!decode_header(&fr,hdr)) |
771 | { |
772 | { |
772 | if((hdr & 0xffffff00) == 0x49443300) |
773 | if((hdr & 0xffffff00) == 0x49443300) |
773 | { |
774 | { |
774 | int id3length = 0; |
775 | int id3length = 0; |
775 | id3length = parse_new_id3(&rd, hdr); |
776 | id3length = parse_new_id3(&rd, hdr); |
776 | continue; |
777 | continue; |
777 | }; |
778 | }; |
778 | rd.strpos-=3; |
779 | rd.strpos-=3; |
779 | rd.stream-=3; |
780 | rd.stream-=3; |
780 | rd.strremain+=3; |
781 | rd.strremain+=3; |
781 | continue; |
782 | continue; |
782 | }; |
783 | }; |
783 | break; |
784 | break; |
784 | }; |
785 | }; |
785 | 786 | ||
786 | first_sync = rd.filepos-rd.strremain-4; |
787 | first_sync = rd.filepos-rd.strremain-4; |
787 | 788 | ||
788 | whdr.riff_id = 0x46464952; |
789 | whdr.riff_id = 0x46464952; |
789 | whdr.riff_format = 0x45564157; |
790 | whdr.riff_format = 0x45564157; |
790 | whdr.wFormatTag = 0x01; |
791 | whdr.wFormatTag = 0x01; |
791 | whdr.nSamplesPerSec = freqs[fr.sampling_frequency]; |
792 | whdr.nSamplesPerSec = freqs[fr.sampling_frequency]; |
792 | whdr.nChannels = 2; |
793 | whdr.nChannels = 2; |
793 | whdr.wBitsPerSample = 16; |
794 | whdr.wBitsPerSample = 16; |
794 | 795 | ||
795 | return test_wav(&whdr); |
796 | return test_wav(&whdr); |
796 | }; |
797 | }; |
797 | 798 | ||
798 | 799 | ||
799 | void play_mp3() |
800 | void play_mp3() |
800 | { char *outPtr; |
801 | { char *outPtr; |
801 | int totalout; |
802 | int totalout; |
802 | int outcount; |
803 | int outcount; |
803 | 804 | ||
804 | // memset(&fr,0,sizeof(fr)); |
805 | // memset(&fr,0,sizeof(fr)); |
805 | fr.down_sample_sblimit = 32; |
806 | fr.down_sample_sblimit = 32; |
806 | fr.single = -1; |
807 | fr.single = -1; |
807 | reset_mpg(); |
808 | reset_mpg(); |
808 | 809 | ||
809 | outPtr = outbuf; |
810 | outPtr = outbuf; |
810 | totalout=0; |
811 | totalout=0; |
811 | done = 0; |
812 | done = 0; |
812 | outremain=0x40000; |
813 | outremain=0x40000; |
813 | 814 | ||
814 | memset(outbuf,0,0x40000); |
815 | memset(outbuf,0,0x40000); |
815 | set_reader(&rd, 0); //;first_sync); |
816 | set_reader(&rd, 0); //;first_sync); |
816 | 817 | ||
817 | while(1) |
818 | while(1) |
818 | { if(status!=ST_PLAY) |
819 | { if(status!=ST_PLAY) |
819 | break; |
820 | break; |
820 | 821 | ||
821 | for(;;) |
822 | for(;;) |
822 | { outcount = 0; |
823 | { outcount = 0; |
823 | if( !read_frame(&rd, &fr)) |
824 | if( !read_frame(&rd, &fr)) |
824 | { done = 1; |
825 | { done = 1; |
825 | break; |
826 | break; |
826 | }; |
827 | }; |
827 | fr.do_layer(&fr, outPtr,&outcount); |
828 | fr.do_layer(&fr, outPtr,&outcount); |
828 | outPtr+= outcount; |
829 | outPtr+= outcount; |
829 | totalout+=outcount; |
830 | totalout+=outcount; |
830 | outremain-=outcount; |
831 | outremain-=outcount; |
831 | if(outremain < outcount*2) |
832 | if(outremain < outcount*2) |
832 | break; |
833 | break; |
833 | }; |
834 | }; |
834 | 835 | ||
835 | if(done) |
836 | if(done) |
836 | { if(totalout < 4096) |
837 | { if(totalout < 4096) |
837 | { memset(outPtr,0,4096-totalout); |
838 | { memset(outPtr,0,4096-totalout); |
838 | totalout = 4096; |
839 | totalout = 4096; |
839 | }; |
840 | }; |
840 | } |
841 | } |
841 | else |
842 | else |
842 | if(totalout < 8192) |
843 | if(totalout < 8192) |
843 | continue; |
844 | continue; |
844 | 845 | ||
845 | outPtr = outbuf; |
846 | outPtr = outbuf; |
846 | while (totalout >= 4096) |
847 | while (totalout >= 4096) |
847 | { |
848 | { |
848 | 849 | ||
849 | WaveOut(hBuff,outPtr,4096); |
850 | WaveOut(hBuff,outPtr,4096); |
850 | if(status!=ST_PLAY) |
851 | if(status!=ST_PLAY) |
851 | { if ((status != ST_EXIT) && (status != ST_STOP)) |
852 | { if ((status != ST_EXIT) && (status != ST_STOP)) |
852 | status = ST_TRACK; |
853 | status = ST_TRACK; |
853 | return; |
854 | return; |
854 | }; |
855 | }; |
855 | totalout-=4096; |
856 | totalout-=4096; |
856 | outPtr+=4096; |
857 | outPtr+=4096; |
857 | outremain+=4096; |
858 | outremain+=4096; |
858 | }; |
859 | }; |
859 | if(done) |
860 | if(done) |
860 | break; |
861 | break; |
861 | 862 | ||
862 | memmove(outbuf,outPtr, totalout); |
863 | memmove(outbuf,outPtr, totalout); |
863 | outPtr = outbuf+totalout; |
864 | outPtr = outbuf+totalout; |
864 | } |
865 | } |
865 | 866 | ||
866 | if ((status != ST_EXIT) && (status != ST_STOP)) |
867 | if ((status != ST_EXIT) && (status != ST_STOP)) |
867 | status = ST_TRACK; |
868 | status = ST_TRACK; |
868 | }; |
869 | }; |
869 | 870 | ||
870 | void play_wave() |
871 | void play_wave() |
871 | { int count; |
872 | { int count; |
872 | 873 | ||
873 | set_reader(&rd,44); |
874 | set_reader(&rd,44); |
874 | while(1) |
875 | while(1) |
875 | { |
876 | { |
876 | if(status!=ST_PLAY) |
877 | if(status!=ST_PLAY) |
877 | break; |
878 | break; |
878 | 879 | ||
879 | if( count=stream_read_raw(&rd,outbuf,32768)) |
880 | if( count=stream_read_raw(&rd,outbuf,32768)) |
880 | { |
881 | { |
881 | WaveOut(hBuff,outbuf,count); |
882 | WaveOut(hBuff,outbuf,count); |
882 | continue; |
883 | continue; |
883 | } |
884 | } |
884 | done = 1; |
885 | done = 1; |
885 | break; |
886 | break; |
886 | }; |
887 | }; |
887 | 888 | ||
888 | if ((status != ST_EXIT) && (status != ST_STOP)) |
889 | if ((status != ST_EXIT) && (status != ST_STOP)) |
889 | status = ST_TRACK; |
890 | status = ST_TRACK; |
890 | }; |
891 | }; |
891 | 892 | ||
892 | void play_xm(){ /* uFMOD integration */ |
893 | void play_xm(){ /* uFMOD integration */ |
893 | while(status == ST_PLAY){ /* uFMOD integration */ |
894 | while(status == ST_PLAY){ /* uFMOD integration */ |
894 | uFMOD_WaveOut(hBuff); /* uFMOD integration */ |
895 | uFMOD_WaveOut(hBuff); /* uFMOD integration */ |
895 | delay(8); /* uFMOD integration */ |
896 | delay(8); /* uFMOD integration */ |
896 | } /* uFMOD integration */ |
897 | } /* uFMOD integration */ |
897 | if ((status != ST_EXIT) && (status != ST_STOP)) status = ST_TRACK; /* uFMOD integration */ |
898 | if ((status != ST_EXIT) && (status != ST_STOP)) status = ST_TRACK; /* uFMOD integration */ |
898 | } /* uFMOD integration */ |
899 | } /* uFMOD integration */ |
899 | 900 | ||
900 | void snd_stop() |
901 | void snd_stop() |
901 | { |
902 | { |
902 | StopBuffer(hBuff); |
903 | StopBuffer(hBuff); |
903 | }; |
904 | }; |
904 | 905 | ||
905 | void _stdcall thread_proc(void *param) |
906 | void _stdcall thread_proc(void *param) |
906 | { int evnt; |
907 | { int evnt; |
907 | int pos; |
908 | int pos; |
908 | int key; |
909 | int key; |
909 | DWORD offset; |
910 | DWORD offset; |
910 | char ipc_buff[16]; |
911 | char ipc_buff[16]; |
911 | 912 | ||
912 | set_event_mask(0x47); //Asper + IPC event |
913 | set_event_mask(0x47); //Asper + IPC event |
913 | ipc_init(ipc_buff, 16); |
914 | ipc_init(ipc_buff, 16); |
914 | 915 | ||
915 | _asm |
916 | _asm |
916 | { |
917 | { |
917 | mov eax, 66 |
918 | mov eax, 66 |
918 | mov ebx, 1 |
919 | mov ebx, 1 |
919 | mov ecx, 1 |
920 | mov ecx, 1 |
920 | int 0x40 |
921 | int 0x40 |
921 | }; |
922 | }; |
922 | 923 | ||
923 | draw_window(); |
924 | draw_window(); |
924 | 925 | ||
925 | while(1) |
926 | while(1) |
926 | { |
927 | { |
927 | if(status==ST_PLAY) |
928 | if(status==ST_PLAY) |
928 | { draw_progress_bar(); |
929 | { draw_progress_bar(); |
929 | evnt = wait_for_event(80); |
930 | evnt = wait_for_event(80); |
930 | } |
931 | } |
931 | else |
932 | else |
932 | evnt = wait_for_event_infinite(); |
933 | evnt = wait_for_event_infinite(); |
933 | 934 | ||
934 | #ifdef DOCKABLE_WINDOW |
935 | #ifdef DOCKABLE_WINDOW |
935 | GetThreadInfo(thread_info, -1); |
936 | GetThreadInfo(thread_info, -1); |
936 | #endif |
937 | #endif |
937 | 938 | ||
938 | switch(evnt) |
939 | switch(evnt) |
939 | { |
940 | { |
940 | case EV_REDRAW: |
941 | case EV_REDRAW: |
941 | draw_window(); |
942 | draw_window(); |
942 | break; |
943 | break; |
943 | 944 | ||
944 | case EV_KEY: |
945 | case EV_KEY: |
945 | if(!get_key(&key)) |
946 | if(!get_key(&key)) |
946 | { |
947 | { |
947 | 948 | ||
948 | switch(key) |
949 | switch(key) |
949 | { case 0xE0: |
950 | { case 0xE0: |
950 | case 0xE1: |
951 | case 0xE1: |
951 | break; |
952 | break; |
952 | default: |
953 | default: |
953 | switch (key) |
954 | switch (key) |
954 | { |
955 | { |
955 | case 0x01: //Esc |
956 | case 0x01: //Esc |
956 | status = ST_EXIT; |
957 | status = ST_EXIT; |
957 | exit(); |
958 | exit(); |
958 | break; |
959 | break; |
959 | 960 | ||
960 | case 0x13: //R - repeat on/off |
961 | case 0x13: //R - repeat on/off |
961 | replay=!replay; |
962 | replay=!replay; |
962 | redraw_R_button(); |
963 | redraw_R_button(); |
963 | break; |
964 | break; |
964 | 965 | ||
965 | case 0x19: //P - playlist |
966 | case 0x19: //P - playlist |
966 | switch (PLStatus) |
967 | switch (PLStatus) |
967 | { case 0x00: //PL not started. |
968 | { case 0x00: //PL not started. |
968 | pl_tid=create_thread(pl_thread_proc, 0, 4096); |
969 | pl_tid=create_thread(pl_thread_proc, 0, 4096); |
969 | PLStatus=0x12; |
970 | PLStatus=0x12; |
970 | break; |
971 | break; |
971 | case 0x01: //PL started, but hidden. |
972 | case 0x01: //PL started, but hidden. |
972 | PLStatus=0x12; |
973 | PLStatus=0x12; |
973 | break; |
974 | break; |
974 | case 0x02: //PL started and showed. |
975 | case 0x02: //PL started and showed. |
975 | PLStatus=0x11; |
976 | PLStatus=0x11; |
976 | break; |
977 | break; |
977 | } |
978 | } |
978 | break; |
979 | break; |
979 | 980 | ||
980 | case 0x2C: //Z - previous |
981 | case 0x2C: //Z - previous |
981 | currActive-=2; |
982 | currActive-=2; |
982 | status = ST_TRACK; |
983 | status = ST_TRACK; |
983 | break; |
984 | break; |
984 | 985 | ||
985 | case 0x2D: //X - play |
986 | case 0x2D: //X - play |
986 | status = ST_PLAY; |
987 | status = ST_PLAY; |
987 | break; |
988 | break; |
988 | 989 | ||
989 | case 0x2E: //C - pause |
990 | case 0x2E: //C - pause |
990 | break; |
991 | break; |
991 | 992 | ||
992 | case 0x2F: //V - stop |
993 | case 0x2F: //V - stop |
993 | status = ST_STOP; |
994 | status = ST_STOP; |
994 | break; |
995 | break; |
995 | 996 | ||
996 | case 0x30: //B - next |
997 | case 0x30: //B - next |
997 | status = ST_TRACK; |
998 | status = ST_TRACK; |
998 | break; |
999 | break; |
999 | 1000 | ||
1000 | case 0x47: //Home |
1001 | case 0x47: //Home |
1001 | if(l_vol < 0) |
1002 | if(l_vol < 0) |
1002 | { l_vol+=100; |
1003 | { l_vol+=100; |
1003 | r_vol+=100; |
1004 | r_vol+=100; |
1004 | SetVolume(hBuff,l_vol,r_vol); |
1005 | SetVolume(hBuff,l_vol,r_vol); |
1005 | }; |
1006 | }; |
1006 | break; |
1007 | break; |
1007 | case 0x4F: //End |
1008 | case 0x4F: //End |
1008 | if(l_vol > -10000) |
1009 | if(l_vol > -10000) |
1009 | { l_vol-=100; |
1010 | { l_vol-=100; |
1010 | r_vol-=100; |
1011 | r_vol-=100; |
1011 | SetVolume(hBuff,l_vol,r_vol); |
1012 | SetVolume(hBuff,l_vol,r_vol); |
1012 | }; |
1013 | }; |
1013 | break; |
1014 | break; |
1014 | case 0x53: |
1015 | case 0x53: |
1015 | if(pan > -10000) |
1016 | if(pan > -10000) |
1016 | { pan -=100; |
1017 | { pan -=100; |
1017 | SetPan(hBuff,pan); |
1018 | SetPan(hBuff,pan); |
1018 | }; |
1019 | }; |
1019 | break; |
1020 | break; |
1020 | case 0x51: |
1021 | case 0x51: |
1021 | if(pan < 10000) |
1022 | if(pan < 10000) |
1022 | { pan +=100; |
1023 | { pan +=100; |
1023 | SetPan(hBuff,pan); |
1024 | SetPan(hBuff,pan); |
1024 | }; |
1025 | }; |
1025 | break; |
1026 | break; |
1026 | } |
1027 | } |
1027 | }; |
1028 | }; |
1028 | }; |
1029 | }; |
1029 | break; |
1030 | break; |
1030 | 1031 | ||
1031 | case EV_BUTTON: |
1032 | case EV_BUTTON: |
1032 | switch(get_button_id()) |
1033 | switch(get_button_id()) |
1033 | { case 1: |
1034 | { case 1: |
1034 | status = ST_EXIT; |
1035 | status = ST_EXIT; |
1035 | exit(); |
1036 | exit(); |
1036 | break; |
1037 | break; |
1037 | 1038 | ||
1038 | case 0x10: |
1039 | case 0x10: |
1039 | status = ST_PLAY; |
1040 | status = ST_PLAY; |
1040 | break;//continue; |
1041 | break;//continue; |
1041 | 1042 | ||
1042 | case 0x11: |
1043 | case 0x11: |
1043 | status = ST_STOP; |
1044 | status = ST_STOP; |
1044 | break; |
1045 | break; |
1045 | case 0x12: |
1046 | case 0x12: |
1046 | currActive-=2; |
1047 | currActive-=2; |
1047 | status = ST_TRACK; |
1048 | status = ST_TRACK; |
1048 | break; |
1049 | break; |
1049 | case 0x13: |
1050 | case 0x13: |
1050 | status = ST_TRACK; |
1051 | status = ST_TRACK; |
1051 | break; |
1052 | break; |
1052 | case 0x14: |
1053 | case 0x14: |
1053 | if(l_vol > -10000) |
1054 | if(l_vol > -10000) |
1054 | { |
1055 | { |
1055 | l_vol-=100; |
1056 | l_vol-=100; |
1056 | r_vol-=100; |
1057 | r_vol-=100; |
1057 | SetVolume(hBuff,l_vol,r_vol); |
1058 | SetVolume(hBuff,l_vol,r_vol); |
1058 | }; |
1059 | }; |
1059 | break; |
1060 | break; |
1060 | 1061 | ||
1061 | case 0x15: |
1062 | case 0x15: |
1062 | if(l_vol < 0) |
1063 | if(l_vol < 0) |
1063 | { l_vol+=100; |
1064 | { l_vol+=100; |
1064 | r_vol+=100; |
1065 | r_vol+=100; |
1065 | SetVolume(hBuff,l_vol,r_vol); |
1066 | SetVolume(hBuff,l_vol,r_vol); |
1066 | }; |
1067 | }; |
1067 | break; |
1068 | break; |
1068 | 1069 | ||
1069 | case 0x16: //Asper+ PL button action |
1070 | case 0x16: //Asper+ PL button action |
1070 | switch (PLStatus) |
1071 | switch (PLStatus) |
1071 | { case 0x00: //PL not started. |
1072 | { case 0x00: //PL not started. |
1072 | pl_tid=create_thread(pl_thread_proc, 0, 4096); |
1073 | pl_tid=create_thread(pl_thread_proc, 0, 4096); |
1073 | PLStatus=0x12; |
1074 | PLStatus=0x12; |
1074 | break; |
1075 | break; |
1075 | case 0x01: //PL started, but hidden. |
1076 | case 0x01: //PL started, but hidden. |
1076 | PLStatus=0x12; |
1077 | PLStatus=0x12; |
1077 | break; |
1078 | break; |
1078 | case 0x02: //PL started and showed. |
1079 | case 0x02: //PL started and showed. |
1079 | PLStatus=0x11; |
1080 | PLStatus=0x11; |
1080 | break; |
1081 | break; |
1081 | } |
1082 | } |
1082 | break; |
1083 | break; |
1083 | case 0x17: //Asper+ PL button action |
1084 | case 0x17: //Asper+ PL button action |
1084 | replay=!replay; |
1085 | replay=!replay; |
1085 | redraw_R_button(); |
1086 | redraw_R_button(); |
1086 | break; |
1087 | break; |
1087 | 1088 | ||
1088 | case 0x30: |
1089 | case 0x30: |
1089 | if(status==ST_DONE) |
1090 | if(status==ST_DONE) |
1090 | break; |
1091 | break; |
1091 | pos = (GetMousePos(REL_WINDOW)>>16)-7; |
1092 | pos = (GetMousePos(REL_WINDOW)>>16)-7; |
1092 | offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC; |
1093 | offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC; |
1093 | set_reader(&rd, offset); |
1094 | set_reader(&rd, offset); |
1094 | draw_progress_bar(); |
1095 | draw_progress_bar(); |
1095 | break; |
1096 | break; |
1096 | }; |
1097 | }; |
1097 | break; |
1098 | break; |
1098 | 1099 | ||
1099 | case EV_IPC: |
1100 | case EV_IPC: |
1100 | *ipc_buff='\0'; |
1101 | *ipc_buff='\0'; |
1101 | update_dynamic_content(); |
1102 | update_dynamic_content(); |
1102 | break; |
1103 | break; |
1103 | 1104 | ||
1104 | }; |
1105 | }; |
1105 | }; |
1106 | }; |
1106 | }; |
1107 | }; |
1107 | 1108 | ||
1108 | void delay (int val) |
1109 | void delay (int val) |
1109 | { |
1110 | { |
1110 | _asm |
1111 | _asm |
1111 | { |
1112 | { |
1112 | mov eax,5 |
1113 | mov eax,5 |
1113 | mov ebx, [val] |
1114 | mov ebx, [val] |
1114 | int 0x40 |
1115 | int 0x40 |
1115 | }; |
1116 | }; |
1116 | } |
1117 | } |
1117 | 1118 | ||
1118 | int wait_for_event(int time) |
1119 | int wait_for_event(int time) |
1119 | { int retval; |
1120 | { int retval; |
1120 | _asm |
1121 | _asm |
1121 | { |
1122 | { |
1122 | mov eax,23 |
1123 | mov eax,23 |
1123 | mov ebx,[time] |
1124 | mov ebx,[time] |
1124 | int 0x40 |
1125 | int 0x40 |
1125 | mov [retval], eax |
1126 | mov [retval], eax |
1126 | }; |
1127 | }; |
1127 | return retval; |
1128 | return retval; |
1128 | }; |
1129 | }; |
1129 | 1130 | ||
1130 | int wait_for_event_infinite() |
1131 | int wait_for_event_infinite() |
1131 | { int retval; |
1132 | { int retval; |
1132 | _asm |
1133 | _asm |
1133 | { |
1134 | { |
1134 | mov eax,10 |
1135 | mov eax,10 |
1135 | int 0x40 |
1136 | int 0x40 |
1136 | mov [retval], eax |
1137 | mov [retval], eax |
1137 | }; |
1138 | }; |
1138 | return retval; |
1139 | return retval; |
1139 | }; |
1140 | }; |
1140 | 1141 | ||
1141 | void BeginDraw() |
1142 | void BeginDraw() |
1142 | {_asm |
1143 | {_asm |
1143 | { |
1144 | { |
1144 | mov eax,12 |
1145 | mov eax,12 |
1145 | mov ebx, 1 |
1146 | mov ebx, 1 |
1146 | int 0x40 |
1147 | int 0x40 |
1147 | }; |
1148 | }; |
1148 | }; |
1149 | }; |
1149 | 1150 | ||
1150 | void EndDraw() |
1151 | void EndDraw() |
1151 | { _asm |
1152 | { _asm |
1152 | { |
1153 | { |
1153 | mov eax,12 |
1154 | mov eax,12 |
1154 | mov ebx, 2 |
1155 | mov ebx, 2 |
1155 | int 0x40 |
1156 | int 0x40 |
1156 | }; |
1157 | }; |
1157 | }; |
1158 | }; |
1158 | 1159 | ||
1159 | //Asper+_______start KolibriOS sys functions___________________ |
1160 | //Asper+_______start KolibriOS sys functions___________________ |
1160 | void ResizeReplaceWindow (DWORD x, DWORD y, DWORD w, DWORD h) //Asper+ |
1161 | void ResizeReplaceWindow (DWORD x, DWORD y, DWORD w, DWORD h) //Asper+ |
1161 | { |
1162 | { |
1162 | _asm |
1163 | _asm |
1163 | { |
1164 | { |
1164 | mov eax, 67 |
1165 | mov eax, 67 |
1165 | mov ebx, [x] |
1166 | mov ebx, [x] |
1166 | mov ecx, [y] |
1167 | mov ecx, [y] |
1167 | mov edx, [w] |
1168 | mov edx, [w] |
1168 | mov esi, [h] |
1169 | mov esi, [h] |
1169 | int 0x40 |
1170 | int 0x40 |
1170 | }; |
1171 | }; |
1171 | } |
1172 | } |
1172 | 1173 | ||
1173 | #ifdef DOCKABLE_WINDOW |
1174 | #ifdef DOCKABLE_WINDOW |
1174 | void GetThreadInfo (char *info, int slot) //Asper+ |
1175 | void GetThreadInfo (char *info, int slot) //Asper+ |
1175 | { |
1176 | { |
1176 | _asm |
1177 | _asm |
1177 | { |
1178 | { |
1178 | mov eax, 9 |
1179 | mov eax, 9 |
1179 | mov ebx, [info] |
1180 | mov ebx, [info] |
1180 | mov ecx, [slot] |
1181 | mov ecx, [slot] |
1181 | int 0x40 |
1182 | int 0x40 |
1182 | } |
1183 | } |
1183 | } |
1184 | } |
1184 | #endif |
1185 | #endif |
1185 | 1186 | ||
1186 | void set_event_mask(int mask) |
1187 | void set_event_mask(int mask) |
1187 | { |
1188 | { |
1188 | _asm |
1189 | _asm |
1189 | { |
1190 | { |
1190 | mov eax, 40 |
1191 | mov eax, 40 |
1191 | mov ebx, [mask] |
1192 | mov ebx, [mask] |
1192 | int 0x40 |
1193 | int 0x40 |
1193 | } |
1194 | } |
1194 | } |
1195 | } |
1195 | 1196 | ||
1196 | void ipc_init(char *buf, int bufsize) |
1197 | void ipc_init(char *buf, int bufsize) |
1197 | { |
1198 | { |
1198 | _asm |
1199 | _asm |
1199 | { |
1200 | { |
1200 | mov eax, 60 |
1201 | mov eax, 60 |
1201 | mov ebx, 1 |
1202 | mov ebx, 1 |
1202 | mov ecx, [buf] |
1203 | mov ecx, [buf] |
1203 | mov edx, [bufsize] |
1204 | mov edx, [bufsize] |
1204 | int 0x40 |
1205 | int 0x40 |
1205 | } |
1206 | } |
1206 | } |
1207 | } |
1207 | 1208 | ||
1208 | int ipc_send_msg(int PID, char *msg) |
1209 | int ipc_send_msg(int PID, char *msg) |
1209 | { |
1210 | { |
1210 | int len = strlen(msg); |
1211 | int len = strlen(msg); |
1211 | int retval; |
1212 | int retval; |
1212 | _asm |
1213 | _asm |
1213 | { |
1214 | { |
1214 | mov eax, 60 |
1215 | mov eax, 60 |
1215 | mov ebx, 2 |
1216 | mov ebx, 2 |
1216 | mov ecx, [PID] |
1217 | mov ecx, [PID] |
1217 | mov edx, [msg] |
1218 | mov edx, [msg] |
1218 | mov esi, [len] |
1219 | mov esi, [len] |
1219 | int 0x40 |
1220 | int 0x40 |
1220 | mov [retval], eax |
1221 | mov [retval], eax |
1221 | } |
1222 | } |
1222 | } |
1223 | } |
1223 | //Asper+_______end KolibriOS sys functions___________________ |
1224 | //Asper+_______end KolibriOS sys functions___________________ |
1224 | 1225 | ||
1225 | //Asper+_______start strings routines___________________ |
1226 | //Asper+_______start strings routines___________________ |
1226 | int _strncmp(char *src, char *dst, DWORD n) |
1227 | int _strncmp(char *src, char *dst, DWORD n) |
1227 | { |
1228 | { |
1228 | _asm{ |
1229 | _asm{ |
1229 | mov esi, src |
1230 | mov esi, src |
1230 | mov edi, dst |
1231 | mov edi, dst |
1231 | mov ecx, n |
1232 | mov ecx, n |
1232 | } |
1233 | } |
1233 | l1: |
1234 | l1: |
1234 | _asm{ |
1235 | _asm{ |
1235 | cmpsb |
1236 | cmpsb |
1236 | jne err |
1237 | jne err |
1237 | loop l1 |
1238 | loop l1 |
1238 | } |
1239 | } |
1239 | return 1; |
1240 | return 1; |
1240 | err: |
1241 | err: |
1241 | return 0; |
1242 | return 0; |
1242 | } |
1243 | } |
1243 | 1244 | ||
1244 | int _strncpy (char *dst, char *src, int n) |
1245 | int _strncpy (char *dst, char *src, int n) |
1245 | { |
1246 | { |
1246 | int i; |
1247 | int i; |
1247 | for (i=0; i |
1248 | for (i=0; i |
1248 | { |
1249 | { |
1249 | dst[i]=src[i]; |
1250 | dst[i]=src[i]; |
1250 | if (src[i]=='\0') break; |
1251 | if (src[i]=='\0') break; |
1251 | } |
1252 | } |
1252 | return 0; |
1253 | return 0; |
1253 | } |
1254 | } |
1254 | 1255 | ||
1255 | void uint2str(unsigned int value, char *string) |
1256 | void uint2str(unsigned int value, char *string) |
1256 | { |
1257 | { |
1257 | char tmp[33]; |
1258 | char tmp[33]; |
1258 | int i, j; |
1259 | int i, j; |
1259 | unsigned v; |
1260 | unsigned v; |
1260 | 1261 | ||
1261 | v = (unsigned)value; |
1262 | v = (unsigned)value; |
1262 | j = 0; |
1263 | j = 0; |
1263 | do{ |
1264 | do{ |
1264 | i = v % 10; |
1265 | i = v % 10; |
1265 | v = v / 10; |
1266 | v = v / 10; |
1266 | if (i < 10) |
1267 | if (i < 10) |
1267 | tmp[j] = i+'0'; |
1268 | tmp[j] = i+'0'; |
1268 | else |
1269 | else |
1269 | tmp[j] = i + 'a' - 10; |
1270 | tmp[j] = i + 'a' - 10; |
1270 | j++; |
1271 | j++; |
1271 | }while (v); |
1272 | }while (v); |
1272 | 1273 | ||
1273 | for (i=0; i |
1274 | for (i=0; i |
1274 | string[i] = tmp[j-i-1]; |
1275 | string[i] = tmp[j-i-1]; |
1275 | string[i] = '\0'; |
1276 | string[i] = '\0'; |
1276 | } |
1277 | } |
1277 | 1278 | ||
1278 | //Asper+_______end strings routines___________________ |
1279 | //Asper+_______end strings routines___________________ |
1279 | 1280 | ||
1280 | 1281 | ||
1281 | ///********* |
1282 | ///********* |
1282 | void * __cdecl memmove ( void * dst, const void * src, unsigned int count) /* uFMOD integration */ |
1283 | void * __cdecl memmove ( void * dst, const void * src, unsigned int count) /* uFMOD integration */ |
1283 | { void *ret; |
1284 | { void *ret; |
1284 | ret = dst; |
1285 | ret = dst; |
1285 | 1286 | ||
1286 | if (dst <= src || (char *)dst >= ((char *)src + count)) |
1287 | if (dst <= src || (char *)dst >= ((char *)src + count)) |
1287 | { |
1288 | { |
1288 | while (count--) |
1289 | while (count--) |
1289 | { *(char *)dst = *(char *)src; |
1290 | { *(char *)dst = *(char *)src; |
1290 | dst = (char *)dst + 1; |
1291 | dst = (char *)dst + 1; |
1291 | src = (char *)src + 1; |
1292 | src = (char *)src + 1; |
1292 | } |
1293 | } |
1293 | } |
1294 | } |
1294 | else |
1295 | else |
1295 | { |
1296 | { |
1296 | dst = (char *)dst + count - 1; |
1297 | dst = (char *)dst + count - 1; |
1297 | src = (char *)src + count - 1; |
1298 | src = (char *)src + count - 1; |
1298 | while (count--) |
1299 | while (count--) |
1299 | { *(char *)dst = *(char *)src; |
1300 | { *(char *)dst = *(char *)src; |
1300 | dst = (char *)dst - 1; |
1301 | dst = (char *)dst - 1; |
1301 | src = (char *)src - 1; |
1302 | src = (char *)src - 1; |
1302 | } |
1303 | } |
1303 | } |
1304 | } |
1304 | return ret; |
1305 | return ret; |
1305 | }; |
1306 | }; |
1306 | //**********/ |
1307 | //**********/ |
1307 | 1308 | ||
1308 | void * __cdecl mem_cpy(void * dst,const void * src,size_t count) |
1309 | void * __cdecl mem_cpy(void * dst,const void * src,size_t count) |
1309 | { void * ret = dst; |
1310 | { void * ret = dst; |
1310 | while (count--) |
1311 | while (count--) |
1311 | { *(char *)dst = *(char *)src; |
1312 | { *(char *)dst = *(char *)src; |
1312 | dst = (char *)dst + 1; |
1313 | dst = (char *)dst + 1; |
1313 | src = (char *)src + 1; |
1314 | src = (char *)src + 1; |
1314 | }; |
1315 | }; |
1315 | return(ret); |
1316 | return(ret); |
1316 | } |
1317 | } |
1317 | 1318 | ||
1318 | char * __cdecl strrchr (const char * string,int ch) |
1319 | char * __cdecl strrchr (const char * string,int ch) |
1319 | { |
1320 | { |
1320 | char *start = (char *)string; |
1321 | char *start = (char *)string; |
1321 | 1322 | ||
1322 | while (*string++) /* find end of string */ |
1323 | while (*string++) /* find end of string */ |
1323 | ; |
1324 | ; |
1324 | /* search towards front */ |
1325 | /* search towards front */ |
1325 | while (--string != start && *string != (char)ch) |
1326 | while (--string != start && *string != (char)ch) |
1326 | ; |
1327 | ; |
1327 | 1328 | ||
1328 | if (*string == (char)ch) /* char found ? */ |
1329 | if (*string == (char)ch) /* char found ? */ |
1329 | return( (char *)string ); |
1330 | return( (char *)string ); |
1330 | 1331 | ||
1331 | return(NULL); |
1332 | return(NULL); |
1332 | } |
1333 | } |
1333 | 1334 | ||
1334 | int __cdecl _stricmp (const char * dst, const char * src) |
1335 | int __cdecl _stricmp (const char * dst, const char * src) |
1335 | { |
1336 | { |
1336 | int f, l; |
1337 | int f, l; |
1337 | 1338 | ||
1338 | do |
1339 | do |
1339 | { |
1340 | { |
1340 | if ( ((f = (unsigned char)(*(dst++))) >= 'A') && (f <= 'Z') ) |
1341 | if ( ((f = (unsigned char)(*(dst++))) >= 'A') && (f <= 'Z') ) |
1341 | f -= 'A' - 'a'; |
1342 | f -= 'A' - 'a'; |
1342 | if ( ((l = (unsigned char)(*(src++))) >= 'A') && (l <= 'Z') ) |
1343 | if ( ((l = (unsigned char)(*(src++))) >= 'A') && (l <= 'Z') ) |
1343 | l -= 'A' - 'a'; |
1344 | l -= 'A' - 'a'; |
1344 | } |
1345 | } |
1345 | while ( f && (f == l) ); |
1346 | while ( f && (f == l) ); |
1346 | 1347 | ||
1347 | return(f - l); |
1348 | return(f - l); |
1348 | }=>=>=>>>>>>>>>(ver>> |
1349 | }=>=>=>>>>>>>>>(ver>> |
1349 | >>><> |
1350 | >>><> |