summaryrefslogtreecommitdiff
path: root/agbx
diff options
context:
space:
mode:
Diffstat (limited to 'agbx')
-rw-r--r--agbx/GNUmakefile2
-rw-r--r--agbx/include/agbx/gfx.h13
-rw-r--r--agbx/source/bs/done.c2
-rw-r--r--agbx/source/gfx/getpx.c19
-rw-r--r--agbx/source/gfx/getvbnk.s2
-rw-r--r--agbx/source/gfx/plot.c11
-rw-r--r--agbx/source/gfx/rd.c24
7 files changed, 61 insertions, 12 deletions
diff --git a/agbx/GNUmakefile b/agbx/GNUmakefile
index 0265379..afd8f50 100644
--- a/agbx/GNUmakefile
+++ b/agbx/GNUmakefile
@@ -43,8 +43,10 @@ OBJS := \
source/bs/set.o \
source/gfx/clrscrn.o \
source/gfx/flip.o \
+ source/gfx/getpx.o \
source/gfx/getvbnk.o \
source/gfx/plot.o \
+ source/gfx/rd.o \
source/gfx/setpx.o \
source/gfx/vsync.o \
source/key/getkeymap.o \
diff --git a/agbx/include/agbx/gfx.h b/agbx/include/agbx/gfx.h
index 2da8974..beec93b 100644
--- a/agbx/include/agbx/gfx.h
+++ b/agbx/include/agbx/gfx.h
@@ -16,12 +16,19 @@ void agbx_vsync( void);
void agbx_setpx1(agbx_i20 vaddr,agbx_i10 px,agbx_i8 col);
void agbx_setpx2(agbx_i20 vaddr,agbx_i10 px,agbx_i10 col);
+agbx_i8 agbx_getpx1(agbx_i20 vaddr,agbx_i10 px);
+agbx_i10 agbx_getpx2(agbx_i20 vaddr,agbx_i10 px);
+
void agbx_clrscrn3(agbx_i10 col);
void agbx_clrscrn4(agbx_i20 vaddr,agbx_i8 col);
void agbx_clrscrn5(agbx_i20 vaddr,agbx_i10 col);
-agbx_i10 agbx_plot3(agbx_i8 x,agbx_i8 y,agbx_i10 col);
-agbx_i10 agbx_plot4(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y,agbx_i8 col);
-agbx_i10 agbx_plot5(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y,agbx_i10 col);
+void agbx_plot3(agbx_i8 x, agbx_i8 y,agbx_i10 col);
+void agbx_plot4(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y, agbx_i8 col);
+void agbx_plot5(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y, agbx_i10 col);
+
+agbx_i10 agbx_rd3(agbx_i8 x, agbx_i8 y);
+agbx_i8 agbx_rd4(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y);
+agbx_i10 agbx_rd5(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y);
#endif
diff --git a/agbx/source/bs/done.c b/agbx/source/bs/done.c
index 8e3726d..64130e3 100644
--- a/agbx/source/bs/done.c
+++ b/agbx/source/bs/done.c
@@ -18,7 +18,7 @@ void agbx_done(agbx_err const _err) {
/* Display the barcode-like error message: */
agbx_set10(0x400'0000u,0x404u);
agbx_set10(0x500'0000u,0x0u);
- agbx_set10(0x500'0002u,0x19u);
+ agbx_set10(0x500'0002u,0b11111u);
agbx_i8 err[0xBu];
for (agbx_i8 pos = 0x0u;pos != 0x8u;++pos) {err[pos] = (agbx_i8)_err >> pos & 0x1u;}
err[0x8u] = 0x0u;
diff --git a/agbx/source/gfx/getpx.c b/agbx/source/gfx/getpx.c
new file mode 100644
index 0000000..5d24db4
--- /dev/null
+++ b/agbx/source/gfx/getpx.c
@@ -0,0 +1,19 @@
+/*
+ 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>
+
+#include <agbx/gfx.h>
+
+agbx_i8 agbx_getpx1(agbx_i20 const _vaddr,agbx_i10 const _px) {
+ agbx_i20 const addr = _vaddr + _px;
+ return __agbx_get8(addr);
+}
+
+agbx_i10 agbx_getpx2(agbx_i20 const _vaddr,agbx_i10 const _px) {
+ agbx_i20 const addr = _vaddr + _px * 0x2u;
+ return __agbx_get8(addr);
+}
diff --git a/agbx/source/gfx/getvbnk.s b/agbx/source/gfx/getvbnk.s
index e04a127..6898266 100644
--- a/agbx/source/gfx/getvbnk.s
+++ b/agbx/source/gfx/getvbnk.s
@@ -35,7 +35,7 @@ __agbx_getvbnk: @ Takes the value of dispcnt in r1.
movs r0,0b10000
tst r1,r0
- bne .vbnk1
+ beq .vbnk1
.vbnk0:
@ Return the address of the first video bank:
diff --git a/agbx/source/gfx/plot.c b/agbx/source/gfx/plot.c
index e23834c..a19a2f1 100644
--- a/agbx/source/gfx/plot.c
+++ b/agbx/source/gfx/plot.c
@@ -8,20 +8,17 @@
#include <agbx/gfx.h>
-agbx_i10 agbx_plot3(agbx_i8 const _x,agbx_i8 const _y,agbx_i10 const _col) {
+void agbx_plot3(agbx_i8 const _x,agbx_i8 const _y,agbx_i10 const _col) {
agbx_i10 const px = _y * 0xF0u + _x;
__agbx_setpx2(0x600'0000u,px,_col)
- return px;
}
-agbx_i10 agbx_plot4(agbx_i20 const _vaddr,agbx_i8 const _x,agbx_i8 const _y,agbx_i8 const _col) {
+void agbx_plot4(agbx_i20 const _vaddr,agbx_i8 const _x,agbx_i8 const _y,agbx_i8 const _col) {
agbx_i10 const px = _y * 0xF0u + _x;
agbx_setpx1(_vaddr,px,_col);
- return px;
}
-agbx_i10 agbx_plot5(agbx_i20 const _vaddr,agbx_i8 const _x,agbx_i8 const _y,agbx_i10 const _col) {
- agbx_i10 const px = _y * 0xF0u + _x;
+void agbx_plot5(agbx_i20 const _vaddr,agbx_i8 const _x,agbx_i8 const _y,agbx_i10 const _col) {
+ agbx_i10 const px = _y * 0xA0u + _x;
__agbx_setpx2(_vaddr,px,_col)
- return px;
}
diff --git a/agbx/source/gfx/rd.c b/agbx/source/gfx/rd.c
new file mode 100644
index 0000000..94dd676
--- /dev/null
+++ b/agbx/source/gfx/rd.c
@@ -0,0 +1,24 @@
+/*
+ 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>
+
+#include <agbx/gfx.h>
+
+agbx_i10 agbx_rd3(agbx_i8 const _x,agbx_i8 const _y) {
+ agbx_i10 const px = _y * 0xF0u + _x;
+ return agbx_getpx2(0x600'0000u,px);
+}
+
+agbx_i8 agbx_rd4(agbx_i20 const _vaddr,agbx_i8 const _x,agbx_i8 const _y) {
+ agbx_i10 const px = _y * 0xF0u + _x;
+ return agbx_getpx1(_vaddr,px);
+}
+
+agbx_i10 agbx_rd5(agbx_i20 const _vaddr,agbx_i8 const _x,agbx_i8 const _y) {
+ agbx_i10 const px = _y * 0xA0u + _x;
+ return agbx_getpx2(_vaddr,px);
+}