ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.54 by root, Wed Apr 19 23:37:48 2006 UTC vs.
Revision 1.58 by root, Sun Apr 23 00:57:38 2006 UTC

33 typedef signed char int8_t; 33 typedef signed char int8_t;
34 typedef signed short int16_t; 34 typedef signed short int16_t;
35 typedef signed int int32_t; 35 typedef signed int int32_t;
36#endif 36#endif
37 37
38#include "glext.h"
39
38#define FOW_DARKNESS 32 40#define FOW_DARKNESS 32
39 41
40#define MAP_EXTEND_X 32 42#define MAP_EXTEND_X 32
41#define MAP_EXTEND_Y 512 43#define MAP_EXTEND_Y 512
44
45#define MIN_FONT_HEIGHT 8 * PANGO_SCALE
42 46
43typedef Mix_Chunk *CFClient__MixChunk; 47typedef Mix_Chunk *CFClient__MixChunk;
44typedef Mix_Music *CFClient__MixMusic; 48typedef Mix_Music *CFClient__MixMusic;
45 49
46static PangoContext *context; 50static PangoContext *context;
65 * reasonably well with bitstream vera 69 * reasonably well with bitstream vera
66 */ 70 */
67 PangoFontDescription *font = pango_context_get_font_description (context); 71 PangoFontDescription *font = pango_context_get_font_description (context);
68 72
69 int height = self->base_height * (PANGO_SCALE * 8 / 10); 73 int height = self->base_height * (PANGO_SCALE * 8 / 10);
74
75 if (height < MIN_FONT_HEIGHT)
76 height = MIN_FONT_HEIGHT;
70 77
71 if (pango_font_description_get_size (font) != height) 78 if (pango_font_description_get_size (font) != height)
72 { 79 {
73 pango_font_description_set_absolute_size (font, height); 80 pango_font_description_set_absolute_size (font, height);
74 pango_layout_context_changed (self->pl); 81 pango_layout_context_changed (self->pl);
237 break; 244 break;
238 245
239 row->col[x - row->c0].darkness = -1; 246 row->col[x - row->c0].darkness = -1;
240 } 247 }
241 } 248 }
249}
250
251static void
252music_finished ()
253{
254 SDL_UserEvent ev;
255
256 ev.type = SDL_USEREVENT;
257 ev.code = 0;
258 ev.data1 = 0;
259 ev.data2 = 0;
260
261 SDL_PushEvent ((SDL_Event *)&ev);
242} 262}
243 263
244MODULE = CFClient PACKAGE = CFClient 264MODULE = CFClient PACKAGE = CFClient
245 265
246PROTOTYPES: ENABLE 266PROTOTYPES: ENABLE
463 } 483 }
464} 484}
465 485
466int 486int
467Mix_OpenAudio (int frequency = 22050, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 512) 487Mix_OpenAudio (int frequency = 22050, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 512)
488 POSTCALL:
489 Mix_HookMusicFinished (music_finished);
468 490
469void 491void
470Mix_CloseAudio () 492Mix_CloseAudio ()
471 493
472int 494int
933 cell->darkness = -1; 955 cell->darkness = -1;
934 } 956 }
935} 957}
936 958
937SV * 959SV *
938mapmap (CFClient::Map self, int w, int h) 960mapmap (CFClient::Map self, int x0, int y0, int w, int h)
939 CODE: 961 CODE:
940{ 962{
941 int x0, x1, x; 963 int x1, x;
942 int y0, y1, y; 964 int y1, y;
943 int z; 965 int z;
944 SV *map_sv = newSV (w * h * sizeof (uint32_t)); 966 SV *map_sv = newSV (w * h * sizeof (uint32_t));
945 uint32_t *map = (uint32_t *)SvPVX (map_sv); 967 uint32_t *map = (uint32_t *)SvPVX (map_sv);
946 968
947 SvPOK_only (map_sv); 969 SvPOK_only (map_sv);
948 SvCUR_set (map_sv, w * h * sizeof (uint32_t)); 970 SvCUR_set (map_sv, w * h * sizeof (uint32_t));
949 971
950 x0 = self->x - w / 2; x1 = x0 + w; 972 x0 += self->x; x1 = x0 + w;
951 y0 = self->y - h / 2; y1 = y0 + h; 973 y0 += self->y; y1 = y0 + h;
952 974
953 for (y = y0; y < y1; y++) 975 for (y = y0; y < y1; y++)
954 { 976 {
955 maprow *row = 0 <= y && y < self->rows 977 maprow *row = 0 <= y && y < self->rows
956 ? self->row + y 978 ? self->row + y
1096 *data++ = 0; /* version 0 format */ 1118 *data++ = 0; /* version 0 format */
1097 *data++ = w >> 8; *data++ = w; 1119 *data++ = w >> 8; *data++ = w;
1098 *data++ = h >> 8; *data++ = h; 1120 *data++ = h >> 8; *data++ = h;
1099 1121
1100 // we need to do this 'cause we don't keep an absolute coord system for rows 1122 // we need to do this 'cause we don't keep an absolute coord system for rows
1101 // TODO: treat rows as we treat 1123 // TODO: treat rows as we treat columns
1102 map_get_row (self, y0 + self->y - self->oy);//D 1124 map_get_row (self, y0 + self->y - self->oy);//D
1103 map_get_row (self, y0 + self->y - self->oy + h - 1);//D 1125 map_get_row (self, y0 + self->y - self->oy + h - 1);//D
1104 1126
1105 x0 += self->x - self->ox; 1127 x0 += self->x - self->ox;
1106 y0 += self->y - self->oy; 1128 y0 += self->y - self->oy;
1170 1192
1171 w = *data++ << 8; w |= *data++; 1193 w = *data++ << 8; w |= *data++;
1172 h = *data++ << 8; h |= *data++; 1194 h = *data++ << 8; h |= *data++;
1173 1195
1174 // we need to do this 'cause we don't keep an absolute coord system for rows 1196 // we need to do this 'cause we don't keep an absolute coord system for rows
1175 // TODO: treat rows as we treat 1197 // TODO: treat rows as we treat columns
1176 map_get_row (self, y0 + self->y - self->oy);//D 1198 map_get_row (self, y0 + self->y - self->oy);//D
1177 map_get_row (self, y0 + self->y - self->oy + h - 1);//D 1199 map_get_row (self, y0 + self->y - self->oy + h - 1);//D
1178 1200
1179 x0 += self->x - self->ox; 1201 x0 += self->x - self->ox;
1180 y0 += self->y - self->oy; 1202 y0 += self->y - self->oy;
1308 const_iv (GL_TEXTURE_WRAP_T), 1330 const_iv (GL_TEXTURE_WRAP_T),
1309 const_iv (GL_CLAMP), 1331 const_iv (GL_CLAMP),
1310 const_iv (GL_REPEAT), 1332 const_iv (GL_REPEAT),
1311 const_iv (GL_NEAREST), 1333 const_iv (GL_NEAREST),
1312 const_iv (GL_LINEAR), 1334 const_iv (GL_LINEAR),
1335 const_iv (GL_NEAREST_MIPMAP_NEAREST),
1336 const_iv (GL_LINEAR_MIPMAP_NEAREST),
1337 const_iv (GL_NEAREST_MIPMAP_LINEAR),
1338 const_iv (GL_LINEAR_MIPMAP_LINEAR),
1339 const_iv (GL_GENERATE_MIPMAP),
1340 const_iv (GL_LINEAR),
1313 const_iv (GL_MODULATE), 1341 const_iv (GL_MODULATE),
1314 const_iv (GL_REPLACE), 1342 const_iv (GL_REPLACE),
1315 const_iv (GL_COLOR_BUFFER_BIT), 1343 const_iv (GL_COLOR_BUFFER_BIT),
1316 const_iv (GL_PROJECTION), 1344 const_iv (GL_PROJECTION),
1317 const_iv (GL_MODELVIEW), 1345 const_iv (GL_MODELVIEW),
1319 const_iv (GL_CONVOLUTION_2D), 1347 const_iv (GL_CONVOLUTION_2D),
1320 const_iv (GL_CONVOLUTION_BORDER_MODE), 1348 const_iv (GL_CONVOLUTION_BORDER_MODE),
1321 const_iv (GL_CONSTANT_BORDER), 1349 const_iv (GL_CONSTANT_BORDER),
1322 const_iv (GL_LINES), 1350 const_iv (GL_LINES),
1323 const_iv (GL_QUADS), 1351 const_iv (GL_QUADS),
1352 const_iv (GL_LINE_LOOP),
1324 const_iv (GL_PERSPECTIVE_CORRECTION_HINT), 1353 const_iv (GL_PERSPECTIVE_CORRECTION_HINT),
1325 const_iv (GL_FASTEST), 1354 const_iv (GL_FASTEST),
1326# undef const_iv 1355# undef const_iv
1327 }; 1356 };
1328 1357

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines