aboutsummaryrefslogtreecommitdiff
path: root/main.c
blob: 265cf02dae996171e925709d27e38d4041eb51a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "dat.h"
#include "regs.h"

ushort *ioram = (ushort*)IORAM;
ushort *vram = (ushort*)VRAM;

Point
Pt(int x, int y)
{
	return (Point){x,y};
}

ushort
rgb(int r, int g, int b)
{
	ushort c;

	c = 0;
	c |= (r&0x1f)<<10;
	c |= (g&0x1f)<<5;
	c |= b&0x1f;
	return c;
}

void
drawpixel(Point p, ushort col)
{
	vram[p.x+p.y*SCRW] = col;
}

int
main()
{
	int i, c;

	ioram[DISPCNT] = BGMODE3|DISPBG2;
	for(i = 0; i < SCRH; i++){
		c = 31*i/SCRH;
		drawpixel(Pt(i,i), rgb(c,c,c));
	}
	for(;;);
	return 0;
}