summaryrefslogtreecommitdiff
path: root/agbx/source/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'agbx/source/gfx')
-rw-r--r--agbx/source/gfx/clrscrn.c20
-rw-r--r--agbx/source/gfx/flip.s10
-rw-r--r--agbx/source/gfx/getpx.s2
-rw-r--r--agbx/source/gfx/getvbnk.s8
-rw-r--r--agbx/source/gfx/plot.c14
-rw-r--r--agbx/source/gfx/plottex.c36
-rw-r--r--agbx/source/gfx/rd.c14
-rw-r--r--agbx/source/gfx/setpx.c18
-rw-r--r--agbx/source/gfx/vsync.s8
9 files changed, 83 insertions, 47 deletions
diff --git a/agbx/source/gfx/clrscrn.c b/agbx/source/gfx/clrscrn.c
index 997d825..cd9a7b3 100644
--- a/agbx/source/gfx/clrscrn.c
+++ b/agbx/source/gfx/clrscrn.c
@@ -1,24 +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/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/
#include <ax/priv.h>
#include <ax/gfx.h>
-void ax_clrscrn3(ax_i10 const _col) {
- ax_i20 const val = _col | _col << 0x8u | _col << 0x10u | _col << 0x18u;
- for (ax_i20 addr = 0x400'0000u;addr != 0x401'2C00u;addr += 0x4u) {ax_set20(addr,val);}
+void ax_clrscrn3(ax_i01 const _col) {
+ ax_i02 const val = (ax_i02)_col | (ax_i02)_col << 0x10u;
+ for (ax_i02 addr = 0x600'0000u;addr != 0x601'2C00u;addr += 0x4u) {__ax_set20(addr,val);}
}
-void ax_clrscrn4(ax_i20 const _vaddr,ax_i8 const _col) {
- ax_i20 const val = _col | _col << 0x8u | _col << 0x10u | _col << 0x18u;
- for (ax_i20 addr = _vaddr;addr != _vaddr + 0x9600u;addr += 0x4u) {ax_set20(addr,val);}
+void ax_clrscrn4(ax_i02 const _vaddr,ax_i8 const _col) {
+ ax_i02 const val = (ax_i02)_col | (ax_i02)_col << 0x8u | (ax_i02)_col << 0x10u | (ax_i02)_col << 0x18u;
+ for (ax_i02 addr = _vaddr;addr != _vaddr + 0x9600u;addr += 0x4u) {__ax_set20(addr,val);}
}
-void ax_clrscrn5(ax_i20 const _vaddr,ax_i10 const _col) {
- ax_i20 const val = _col | _col << 0x10u;
- for (ax_i20 addr = _vaddr;addr != _vaddr + 0xA000u;addr += 0x4u) {ax_set20(addr,val);}
+void ax_clrscrn5(ax_i02 const _vaddr,ax_i01 const _col) {
+ ax_i02 const val = (ax_i02)_col | (ax_i02)_col << 0x10u;
+ for (ax_i02 addr = _vaddr;addr != _vaddr + 0xA000u;addr += 0x4u) {__ax_set20(addr,val);}
}
diff --git a/agbx/source/gfx/flip.s b/agbx/source/gfx/flip.s
index 95f59a6..887377d 100644
--- a/agbx/source/gfx/flip.s
+++ b/agbx/source/gfx/flip.s
@@ -1,6 +1,6 @@
@ 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/.
+@ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
.syntax unified
@@ -16,18 +16,18 @@
ax_flip:
@ Get the current value of dispcnt:
- ldr r0,.dispcntaddr @ ax_i20 dispcntaddr = 0x4000000u;
- ldrh r1,[r0] @ ax_i10 dispcnt = *(ax_i10 *)dispcntaddr;
+ ldr r0,.dispcntaddr @ ax_i02 dispcntaddr = 0x4000000u;
+ ldrh r1,[r0] @ ax_i01 dispcnt = *(ax_i01 *)dispcntaddr;
@ XOR bit five:
movs r2,0b10000
eors r1,r2 @ dispcnt ^= 0b10000u;
@ Save dispcnt:
- strh r1,[r0] @ *(ax_i10 *)dispcntaddr = dispcnt;
+ strh r1,[r0] @ *(ax_i01 *)dispcntaddr = dispcnt;
@ Get the address of the video bank:
- b __ax_getvbnk @ ax_i20 vaddr = __ax_getvbnk();
+ b __ax_getvbnk @ ax_i02 vaddr = __ax_getvbnk();
bx lr @ return vaddr;
diff --git a/agbx/source/gfx/getpx.s b/agbx/source/gfx/getpx.s
index 0bdcef4..1db82a8 100644
--- a/agbx/source/gfx/getpx.s
+++ b/agbx/source/gfx/getpx.s
@@ -1,6 +1,6 @@
@ 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/.
+@ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
.syntax unified
diff --git a/agbx/source/gfx/getvbnk.s b/agbx/source/gfx/getvbnk.s
index 1c6a64e..d3dcbcf 100644
--- a/agbx/source/gfx/getvbnk.s
+++ b/agbx/source/gfx/getvbnk.s
@@ -1,6 +1,6 @@
@ 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/.
+@ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
.syntax unified
@@ -15,11 +15,11 @@
ax_getvbnk:
@ Get the current value of dispcnt:
- ldr r0,.dispcntaddr @ ax_i20 dispcntaddr = 0x4000000u;
- ldrh r1,[r0] @ ax_i10 dispcnt = *(ax_i10 *)dispcntaddr;
+ ldr r0,.dispcntaddr @ ax_i02 dispcntaddr = 0x4000000u;
+ ldrh r1,[r0] @ ax_i01 dispcnt = *(ax_i01 *)dispcntaddr;
@ Get the address:
- b __ax_getvbnk @ ax_i20 vaddr = __ax_getvbnk();
+ b __ax_getvbnk @ ax_i02 vaddr = __ax_getvbnk();
bx lr @ return vaddr;
diff --git a/agbx/source/gfx/plot.c b/agbx/source/gfx/plot.c
index f12c39b..a100208 100644
--- a/agbx/source/gfx/plot.c
+++ b/agbx/source/gfx/plot.c
@@ -1,24 +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/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/
#include <ax/priv.h>
#include <ax/gfx.h>
-void ax_plot3(ax_i8 const _x,ax_i8 const _y,ax_i10 const _col) {
- ax_i10 const px = _y * 0xF0u + _x;
+void ax_plot3(ax_i8 const _x,ax_i8 const _y,ax_i01 const _col) {
+ ax_i01 const px = _y * 0xF0u + _x;
__ax_setpx2(0x600'0000u,px,_col)
}
-void ax_plot4(ax_i20 const _vaddr,ax_i8 const _x,ax_i8 const _y,ax_i8 const _col) {
- ax_i10 const px = _y * 0xF0u + _x;
+void ax_plot4(ax_i02 const _vaddr,ax_i8 const _x,ax_i8 const _y,ax_i8 const _col) {
+ ax_i01 const px = _y * 0xF0u + _x;
ax_setpx1(_vaddr,px,_col);
}
-void ax_plot5(ax_i20 const _vaddr,ax_i8 const _x,ax_i8 const _y,ax_i10 const _col) {
- ax_i10 const px = _y * 0xA0u + _x;
+void ax_plot5(ax_i02 const _vaddr,ax_i8 const _x,ax_i8 const _y,ax_i01 const _col) {
+ ax_i01 const px = _y * 0xA0u + _x;
__ax_setpx2(_vaddr,px,_col)
}
diff --git a/agbx/source/gfx/plottex.c b/agbx/source/gfx/plottex.c
new file mode 100644
index 0000000..2165c52
--- /dev/null
+++ b/agbx/source/gfx/plottex.c
@@ -0,0 +1,36 @@
+/*
+ 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 <ax/priv.h>
+
+#include <ax/gfx.h>
+
+void ax_plottex3(ax_i01 const * const _tex,ax_i8 const _x,ax_i8 const _y,ax_i8 const _w,ax_i8 const _h) {
+ ax_i01 const * texpos = _tex;
+ for (ax_i8 y = _y;y != _y + _h;++y) {
+ for (ax_i8 x = _x;x != _x + _w;++x) {
+ ax_plot3(x,y,*(texpos++));
+ }
+ }
+}
+
+void ax_plottex4(ax_i02 const _vaddr,ax_i8 const * const _tex,ax_i8 const _x,ax_i8 const _y,ax_i8 const _w,ax_i8 const _h) {
+ ax_i8 const * texpos = _tex;
+ for (ax_i8 y = _y;y != _y + _h;++y) {
+ for (ax_i8 x = _x;x != _x + _w;++x) {
+ ax_plot4(_vaddr,x,y,*(texpos++));
+ }
+ }
+}
+
+void ax_plottex5(ax_i02 const _vaddr,ax_i01 const * const _tex,ax_i8 const _x,ax_i8 const _y,ax_i8 const _w,ax_i8 const _h) {
+ ax_i01 const * texpos = _tex;
+ for (ax_i8 y = _y;y != _y + _h;++y) {
+ for (ax_i8 x = _x;x != _x + _w;++x) {
+ ax_plot5(_vaddr,x,y,*(texpos++));
+ }
+ }
+}
diff --git a/agbx/source/gfx/rd.c b/agbx/source/gfx/rd.c
index e53a3fe..aba36b1 100644
--- a/agbx/source/gfx/rd.c
+++ b/agbx/source/gfx/rd.c
@@ -1,24 +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/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/
#include <ax/priv.h>
#include <ax/gfx.h>
-ax_i10 ax_rd3(ax_i8 const _x,ax_i8 const _y) {
- ax_i10 const px = _y * 0xF0u + _x;
+ax_i01 ax_rd3(ax_i8 const _x,ax_i8 const _y) {
+ ax_i01 const px = _y * 0xF0u + _x;
return ax_getpx2(0x600'0000u,px);
}
-ax_i8 ax_rd4(ax_i20 const _vaddr,ax_i8 const _x,ax_i8 const _y) {
- ax_i10 const px = _y * 0xF0u + _x;
+ax_i8 ax_rd4(ax_i02 const _vaddr,ax_i8 const _x,ax_i8 const _y) {
+ ax_i01 const px = _y * 0xF0u + _x;
return ax_getpx1(_vaddr,px);
}
-ax_i10 ax_rd5(ax_i20 const _vaddr,ax_i8 const _x,ax_i8 const _y) {
- ax_i10 const px = _y * 0xA0u + _x;
+ax_i01 ax_rd5(ax_i02 const _vaddr,ax_i8 const _x,ax_i8 const _y) {
+ ax_i01 const px = _y * 0xA0u + _x;
return ax_getpx2(_vaddr,px);
}
diff --git a/agbx/source/gfx/setpx.c b/agbx/source/gfx/setpx.c
index c82c980..7110d02 100644
--- a/agbx/source/gfx/setpx.c
+++ b/agbx/source/gfx/setpx.c
@@ -1,19 +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/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/
#include <ax/priv.h>
#include <ax/gfx.h>
-void ax_setpx1(ax_i20 const _vaddr,ax_i10 const _px,ax_i8 const _col) {
+void ax_setpx1(ax_i02 const _vaddr,ax_i01 const _px,ax_i8 const _col) {
/* We can only write halfwords to VRAM, so we need to load the adjacent pixel value and combine it into a halfword. */
- bool const odd = _px & 0x1u;
- ax_i20 addr = _vaddr + _px - odd;
- ax_i10 precol = __ax_get10(addr);
- ax_i10 col = _col;
+ bool const odd = _px & 0x1u;
+ ax_i02 addr = _vaddr + _px - odd;
+ ax_i01 precol = __ax_get10(addr);
+ ax_i01 col = _col;
if (odd) {
precol &= 0b11111111u;
col <<= 0x8u;
@@ -21,11 +21,11 @@ void ax_setpx1(ax_i20 const _vaddr,ax_i10 const _px,ax_i8 const _col) {
else {
precol &= 0b1111111100000000u;
}
- ax_i10 const newcol = precol | col;
+ ax_i01 const newcol = precol | col;
__ax_set10(addr,newcol);
}
-void ax_setpx2(ax_i20 const _vaddr,ax_i10 const _px,ax_i10 const _col) {
- ax_i20 const addr = _vaddr + _px;
+void ax_setpx2(ax_i02 const _vaddr,ax_i01 const _px,ax_i01 const _col) {
+ ax_i02 const addr = _vaddr + _px;
__ax_set10(addr,_col);
}
diff --git a/agbx/source/gfx/vsync.s b/agbx/source/gfx/vsync.s
index 7ecd7fb..e16724f 100644
--- a/agbx/source/gfx/vsync.s
+++ b/agbx/source/gfx/vsync.s
@@ -1,6 +1,6 @@
@ 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/.
+@ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
.syntax unified
@@ -14,12 +14,12 @@
ax_vsync:
@ Set the constants:
- ldr r0,.vcountaddr @ ax_i20 vcountaddr = 0x4000006u;
- movs r1,0xA0 @ ax_i20 numhline = 0xA0;
+ ldr r0,.vcountaddr @ ax_i02 vcountaddr = 0x4000006u;
+ movs r1,0xA0 @ ax_i02 numhline = 0xA0;
.loop:
@ Check the scanline counter:
- ldrh r2,[r0] @ ax_i20 vcount = *(ax_i10 *)vcountaddr;
+ ldrh r2,[r0] @ ax_i02 vcount = *(ax_i01 *)vcountaddr;
cmp r2,r1
beq .ret @ if (vcount == numhline) {goto ret;}