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