Subversion Repositories Kolibri OS

Rev

Rev 1702 | Rev 4620 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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