fixed crash while trying to work with an empty playlist.

git-svn-id: svn://kolibrios.org@4620 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2014-03-08 11:35:53 +00:00
parent 43101a8623
commit fd5287e58e
2 changed files with 108 additions and 104 deletions

View File

@ -7,6 +7,8 @@
; ;
; COMPILE WITH FASM ; COMPILE WITH FASM
format binary as ""
PLAYLIST_PATH equ '/HD0/1/PLAYLIST.TXT' PLAYLIST_PATH equ '/HD0/1/PLAYLIST.TXT'
;APP_MEM equ 150*1024 ;APP_MEM equ 150*1024
@ -18,7 +20,7 @@ IPC_NEXT equ 0xb2
LISTITEMS equ 40 LISTITEMS equ 40
WND_BACK equ 0x24263c WND_BACK equ 0x24263c
PLY equ 63 PLY equ 63
WND_HEIGHT equ (PLY+9*LISTITEMS+10)+25 WND_HEIGHT equ (PLY+9*LISTITEMS+10)+25
BTNS_XY equ 14 shl 16+42 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_X equ 10 shl 16+8
BROWSE_Y equ 26 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_WIDTH equ 251
BAR_X equ 10 shl 16 BAR_X equ 10 shl 16
BAR_Y equ 29 shl 16+5 BAR_Y equ 29 shl 16+5
TOTALTIME_XY equ 124 shl 16+28 TOTALTIME_XY equ 124 shl 16+28
CURTIME_X equ 225 shl 16+40 CURTIME_X equ 225 shl 16+40
CURTIME_Y equ 15 shl 16+11 CURTIME_Y equ 15 shl 16+11
@ -44,30 +46,30 @@ FL_REPEAT equ 0x02
FL_HIDDEN equ 0x04 FL_HIDDEN equ 0x04
FL_MUTE equ 0x08 FL_MUTE equ 0x08
FL_REVERSE equ 0x10 FL_REVERSE equ 0x10
FL_ADD equ 0x20 FL_ADD equ 0x20
FL_PLAY equ 0x40 FL_PLAY equ 0x40
FL_LOCK equ 0x80 FL_LOCK equ 0x80
FL_BOTTRED equ 0x100 FL_BOTTRED equ 0x100
FL_MULSEL equ 0x8000 FL_MULSEL equ 0x8000
use32 use32
org 0x0 org 0x0
db 'MENUET01' db 'MENUET01'
dd 0x01 dd 0x01
dd START dd START
dd IM_END dd IM_END
dd I_END ;APP_MEM dd I_END ;APP_MEM
dd stacktop ;APP_MEM - 1024 dd stacktop ;APP_MEM - 1024
dd I_PARAM dd I_PARAM
dd cur_dir_path dd cur_dir_path
listsel dd 0 listsel dd 0
channel dd 0 channel dd 0
COLOR_ORDER equ MENUETOS COLOR_ORDER equ MENUETOS
include '../../../config.inc' ;for nightbuild include '../../../config.inc' ;for nightbuild
include '../../../macros.inc' ; decrease code size (optional) 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 @use_library
@ -97,10 +99,10 @@ load_libraries l_libs_start,end_l_libs
mov byte [edi-1], 0 mov byte [edi-1], 0
@@: @@:
;OpenDialog initialisation ;OpenDialog initialisation
push dword OpenDialog_data push dword OpenDialog_data
call [OpenDialog_Init] call [OpenDialog_Init]
or [flag],FL_BOTTRED;+FL_MUTE or [flag],FL_BOTTRED;+FL_MUTE
mov ecx,ipcarea mov ecx,ipcarea
call init_ipc call init_ipc
mcall 40,1000111b mcall 40,1000111b
@ -122,18 +124,18 @@ load_libraries l_libs_start,end_l_libs
jnz .yesparam jnz .yesparam
call PL_load call PL_load
cmp [list_count],0 cmp [list_count],0
je noparam je noparam
mov eax,[pl_ptr] mov eax,[pl_ptr]
or word[eax],FL_MULSEL or word[eax],FL_MULSEL
jmp auto_load jmp auto_load
.yesparam: .yesparam:
mov al,byte[esi] mov al,byte[esi]
cmp al,'/' cmp al,'/'
je .defact je .defact
mov [param],al mov [param],al
inc esi inc esi
.defact: .defact:
mov edi,filename;fnbuf mov edi,filename;fnbuf
mov ecx,64 mov ecx,64
rep movsd rep movsd
jmp open_file jmp open_file
@ -142,42 +144,42 @@ clearpath:
mov [fname_len],0 mov [fname_len],0
noparam: noparam:
mov [param],'W' mov [param],'W'
or [flag],FL_ADD or [flag],FL_ADD
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;OpenDialog_start: ;OpenDialog_start:
; copy_path open_dialog_name,path,library_path,0 ; copy_path open_dialog_name,path,library_path,0
mov [OpenDialog_data.type],0 ; Open mov [OpenDialog_data.type],0 ; Open
or [flag],FL_LOCK or [flag],FL_LOCK
push dword OpenDialog_data push dword OpenDialog_data
call [OpenDialog_Start] call [OpenDialog_Start]
and [flag],not FL_LOCK and [flag],not FL_LOCK
; cmp [OpenDialog_data.status],2 ; OpenDialog does not start ; cmp [OpenDialog_data.status],2 ; OpenDialog does not start
; je .fopen ; some kind of alternative, instead OpenDialog ; je .fopen ; some kind of alternative, instead OpenDialog
cmp [OpenDialog_data.status],1 cmp [OpenDialog_data.status],1
; je open_file ; je open_file
; jmp still ; jmp still
jne still jne still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;.fopen: ;.fopen:
; call fopen ; call fopen
; get_path: ; get_path:
; cmp byte[filename],0 ; cmp byte[filename],0
; jz still ; jz still
open_file: open_file:
cmp [param],'W' cmp [param],'W'
je .noplay je .noplay
cmp [param],'H' cmp [param],'H'
jne .nohidd jne .nohidd
; or [flag],FL_PLAY ; or [flag],FL_PLAY
or [flag],FL_HIDDEN or [flag],FL_HIDDEN
call draw_window call draw_window
and [flag],not FL_HIDDEN and [flag],not FL_HIDDEN
call Shade call Shade
; jmp .noplay ; jmp .noplay
.nohidd: .nohidd:
or [flag],FL_PLAY or [flag],FL_PLAY
.noplay: .noplay:
xor eax,eax xor eax,eax
mov [play_area],ax mov [play_area],ax
@ -229,7 +231,7 @@ decode_end:
.count_ticks: .count_ticks:
lodsw lodsw
test eax,eax test eax,eax
jz .eof jz .eof
and eax,0x7f and eax,0x7f
add edx,eax add edx,eax
jmp .count_ticks jmp .count_ticks
@ -241,14 +243,14 @@ decode_end:
end if end if
and [flag],not FL_LOCK and [flag],not FL_LOCK
test [flag],FL_PLAY test [flag],FL_PLAY
jz .noplay jz .noplay
call draw_window call draw_window
mcall 5,100 mcall 5,100
mov eax,IPC_PLAY mov eax,IPC_PLAY
call ipc_send call ipc_send
.noplay: .noplay:
test [flag],FL_ADD test [flag],FL_ADD
jz red jz red
mov esi,filename mov esi,filename
mov ecx,[fname_len] mov ecx,[fname_len]
movzx eax,[list_count] movzx eax,[list_count]
@ -265,14 +267,14 @@ still:
mcall mcall
prc_event: prc_event:
test eax,eax test eax,eax
jz still jz still
.evt: .evt:
cmp eax,1 cmp eax,1
je red je red
cmp eax,2 cmp eax,2
je key je key
cmp eax,3 cmp eax,3
je button je button
cmp eax,7 cmp eax,7
jne still jne still
movzx eax,byte[ipcarea+16] movzx eax,byte[ipcarea+16]
@ -284,10 +286,10 @@ prc_event:
cmp eax,IPC_NEXT cmp eax,IPC_NEXT
jne still jne still
cmp [param],'H' cmp [param],'H'
je _close je _close
xor edx,edx xor edx,edx
test [flag],FL_SHUFFLE test [flag],FL_SHUFFLE
jz .noshuf jz .noshuf
mcall 26,9 mcall 26,9
movzx ebx,byte[list_count] movzx ebx,byte[list_count]
div ebx div ebx
@ -299,7 +301,7 @@ prc_event:
mov eax,[play_num] mov eax,[play_num]
inc eax inc eax
cmp al,[list_count] cmp al,[list_count]
jb bList.next jb bList.next
mov eax,IPC_PAUS mov eax,IPC_PAUS
call ipc_send call ipc_send
jmp red jmp red
@ -335,7 +337,7 @@ str_len:
ret ret
;fopen: ;fopen:
; or [flag],FL_LOCK ; or [flag],FL_LOCK
;; opendialog draw_window, ret_path, ret_path, filename ;; opendialog draw_window, ret_path, ret_path, filename
;ret_path: ;ret_path:
; and [flag],not FL_LOCK ; and [flag],not FL_LOCK
@ -372,38 +374,38 @@ btncoords2:
ipcarea rb 20 ipcarea rb 20
ipcarea2 rb 20 ipcarea2 rb 20
dots db ':-' dots db ':-'
text db 'tone> chnl> <trk' text db 'tone> chnl> <trk'
text_end: text_end:
coo dd main_coo coo dd main_coo
play_limit dd playlist play_limit dd playlist
pl_ptr dd playlist pl_ptr dd playlist
param db 'W' param db 'W'
curnote db 0x80 curnote db 0x80
tick_count dd 0 tick_count dd 0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
OpenDialog_data: OpenDialog_data:
.type dd 0 .type dd 0
.procinfo dd prcinfo ;+4 .procinfo dd prcinfo ;+4
.com_area_name dd communication_area_name ;+8 .com_area_name dd communication_area_name ;+8
.com_area dd 0 ;+12 .com_area dd 0 ;+12
.opendir_pach dd temp_dir_pach ;+16 .opendir_pach dd temp_dir_pach ;+16
.dir_default_pach dd communication_area_default_pach ;+20 .dir_default_pach dd communication_area_default_pach ;+20
.start_path dd open_dialog_path ;+24 .start_path dd open_dialog_path ;+24
.draw_window dd draw_window ;+28 .draw_window dd draw_window ;+28
.status dd 0 ;+32 .status dd 0 ;+32
.openfile_pach dd filename ;+36 .openfile_pach dd filename ;+36
.filename_area dd 0 ;+40 .filename_area dd 0 ;+40
.filter_area dd Filter .filter_area dd Filter
.x: .x:
.x_size dw 420 ;+48 ; Window X size .x_size dw 420 ;+48 ; Window X size
.x_start dw 10 ;+50 ; Window X position .x_start dw 10 ;+50 ; Window X position
.y: .y:
.y_size dw 320 ;+52 ; Window y size .y_size dw 320 ;+52 ; Window y size
.y_start dw 10 ;+54 ; Window Y position .y_start dw 10 ;+54 ; Window Y position
communication_area_name: communication_area_name:
db 'FFFFFFFF_open_dialog',0 db 'FFFFFFFF_open_dialog',0
open_dialog_path: open_dialog_path:
if __nightbuild eq yes if __nightbuild eq yes
db '/sys/MANAGERS/opendial',0 db '/sys/MANAGERS/opendial',0
@ -411,7 +413,7 @@ else
db '/sys/File Managers/opendial',0 db '/sys/File Managers/opendial',0
end if end if
communication_area_default_pach: communication_area_default_pach:
db '/rd/1',0 db '/rd/1',0
Filter: Filter:
dd Filter.end - Filter dd Filter.end - Filter
@ -420,25 +422,25 @@ db 'MID',0
.end: .end:
db 0 db 0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
system_dir_ProcLib db '/sys/lib/proc_lib.obj',0 system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
head_f_i: head_f_i:
head_f_l db 'error',0 head_f_l db 'error',0
err_message_found_lib2 db 'proc_lib.obj - Not found!',0 err_message_found_lib2 db 'proc_lib.obj - Not found!',0
err_message_import2 db 'proc_lib.obj - Wrong import!',0 err_message_import2 db 'proc_lib.obj - Wrong import!',0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
ProcLib_import: ProcLib_import:
OpenDialog_Init dd aOpenDialog_Init OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start OpenDialog_Start dd aOpenDialog_Start
;OpenDialog__Version dd aOpenDialog_Version ;OpenDialog__Version dd aOpenDialog_Version
dd 0 dd 0
dd 0 dd 0
aOpenDialog_Init db 'OpenDialog_init',0 aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0 aOpenDialog_Start db 'OpenDialog_start',0
;aOpenDialog_Version db 'Version_OpenDialog',0 ;aOpenDialog_Version db 'Version_OpenDialog',0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
l_libs_start: l_libs_start:
@ -457,41 +459,41 @@ dir_info:
dd filename dd filename
play_area dw ? play_area dw ?
file_info: file_info:
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
fsize dd 120*1024 ;APP_MEM-2048-workarea ; max size fsize dd 120*1024 ;APP_MEM-2048-workarea ; max size
dd workarea dd workarea
IM_END: ; ª®­¥æ ¯à®£à ¬¬ë IM_END: ; ª®­¥æ ¯à®£à ¬¬ë
filename: filename:
rb 4096 ;1024+16 rb 4096 ;1024+16
prcinfo process_information prcinfo process_information
I_PARAM rb 256 I_PARAM rb 256
childPID dd ? childPID dd ?
parentPID dd ? parentPID dd ?
play_num dd ? play_num dd ?
counter dd ? counter dd ?
flag dd ? flag dd ?
fname_len dd ? fname_len dd ?
fn_ptr dd ? fn_ptr dd ?
delta dd ? delta dd ?
cur_ptr dd ? cur_ptr dd ?
cur_tick dd ? cur_tick dd ?
quarter dd ? quarter dd ?
octave db ? octave db ?
tempo dd ? tempo dd ?
midi_limit dd ? midi_limit dd ?
track_len dd ? track_len dd ?
list_count db ? list_count db ?
cur_track db ? cur_track db ?
sel_track db ? sel_track db ?
ipcmsg db ? ipcmsg db ?
fnbuf: fnbuf:
rb 1024 rb 1024
btn_raw rb 222*17*3+8 btn_raw rb 222*17*3+8
hdr_raw rb 275*29*3+8 hdr_raw rb 275*29*3+8
bottom_raw rb 25*378*3+8 bottom_raw rb 25*378*3+8
rb 4 rb 4
playlist rb 256*LISTITEMS playlist rb 256*LISTITEMS
IncludeUGlobals IncludeUGlobals
;---------------------------------------------------------------- ;----------------------------------------------------------------
@ -499,15 +501,15 @@ temp_dir_pach:
rb 4096 rb 4096
;---------------------------------------------------------------- ;----------------------------------------------------------------
cur_dir_path: cur_dir_path:
rb 4096 rb 4096
;---------------------------------------------------------------- ;----------------------------------------------------------------
rb 4096 rb 4096
thread_stack: thread_stack:
rb 4096 rb 4096
stacktop: stacktop:
;---------------------------------------------------------------- ;----------------------------------------------------------------
dir_table: dir_table:
rb 32+304 rb 32+304
workarea: workarea:
rb 120*1024 rb 120*1024
I_END: I_END:

View File

@ -173,6 +173,8 @@ PL_get1stsel:
PL_getnextsel: PL_getnextsel:
push eax ecx push eax ecx
movzx ecx,[list_count] movzx ecx,[list_count]
test ecx, ecx
jz .ex2
.lp: .lp:
movzx eax,word[esi] movzx eax,word[esi]
btr eax,15 btr eax,15