2005-03-02 23:49:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "rockmacros.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "rc.h"
|
|
|
|
#include "exports.h"
|
|
|
|
#include "emu.h"
|
|
|
|
#include "loader.h"
|
|
|
|
#include "hw.h"
|
|
|
|
|
|
|
|
//#include "Version"
|
|
|
|
|
|
|
|
|
|
|
|
static char *defaultconfig[] =
|
|
|
|
{
|
|
|
|
"bind up +up",
|
|
|
|
"bind down +down",
|
|
|
|
"bind left +left",
|
|
|
|
"bind right +right",
|
|
|
|
"bind joy0 +b",
|
|
|
|
"bind joy1 +a",
|
|
|
|
"bind joy2 +select",
|
|
|
|
"bind joy3 +start",
|
|
|
|
"bind ins savestate",
|
|
|
|
"bind del loadstate",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void doevents()
|
|
|
|
{
|
|
|
|
event_t ev;
|
|
|
|
int st;
|
|
|
|
|
|
|
|
ev_poll();
|
|
|
|
while (ev_getevent(&ev))
|
|
|
|
{
|
|
|
|
if (ev.type != EV_PRESS && ev.type != EV_RELEASE)
|
|
|
|
continue;
|
|
|
|
st = (ev.type != EV_RELEASE);
|
|
|
|
pad_set(ev.code, st);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-03 19:54:47 +00:00
|
|
|
/* convenience macro for printing loading state */
|
|
|
|
#define PUTS(str) do { \
|
2005-12-02 08:08:54 +00:00
|
|
|
rb->lcd_putsxy(1, y, (unsigned char *)str); \
|
|
|
|
rb->lcd_getstringsize((unsigned char *)str, &w, &h); \
|
2005-03-03 19:54:47 +00:00
|
|
|
y += h + 1; \
|
|
|
|
} while (0)
|
|
|
|
|
2005-03-02 23:49:38 +00:00
|
|
|
int gnuboy_main(char *rom)
|
|
|
|
{
|
2005-03-03 19:54:47 +00:00
|
|
|
int i, w, h, y;
|
2005-03-02 23:49:38 +00:00
|
|
|
|
2005-03-03 19:54:47 +00:00
|
|
|
y = 1;
|
2005-03-02 23:49:38 +00:00
|
|
|
// Avoid initializing video if we don't have to
|
|
|
|
// If we have special perms, drop them ASAP!
|
2005-03-03 19:54:47 +00:00
|
|
|
PUTS("Init exports");
|
2005-03-02 23:49:38 +00:00
|
|
|
init_exports();
|
|
|
|
|
2005-03-03 19:54:47 +00:00
|
|
|
PUTS("Loading default config");
|
2005-03-02 23:49:38 +00:00
|
|
|
for (i = 0; defaultconfig[i]; i++)
|
|
|
|
rc_command(defaultconfig[i]);
|
|
|
|
|
|
|
|
// sprintf(cmd, "source %s", rom);
|
|
|
|
// s = strchr(cmd, '.');
|
|
|
|
// if (s) *s = 0;
|
|
|
|
// strcat(cmd, ".rc");
|
|
|
|
// rc_command(cmd);
|
|
|
|
|
|
|
|
// FIXME - make interface modules responsible for atexit()
|
2005-03-03 19:54:47 +00:00
|
|
|
PUTS("Init video");
|
2005-03-02 23:49:38 +00:00
|
|
|
vid_init();
|
2005-03-20 23:06:47 +00:00
|
|
|
PUTS("Init sound");
|
2005-03-02 23:49:38 +00:00
|
|
|
pcm_init();
|
2005-03-03 19:54:47 +00:00
|
|
|
PUTS("Loading rom");
|
2005-03-02 23:49:38 +00:00
|
|
|
loader_init(rom);
|
|
|
|
if(shut)
|
|
|
|
return PLUGIN_ERROR;
|
2005-03-03 19:54:47 +00:00
|
|
|
PUTS("Emu reset");
|
2005-03-02 23:49:38 +00:00
|
|
|
emu_reset();
|
2005-03-03 19:54:47 +00:00
|
|
|
PUTS("Emu run");
|
2005-11-16 22:59:28 +00:00
|
|
|
#if (LCD_HEIGHT > 144) || (LCD_WIDTH > 160)
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_drawrect((LCD_WIDTH-160)/2-1, (LCD_HEIGHT-144)/2-1, 162, 146);
|
|
|
|
rb->lcd_update();
|
|
|
|
#endif
|
2005-03-02 23:49:38 +00:00
|
|
|
emu_run();
|
|
|
|
|
|
|
|
// never reached
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|
2005-03-03 19:54:47 +00:00
|
|
|
#undef PUTS
|