diff options
-rw-r--r-- | dat.h | 17 | ||||
-rw-r--r-- | main.c | 43 | ||||
-rw-r--r-- | regs.h | 9 |
3 files changed, 69 insertions, 0 deletions
@@ -0,0 +1,17 @@ +enum { + SCRW = 240, + SCRH = 160 +}; + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned long long uvlong; + +typedef struct Point Point; + +struct Point +{ + int x, y; +}; @@ -0,0 +1,43 @@ +#include "dat.h" +#include "regs.h" + +uint *ioram = (uint*)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 = 0x0403; + for(i = 0; i < SCRH; i++){ + c = 31*i/SCRH; + drawpixel(Pt(i,i), rgb(c,c,c)); + } + for(;;); + return 0; +} @@ -0,0 +1,9 @@ +#define SYSROM 0x00000000UL +#define EWRAM 0x02000000UL +#define IWRAM 0x03000000UL +#define IORAM 0x04000000UL +#define PALRAM 0x05000000UL +#define VRAM 0x06000000UL +#define OAM 0x07000000UL +#define PAKROM 0x08000000UL +#define CART 0x0E000000UL |