… | |
… | |
241 | |
241 | |
242 | PROTOTYPES: ENABLE |
242 | PROTOTYPES: ENABLE |
243 | |
243 | |
244 | BOOT: |
244 | BOOT: |
245 | { |
245 | { |
|
|
246 | HV *stash = gv_stashpv ("CFClient", 1); |
|
|
247 | static const struct { |
|
|
248 | const char *name; |
|
|
249 | IV iv; |
|
|
250 | } *civ, const_iv[] = { |
|
|
251 | # define const_iv(name) { # name, (IV)name } |
|
|
252 | const_iv (SDL_ACTIVEEVENT), |
|
|
253 | const_iv (SDL_KEYDOWN), |
|
|
254 | const_iv (SDL_KEYUP), |
|
|
255 | const_iv (SDL_MOUSEMOTION), |
|
|
256 | const_iv (SDL_MOUSEBUTTONDOWN), |
|
|
257 | const_iv (SDL_MOUSEBUTTONUP), |
|
|
258 | const_iv (SDL_JOYAXISMOTION), |
|
|
259 | const_iv (SDL_JOYBALLMOTION), |
|
|
260 | const_iv (SDL_JOYHATMOTION), |
|
|
261 | const_iv (SDL_JOYBUTTONDOWN), |
|
|
262 | const_iv (SDL_JOYBUTTONUP), |
|
|
263 | const_iv (SDL_QUIT), |
|
|
264 | const_iv (SDL_SYSWMEVENT), |
|
|
265 | const_iv (SDL_EVENT_RESERVEDA), |
|
|
266 | const_iv (SDL_EVENT_RESERVEDB), |
|
|
267 | const_iv (SDL_VIDEORESIZE), |
|
|
268 | const_iv (SDL_VIDEOEXPOSE), |
|
|
269 | const_iv (SDL_USEREVENT), |
|
|
270 | const_iv (SDLK_KP0), |
|
|
271 | const_iv (SDLK_KP1), |
|
|
272 | const_iv (SDLK_KP2), |
|
|
273 | const_iv (SDLK_KP3), |
|
|
274 | const_iv (SDLK_KP4), |
|
|
275 | const_iv (SDLK_KP5), |
|
|
276 | const_iv (SDLK_KP6), |
|
|
277 | const_iv (SDLK_KP7), |
|
|
278 | const_iv (SDLK_KP8), |
|
|
279 | const_iv (SDLK_KP9), |
|
|
280 | const_iv (SDLK_KP_PERIOD), |
|
|
281 | const_iv (SDLK_KP_DIVIDE), |
|
|
282 | const_iv (SDLK_KP_MULTIPLY), |
|
|
283 | const_iv (SDLK_KP_MINUS), |
|
|
284 | const_iv (SDLK_KP_PLUS), |
|
|
285 | const_iv (SDLK_KP_ENTER), |
|
|
286 | const_iv (SDLK_KP_EQUALS), |
|
|
287 | const_iv (SDLK_UP), |
|
|
288 | const_iv (SDLK_DOWN), |
|
|
289 | const_iv (SDLK_RIGHT), |
|
|
290 | const_iv (SDLK_LEFT), |
|
|
291 | const_iv (SDLK_INSERT), |
|
|
292 | const_iv (SDLK_HOME), |
|
|
293 | const_iv (SDLK_END), |
|
|
294 | const_iv (SDLK_PAGEUP), |
|
|
295 | const_iv (SDLK_PAGEDOWN), |
|
|
296 | const_iv (SDLK_F1), |
|
|
297 | const_iv (SDLK_F2), |
|
|
298 | const_iv (SDLK_F3), |
|
|
299 | const_iv (SDLK_F4), |
|
|
300 | const_iv (SDLK_F5), |
|
|
301 | const_iv (SDLK_F6), |
|
|
302 | const_iv (SDLK_F7), |
|
|
303 | const_iv (SDLK_F8), |
|
|
304 | const_iv (SDLK_F9), |
|
|
305 | const_iv (SDLK_F10), |
|
|
306 | const_iv (SDLK_F11), |
|
|
307 | const_iv (SDLK_F12), |
|
|
308 | const_iv (SDLK_F13), |
|
|
309 | const_iv (SDLK_F14), |
|
|
310 | const_iv (SDLK_F15), |
|
|
311 | const_iv (SDLK_NUMLOCK), |
|
|
312 | const_iv (SDLK_CAPSLOCK), |
|
|
313 | const_iv (SDLK_SCROLLOCK), |
|
|
314 | const_iv (SDLK_RSHIFT), |
|
|
315 | const_iv (SDLK_LSHIFT), |
|
|
316 | const_iv (SDLK_RCTRL), |
|
|
317 | const_iv (SDLK_LCTRL), |
|
|
318 | const_iv (SDLK_RALT), |
|
|
319 | const_iv (SDLK_LALT), |
|
|
320 | const_iv (SDLK_RMETA), |
|
|
321 | const_iv (SDLK_LMETA), |
|
|
322 | const_iv (SDLK_LSUPER), |
|
|
323 | const_iv (SDLK_RSUPER), |
|
|
324 | const_iv (SDLK_MODE), |
|
|
325 | const_iv (SDLK_COMPOSE), |
|
|
326 | const_iv (SDLK_HELP), |
|
|
327 | const_iv (SDLK_PRINT), |
|
|
328 | const_iv (SDLK_SYSREQ), |
|
|
329 | const_iv (SDLK_BREAK), |
|
|
330 | const_iv (SDLK_MENU), |
|
|
331 | const_iv (SDLK_POWER), |
|
|
332 | const_iv (SDLK_EURO), |
|
|
333 | const_iv (SDLK_UNDO), |
|
|
334 | const_iv (KMOD_NONE), |
|
|
335 | const_iv (KMOD_LSHIFT), |
|
|
336 | const_iv (KMOD_RSHIFT), |
|
|
337 | const_iv (KMOD_LCTRL), |
|
|
338 | const_iv (KMOD_RCTRL), |
|
|
339 | const_iv (KMOD_LALT), |
|
|
340 | const_iv (KMOD_RALT), |
|
|
341 | const_iv (KMOD_LMETA), |
|
|
342 | const_iv (KMOD_RMETA), |
|
|
343 | const_iv (KMOD_NUM), |
|
|
344 | const_iv (KMOD_CAPS), |
|
|
345 | const_iv (KMOD_MODE), |
|
|
346 | const_iv (KMOD_CTRL), |
|
|
347 | const_iv (KMOD_SHIFT), |
|
|
348 | const_iv (KMOD_ALT), |
|
|
349 | const_iv (KMOD_META) |
|
|
350 | # undef const_iv |
|
|
351 | }; |
|
|
352 | |
|
|
353 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
|
|
354 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
355 | |
246 | fontmap = pango_ft2_font_map_new (); |
356 | fontmap = pango_ft2_font_map_new (); |
247 | pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, substitute_func, 0, 0); |
357 | pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, substitute_func, 0, 0); |
248 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
358 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
249 | } |
359 | } |
|
|
360 | |
|
|
361 | int |
|
|
362 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
|
|
363 | |
|
|
364 | void |
|
|
365 | SDL_Quit () |
|
|
366 | |
|
|
367 | void |
|
|
368 | SDL_ListModes () |
|
|
369 | PPCODE: |
|
|
370 | { |
|
|
371 | SDL_Rect **m; |
|
|
372 | |
|
|
373 | SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5); |
|
|
374 | SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5); |
|
|
375 | SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5); |
|
|
376 | SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 1); |
|
|
377 | |
|
|
378 | SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0); |
|
|
379 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
|
|
380 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
|
|
381 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
|
|
382 | |
|
|
383 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
384 | SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15); |
|
|
385 | SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0); |
|
|
386 | |
|
|
387 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
|
|
388 | |
|
|
389 | if (m && m != (SDL_Rect **)-1) |
|
|
390 | while (*m) |
|
|
391 | { |
|
|
392 | AV *av = newAV (); |
|
|
393 | av_push (av, newSViv ((*m)->w)); |
|
|
394 | av_push (av, newSViv ((*m)->h)); |
|
|
395 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
396 | |
|
|
397 | ++m; |
|
|
398 | } |
|
|
399 | } |
|
|
400 | |
|
|
401 | int |
|
|
402 | SDL_SetVideoMode (int w, int h, int fullscreen) |
|
|
403 | CODE: |
|
|
404 | RETVAL = !!SDL_SetVideoMode ( |
|
|
405 | w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0) |
|
|
406 | ); |
|
|
407 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
|
|
408 | OUTPUT: |
|
|
409 | RETVAL |
250 | |
410 | |
251 | void |
411 | void |
252 | lowdelay (int fd, int val = 1) |
412 | lowdelay (int fd, int val = 1) |
253 | CODE: |
413 | CODE: |
254 | #ifndef _WIN32 |
414 | #ifndef _WIN32 |
… | |
… | |
307 | croak ("load_image: %s", SDL_GetError ()); |
467 | croak ("load_image: %s", SDL_GetError ()); |
308 | |
468 | |
309 | fmt.palette = NULL; |
469 | fmt.palette = NULL; |
310 | fmt.BitsPerPixel = 32; |
470 | fmt.BitsPerPixel = 32; |
311 | fmt.BytesPerPixel = 4; |
471 | fmt.BytesPerPixel = 4; |
|
|
472 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
312 | fmt.Rmask = 0x000000ff; |
473 | fmt.Rmask = 0x000000ff; |
313 | fmt.Gmask = 0x0000ff00; |
474 | fmt.Gmask = 0x0000ff00; |
314 | fmt.Bmask = 0x00ff0000; |
475 | fmt.Bmask = 0x00ff0000; |
315 | fmt.Amask = 0xff000000; |
476 | fmt.Amask = 0xff000000; |
|
|
477 | #else |
|
|
478 | fmt.Rmask = 0xff000000; |
|
|
479 | fmt.Gmask = 0x00ff0000; |
|
|
480 | fmt.Bmask = 0x0000ff00; |
|
|
481 | fmt.Amask = 0x000000ff; |
|
|
482 | #endif |
316 | fmt.Rloss = 0; |
483 | fmt.Rloss = 0; |
317 | fmt.Gloss = 0; |
484 | fmt.Gloss = 0; |
318 | fmt.Bloss = 0; |
485 | fmt.Bloss = 0; |
319 | fmt.Aloss = 0; |
486 | fmt.Aloss = 0; |
320 | fmt.Rshift = 0; |
487 | fmt.Rshift = 0; |
… | |
… | |
334 | SDL_LockSurface (surface2); |
501 | SDL_LockSurface (surface2); |
335 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
502 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
336 | SDL_UnlockSurface (surface2); |
503 | SDL_UnlockSurface (surface2); |
337 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
504 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
338 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
505 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
339 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV))); |
506 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
340 | |
507 | |
341 | SDL_FreeSurface (surface); |
508 | SDL_FreeSurface (surface); |
342 | SDL_FreeSurface (surface2); |
509 | SDL_FreeSurface (surface2); |
343 | } |
510 | } |
344 | |
511 | |
… | |
… | |
368 | } |
535 | } |
369 | |
536 | |
370 | void |
537 | void |
371 | fatal (char *message) |
538 | fatal (char *message) |
372 | CODE: |
539 | CODE: |
373 | #ifdef WIN32 |
540 | #ifdef _WIN32 |
374 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); |
541 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); |
375 | #else |
542 | #else |
376 | fprintf (stderr, "FATAL: %s\n", message); |
543 | fprintf (stderr, "FATAL: %s\n", message); |
377 | #endif |
544 | #endif |
378 | exit (1); |
545 | exit (1); |