src/video/sdl_v.cpp
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6314 f738bcf05ad6
child 9911 0b8b245a2391
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
    47 	}
    47 	}
    48 
    48 
    49 	SDL_CALL SDL_SetColors(_sdl_screen, pal, start, count);
    49 	SDL_CALL SDL_SetColors(_sdl_screen, pal, start, count);
    50 }
    50 }
    51 
    51 
    52 static void InitPalette(void)
    52 static void InitPalette()
    53 {
    53 {
    54 	UpdatePalette(0, 256);
    54 	UpdatePalette(0, 256);
    55 }
    55 }
    56 
    56 
    57 static void CheckPaletteAnim(void)
    57 static void CheckPaletteAnim()
    58 {
    58 {
    59 	if (_pal_last_dirty != -1) {
    59 	if (_pal_last_dirty != -1) {
    60 		UpdatePalette(_pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1);
    60 		UpdatePalette(_pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1);
    61 		_pal_last_dirty = -1;
    61 		_pal_last_dirty = -1;
    62 	}
    62 	}
    63 }
    63 }
    64 
    64 
    65 static void DrawSurfaceToScreen(void)
    65 static void DrawSurfaceToScreen()
    66 {
    66 {
    67 	int n = _num_dirty_rects;
    67 	int n = _num_dirty_rects;
    68 	if (n != 0) {
    68 	if (n != 0) {
    69 		_num_dirty_rects = 0;
    69 		_num_dirty_rects = 0;
    70 		if (n > MAX_DIRTY_RECTS)
    70 		if (n > MAX_DIRTY_RECTS)
    86 	{1600, 1200},
    86 	{1600, 1200},
    87 	{1680, 1050},
    87 	{1680, 1050},
    88 	{1920, 1200}
    88 	{1920, 1200}
    89 };
    89 };
    90 
    90 
    91 static void GetVideoModes(void)
    91 static void GetVideoModes()
    92 {
    92 {
    93 	int i;
    93 	int i;
    94 	SDL_Rect **modes;
    94 	SDL_Rect **modes;
    95 
    95 
    96 	modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
    96 	modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
   207 	GameSizeChanged();
   207 	GameSizeChanged();
   208 
   208 
   209 	return true;
   209 	return true;
   210 }
   210 }
   211 
   211 
   212 typedef struct VkMapping {
   212 struct VkMapping {
   213 	uint16 vk_from;
   213 	uint16 vk_from;
   214 	byte vk_count;
   214 	byte vk_count;
   215 	byte map_to;
   215 	byte map_to;
   216 } VkMapping;
   216 };
   217 
   217 
   218 #define AS(x, z) {x, 0, z}
   218 #define AS(x, z) {x, 0, z}
   219 #define AM(x, y, z, w) {x, y - x, z}
   219 #define AM(x, y, z, w) {x, y - x, z}
   220 
   220 
   221 static const VkMapping _vk_mapping[] = {
   221 static const VkMapping _vk_mapping[] = {
   299 	DEBUG(driver, 0, "Unicode character pressed %u", sym->unicode);
   299 	DEBUG(driver, 0, "Unicode character pressed %u", sym->unicode);
   300 #endif
   300 #endif
   301 	return (key << 16) + sym->unicode;
   301 	return (key << 16) + sym->unicode;
   302 }
   302 }
   303 
   303 
   304 static int PollEvent(void)
   304 static int PollEvent()
   305 {
   305 {
   306 	SDL_Event ev;
   306 	SDL_Event ev;
   307 
   307 
   308 	if (!SDL_CALL SDL_PollEvent(&ev)) return -2;
   308 	if (!SDL_CALL SDL_PollEvent(&ev)) return -2;
   309 
   309 
   413 	SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
   413 	SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
   414 	SDL_CALL SDL_EnableUNICODE(1);
   414 	SDL_CALL SDL_EnableUNICODE(1);
   415 	return NULL;
   415 	return NULL;
   416 }
   416 }
   417 
   417 
   418 static void SdlVideoStop(void)
   418 static void SdlVideoStop()
   419 {
   419 {
   420 	SdlClose(SDL_INIT_VIDEO);
   420 	SdlClose(SDL_INIT_VIDEO);
   421 }
   421 }
   422 
   422 
   423 static void SdlVideoMainLoop(void)
   423 static void SdlVideoMainLoop()
   424 {
   424 {
   425 	uint32 cur_ticks = SDL_CALL SDL_GetTicks();
   425 	uint32 cur_ticks = SDL_CALL SDL_GetTicks();
   426 	uint32 next_tick = cur_ticks + 30;
   426 	uint32 next_tick = cur_ticks + 30;
   427 	uint32 pal_tick = 0;
   427 	uint32 pal_tick = 0;
   428 	uint32 mod;
   428 	uint32 mod;
   450 		} else if (_fast_forward & 2) {
   450 		} else if (_fast_forward & 2) {
   451 			_fast_forward = 0;
   451 			_fast_forward = 0;
   452 		}
   452 		}
   453 
   453 
   454 		cur_ticks = SDL_CALL SDL_GetTicks();
   454 		cur_ticks = SDL_CALL SDL_GetTicks();
   455 		if (cur_ticks >= next_tick || (_fast_forward && !_pause) || cur_ticks < prev_cur_ticks) {
   455 		if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) {
   456 			next_tick = cur_ticks + 30;
   456 			next_tick = cur_ticks + 30;
   457 
   457 
   458 			_ctrl_pressed  = !!(mod & KMOD_CTRL);
   458 			_ctrl_pressed  = !!(mod & KMOD_CTRL);
   459 			_shift_pressed = !!(mod & KMOD_SHIFT);
   459 			_shift_pressed = !!(mod & KMOD_SHIFT);
   460 #ifdef _DEBUG
   460 #ifdef _DEBUG