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
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
@ -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> <trk'
dots db ':-'
text db 'tone> chnl> <trk'
text_end:
coo dd main_coo
coo dd main_coo
play_limit dd playlist
pl_ptr dd playlist
param db 'W'
pl_ptr dd playlist
param db 'W'
curnote db 0x80
tick_count dd 0
;---------------------------------------------------------------------
OpenDialog_data:
.type dd 0
.procinfo dd prcinfo ;+4
.com_area_name dd communication_area_name ;+8
.com_area dd 0 ;+12
.opendir_pach dd temp_dir_pach ;+16
.dir_default_pach dd communication_area_default_pach ;+20
.start_path dd open_dialog_path ;+24
.draw_window dd draw_window ;+28
.status dd 0 ;+32
.openfile_pach dd filename ;+36
.filename_area dd 0 ;+40
.filter_area dd Filter
.type dd 0
.procinfo dd prcinfo ;+4
.com_area_name dd communication_area_name ;+8
.com_area dd 0 ;+12
.opendir_pach dd temp_dir_pach ;+16
.dir_default_pach dd communication_area_default_pach ;+20
.start_path dd open_dialog_path ;+24
.draw_window dd draw_window ;+28
.status dd 0 ;+32
.openfile_pach dd filename ;+36
.filename_area dd 0 ;+40
.filter_area dd Filter
.x:
.x_size dw 420 ;+48 ; Window X size
.x_start dw 10 ;+50 ; Window X position
.x_size dw 420 ;+48 ; Window X size
.x_start dw 10 ;+50 ; Window X position
.y:
.y_size dw 320 ;+52 ; Window y size
.y_start dw 10 ;+54 ; Window Y position
.y_size dw 320 ;+52 ; Window y size
.y_start dw 10 ;+54 ; Window Y position
communication_area_name:
db 'FFFFFFFF_open_dialog',0
db 'FFFFFFFF_open_dialog',0
open_dialog_path:
if __nightbuild eq yes
db '/sys/MANAGERS/opendial',0
@ -411,7 +413,7 @@ else
db '/sys/File Managers/opendial',0
end if
communication_area_default_pach:
db '/rd/1',0
db '/rd/1',0
Filter:
dd Filter.end - Filter
@ -420,25 +422,25 @@ db 'MID',0
.end:
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_l db 'error',0
err_message_found_lib2 db 'proc_lib.obj - Not found!',0
head_f_l db 'error',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
ProcLib_import:
OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start
;OpenDialog__Version dd aOpenDialog_Version
OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start
;OpenDialog__Version dd aOpenDialog_Version
dd 0
dd 0
aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0
;aOpenDialog_Version db 'Version_OpenDialog',0
aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0
;aOpenDialog_Version db 'Version_OpenDialog',0
;---------------------------------------------------------------------
l_libs_start:
@ -457,41 +459,41 @@ dir_info:
dd filename
play_area dw ?
file_info:
dd 0
dd 0
dd 0
fsize dd 120*1024 ;APP_MEM-2048-workarea ; max size
dd workarea
IM_END: ; ª®­¥æ ¯à®£à ¬¬ë
dd 0
dd 0
dd 0
fsize dd 120*1024 ;APP_MEM-2048-workarea ; max size
dd workarea
IM_END: ; ª®­¥æ ¯à®£à ¬¬ë
filename:
rb 4096 ;1024+16
rb 4096 ;1024+16
prcinfo process_information
I_PARAM rb 256
childPID dd ?
parentPID dd ?
play_num dd ?
counter dd ?
flag dd ?
flag dd ?
fname_len dd ?
fn_ptr dd ?
delta dd ?
fn_ptr dd ?
delta dd ?
cur_ptr dd ?
cur_tick dd ?
quarter dd ?
octave db ?
tempo dd ?
octave db ?
tempo dd ?
midi_limit dd ?
track_len dd ?
list_count db ?
cur_track db ?
sel_track db ?
ipcmsg db ?
ipcmsg db ?
fnbuf:
rb 1024
rb 1024
btn_raw rb 222*17*3+8
hdr_raw rb 275*29*3+8
bottom_raw rb 25*378*3+8
rb 4
rb 4
playlist rb 256*LISTITEMS
IncludeUGlobals
;----------------------------------------------------------------
@ -499,15 +501,15 @@ temp_dir_pach:
rb 4096
;----------------------------------------------------------------
cur_dir_path:
rb 4096
rb 4096
;----------------------------------------------------------------
rb 4096
rb 4096
thread_stack:
rb 4096
rb 4096
stacktop:
;----------------------------------------------------------------
dir_table:
rb 32+304
rb 32+304
workarea:
rb 120*1024
rb 120*1024
I_END:

View File

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