From 5a3198e108fc868da57a002abaca9a4db28d096b Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 15 Feb 2020 09:41:35 +0000 Subject: initial rom with basic gradient. --- dat.h | 17 +++++++++++++++++ main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ regs.h | 9 +++++++++ 3 files changed, 69 insertions(+) create mode 100644 dat.h create mode 100644 main.c create mode 100644 regs.h diff --git a/dat.h b/dat.h new file mode 100644 index 0000000..c852a09 --- /dev/null +++ b/dat.h @@ -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; +}; diff --git a/main.c b/main.c new file mode 100644 index 0000000..caa0e59 --- /dev/null +++ b/main.c @@ -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; +} diff --git a/regs.h b/regs.h new file mode 100644 index 0000000..2c93048 --- /dev/null +++ b/regs.h @@ -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 -- cgit v1.2.3