Subversion Repositories Kolibri OS

Rev

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