/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id: main_menu.c,v 1.55 2002/08/31 23:07:11 adiamas Exp $ * * Copyright (C) 2002 Bj%/1iso8859-15rn Stenberg * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include #include #include #include "db.h" #include int handle_db; void copy_buff_buff(struct dbentry *entry, struct db *db,int *i) { while (1) { entry->buff[*i]=(db->buff[db->buff_index++]); if (db->buff_index == MAX_DB_BUFF) { load_db(db->file_index+1,db); } if (entry->buff[*i]=='\n') { entry->buff[(*i)++]='\0'; break; } (*i)++; } } void load_db(int sector,struct db *db) { lseek(db->handle_db, MAX_DB_BUFF*sector,SEEK_SET); read (db->handle_db,db->buff,MAX_DB_BUFF); db->buff_index=0; db->file_index=sector; } void fill_entry( struct dbentry *entry, struct db *db) { int i=0; entry->full_path=entry->buff; copy_buff_buff(entry,db,&i); debugf("%s\n",entry->full_path); entry->title=entry->buff+i; copy_buff_buff(entry,db,&i); entry->artist=entry->buff+i; copy_buff_buff(entry,db,&i); entry->album=entry->buff+i; copy_buff_buff(entry,db,&i); } extern int dbtest(void) { int i=0; struct dbentry test_entry; struct db database; database.handle_db=open("/db.db",O_RDONLY); load_db(0,&database); fill_entry(&test_entry,&database); lcd_clear_display(); lcd_puts(0,0,test_entry.full_path); lcd_puts(0,1,test_entry.title); lcd_puts(0,2,test_entry.artist); lcd_puts(0,3,test_entry.album); lcd_update(); while (i< 1000) { fill_entry(&test_entry,&database); lcd_clear_display(); lcd_puts(0,0,test_entry.full_path); lcd_puts(0,1,test_entry.title); lcd_puts(0,2,test_entry.artist); lcd_puts(0,3,test_entry.album); lcd_update(); i++; } return 0; } /*******Set the db index to the beginning of the dir, return the byte of the end*/ int sel_dirdb(struct db *db, char *dir_name) { return 0; }