2005-03-02 23:49:38 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Jens Arnold
|
|
|
|
*
|
|
|
|
* Overlay loader for rockboy on Archos
|
|
|
|
*
|
|
|
|
* 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 "plugin.h"
|
|
|
|
|
|
|
|
#if MEM <= 8 && !defined(SIMULATOR)
|
|
|
|
|
2006-01-15 18:20:18 +00:00
|
|
|
PLUGIN_HEADER
|
|
|
|
|
2005-03-02 23:49:38 +00:00
|
|
|
#define OVL_NAME "/.rockbox/viewers/rockboy.ovl"
|
|
|
|
#define OVL_DISPLAYNAME "RockBoy"
|
|
|
|
|
|
|
|
struct plugin_api* rb;
|
2005-04-05 11:33:58 +00:00
|
|
|
unsigned char *audiobuf;
|
|
|
|
int audiobuf_size;
|
2005-03-02 23:49:38 +00:00
|
|
|
|
|
|
|
/* this is the plugin entry point */
|
|
|
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|
|
|
{
|
|
|
|
int fh, readsize;
|
|
|
|
struct {
|
|
|
|
unsigned long magic;
|
|
|
|
unsigned char *start_addr;
|
|
|
|
unsigned char *end_addr;
|
|
|
|
enum plugin_status(*entry_point)(struct plugin_api*, void*);
|
|
|
|
} header;
|
|
|
|
|
|
|
|
rb = api;
|
|
|
|
|
|
|
|
fh = rb->open(OVL_NAME, O_RDONLY);
|
|
|
|
if (fh < 0)
|
|
|
|
{
|
|
|
|
rb->splash(2*HZ, true, "Couldn't open " OVL_DISPLAYNAME " overlay.");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
|
|
|
readsize = rb->read(fh, &header, sizeof(header));
|
|
|
|
if (readsize != sizeof(header) || header.magic != 0x524f564c)
|
|
|
|
{
|
|
|
|
rb->close(fh);
|
|
|
|
rb->splash(2*HZ, true, OVL_NAME " is not a valid Rockbox overlay.");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
|
|
|
|
2005-04-05 11:33:58 +00:00
|
|
|
audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
|
|
|
|
if (header.start_addr < audiobuf ||
|
|
|
|
header.end_addr > audiobuf + audiobuf_size)
|
2005-03-02 23:49:38 +00:00
|
|
|
{
|
|
|
|
rb->close(fh);
|
|
|
|
rb->splash(2*HZ, true, OVL_DISPLAYNAME
|
|
|
|
" overlay doesn't fit into memory.");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
2006-01-08 23:45:29 +00:00
|
|
|
rb->memset(header.start_addr, 0, header.end_addr - header.start_addr);
|
|
|
|
|
2005-03-02 23:49:38 +00:00
|
|
|
rb->lseek(fh, 0, SEEK_SET);
|
|
|
|
readsize = rb->read(fh, header.start_addr, header.end_addr - header.start_addr);
|
|
|
|
rb->close(fh);
|
2006-01-09 01:03:21 +00:00
|
|
|
if (readsize <= (int)sizeof(header))
|
2005-03-02 23:49:38 +00:00
|
|
|
{
|
|
|
|
rb->splash(2*HZ, true, "Error loading " OVL_DISPLAYNAME " overlay.");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
|
|
|
return header.entry_point(api, parameter);
|
|
|
|
}
|
|
|
|
#endif
|