Project

General

Profile

Revision 112

fixed problemin 3rd function

View differences:

lab5/graphics.c
73 73
    return (vbe_mem_info.BitsPerPixel + 7) >> 3;
74 74
}
75 75

  
76
uint16_t get_RedMaskSize(void){
77
    return vbe_mem_info.RedMaskSize;
78
}
76
uint16_t get_RedMaskSize  (void){ return vbe_mem_info.RedMaskSize  ; }
77
uint16_t get_GreenMaskSize(void){ return vbe_mem_info.GreenMaskSize; }
78
uint16_t get_BlueMaskSize (void){ return vbe_mem_info.BlueMaskSize ; }
79 79

  
80
uint16_t get_GreenMaskSize(void){
81
    return vbe_mem_info.GreenMaskSize;
82
}
83

  
84
uint16_t get_BlueMaskSize(void){
85
    return vbe_mem_info.BlueMaskSize;
86
}
87

  
88 80
int (map_vram)(void) {
89 81
    int r;
90 82
    unsigned int vram_base = get_phys_addr();
......
104 96
    return !lm_free(&mem_map);
105 97
}
106 98

  
107
int (set_pixel)(uint16_t row, uint16_t col, uint32_t color) {
108
    if (row >= vbe_mem_info.XResolution || col >= vbe_mem_info.YResolution) {
99
int (set_pixel)(uint16_t x, uint16_t y, uint32_t color) {
100
    if (x >= vbe_mem_info.XResolution || y >= vbe_mem_info.YResolution) {
109 101
        printf("%s: invalid pixel.\n", __func__);
110 102
        return OUT_OF_RANGE;
111 103
    }
112
    unsigned int pos = (row + col * vbe_mem_info.XResolution) * get_bytes_pixel();
104
    unsigned int pos = (x + y * vbe_mem_info.XResolution) * get_bytes_pixel();
113 105
    memcpy((void*)((unsigned int)video_mem + pos), &color, get_bytes_pixel());
114 106
    return SUCCESS;
115 107
}
......
138 130
    int r;
139 131
    for (int i = 0; i < len; i++)
140 132
        if ((r = set_pixel(x + i, y, color))) return r;
141

  
142 133
    return SUCCESS;
143 134
}
144 135

  
lab5/lab5.c
184 184
        if (vg_exit()) printf("%s: vg_exit failed to exit to text mode.\n", __func__);
185 185
        return 1;
186 186
    }
187

  
187 188
    uint16_t W = get_XRes()/no_rectangles;
188 189
    uint16_t H = get_YRes()/no_rectangles;
189 190
    uint32_t color, R, G, B;
190 191
    for(uint8_t row = 0; row < no_rectangles; ++row){
191 192
        for(uint8_t col = 0; col < no_rectangles; ++col){
192
            if(mode == 0x105){
193
            if(get_bytes_pixel() == 1){
193 194
                color = (first + (row * no_rectangles + col) * step) % (1 << get_bits_pixel());
194 195
            }else{
195
                R = (first + col*step) % (1 << get_RedMaskSize());
196
                G = (first + row*step) % (1 << get_GreenMaskSize());
197
                B = (first + (col+row)*step) % (1 << get_BlueMaskSize());
196
                R = (0xFF&(first>>16) + col*step) % (1 << get_RedMaskSize());
197
                G = (0xFF&(first>> 8) + row*step) % (1 << get_GreenMaskSize());
198
                B = (0xFF&(first    ) + (col+row)*step) % (1 << get_BlueMaskSize());
198 199
                color = (R<<16) | (G<<8) | (B);
199 200
            }
200 201
            if (vg_draw_rectangle(col*W,row*H,W,H,color)) {

Also available in: Unified diff