Beispiel #1
0
int main(int argc, char* argv[])
{
    SetSphereDirectory();

    // load the configuration settings, then save it for future reference
    SPHERECONFIG config;
    LoadSphereConfiguration(&config);

    for (int i = 0; i < 4; i++)
    {
        SetPlayerConfig(i,
                KeyStringToKeyCode(config.player_configurations[i].key_menu_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_up_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_down_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_left_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_right_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_a_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_b_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_x_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_y_str.c_str()),
                config.player_configurations[i].keyboard_input_allowed,
                config.player_configurations[i].joypad_input_allowed);
    }

	SetGlobalConfig(config.language, config.sound, config.allow_networking);
    SaveSphereConfig(&config, (GetSphereDirectory() + "/engine.ini").c_str());

    // initialize screenshot directory
    std::string sphere_directory;
    char screenshot_directory[512];
    GetDirectory(sphere_directory);
    sprintf(screenshot_directory, "%s/screenshots", sphere_directory.c_str());
    SetScreenshotDirectory(screenshot_directory);

    // initialize video subsystem
    if (InitVideo(&config) == false)
    {
        printf("Video subsystem could not be initialized...\n");
        return 0;
    }

    // initialize input
    InitInput();

    // initialize audio
    if (!InitAudio(&config))
    {
        printf("Sound could not be initialized...\n");
    }

    atexit(CloseVideo);
    atexit(CloseAudio);

    RunSphere(argc, const_cast<const char **>(argv));

    return 0;
}
Beispiel #2
0
int main(int argc, const char* argv[])
{
    SetSphereDirectory();

    // load the configuration settings, then save it for future reference
    SPHERECONFIG config;
    LoadSphereConfiguration(&config);

    for (int i = 0; i < 4; i++)
    {
      SetPlayerConfig(i,
                KeyStringToKeyCode(config.player_configurations[i].key_menu_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_up_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_down_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_left_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_right_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_a_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_b_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_x_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_y_str.c_str()),
                config.player_configurations[i].keyboard_input_allowed,
                config.player_configurations[i].joypad_input_allowed);
    }

	SetGlobalConfig(config.language, config.sound, config.allow_networking);
    SaveSphereConfig(&config, (GetSphereDirectory() + "/engine.ini").c_str());

    original_directory = getcwd(NULL, 0);
    char* env_data_dir = getenv("SPHERE_DATA_DIR");

    if (env_data_dir != NULL)
        strcpy(unix_data_dir, env_data_dir);

    if (getopt(argc, const_cast<char**>(argv), "d:") == 'd')
        strcpy(unix_data_dir, optarg);

    chdir(unix_data_dir);
    srand((unsigned)GetTime());

    // initialize video subsystem
    if (InitVideo(&config) == false)
    {
        printf("Video subsystem could not be initialized...\n");
        return 0;
    }

    // initialize input
    InitializeInput();

    // initialize audio
    if (!InitAudio(&config))
    {
        printf("Sound could not be initialized...\n");
    }

    atexit(CloseVideo);
    atexit(CloseAudio);

    RunSphere(argc, argv);

}
Beispiel #3
0
static void LoadSphereConfiguration(SPHERECONFIG* config)
{
  // Loads configuration settings
  LoadSphereConfig(config, (GetSphereDirectory() + "/engine.ini").c_str());
}
Beispiel #4
0
bool InitVideo(SPHERECONFIG* config)
{

    // load the video driver
    std::string driver_path = GetSphereDirectory() + "/system/video/" + config->videodriver;
    GraphicsDriver = dlopen(driver_path.c_str(), RTLD_LAZY);

    if (GraphicsDriver == NULL)
    {
        fprintf(stderr, "Could not load '%s':\n%s\n", config->videodriver.c_str(), dlerror());
        return false;
    }

    // get addresses of all of the graphics functions
    assign(_FlipScreen,            dlsym(GraphicsDriver, "FlipScreen"));
    assign(SetClippingRectangle,   dlsym(GraphicsDriver, "SetClippingRectangle"));
    assign(GetClippingRectangle,   dlsym(GraphicsDriver, "GetClippingRectangle"));
    assign(CreateImage,            dlsym(GraphicsDriver, "CreateImage"));
    assign(CloneImage,             dlsym(GraphicsDriver, "CloneImage"));
    assign(GrabImage,              dlsym(GraphicsDriver, "GrabImage"));
    assign(DestroyImage,           dlsym(GraphicsDriver, "DestroyImage"));
    assign(BlitImage,              dlsym(GraphicsDriver, "BlitImage"));
    assign(BlitImageMask,          dlsym(GraphicsDriver, "BlitImageMask"));
    assign(TransformBlitImage,     dlsym(GraphicsDriver, "TransformBlitImage"));
    assign(TransformBlitImageMask, dlsym(GraphicsDriver, "TransformBlitImageMask"));
    assign(GetImageWidth,          dlsym(GraphicsDriver, "GetImageWidth"));
    assign(GetImageHeight,         dlsym(GraphicsDriver, "GetImageHeight"));
    assign(LockImage,              dlsym(GraphicsDriver, "LockImage"));
    assign(UnlockImage,            dlsym(GraphicsDriver, "UnlockImage"));
    assign(DirectBlit,             dlsym(GraphicsDriver, "DirectBlit"));
    assign(DirectTransformBlit,    dlsym(GraphicsDriver, "DirectTransformBlit"));
    assign(DirectGrab,             dlsym(GraphicsDriver, "DirectGrab"));
    assign(DrawPoint,              dlsym(GraphicsDriver, "DrawPoint"));
    assign(DrawPointSeries,        dlsym(GraphicsDriver, "DrawPointSeries"));
    assign(DrawLine,               dlsym(GraphicsDriver, "DrawLine"));
    assign(DrawGradientLine,       dlsym(GraphicsDriver, "DrawGradientLine"));
    assign(DrawLineSeries,         dlsym(GraphicsDriver, "DrawLineSeries"));
    assign(DrawBezierCurve,        dlsym(GraphicsDriver, "DrawBezierCurve"));
    assign(DrawTriangle,           dlsym(GraphicsDriver, "DrawTriangle"));
    assign(DrawGradientTriangle,   dlsym(GraphicsDriver, "DrawGradientTriangle"));
    assign(DrawPolygon,            dlsym(GraphicsDriver, "DrawPolygon"));
    assign(DrawOutlinedRectangle,  dlsym(GraphicsDriver, "DrawOutlinedRectangle"));
    assign(DrawRectangle,          dlsym(GraphicsDriver, "DrawRectangle"));
    assign(DrawGradientRectangle,  dlsym(GraphicsDriver, "DrawGradientRectangle"));
    assign(DrawOutlinedComplex,    dlsym(GraphicsDriver, "DrawOutlinedComplex"));
    assign(DrawFilledComplex,      dlsym(GraphicsDriver, "DrawFilledComplex"));
    assign(DrawGradientComplex,    dlsym(GraphicsDriver, "DrawGradientComplex"));
    assign(DrawOutlinedEllipse,    dlsym(GraphicsDriver, "DrawOutlinedEllipse"));
    assign(DrawFilledEllipse,      dlsym(GraphicsDriver, "DrawFilledEllipse"));
    assign(DrawOutlinedCircle,     dlsym(GraphicsDriver, "DrawOutlinedCircle"));
    assign(DrawFilledCircle,       dlsym(GraphicsDriver, "DrawFilledCircle"));
    assign(DrawGradientCircle,     dlsym(GraphicsDriver, "DrawGradientCircle"));

    // ensure that we got all entry points
    if (!_FlipScreen ||
        !SetClippingRectangle ||
        !GetClippingRectangle ||
        !CreateImage ||
        !CloneImage ||
        !GrabImage ||
        !DestroyImage ||
        !BlitImage ||
        !BlitImageMask ||
        !TransformBlitImage ||
        !TransformBlitImageMask ||
        !GetImageWidth ||
        !GetImageHeight ||
        !LockImage ||
        !UnlockImage ||
        !DirectBlit ||
        !DirectTransformBlit ||
        !DirectGrab ||
        !DrawPoint ||
        !DrawPointSeries ||
        !DrawLine ||
        !DrawGradientLine ||
        !DrawLineSeries ||
        !DrawBezierCurve ||
        !DrawTriangle ||
        !DrawGradientTriangle ||
        !DrawPolygon ||
        !DrawOutlinedRectangle ||
        !DrawRectangle ||
        !DrawGradientRectangle ||
        !DrawOutlinedComplex ||
        !DrawFilledComplex ||
        !DrawGradientComplex ||
        !DrawOutlinedEllipse ||
        !DrawFilledEllipse ||
        !DrawOutlinedCircle ||
        !DrawFilledCircle ||
        !DrawGradientCircle)
    {
        puts("Couldn't get all entry points");
        dlclose(GraphicsDriver);
        return false;
    }

    return true;
}