Rev 8346 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8346 | IgorA | 1 | ; MIDI PLAYER FOR KOLIBRI v1.0 |
1583 | mario79 | 2 | ; Written in pure assembler by Ivushkin Andrey aka Willow |
3 | ; |
||
4 | ; |
||
5 | ; Created: December 7, 2004 |
||
8346 | IgorA | 6 | ; Last changed: December 8, 2020 |
1583 | mario79 | 7 | ; |
8 | ; COMPILE WITH FASM |
||
9 | |||
4620 | hidnplayr | 10 | format binary as "" |
11 | |||
1583 | mario79 | 12 | PLAYLIST_PATH equ '/HD0/1/PLAYLIST.TXT' |
13 | ;APP_MEM equ 150*1024 |
||
14 | |||
15 | IPC_PLAY equ 0xa1 |
||
16 | IPC_PAUS equ 0xa2 |
||
17 | IPC_TRIG equ 0xa3 |
||
18 | IPC_UPDT equ 0xb1 |
||
19 | IPC_NEXT equ 0xb2 |
||
20 | |||
21 | LISTITEMS equ 40 |
||
22 | WND_BACK equ 0x24263c |
||
4620 | hidnplayr | 23 | PLY equ 63 |
1583 | mario79 | 24 | WND_HEIGHT equ (PLY+9*LISTITEMS+10)+25 |
25 | |||
26 | BTNS_XY equ 14 shl 16+42 |
||
27 | BTNS_SIZE equ 222 shl 16+17 |
||
28 | |||
29 | BROWSE_X equ 10 shl 16+8 |
||
30 | BROWSE_Y equ 26 shl 16+8 |
||
4620 | hidnplayr | 31 | FN_XY equ 12 shl 16+15 |
1583 | mario79 | 32 | BAR_WIDTH equ 251 |
4620 | hidnplayr | 33 | BAR_X equ 10 shl 16 |
34 | BAR_Y equ 29 shl 16+5 |
||
1583 | mario79 | 35 | TOTALTIME_XY equ 124 shl 16+28 |
36 | CURTIME_X equ 225 shl 16+40 |
||
37 | CURTIME_Y equ 15 shl 16+11 |
||
38 | CURTIME_XY equ 236 shl 16+15 |
||
39 | |||
40 | NONCRITICAL_MSG equ 0 |
||
41 | SOUND equ ON;OFF |
||
42 | OUTDUMP equ 0 |
||
43 | OUTLINE equ 8 |
||
44 | FL_SHUFFLE equ 0x01 |
||
45 | FL_REPEAT equ 0x02 |
||
46 | FL_HIDDEN equ 0x04 |
||
47 | FL_MUTE equ 0x08 |
||
48 | FL_REVERSE equ 0x10 |
||
4620 | hidnplayr | 49 | FL_ADD equ 0x20 |
1583 | mario79 | 50 | FL_PLAY equ 0x40 |
51 | FL_LOCK equ 0x80 |
||
52 | FL_BOTTRED equ 0x100 |
||
53 | FL_MULSEL equ 0x8000 |
||
54 | |||
55 | use32 |
||
8346 | IgorA | 56 | org 0 |
1583 | mario79 | 57 | |
4620 | hidnplayr | 58 | db 'MENUET01' |
8346 | IgorA | 59 | dd 1, START, IM_END |
4620 | hidnplayr | 60 | dd I_END ;APP_MEM |
61 | dd stacktop ;APP_MEM - 1024 |
||
8346 | IgorA | 62 | dd I_PARAM, cur_dir_path |
1583 | mario79 | 63 | |
64 | listsel dd 0 |
||
65 | channel dd 0 |
||
66 | COLOR_ORDER equ MENUETOS |
||
4620 | hidnplayr | 67 | include '../../../config.inc' ;for nightbuild |
1583 | mario79 | 68 | include '../../../macros.inc' ; decrease code size (optional) |
8346 | IgorA | 69 | include '../../../KOSfuncs.inc' |
70 | include '../../../load_lib.mac' |
||
1583 | mario79 | 71 | |
72 | @use_library |
||
73 | |||
5098 | clevermous | 74 | include 'lang.inc' |
1583 | mario79 | 75 | ;purge mov |
3013 | dunkaist | 76 | include '../../../debug.inc' |
1588 | mario79 | 77 | ;include 'dlg.inc' |
1583 | mario79 | 78 | include 'playlist.inc' |
79 | include 'gif_lite.inc' |
||
80 | bottom: |
||
81 | file 'bottom.gif' |
||
82 | hdrimg: |
||
83 | file 'hdr.gif' |
||
84 | btns: |
||
85 | file 'buttons.gif' |
||
86 | START: |
||
8346 | IgorA | 87 | mcall SF_SYS_MISC, SSF_HEAP_INIT |
88 | |||
1583 | mario79 | 89 | load_libraries l_libs_start,end_l_libs |
90 | |||
1595 | mario79 | 91 | mov esi,I_PARAM |
92 | cmp dword[esi],0 |
||
93 | jz @f |
||
94 | mov edi,filename |
||
95 | mov ecx,256/4 |
||
96 | rep movsd |
||
97 | mov byte [edi-1], 0 |
||
98 | @@: |
||
1583 | mario79 | 99 | ;OpenDialog initialisation |
8346 | IgorA | 100 | push dword OpenDialog_data |
101 | call [OpenDialog_Init] |
||
1583 | mario79 | 102 | |
4620 | hidnplayr | 103 | or [flag],FL_BOTTRED;+FL_MUTE |
1583 | mario79 | 104 | mov ecx,ipcarea |
105 | call init_ipc |
||
8346 | IgorA | 106 | mcall SF_SET_EVENTS_MASK,1000111b |
1583 | mario79 | 107 | mov esi,btns |
108 | mov edi,btn_raw |
||
109 | call ReadGIF |
||
110 | mov esi,hdrimg |
||
111 | mov edi,hdr_raw |
||
112 | call ReadGIF |
||
113 | mov esi,bottom |
||
114 | mov edi,bottom_raw |
||
115 | call ReadGIF |
||
116 | call respawn |
||
8346 | IgorA | 117 | mcall SF_THREAD_INFO,prcinfo,-1 |
1583 | mario79 | 118 | mov edx,[ebx+30] |
119 | mov [parentPID],edx |
||
120 | mov esi,I_PARAM |
||
121 | cmp dword[esi],0 |
||
122 | jnz .yesparam |
||
123 | call PL_load |
||
124 | cmp [list_count],0 |
||
4620 | hidnplayr | 125 | je noparam |
1583 | mario79 | 126 | mov eax,[pl_ptr] |
4620 | hidnplayr | 127 | or word[eax],FL_MULSEL |
1583 | mario79 | 128 | jmp auto_load |
129 | .yesparam: |
||
130 | mov al,byte[esi] |
||
131 | cmp al,'/' |
||
4620 | hidnplayr | 132 | je .defact |
1583 | mario79 | 133 | mov [param],al |
134 | inc esi |
||
135 | .defact: |
||
4620 | hidnplayr | 136 | mov edi,filename;fnbuf |
1583 | mario79 | 137 | mov ecx,64 |
138 | rep movsd |
||
139 | jmp open_file |
||
140 | clearpath: |
||
141 | newline |
||
142 | mov [fname_len],0 |
||
143 | noparam: |
||
144 | mov [param],'W' |
||
4620 | hidnplayr | 145 | or [flag],FL_ADD |
1583 | mario79 | 146 | ;--------------------------------------------------------------------- |
147 | ;OpenDialog_start: |
||
4620 | hidnplayr | 148 | ; copy_path open_dialog_name,path,library_path,0 |
149 | mov [OpenDialog_data.type],0 ; Open |
||
150 | or [flag],FL_LOCK |
||
151 | push dword OpenDialog_data |
||
152 | call [OpenDialog_Start] |
||
153 | and [flag],not FL_LOCK |
||
154 | ; cmp [OpenDialog_data.status],2 ; OpenDialog does not start |
||
155 | ; je .fopen ; some kind of alternative, instead OpenDialog |
||
156 | cmp [OpenDialog_data.status],1 |
||
157 | ; je open_file |
||
158 | ; jmp still |
||
159 | jne still |
||
1583 | mario79 | 160 | ;--------------------------------------------------------------------- |
161 | |||
1588 | mario79 | 162 | ;.fopen: |
163 | ; call fopen |
||
164 | ; get_path: |
||
165 | ; cmp byte[filename],0 |
||
4620 | hidnplayr | 166 | ; jz still |
1583 | mario79 | 167 | open_file: |
168 | cmp [param],'W' |
||
4620 | hidnplayr | 169 | je .noplay |
1583 | mario79 | 170 | cmp [param],'H' |
171 | jne .nohidd |
||
172 | ; or [flag],FL_PLAY |
||
4620 | hidnplayr | 173 | or [flag],FL_HIDDEN |
1583 | mario79 | 174 | call draw_window |
175 | and [flag],not FL_HIDDEN |
||
176 | call Shade |
||
177 | ; jmp .noplay |
||
178 | |||
179 | .nohidd: |
||
4620 | hidnplayr | 180 | or [flag],FL_PLAY |
1583 | mario79 | 181 | .noplay: |
182 | xor eax,eax |
||
183 | mov [play_area],ax |
||
184 | mov [tick_count],eax |
||
185 | mov [delta],eax |
||
186 | mov [curnote],0x80 |
||
187 | mov ecx,64 |
||
188 | mov esi,filename |
||
189 | mov edi,I_PARAM |
||
190 | rep movsd |
||
8346 | IgorA | 191 | mcall SF_FILE,file_info |
1583 | mario79 | 192 | add ebx,workarea |
193 | mov [midi_limit],ebx |
||
194 | mov edi,I_PARAM |
||
195 | call find_slash |
||
196 | mov [fn_ptr],edi |
||
197 | mov edi,filename |
||
198 | call str_len |
||
199 | mov [fname_len],eax |
||
200 | midi_kill: |
||
201 | call kill |
||
202 | include 'midilite.inc' |
||
203 | |||
204 | decode_end: |
||
205 | ; dpd edi |
||
206 | ; dps <13,10,'Notes='> |
||
207 | ; sub edi,[midi_limit] |
||
208 | ; shr edi,1 |
||
209 | ; dpd edi |
||
210 | dps ' Notes: max=' |
||
211 | movzx eax,[max_note] |
||
212 | dpd eax |
||
213 | dps 'min=' |
||
214 | movzx eax,[min_note] |
||
215 | dpd eax |
||
216 | newline |
||
217 | ; sub esi,workarea |
||
218 | ; jmp _close |
||
219 | .play: |
||
220 | call kill |
||
221 | call respawn |
||
222 | xor edx,edx |
||
223 | mov esi,[midi_limit] |
||
224 | mov [cur_ptr],esi |
||
225 | mov [cur_tick],edx |
||
226 | mov [delta],edx |
||
227 | .count_ticks: |
||
228 | lodsw |
||
229 | test eax,eax |
||
4620 | hidnplayr | 230 | jz .eof |
1583 | mario79 | 231 | and eax,0x7f |
232 | add edx,eax |
||
233 | jmp .count_ticks |
||
234 | .eof: |
||
235 | mov [tick_count],edx |
||
236 | if OUTDUMP eq 1 |
||
237 | mov esi,[midi_limit] |
||
238 | call out_dump |
||
239 | end if |
||
240 | and [flag],not FL_LOCK |
||
241 | test [flag],FL_PLAY |
||
4620 | hidnplayr | 242 | jz .noplay |
1583 | mario79 | 243 | call draw_window |
8346 | IgorA | 244 | mcall SF_SLEEP,100 |
1583 | mario79 | 245 | mov eax,IPC_PLAY |
246 | call ipc_send |
||
247 | .noplay: |
||
248 | test [flag],FL_ADD |
||
4620 | hidnplayr | 249 | jz red |
1583 | mario79 | 250 | mov esi,filename |
251 | mov ecx,[fname_len] |
||
252 | movzx eax,[list_count] |
||
253 | mov [play_num],eax |
||
254 | add_song: |
||
255 | call PL_add |
||
256 | and [flag],not FL_ADD |
||
257 | red: |
||
258 | call draw_window |
||
259 | still: |
||
260 | mov ecx,ipcarea |
||
261 | call init_ipc |
||
8346 | IgorA | 262 | mcall SF_WAIT_EVENT |
1583 | mario79 | 263 | prc_event: |
264 | test eax,eax |
||
4620 | hidnplayr | 265 | jz still |
1583 | mario79 | 266 | .evt: |
267 | cmp eax,1 |
||
4620 | hidnplayr | 268 | je red |
1583 | mario79 | 269 | cmp eax,2 |
4620 | hidnplayr | 270 | je key |
1583 | mario79 | 271 | cmp eax,3 |
4620 | hidnplayr | 272 | je button |
1583 | mario79 | 273 | cmp eax,7 |
274 | jne still |
||
275 | movzx eax,byte[ipcarea+16] |
||
276 | cmp eax,IPC_UPDT |
||
277 | jne .noupdt |
||
278 | call draw_bar |
||
279 | jmp still |
||
280 | .noupdt: |
||
281 | cmp eax,IPC_NEXT |
||
282 | jne still |
||
283 | cmp [param],'H' |
||
4620 | hidnplayr | 284 | je _close |
1583 | mario79 | 285 | xor edx,edx |
286 | test [flag],FL_SHUFFLE |
||
4620 | hidnplayr | 287 | jz .noshuf |
8346 | IgorA | 288 | mcall SF_SYSTEM_GET,SSF_TIME_COUNT |
1583 | mario79 | 289 | movzx ebx,byte[list_count] |
290 | div ebx |
||
291 | mov eax,edx |
||
292 | jmp play_ |
||
293 | .noshuf: |
||
294 | test [flag],FL_REPEAT |
||
295 | jnz decode_end.play |
||
296 | mov eax,[play_num] |
||
297 | inc eax |
||
298 | cmp al,[list_count] |
||
4620 | hidnplayr | 299 | jb bList.next |
1583 | mario79 | 300 | mov eax,IPC_PAUS |
301 | call ipc_send |
||
302 | jmp red |
||
303 | |||
304 | if OUTDUMP eq 1 |
||
305 | out_dump: |
||
306 | mov ecx,OUTLINE |
||
307 | .next_byte: |
||
308 | lodsd |
||
309 | bswap eax |
||
310 | dph eax |
||
311 | dps ' ' |
||
312 | lodsd |
||
313 | bswap eax |
||
314 | dph eax |
||
315 | dps <13,10> |
||
316 | loop .next_byte |
||
317 | ret |
||
318 | end if |
||
319 | |||
320 | str_len: |
||
321 | ; in: edi-str ptr |
||
322 | ; out: eax-str length |
||
323 | push ecx edi |
||
324 | xor eax,eax |
||
325 | mov ecx,256 |
||
326 | repne scasb |
||
327 | jecxz .nofn |
||
328 | sub edi,[esp] |
||
329 | mov eax,edi |
||
330 | .nofn: |
||
331 | pop edi ecx |
||
332 | ret |
||
333 | |||
1588 | mario79 | 334 | ;fopen: |
4620 | hidnplayr | 335 | ; or [flag],FL_LOCK |
1588 | mario79 | 336 | ;; opendialog draw_window, ret_path, ret_path, filename |
337 | ;ret_path: |
||
338 | ; and [flag],not FL_LOCK |
||
339 | ; ret |
||
1583 | mario79 | 340 | |
341 | include 'event.inc' |
||
342 | include "thread.inc" |
||
343 | include "draw.inc" |
||
344 | ; Здесь находятся данные программы: |
||
345 | |||
346 | dd -2 shl 16+4,251,12 shl 16,29 shl 16+5 |
||
347 | dd 21,16 |
||
348 | main_coo: |
||
349 | dd 14 shl 16, 42 shl 16,23 shl 16 |
||
350 | dd 228 shl 16+38 |
||
351 | dd 14 shl 16+10 |
||
352 | dd 236 shl 16+15 |
||
353 | btncoords: |
||
354 | dd 120 shl 16+20, 1 shl 16+15 |
||
355 | dd 149 shl 16+44, 2 shl 16+12 |
||
356 | dd 195 shl 16+26, 2 shl 16+12 |
||
357 | |||
358 | dd -2 shl 16+4,54,63 shl 16,6 shl 16+4 |
||
359 | dd 6,6 |
||
360 | main_coo2: |
||
361 | dd 169 shl 16, 4 shl 16,9 shl 16 |
||
362 | dd 121 shl 16+40 |
||
363 | dd 3 shl 16+9 |
||
364 | dd 130 shl 16+4 |
||
365 | btncoords2: |
||
366 | dd 48 shl 16+6, 6 |
||
367 | dd 2000 shl 16+44, 2 shl 16+12 |
||
368 | dd 2000 shl 16+26, 2 shl 16+12 |
||
369 | ipcarea rb 20 |
||
370 | ipcarea2 rb 20 |
||
371 | |||
4620 | hidnplayr | 372 | dots db ':-' |
373 | text db 'tone> chnl> |
||
1583 | mario79 | 374 | text_end: |
4620 | hidnplayr | 375 | coo dd main_coo |
1583 | mario79 | 376 | play_limit dd playlist |
4620 | hidnplayr | 377 | pl_ptr dd playlist |
378 | param db 'W' |
||
1583 | mario79 | 379 | curnote db 0x80 |
380 | tick_count dd 0 |
||
381 | ;--------------------------------------------------------------------- |
||
382 | OpenDialog_data: |
||
4620 | hidnplayr | 383 | .type dd 0 |
384 | .procinfo dd prcinfo ;+4 |
||
385 | .com_area_name dd communication_area_name ;+8 |
||
386 | .com_area dd 0 ;+12 |
||
387 | .opendir_pach dd temp_dir_pach ;+16 |
||
388 | .dir_default_pach dd communication_area_default_pach ;+20 |
||
389 | .start_path dd open_dialog_path ;+24 |
||
390 | .draw_window dd draw_window ;+28 |
||
391 | .status dd 0 ;+32 |
||
392 | .openfile_pach dd filename ;+36 |
||
393 | .filename_area dd 0 ;+40 |
||
394 | .filter_area dd Filter |
||
1583 | mario79 | 395 | .x: |
4620 | hidnplayr | 396 | .x_size dw 420 ;+48 ; Window X size |
397 | .x_start dw 10 ;+50 ; Window X position |
||
1583 | mario79 | 398 | .y: |
4620 | hidnplayr | 399 | .y_size dw 320 ;+52 ; Window y size |
400 | .y_start dw 10 ;+54 ; Window Y position |
||
1583 | mario79 | 401 | |
402 | communication_area_name: |
||
4620 | hidnplayr | 403 | db 'FFFFFFFF_open_dialog',0 |
1583 | mario79 | 404 | open_dialog_path: |
1702 | Lrz | 405 | if __nightbuild eq yes |
406 | db '/sys/MANAGERS/opendial',0 |
||
407 | else |
||
408 | db '/sys/File Managers/opendial',0 |
||
409 | end if |
||
1583 | mario79 | 410 | communication_area_default_pach: |
9587 | vitalkrilo | 411 | db '/sys',0 |
1583 | mario79 | 412 | |
413 | Filter: |
||
414 | dd Filter.end - Filter |
||
415 | .1: |
||
416 | db 'MID',0 |
||
417 | .end: |
||
418 | db 0 |
||
419 | ;--------------------------------------------------------------------- |
||
4620 | hidnplayr | 420 | system_dir_ProcLib db '/sys/lib/proc_lib.obj',0 |
1583 | mario79 | 421 | |
422 | ;--------------------------------------------------------------------- |
||
423 | align 4 |
||
424 | ProcLib_import: |
||
4620 | hidnplayr | 425 | OpenDialog_Init dd aOpenDialog_Init |
426 | OpenDialog_Start dd aOpenDialog_Start |
||
427 | ;OpenDialog__Version dd aOpenDialog_Version |
||
1583 | mario79 | 428 | dd 0 |
429 | dd 0 |
||
4620 | hidnplayr | 430 | aOpenDialog_Init db 'OpenDialog_init',0 |
431 | aOpenDialog_Start db 'OpenDialog_start',0 |
||
432 | ;aOpenDialog_Version db 'Version_OpenDialog',0 |
||
1583 | mario79 | 433 | ;--------------------------------------------------------------------- |
434 | l_libs_start: |
||
435 | |||
8346 | IgorA | 436 | library01 l_libs system_dir_ProcLib+9, temp_dir_pach, system_dir_ProcLib, \ |
437 | ProcLib_import |
||
1583 | mario79 | 438 | |
439 | end_l_libs: |
||
440 | ;--------------------------------------------------------------------- |
||
441 | dir_info: |
||
442 | dd 1 |
||
443 | dd 0 |
||
444 | dd 0 |
||
445 | dd 1 |
||
446 | dd dir_table |
||
447 | db 0 |
||
448 | dd filename |
||
449 | play_area dw ? |
||
450 | file_info: |
||
4620 | hidnplayr | 451 | dd 0 |
452 | dd 0 |
||
453 | dd 0 |
||
454 | fsize dd 120*1024 ;APP_MEM-2048-workarea ; max size |
||
455 | dd workarea |
||
456 | IM_END: ; конец программы |
||
1583 | mario79 | 457 | filename: |
4620 | hidnplayr | 458 | rb 4096 ;1024+16 |
1583 | mario79 | 459 | prcinfo process_information |
460 | I_PARAM rb 256 |
||
461 | childPID dd ? |
||
462 | parentPID dd ? |
||
463 | play_num dd ? |
||
464 | counter dd ? |
||
4620 | hidnplayr | 465 | flag dd ? |
1583 | mario79 | 466 | fname_len dd ? |
4620 | hidnplayr | 467 | fn_ptr dd ? |
468 | delta dd ? |
||
1583 | mario79 | 469 | cur_ptr dd ? |
470 | cur_tick dd ? |
||
471 | quarter dd ? |
||
4620 | hidnplayr | 472 | octave db ? |
473 | tempo dd ? |
||
1583 | mario79 | 474 | midi_limit dd ? |
475 | track_len dd ? |
||
476 | list_count db ? |
||
477 | cur_track db ? |
||
478 | sel_track db ? |
||
4620 | hidnplayr | 479 | ipcmsg db ? |
1583 | mario79 | 480 | fnbuf: |
4620 | hidnplayr | 481 | rb 1024 |
1583 | mario79 | 482 | btn_raw rb 222*17*3+8 |
483 | hdr_raw rb 275*29*3+8 |
||
484 | bottom_raw rb 25*378*3+8 |
||
4620 | hidnplayr | 485 | rb 4 |
1583 | mario79 | 486 | playlist rb 256*LISTITEMS |
487 | IncludeUGlobals |
||
488 | ;---------------------------------------------------------------- |
||
489 | temp_dir_pach: |
||
490 | rb 4096 |
||
491 | ;---------------------------------------------------------------- |
||
492 | cur_dir_path: |
||
4620 | hidnplayr | 493 | rb 4096 |
1583 | mario79 | 494 | ;---------------------------------------------------------------- |
4620 | hidnplayr | 495 | rb 4096 |
1583 | mario79 | 496 | thread_stack: |
4620 | hidnplayr | 497 | rb 4096 |
1583 | mario79 | 498 | stacktop: |
499 | ;---------------------------------------------------------------- |
||
1588 | mario79 | 500 | dir_table: |
4620 | hidnplayr | 501 | rb 32+304 |
1583 | mario79 | 502 | workarea: |
4620 | hidnplayr | 503 | rb 120*1024 |
3013 | dunkaist | 504 | I_END: |