Root/liballegro/patches/050-shooter-gfx-mode.patch

1Index: allegro-4.4.2/demos/shooter/demo.c
2===================================================================
3--- allegro-4.4.2.orig/demos/shooter/demo.c 2011-06-02 12:32:25.000000000 +0200
4+++ allegro-4.4.2/demos/shooter/demo.c 2011-06-02 12:32:44.000000000 +0200
5@@ -1,3 +1,5 @@
6+#define DEBUGMODE
7+
8 #include "demo.h"
9 #include "data.h"
10 #include "expl.h"
11@@ -90,7 +92,6 @@
12       allegro_message("Error initialising joystick\n%s\n", allegro_error);
13       install_joystick(JOY_TYPE_NONE);
14    }
15-
16    if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
17       if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
18          set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
19Index: allegro-4.4.2/demos/shooter/display.c
20===================================================================
21--- allegro-4.4.2.orig/demos/shooter/display.c 2011-06-02 12:30:09.000000000 +0200
22+++ allegro-4.4.2/demos/shooter/display.c 2011-06-02 12:32:44.000000000 +0200
23@@ -28,18 +28,19 @@
24          break;
25    }
26 
27- set_color_depth(8);
28+ set_color_depth(32);
29 #ifdef ALLEGRO_VRAM_SINGLE_SURFACE
30    if (set_gfx_mode(mode, w, h, w, h * num_pages) != 0) {
31 #else
32    if (set_gfx_mode(mode, w, h, 0, 0) != 0) {
33 #endif
34       set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
35- allegro_message("Error setting 8bpp graphics mode\n%s\n",
36+ allegro_message("Error setting 32bpp graphics mode\n%s\n",
37                       allegro_error);
38       exit(1);
39    }
40 
41+ set_color_depth(8);
42    page1 = NULL;
43    page2 = NULL;
44    page3 = NULL;
45@@ -49,7 +50,7 @@
46 
47       case DOUBLE_BUFFER:
48       case DIRTY_RECTANGLE:
49- memory_buffer = create_bitmap(SCREEN_W, SCREEN_H);
50+ memory_buffer = create_bitmap_ex(8, SCREEN_W, SCREEN_H);
51 
52          if (!memory_buffer) {
53             set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
54Index: allegro-4.4.2/demos/shooter/game.c
55===================================================================
56--- allegro-4.4.2.orig/demos/shooter/game.c 2011-06-02 12:30:09.000000000 +0200
57+++ allegro-4.4.2/demos/shooter/game.c 2011-06-02 12:36:29.000000000 +0200
58@@ -58,12 +58,18 @@
59 static void draw_intro_item(int item, int size)
60 {
61    BITMAP *b = (BITMAP *) data[item].dat;
62+ BITMAP *b_n = create_bitmap_ex(bitmap_color_depth(screen), b->w, b->h);
63+ clear_to_color(b_n,0xffff);
64+ set_palette(data[GAME_PAL].dat);
65+ blit (b, b_n, 0, 0, 0, 0, b->w, b->h);
66+
67    int w = MIN(SCREEN_W, (SCREEN_W * 2 / size));
68    int h = SCREEN_H / size;
69 
70    clear_bitmap(screen);
71- stretch_blit(b, screen, 0, 0, b->w, b->h, (SCREEN_W - w) / 2,
72+ stretch_blit(b_n, screen, 0, 0, b->w, b->h, (SCREEN_W - w) / 2,
73                 (SCREEN_H - h) / 2, w, h);
74+ destroy_bitmap(b_n);
75 }
76 
77 
78Index: allegro-4.4.2/demos/shooter/title.c
79===================================================================
80--- allegro-4.4.2.orig/demos/shooter/title.c 2011-06-02 12:32:26.000000000 +0200
81+++ allegro-4.4.2/demos/shooter/title.c 2011-06-02 12:38:29.000000000 +0200
82@@ -844,10 +844,18 @@
83    scroll_count = 1;
84    install_int(scroll_counter, 5);
85 
86+ /* fix for stretch_blit: won't work over different color depth */
87+ BITMAP *title = data[TITLE_BMP].dat;
88+ BITMAP *title_n = create_bitmap_ex(bitmap_color_depth(screen),
89+ title->w, title->h);
90+ blit (title, title_n, 0, 0, 0, 0, title->w, title->h);
91    while ((c = scroll_count) < 160)
92- stretch_blit(data[TITLE_BMP].dat, screen, 0, 0, 320, 128,
93+ {
94+ stretch_blit(title_n, screen, 0, 0, 320, 128,
95                    SCREEN_W / 2 - c, SCREEN_H / 2 - c * 64 / 160 - 32,
96                    c * 2, c * 128 / 160);
97+ }
98+ destroy_bitmap(title_n);
99 
100    remove_int(scroll_counter);
101 
102Index: allegro-4.4.2/demos/shooter/dirty.c
103===================================================================
104--- allegro-4.4.2.orig/demos/shooter/dirty.c 2011-06-02 12:30:09.000000000 +0200
105+++ allegro-4.4.2/demos/shooter/dirty.c 2011-06-02 12:33:37.000000000 +0200
106@@ -92,10 +92,13 @@
107 
108    acquire_screen();
109 
110+ /* setup palette_color[] */
111+ set_color_depth(32);
112+
113    for (c = 0; c < old_dirty.count; c++) {
114       if ((old_dirty.rect[c].w == 1) && (old_dirty.rect[c].h == 1)) {
115          putpixel(screen, old_dirty.rect[c].x, old_dirty.rect[c].y,
116- getpixel(bmp, old_dirty.rect[c].x, old_dirty.rect[c].y));
117+ palette_color[getpixel(bmp, old_dirty.rect[c].x, old_dirty.rect[c].y)]);
118       }
119       else {
120          blit(bmp, screen, old_dirty.rect[c].x, old_dirty.rect[c].y,
121@@ -103,6 +106,7 @@
122               old_dirty.rect[c].w, old_dirty.rect[c].h);
123       }
124    }
125+ set_color_depth(8);
126 
127    release_screen();
128 }
129

Archive Download this file



interactive