29 |
29 |
|
30 |
30 |
static vbe_mode_info_t vbe_mem_info;
|
31 |
31 |
|
32 |
|
/// PUBLIC GET
|
33 |
|
uint16_t (graph_get_XRes) (void){ return vbe_mem_info.XResolution; }
|
34 |
|
uint16_t (graph_get_YRes) (void){ return vbe_mem_info.YResolution; }
|
35 |
|
|
36 |
32 |
/// PRIVATE GET
|
37 |
33 |
static uint16_t (graph_get_bits_pixel) (void){ return vbe_mem_info.BitsPerPixel; }
|
38 |
|
static uint16_t (graph_get_bytes_pixel) (void){ return (graph_get_bits_pixel() + 7) >> 3; }
|
39 |
34 |
static phys_bytes (graph_get_phys_addr) (void){ return vbe_mem_info.PhysBasePtr; }
|
40 |
35 |
static unsigned (graph_get_vram_size) (void){ return vbe_mem_info.XResolution * vbe_mem_info.YResolution * graph_get_bytes_pixel(); }
|
41 |
36 |
//static uint16_t (graph_get_RedMaskSize) (void){ return vbe_mem_info.RedMaskSize ; }
|
42 |
37 |
//static uint16_t (graph_get_GreenMaskSize)(void){ return vbe_mem_info.GreenMaskSize; }
|
43 |
38 |
//static uint16_t (graph_get_BlueMaskSize) (void){ return vbe_mem_info.BlueMaskSize ; }
|
44 |
39 |
|
|
40 |
/// PUBLIC GET
|
|
41 |
uint16_t (graph_get_XRes) (void){ return vbe_mem_info.XResolution; }
|
|
42 |
uint16_t (graph_get_YRes) (void){ return vbe_mem_info.YResolution; }
|
|
43 |
uint16_t (graph_get_bytes_pixel) (void){ return (graph_get_bits_pixel() + 7) >> 3; }
|
|
44 |
|
|
45 |
///
|
45 |
46 |
static int (get_permission)(unsigned int base_addr, unsigned int size) {
|
46 |
47 |
struct minix_mem_range mmr;
|
47 |
48 |
mmr.mr_base = base_addr;
|
... | ... | |
244 |
245 |
|
245 |
246 |
/// PIXEL DRAWING
|
246 |
247 |
int (graph_set_pixel)(uint16_t x, uint16_t y, uint32_t color) {
|
247 |
|
/*
|
248 |
248 |
if (x < 0 || vbe_mem_info.XResolution <= x || y < 0 || vbe_mem_info.YResolution <= y) {
|
249 |
249 |
//printf("%s: invalid pixel.\n", __func__);
|
250 |
250 |
return OUT_OF_RANGE;
|
... | ... | |
252 |
252 |
unsigned int pos = (x + y * vbe_mem_info.XResolution) * graph_get_bytes_pixel();
|
253 |
253 |
memcpy(video_buf + pos, &color, graph_get_bytes_pixel());
|
254 |
254 |
return SUCCESS;
|
255 |
|
*/
|
256 |
|
return graph_set_pixel_buffer(x, y, color, video_buf, graph_get_XRes(), graph_get_YRes());
|
257 |
255 |
}
|
258 |
|
int (graph_set_pixel_buffer)(uint16_t x, uint16_t y, uint32_t color, uint8_t *buf, uint16_t W, uint16_t H) {
|
259 |
|
if(buf == NULL) return NULL_PTR;
|
260 |
|
if (x < 0 || W <= x || y < 0 || H <= y) {
|
261 |
|
//printf("%s: invalid pixel.\n", __func__);
|
262 |
|
return OUT_OF_RANGE;
|
263 |
|
}
|
264 |
|
unsigned int pos = (x + y * W) * graph_get_bytes_pixel();
|
265 |
|
memcpy(buf + pos, &color, graph_get_bytes_pixel());
|
266 |
|
return SUCCESS;
|
267 |
|
}
|
268 |
|
int (graph_set_pixel_alpha_buffer)(uint16_t x, uint16_t y, uint8_t alpha, uint8_t *alp_buf, uint16_t W, uint16_t H) {
|
269 |
|
if(alp_buf == NULL) return NULL_PTR;
|
270 |
|
if (x < 0 || W <= x || y < 0 || H <= y) {
|
271 |
|
//printf("%s: invalid pixel.\n", __func__);
|
272 |
|
return OUT_OF_RANGE;
|
273 |
|
}
|
274 |
|
unsigned int pos = x + y * W;
|
275 |
|
memcpy(alp_buf + pos, &alpha, 1);
|
276 |
|
return SUCCESS;
|
277 |
|
}
|
278 |
|
/*
|
279 |
|
int (graph_set_pixel_alpha)(uint16_t x, uint16_t y, uint32_t color, uint8_t alpha){
|
280 |
|
if (x >= vbe_mem_info.XResolution || y >= vbe_mem_info.YResolution) {
|
281 |
|
//printf("%s: invalid pixel.\n", __func__);
|
282 |
|
return OUT_OF_RANGE;
|
283 |
|
}
|
284 |
|
unsigned int pos = (x + y * vbe_mem_info.XResolution) * graph_get_bytes_pixel();
|
285 |
|
uint32_t color_;
|
286 |
|
memcpy(&color_, video_buf + pos, graph_get_bytes_pixel());
|
287 |
|
float a = 1.0-(alpha&0xFF)/(float)0xFF;
|
288 |
|
uint8_t r = GET_RED(color)*a + GET_RED(color_)*(1.0-a);
|
289 |
|
uint8_t g = GET_GRE(color)*a + GET_GRE(color_)*(1.0-a);
|
290 |
|
uint8_t b = GET_BLU(color)*a + GET_BLU(color_)*(1.0-a); (void)(r*g*b);
|
291 |
|
//return graph_set_pixel(x,y,SET_RGB(r,g,b));
|
292 |
|
color = SET_RGB(r,g,b);
|
293 |
|
//unsigned int pos = (x + y * W) * graph_get_bytes_pixel();
|
|
256 |
void (graph_set_pixel_pos)(unsigned pos, uint32_t color){
|
294 |
257 |
memcpy(video_buf + pos, &color, graph_get_bytes_pixel());
|
295 |
|
return SUCCESS;
|
296 |
258 |
}
|
297 |
|
*/
|
298 |
|
int (graph_clear_screen)(void){
|
299 |
|
//return graph_paint_screen(BLACK);
|
300 |
|
memset(video_buf, 0, graph_get_vram_size());
|
301 |
|
return SUCCESS;
|
302 |
|
}
|
|
259 |
int (graph_clear_screen)(void){ memset(video_buf, 0, graph_get_vram_size()); return SUCCESS; }
|
|
260 |
int (graph_draw)(void){ memcpy(video_mem, video_buf, graph_get_vram_size()); return SUCCESS; }
|
303 |
261 |
|
304 |
|
int (graph_draw)(void){
|
305 |
|
memcpy(video_mem, video_buf, graph_get_vram_size());
|
306 |
|
return 0;
|
307 |
|
}
|
|
262 |
/// SPRITE
|