From fd5287e58e651a1af9d17f8116d7f565a6022e2d Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sat, 8 Mar 2014 11:35:53 +0000 Subject: [PATCH] fixed crash while trying to work with an empty playlist. git-svn-id: svn://kolibrios.org@4620 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/media/midamp/trunk/midamp.asm | 210 ++++++++++++----------- programs/media/midamp/trunk/playlist.inc | 2 + 2 files changed, 108 insertions(+), 104 deletions(-) diff --git a/programs/media/midamp/trunk/midamp.asm b/programs/media/midamp/trunk/midamp.asm index 59b1b838b4..721d3a31e6 100644 --- a/programs/media/midamp/trunk/midamp.asm +++ b/programs/media/midamp/trunk/midamp.asm @@ -7,6 +7,8 @@ ; ; COMPILE WITH FASM +format binary as "" + PLAYLIST_PATH equ '/HD0/1/PLAYLIST.TXT' ;APP_MEM equ 150*1024 @@ -18,7 +20,7 @@ IPC_NEXT equ 0xb2 LISTITEMS equ 40 WND_BACK equ 0x24263c -PLY equ 63 +PLY equ 63 WND_HEIGHT equ (PLY+9*LISTITEMS+10)+25 BTNS_XY equ 14 shl 16+42 @@ -26,10 +28,10 @@ BTNS_SIZE equ 222 shl 16+17 BROWSE_X equ 10 shl 16+8 BROWSE_Y equ 26 shl 16+8 -FN_XY equ 12 shl 16+15 +FN_XY equ 12 shl 16+15 BAR_WIDTH equ 251 -BAR_X equ 10 shl 16 -BAR_Y equ 29 shl 16+5 +BAR_X equ 10 shl 16 +BAR_Y equ 29 shl 16+5 TOTALTIME_XY equ 124 shl 16+28 CURTIME_X equ 225 shl 16+40 CURTIME_Y equ 15 shl 16+11 @@ -44,30 +46,30 @@ FL_REPEAT equ 0x02 FL_HIDDEN equ 0x04 FL_MUTE equ 0x08 FL_REVERSE equ 0x10 -FL_ADD equ 0x20 +FL_ADD equ 0x20 FL_PLAY equ 0x40 FL_LOCK equ 0x80 FL_BOTTRED equ 0x100 FL_MULSEL equ 0x8000 use32 - org 0x0 + org 0x0 - db 'MENUET01' - dd 0x01 - dd START - dd IM_END - dd I_END ;APP_MEM - dd stacktop ;APP_MEM - 1024 - dd I_PARAM + db 'MENUET01' + dd 0x01 + dd START + dd IM_END + dd I_END ;APP_MEM + dd stacktop ;APP_MEM - 1024 + dd I_PARAM dd cur_dir_path listsel dd 0 channel dd 0 COLOR_ORDER equ MENUETOS -include '../../../config.inc' ;for nightbuild +include '../../../config.inc' ;for nightbuild include '../../../macros.inc' ; decrease code size (optional) -include '../../../develop/libraries/box_lib/load_lib.mac' +include '../../../develop/libraries/box_lib/load_lib.mac' @use_library @@ -85,7 +87,7 @@ btns: file 'buttons.gif' START: mcall 68, 11 - + load_libraries l_libs_start,end_l_libs mov esi,I_PARAM @@ -97,10 +99,10 @@ load_libraries l_libs_start,end_l_libs mov byte [edi-1], 0 @@: ;OpenDialog initialisation - push dword OpenDialog_data - call [OpenDialog_Init] + push dword OpenDialog_data + call [OpenDialog_Init] - or [flag],FL_BOTTRED;+FL_MUTE + or [flag],FL_BOTTRED;+FL_MUTE mov ecx,ipcarea call init_ipc mcall 40,1000111b @@ -122,18 +124,18 @@ load_libraries l_libs_start,end_l_libs jnz .yesparam call PL_load cmp [list_count],0 - je noparam + je noparam mov eax,[pl_ptr] - or word[eax],FL_MULSEL + or word[eax],FL_MULSEL jmp auto_load .yesparam: mov al,byte[esi] cmp al,'/' - je .defact + je .defact mov [param],al inc esi .defact: - mov edi,filename;fnbuf + mov edi,filename;fnbuf mov ecx,64 rep movsd jmp open_file @@ -142,42 +144,42 @@ clearpath: mov [fname_len],0 noparam: mov [param],'W' - or [flag],FL_ADD + or [flag],FL_ADD ;--------------------------------------------------------------------- ;OpenDialog_start: -; copy_path open_dialog_name,path,library_path,0 - mov [OpenDialog_data.type],0 ; Open - or [flag],FL_LOCK - push dword OpenDialog_data - call [OpenDialog_Start] - and [flag],not FL_LOCK -; cmp [OpenDialog_data.status],2 ; OpenDialog does not start -; je .fopen ; some kind of alternative, instead OpenDialog - cmp [OpenDialog_data.status],1 -; je open_file -; jmp still - jne still +; copy_path open_dialog_name,path,library_path,0 + mov [OpenDialog_data.type],0 ; Open + or [flag],FL_LOCK + push dword OpenDialog_data + call [OpenDialog_Start] + and [flag],not FL_LOCK +; cmp [OpenDialog_data.status],2 ; OpenDialog does not start +; je .fopen ; some kind of alternative, instead OpenDialog + cmp [OpenDialog_data.status],1 +; je open_file +; jmp still + jne still ;--------------------------------------------------------------------- ;.fopen: ; call fopen ; get_path: ; cmp byte[filename],0 -; jz still +; jz still open_file: cmp [param],'W' - je .noplay + je .noplay cmp [param],'H' jne .nohidd ; or [flag],FL_PLAY - or [flag],FL_HIDDEN + or [flag],FL_HIDDEN call draw_window and [flag],not FL_HIDDEN call Shade ; jmp .noplay .nohidd: - or [flag],FL_PLAY + or [flag],FL_PLAY .noplay: xor eax,eax mov [play_area],ax @@ -229,7 +231,7 @@ decode_end: .count_ticks: lodsw test eax,eax - jz .eof + jz .eof and eax,0x7f add edx,eax jmp .count_ticks @@ -241,14 +243,14 @@ decode_end: end if and [flag],not FL_LOCK test [flag],FL_PLAY - jz .noplay + jz .noplay call draw_window mcall 5,100 mov eax,IPC_PLAY call ipc_send .noplay: test [flag],FL_ADD - jz red + jz red mov esi,filename mov ecx,[fname_len] movzx eax,[list_count] @@ -265,14 +267,14 @@ still: mcall prc_event: test eax,eax - jz still + jz still .evt: cmp eax,1 - je red + je red cmp eax,2 - je key + je key cmp eax,3 - je button + je button cmp eax,7 jne still movzx eax,byte[ipcarea+16] @@ -284,10 +286,10 @@ prc_event: cmp eax,IPC_NEXT jne still cmp [param],'H' - je _close + je _close xor edx,edx test [flag],FL_SHUFFLE - jz .noshuf + jz .noshuf mcall 26,9 movzx ebx,byte[list_count] div ebx @@ -299,7 +301,7 @@ prc_event: mov eax,[play_num] inc eax cmp al,[list_count] - jb bList.next + jb bList.next mov eax,IPC_PAUS call ipc_send jmp red @@ -335,7 +337,7 @@ str_len: ret ;fopen: -; or [flag],FL_LOCK +; or [flag],FL_LOCK ;; opendialog draw_window, ret_path, ret_path, filename ;ret_path: ; and [flag],not FL_LOCK @@ -372,38 +374,38 @@ btncoords2: ipcarea rb 20 ipcarea2 rb 20 -dots db ':-' -text db 'tone> chnl> chnl>