Exemple #1
0
/*------------------------------------------------------------------------------*
| <<< ゲーム初期化 >>>
*------------------------------------------------------------------------------*/
void	game_init(void)
{
	//--- テクスチャー読み込み ----------------------------------------
	FOLDER_SET("画像");
	d3_tex_load(TEX_MOJI, "文字.png");

	//--- X ファイル読み込み ----------------------------------------------
	FOLDER_SET("3Dモデル");
	skin_load(	X_ENEMY, "enemy.x");
	d3_xfile_load(X_LEFT,	"punch.mqo");
	d3_xfile_load(X_RIGHT,	"punch.mqo");

	//--- テクスチャー読み込み ---------------------------------------------
	FOLDER_SET("画像");
	d3_tex_load(TEX_BACK,	"リング.jpg");
	d3_tex_load(TEX_KO_BAR,	"ko.png");
	d3_tex_load(TEX_TITLE,	"タイトル.jpg");
	d3_tex_load(TEX_INFO,	"説明.jpg");
	d3_tex_load(TEX_WIN,	"勝利.jpg");
	d3_tex_load(TEX_LOSE,	"敗北.jpg");

	//--- 効果音読み込み ---------------------------------------------------
	FOLDER_SET("サウンド");
	snd_load(SND_PUNCH,		"パンチ.wav",				false);
	snd_load(SND_GUARD,		"ガード.wav",				false);
	snd_load(SND_PLY_DAMAGE,"プレイヤーダメージ.wav",	false);
	snd_load(SND_ENE_DAMAGE,"エネミーダメージ.wav",		false);
	snd_load(SND_WIN_LOSE,	"試合終了.wav",				false);
	snd_load(SND_OK,		"ゴング.wav",				false);

	//--- カメラ位置 -------------------------------------------------------
	d3.vecCamera = VEC3(0, 15, -10);
	d3.vecEye	 = VEC3(0, 15,   0);

	d3.light.Direction.x = 0;
	d3.light.Direction.y = 0;
	d3.light.Direction.z = -d3.vecCamera.z;
}
Exemple #2
0
/**
 * @brief Load a skin file
 *
 * @param file the skin file
 *
 * @return false on an error
 */
bool Settings::load(const QString& file)
{
    qDebug() << "Settings: load";
    delete m_image;

    GError *err = NULL;
    m_private = new SettingsPrivate;
    if(skin_load(m_private,file.toLocal8Bit().data(),&err) != 0) {
        qDebug() << "Settings: couldn't load";
        return false;
    }

    m_image = new QImage();

    GdkPixbuf* pixbuf = m_private->raw;
    const uchar* bdata = (const uchar*)gdk_pixbuf_get_pixels(pixbuf);
    QSize bsize(gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
    int stride = gdk_pixbuf_get_rowstride(pixbuf);

    QImage im(bdata, bsize.width(), bsize.height(), stride, QImage::Format_RGB888 );
    *m_image = im.rgbSwapped();
    if(m_image->isNull()) {
         qDebug() << "Image Error";
         delete m_image;
         return false;
    }

    m_keyPos.clear();

    for(int iii = 0; iii < SKIN_KEYS; iii++) {
        QRect r = transform(m_private->keys_pos[iii]);
        if(!r.isValid())
            break;
        m_keyPos << r;
    }

    return true;
}
Exemple #3
0
int  hid_init(void)
{
    // Found a PC keyboard keymap
    match_keymap(tihw.calc_type);

    // Load kbd keymap
    if(keymap_load(options.keys_file) == -1)
    {
	    gchar *s = g_strdup_printf("unable to load this keymap: <%s>\n", options.keys_file);
	    tiemu_error(0, s);
	    g_free(s);
	    return -1;
    }

    // Found a skin
	match_skin(tihw.calc_type);

    // Load skin (2 parts)
    if(skin_load(&skin_infos, options.skin_file) == -1) 
    {
	    gchar *s = g_strdup_printf("unable to load this skin: <%s>\n", options.skin_file);
	    tiemu_error(0, s);
	    g_free(s);
	    return -1;
    }

	// Allocate the skn pixbuf (if needed)
	skn = skin_infos.image;
  
	// Set skin keymap depending on calculator type
    switch(tihw.calc_type)
    {
    case TI92:
    case TI92p:
    case V200:
        skn_keymap = sknKey92;
        break;
    case TI89:
    case TI89t:
      	skn_keymap = sknKey89;
        break;
    default:
        {
	  	gchar *s = g_strdup_printf("no skin found for this calc\n");
	  	tiemu_error(0, s);
	  	g_free(s);
	  	return -1;
        }
	}

	// Set window/LCD sizes
	set_scale(options.view);
	set_infos();

    // Allocate the TI screen buffer
	lcd_bytmap = (uint32_t *)malloc(LCDMEM_W * LCDMEM_H);

    // Allocate the lcd pixbuf
    lcd = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, si.t * LCDMEM_W, si.t * LCDMEM_H);
    if(lcd == NULL)
    {
        gchar *s = g_strdup_printf("unable to create LCD pixbuf.\n");
	    tiemu_error(0, s);
	    g_free(s);
	    return -1;
    }

	// Used by TI89 (the LCD view is clipped from memory view)
	si.l = gdk_pixbuf_new_subpixbuf(lcd, 0, 0, tihw.lcd_w, tihw.lcd_h);
    
	// Constants for LCD update (speed-up)
    li.n_channels = gdk_pixbuf_get_n_channels (lcd);
	li.width = gdk_pixbuf_get_width (lcd);
	li.height = gdk_pixbuf_get_height (lcd);
	li.rowstride = gdk_pixbuf_get_rowstride (lcd);
	li.pixels = gdk_pixbuf_get_pixels (lcd);

	// Create main window
	display_main_wnd();

    // Allocate the backing pixmap (used for drawing and refresh)
    pixmap = gdk_pixmap_new(main_wnd->window, wr.w, wr.h, -1);
    if(pixmap == NULL)
    {
        gchar *s = g_strdup_printf("unable to create backing pixbuf.\n");
	    tiemu_error(0, s);
	    g_free(s);
	    return -1;
    }
    
    // Draw the skin and compute grayscale palette
	redraw_skin();
  	compute_grayscale();

    // Init the planar/chunky conversion table for LCD
  	compute_convtable();

    // Install LCD refresh: 100 FPS (10 ms)
    tid = g_timeout_add((params.lcd_rate == -1) ? 50 : params.lcd_rate, 
		(GtkFunction)hid_refresh, NULL);

	gtk_widget_show(main_wnd);	// show wnd here

	if(options.view == VIEW_FULL)
		gdk_window_fullscreen(main_wnd->window);
	
    return 0;
}