summaryrefslogtreecommitdiff
path: root/agbx/source/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'agbx/source/gfx')
-rw-r--r--agbx/source/gfx/plot.c34
-rw-r--r--agbx/source/gfx/setpx.c33
2 files changed, 67 insertions, 0 deletions
diff --git a/agbx/source/gfx/plot.c b/agbx/source/gfx/plot.c
new file mode 100644
index 0000000..5a65972
--- /dev/null
+++ b/agbx/source/gfx/plot.c
@@ -0,0 +1,34 @@
+/*
+ Copyright 2022 Gabriel Jensen.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+*/
+
+#include <agbx/priv.h>
+
+agbx_i10 agbx_plot3(agbx_i8 const _x,agbx_i8 const _y,agbx_i10 const _col) {
+#if defined(__agbx_dbg)
+ if (_x >= 0xF0u || _y >= 0xA0u) {agbx_done(agbx_err_pos2big);}
+#endif
+ agbx_i10 const px = _y * 0xF0u + _x;
+ __agbx_setpx2(px,_col)
+ return px;
+}
+
+agbx_i10 agbx_plot4(agbx_i8 const _x,agbx_i8 const _y,agbx_i8 const _col) {
+#if defined(__agbx_dbg)
+ if (_x >= 0xF0u || _y >= 0xA0u) {agbx_done(agbx_err_pos2big);}
+#endif
+ agbx_i10 const px = _y * 0xF0u + _x;
+ __agbx_setpx1(px,_col)
+ return px;
+}
+
+agbx_i10 agbx_plot5(agbx_i8 const _x,agbx_i8 const _y,agbx_i10 const _col) {
+#if defined(__agbx_dbg)
+ if (_x >= 0xA0u || _y >= 0x80u) {agbx_done(agbx_err_pos2big);}
+#endif
+ agbx_i10 const px = _y * 0xA0u + _x;
+ __agbx_setpx2(px,_col)
+ return px;
+}
diff --git a/agbx/source/gfx/setpx.c b/agbx/source/gfx/setpx.c
new file mode 100644
index 0000000..ace2463
--- /dev/null
+++ b/agbx/source/gfx/setpx.c
@@ -0,0 +1,33 @@
+/*
+ Copyright 2022 Gabriel Jensen.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+*/
+
+#include <agbx/priv.h>
+
+void agbx_setpx1(agbx_i10 const _px,agbx_i8 const _col) {
+#if defined(__agbx_dbg)
+ agbx_i10 const dispcnt = agbx_get10(0x4000000u);
+ agbx_i8 const md = dispcnt & 0x7u;
+ if (md == 0x3u || md == 0x5u) {agbx_done(agbx_err_badmd);}
+ if (_px >= 0x9600u) {agbx_done(agbx_err_px2big);}
+#endif
+ __agbx_setpx1(_px,_col)
+}
+
+void agbx_setpx2(agbx_i10 const _px,agbx_i10 const _col) {
+#if defined(__agbx_dbg)
+ agbx_i10 const dispcnt = agbx_get10(0x4000000u);
+ agbx_i8 const md = dispcnt & 0x7u;
+ if (md == 0x4u) {agbx_done(agbx_err_badmd);}
+ if (md == 0x5u) {
+ if (_px >= 0x5000u) {agbx_done(agbx_err_px2big);}
+ }
+ else {
+ if (md != 0x3u) {agbx_done(agbx_err_badmd);}
+ if (_px >= 0x9600u) {agbx_done(agbx_err_px2big);}
+ }
+#endif
+ __agbx_setpx2(_px,_col)
+}