diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2005-03-02 23:49:38 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2005-03-02 23:49:38 +0000 |
| commit | 384de102469fee4e0792df8fe38586d3206774ed (patch) | |
| tree | ee5342103e17738acfb8421328ea7c57433f55e6 /apps/plugins/rockboy.c | |
| parent | 48dad47df98bdec632e8930b6a97359dc2c428f5 (diff) | |
| download | rockbox-384de102469fee4e0792df8fe38586d3206774ed.zip rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.gz rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.bz2 rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.xz | |
Rockboy - gameboy emulation for rockbox, based on gnuboy. Still a bit early, but already playable on iRiver H1xx and the simulators. The archos recorder version is currently rather slow...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6104 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy.c')
| -rw-r--r-- | apps/plugins/rockboy.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/apps/plugins/rockboy.c b/apps/plugins/rockboy.c new file mode 100644 index 0000000..4778fa8 --- /dev/null +++ b/apps/plugins/rockboy.c @@ -0,0 +1,81 @@ +/*************************************************************************** + * __________ __ ___. + * 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) + +#define OVL_NAME "/.rockbox/viewers/rockboy.ovl" +#define OVL_DISPLAYNAME "RockBoy" + +struct plugin_api* rb; +unsigned char *mp3buf; +int mp3buf_size; + +/* 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; + + /* this macro should be called as the first thing you do in the plugin. + it test that the api version and model the plugin was compiled for + matches the machine it is running on */ + TEST_PLUGIN_API(api); + 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; + } + + mp3buf = rb->plugin_get_mp3_buffer(&mp3buf_size); + if (header.start_addr < mp3buf || header.end_addr > mp3buf + mp3buf_size) + { + rb->close(fh); + rb->splash(2*HZ, true, OVL_DISPLAYNAME + " overlay doesn't fit into memory."); + return PLUGIN_ERROR; + } + rb->lseek(fh, 0, SEEK_SET); + readsize = rb->read(fh, header.start_addr, header.end_addr - header.start_addr); + rb->close(fh); + if (readsize != header.end_addr - header.start_addr) + { + rb->splash(2*HZ, true, "Error loading " OVL_DISPLAYNAME " overlay."); + return PLUGIN_ERROR; + } + return header.entry_point(api, parameter); +} +#endif |