aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-02-15 09:41:35 +0000
committerrodri <rgl@antares-labs.eu>2020-02-15 09:41:35 +0000
commit5a3198e108fc868da57a002abaca9a4db28d096b (patch)
tree004bbc9743f430c7089df580eb86c8c9d6b2e840
downloadgbadev-5a3198e108fc868da57a002abaca9a4db28d096b.tar.gz
gbadev-5a3198e108fc868da57a002abaca9a4db28d096b.tar.bz2
gbadev-5a3198e108fc868da57a002abaca9a4db28d096b.zip
initial rom with basic gradient.
-rw-r--r--dat.h17
-rw-r--r--main.c43
-rw-r--r--regs.h9
3 files changed, 69 insertions, 0 deletions
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