1 /* 2 * Write to display memory. 3 * 4 * Copyright (C) 2017 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include <stdint.h> 21 #include "mips.h" 22 #include "vga.h" 23 24 void init_framebuffer(uint32_t *data) 25 { 26 uint32_t *addr = (uint32_t *) SCREEN_BASE_KSEG0; 27 uint16_t x, y; 28 29 for (y = 0; y < LINE_COUNT; y++) 30 { 31 for (x = 0; x < LINE_LENGTH; x += 4) 32 { 33 *addr = *data; 34 addr++; 35 data++; 36 } 37 } 38 } 39 40 void init_framebuffer_with_pattern() 41 { 42 uint32_t *addr = (uint32_t *) SCREEN_BASE_KSEG0; 43 uint32_t base, value; 44 uint16_t x, y; 45 uint8_t row, offset; 46 47 for (y = 0; y < LINE_COUNT; y++) 48 { 49 /* Start each line with a base value. */ 50 51 row = y / 16; 52 base = (row << 26) | (row << 18) | (row << 10) | (row << 2); 53 54 /* Set the intensity bit on every other palette row. */ 55 56 if (row % 2) base |= 0x80808080; 57 58 for (x = 0; x < LINE_LENGTH; x += 4) 59 { 60 /* Combine the base value with the offset. */ 61 62 offset = x / 20; 63 value = base | (offset << 24) | (offset << 16) | (offset << 8) | offset; 64 65 /* Store the value. */ 66 67 *addr = value; 68 69 /* Access the next word. */ 70 71 addr++; 72 } 73 } 74 }