equal
deleted
inserted
replaced
35 _num_dirty_rects++; |
35 _num_dirty_rects++; |
36 } |
36 } |
37 |
37 |
38 static void UpdatePalette(uint start, uint count) |
38 static void UpdatePalette(uint start, uint count) |
39 { |
39 { |
40 /* We can only update the palette in 8bpp for now */ |
|
41 /* TODO -- We need support for other bpps too! */ |
|
42 if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() != 8) return; |
|
43 |
|
44 SDL_Color pal[256]; |
40 SDL_Color pal[256]; |
45 uint i; |
41 uint i; |
46 |
42 |
47 for (i = 0; i != count; i++) { |
43 for (i = 0; i != count; i++) { |
48 pal[i].r = _cur_palette[start + i].r; |
44 pal[i].r = _cur_palette[start + i].r; |
59 UpdatePalette(0, 256); |
55 UpdatePalette(0, 256); |
60 } |
56 } |
61 |
57 |
62 static void CheckPaletteAnim() |
58 static void CheckPaletteAnim() |
63 { |
59 { |
64 if (_pal_last_dirty != -1) { |
60 if (_pal_count_dirty != 0) { |
65 UpdatePalette(_pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1); |
61 Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
66 _pal_last_dirty = -1; |
62 |
|
63 switch (blitter->UsePaletteAnimation()) { |
|
64 case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND: |
|
65 UpdatePalette(_pal_first_dirty, _pal_count_dirty); |
|
66 break; |
|
67 |
|
68 case Blitter::PALETTE_ANIMATION_BLITTER: |
|
69 blitter->PaletteAnimate(_pal_first_dirty, _pal_count_dirty); |
|
70 break; |
|
71 |
|
72 case Blitter::PALETTE_ANIMATION_NONE: |
|
73 break; |
|
74 |
|
75 default: |
|
76 NOT_REACHED(); |
|
77 } |
|
78 _pal_count_dirty = 0; |
67 } |
79 } |
68 } |
80 } |
69 |
81 |
70 static void DrawSurfaceToScreen() |
82 static void DrawSurfaceToScreen() |
71 { |
83 { |
428 } |
440 } |
429 |
441 |
430 static void SdlVideoMainLoop() |
442 static void SdlVideoMainLoop() |
431 { |
443 { |
432 uint32 cur_ticks = SDL_CALL SDL_GetTicks(); |
444 uint32 cur_ticks = SDL_CALL SDL_GetTicks(); |
|
445 uint32 last_cur_ticks = cur_ticks; |
433 uint32 next_tick = cur_ticks + 30; |
446 uint32 next_tick = cur_ticks + 30; |
434 uint32 pal_tick = 0; |
447 uint32 pal_tick = 0; |
435 uint32 mod; |
448 uint32 mod; |
436 int numkeys; |
449 int numkeys; |
437 Uint8 *keys; |
450 Uint8 *keys; |
458 _fast_forward = 0; |
471 _fast_forward = 0; |
459 } |
472 } |
460 |
473 |
461 cur_ticks = SDL_CALL SDL_GetTicks(); |
474 cur_ticks = SDL_CALL SDL_GetTicks(); |
462 if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) { |
475 if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) { |
|
476 _realtime_tick += cur_ticks - last_cur_ticks; |
|
477 last_cur_ticks = cur_ticks; |
463 next_tick = cur_ticks + 30; |
478 next_tick = cur_ticks + 30; |
464 |
479 |
465 _ctrl_pressed = !!(mod & KMOD_CTRL); |
480 _ctrl_pressed = !!(mod & KMOD_CTRL); |
466 _shift_pressed = !!(mod & KMOD_SHIFT); |
481 _shift_pressed = !!(mod & KMOD_SHIFT); |
467 #ifdef _DEBUG |
|
468 _dbg_screen_rect = !!(mod & KMOD_CAPS); |
|
469 #endif |
|
470 |
482 |
471 // determine which directional keys are down |
483 // determine which directional keys are down |
472 _dirkeys = |
484 _dirkeys = |
473 (keys[SDLK_LEFT] ? 1 : 0) | |
485 (keys[SDLK_LEFT] ? 1 : 0) | |
474 (keys[SDLK_UP] ? 2 : 0) | |
486 (keys[SDLK_UP] ? 2 : 0) | |