Debian Codegraph @

src/gp2xwiz/wiz_display_fb.c

raw
1 /* ______ ___ ___
2 * /\ _ \ /\_ \ /\_ \
3 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
4 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
5 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
6 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
7 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
8 * /\____/
9 * \_/__/
10 *
11 * GP2X Wiz framebuffer display driver
12 *
13 * By Trent Gamblin.
14 *
15 */
16
17 #include "allegro5/internal/aintern_gp2xwiz.h"
18 #include "allegro5/internal/aintern_bitmap.h"
19 #include "allegro5/internal/aintern_opengl.h"
20
21 ALLEGRO_DEBUG_CHANNEL("display")
22
23 static ALLEGRO_DISPLAY_INTERFACE *gp2xwiz_vt;
24
25 static bool set_gfx_mode = false;
26
27 /* Create a new X11 display, which maps directly to a GLX window. */
28 static ALLEGRO_DISPLAY *gp2xwiz_create_display_fb(int w, int h)
29 {
30 (void)w;
31 (void)h;
32
33 /* Only one display allowed at a time */
34 if (set_gfx_mode)
35 return NULL;
36
37 lc_init_rest();
38
39 ALLEGRO_DISPLAY_GP2XWIZ_FB *d = al_calloc(1, sizeof *d);
40 ALLEGRO_DISPLAY *display = (void *)d;
41
42 ALLEGRO_SYSTEM_GP2XWIZ *system = (void *)al_get_system_driver();
43
44 display->w = 320;
45 display->h = 240;
46 display->vt = _al_display_gp2xwiz_framebuffer_driver();
47 display->refresh_rate = 60;
48 display->flags = al_get_new_display_flags();
49
50 display->flags |= ALLEGRO_FULLSCREEN;
51
52 /* Add ourself to the list of displays. */
53 ALLEGRO_DISPLAY_GP2XWIZ_FB **add;
54 add = _al_vector_alloc_back(&system->system.displays);
55 *add = d;
56
57 /* Each display is an event source. */
58 _al_event_source_init(&display->es);
59
60 /* Create a backbuffer and point it to the framebuffer */
61 al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
62 d->backbuffer = al_create_bitmap(320, 240);
63 d->screen_mem = d->backbuffer->memory;
64 d->backbuffer->memory = (unsigned char *)lc_fb1;
65
66 set_gfx_mode = true;
67
68 ALLEGRO_DEBUG("Display created successfully\n");
69
70 return display;
71 }
72
73
74 static void gp2xwiz_destroy_display_fb(ALLEGRO_DISPLAY *d)
75 {
76 ALLEGRO_SYSTEM_GP2XWIZ *s = (void *)al_get_system_driver();
77 ALLEGRO_DISPLAY_GP2XWIZ_FB *wiz_disp = (void *)d;
78
79 _al_vector_find_and_delete(&s->system.displays, &d);
80
81 /* All bitmaps are memory bitmaps, no need to do anything */
82
83 _al_vector_free(&d->bitmaps);
84 _al_event_source_free(&d->es);
85
86 wiz_disp->backbuffer->memory = wiz_disp->screen_mem;
87 al_destroy_bitmap(wiz_disp->backbuffer);
88
89 al_free(d->vertex_cache);
90 al_free(d);
91
92 set_gfx_mode = false;
93 }
94
95
96 static bool gp2xwiz_set_current_display_fb(ALLEGRO_DISPLAY *d)
97 {
98 (void)d;
99 return true;
100 }
101
102
103 static void gp2xwiz_flip_display_fb(ALLEGRO_DISPLAY *d)
104 {
105 (void)d;
106 }
107
108 static void gp2xwiz_update_display_region_fb(ALLEGRO_DISPLAY *d, int x, int y,
109 int w, int h)
110 {
111 (void)x;
112 (void)y;
113 (void)w;
114 (void)h;
115 gp2xwiz_flip_display_fb(d);
116 }
117
118 static bool gp2xwiz_acknowledge_resize_fb(ALLEGRO_DISPLAY *d)
119 {
120 (void)d;
121 return false;
122 }
123
124
125 static bool gp2xwiz_resize_display_fb(ALLEGRO_DISPLAY *d, int w, int h)
126 {
127 (void)d;
128 (void)w;
129 (void)h;
130 return false;
131 }
132
133
134 static bool gp2xwiz_is_compatible_bitmap_fb(ALLEGRO_DISPLAY *display,
135 ALLEGRO_BITMAP *bitmap)
136 {
137 (void)display;
138 (void)bitmap;
139 return true;
140 }
141
142
143 static void gp2xwiz_get_window_position_fb(ALLEGRO_DISPLAY *display, int *x, int *y)
144 {
145 (void)display;
146 *x = 0;
147 *y = 0;
148 }
149
150
151 static bool gp2xwiz_wait_for_vsync_fb(ALLEGRO_DISPLAY *display)
152 {
153 (void)display;
154 return false;
155 }
156
157
158 static ALLEGRO_BITMAP *gp2xwiz_get_backbuffer_fb(ALLEGRO_DISPLAY *display)
159 {
160 ALLEGRO_DISPLAY_GP2XWIZ_FB *d = (void *)display;
161 return d->backbuffer;
162 }
163
164
165 /* Obtain a reference to this driver. */
166 ALLEGRO_DISPLAY_INTERFACE *_al_display_gp2xwiz_framebuffer_driver(void)
167 {
168 if (gp2xwiz_vt)
169 return gp2xwiz_vt;
170
171 gp2xwiz_vt = al_calloc(1, sizeof *gp2xwiz_vt);
172
173 gp2xwiz_vt->create_display = gp2xwiz_create_display_fb;
174 gp2xwiz_vt->destroy_display = gp2xwiz_destroy_display_fb;
175 gp2xwiz_vt->set_current_display = gp2xwiz_set_current_display_fb;
176 gp2xwiz_vt->flip_display = gp2xwiz_flip_display_fb;
177 gp2xwiz_vt->update_display_region = gp2xwiz_update_display_region_fb;
178 gp2xwiz_vt->acknowledge_resize = gp2xwiz_acknowledge_resize_fb;
179 gp2xwiz_vt->create_bitmap = NULL;
180 gp2xwiz_vt->get_backbuffer = gp2xwiz_get_backbuffer_fb;
181 gp2xwiz_vt->set_target_bitmap = NULL;
182 gp2xwiz_vt->is_compatible_bitmap = gp2xwiz_is_compatible_bitmap_fb;
183 gp2xwiz_vt->resize_display = gp2xwiz_resize_display_fb;
184 gp2xwiz_vt->set_icons = NULL;
185 gp2xwiz_vt->set_window_title = NULL;
186 gp2xwiz_vt->set_window_position = NULL;
187 gp2xwiz_vt->get_window_position = gp2xwiz_get_window_position_fb;
188 gp2xwiz_vt->set_window_constraints = NULL;
189 gp2xwiz_vt->get_window_constraints = NULL;
190 gp2xwiz_vt->set_display_flag = NULL;
191 gp2xwiz_vt->wait_for_vsync = gp2xwiz_wait_for_vsync_fb;
192
193 return gp2xwiz_vt;
194 }
195
196 /* vi: set sts=3 sw=3 et: */