Display color gradient from black->RGB on separate lines

This commit is contained in:
Myles Busig 2024-02-22 16:03:09 -07:00
parent 7489fe4849
commit 619badb068

View File

@ -1,4 +1,10 @@
#include <tonc.h> #include <tonc.h>
#include <stdint.h>
const struct {
size_t w = 240;
size_t h = 160;
} mode3;
int main(void) { int main(void) {
// Mode 3-5 are bitmap modes. // Mode 3-5 are bitmap modes.
@ -9,6 +15,14 @@ int main(void) {
// BG2 is the only available background in bitmap modes. // BG2 is the only available background in bitmap modes.
REG_DISPCNT = DCNT_MODE3 | DCNT_BG2; REG_DISPCNT = DCNT_MODE3 | DCNT_BG2;
// Write gradient from black -> RGB in first three lines.
// Each color is displayed on a separate line.
for (size_t i = 0; i < 32; ++i) {
vid_mem[i] = i;
vid_mem[mode3.w + i] = i << 5;
vid_mem[2 * mode3.w + i] = i << 10;
}
while (true) { while (true) {
// Busy-loop VSync, should be replaced with an interrupt. // Busy-loop VSync, should be replaced with an interrupt.
vid_vsync(); vid_vsync();