Project

General

Profile

Revision 105

set pixel function

View differences:

graphics.c
69 69
    return vbe_mem_info.BitsPerPixel;
70 70
}
71 71

  
72
uint16_t get_bytes_pixel(void) {
73
    return (vbe_mem_info.BitsPerPixel + 7) >> 3;
74
}
75

  
72 76
int (map_vram)(void) {
73 77
    int r;
74 78
    unsigned int vram_base = get_phys_addr();
......
88 92
    return !lm_free(&mem_map);
89 93
}
90 94

  
95
int (set_pixel)(uint16_t row, uint16_t col, uint32_t color) {
96
    if (row >= vbe_mem_info.XResolution || col >= vbe_mem_info.YResolution) {
97
        printf("%s: invalid pixel.\n", __func__);
98
        return OUT_OF_RANGE;
99
    }
100
    unsigned int pos = (row + col * vbe_mem_info.XResolution) * get_bytes_pixel();
101
    memcpy((void*)(video_mem + pos), &color, get_bytes_pixel());
102
    return SUCCESS;
103
}
104

  
91 105
int (set_graphics_mode)(uint16_t mode) {
92 106
    struct reg86 reg_86;
93 107

  

Also available in: Unified diff