From: Jos v.d.V. <jo...@us...> - 2005-05-16 22:11:19
|
Update of /cvsroot/win32forth/win32forth/apps/Player4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30511/win32forth/apps/Player4 Modified Files: Catalog.f shell_r.f Log Message: Jos: Improoved the random sort by adding a binary sort method. Index: Catalog.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/Player4/Catalog.f,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Catalog.f 10 May 2005 15:48:33 -0000 1.6 --- Catalog.f 16 May 2005 16:18:13 -0000 1.7 *************** *** 30,34 **** 256 constant /file_name 40 constant /Artist ! 40 constant /Title struct{ \ catalog --- 30,34 ---- 256 constant /file_name 40 constant /Artist ! 36 constant /Title struct{ \ catalog *************** *** 39,55 **** /Title Field: Title BYTE Cnt_Title BYTE Deleted- BYTE Excluded- \ Was: LastPlayed BYTE Not_used2 - BYTE Not_used3 Offset Deleted-thread DWORD RandomLevel DWORD #played ! DWORD Played- }struct RecordDef \ database part ! \ Advantages of an inline record: \ An easy way to create and debug a fixed record --- 39,56 ---- /Title Field: Title BYTE Cnt_Title + DWORD FileSize BYTE Deleted- BYTE Excluded- \ Was: LastPlayed + BYTE Played- BYTE Not_used2 Offset Deleted-thread DWORD RandomLevel DWORD #played ! DWORD Not_used1 }struct RecordDef \ database part ! \ Advantages of an inline record: \ An easy way to create and debug a fixed record *************** *** 121,124 **** --- 122,126 ---- \ Define key-len and key-start before using sort-database : sort-database ( - ) 0 n>aptr database-mhndl #records-in-database shell-rel ; + : sort-database-bin ( - ) 0 n>aptr database-mhndl #records-in-database shell-rel-c ; : rebuild-index-hdrs ( - ) \ database must mapped *************** *** 189,193 **** 2dup RandomLevel ! 2dup #played ! ! Played- ! ; --- 191,195 ---- 2dup RandomLevel ! 2dup #played ! ! Played- c! ; *************** *** 223,228 **** ; - : by_RandomLevel ( - ) 3 cells to key-len 0 RandomLevel to key-start ; : by_FileName ( - ) /file_name to key-len 0 File_name to key-start ; : not-deleted? ( rec-adr - flag ) s" deleted- c@ 0= " EVALUATE ; IMMEDIATE --- 225,230 ---- ; : by_FileName ( - ) /file_name to key-len 0 File_name to key-start ; + : by_FileSize ( - ) 1 cells to key-len 0 FileSize to key-start ; : not-deleted? ( rec-adr - flag ) s" deleted- c@ 0= " EVALUATE ; IMMEDIATE *************** *** 236,239 **** --- 238,242 ---- r@ Played- c@ . r@ Excluded- c@ . + r@ FileSize @ 12 U,.R then r>drop *************** *** 249,256 **** : change-randomlevel ( level n - ) n>record over random swap RandomLevel ! ; : sort_by_filename ( - ) by_FileName sort-database ; : random-shuffle ( - ) vadr-config MaximumRandomLevel @ 0 for-all-records-from# change-randomlevel drop ! by_RandomLevel sort-database ; --- 252,268 ---- : change-randomlevel ( level n - ) n>record over random swap RandomLevel ! ; : sort_by_filename ( - ) by_FileName sort-database ; + : sort_by_filesize ( - ) by_FileSize sort-database-bin ; + + : sort-by_RandomLevel ( - ) + 1 cells to key-len + 0 #played to key-start sort-database-bin + 0 RandomLevel to key-start sort-database-bin + 0 Deleted- to key-start sort-database-bin + + ; : random-shuffle ( - ) vadr-config MaximumRandomLevel @ 0 for-all-records-from# change-randomlevel drop ! sort-by_RandomLevel ; *************** *** 260,265 **** internal ! : (add-file) ( wHndl addr len - wHndl ) \ add a file to the catalog InlineRecord [ sizeof RecordDef ] literal erase >r >struct InlineRecord File_name r@ cmove --- 272,285 ---- internal ! : add.dir->file-size ( -- file-size ) ! _win32-find-data @ FILE_ATTRIBUTE_DIRECTORY and ! if 0 ! else _win32-find-data 8 cells+ @ ! then ; ! ! ! : (add-file) ( wHndl addr len file-size - wHndl ) \ add a file to the catalog InlineRecord [ sizeof RecordDef ] literal erase + >struct InlineRecord FileSize ! >r >struct InlineRecord File_name r@ cmove *************** *** 273,278 **** : add-file ( wHndl addr len - wHndl ) \ add a file to the catalog ! 2dup IsValidFileType? ! if (add-file) else 2drop then ; 0 value played_from_catalog --- 293,300 ---- : add-file ( wHndl addr len - wHndl ) \ add a file to the catalog ! 2dup IsValidFileType? ! if add.dir->file-size (add-file) ! else 2drop ! then ; 0 value played_from_catalog *************** *** 312,316 **** : proc_fileinfo_sdir ( wHndl - wHndl ) ! name-buf count add-file ; external --- 334,339 ---- : proc_fileinfo_sdir ( wHndl - wHndl ) ! name-buf count add-file ! ; external Index: shell_r.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/Player4/shell_r.f,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvs3fw3WW and /tmp/cvsv6Ob6Y differ |