summaryrefslogtreecommitdiff
path: root/agbx/source
diff options
context:
space:
mode:
Diffstat (limited to 'agbx/source')
-rw-r--r--agbx/source/algo/cp.c4
-rw-r--r--agbx/source/bs/done.c4
-rw-r--r--agbx/source/bs/get.s6
-rw-r--r--agbx/source/bs/set.s6
-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
-rw-r--r--agbx/source/key/getkeymap.s6
-rw-r--r--agbx/source/priv/init.s2
15 files changed, 97 insertions, 61 deletions
diff --git a/agbx/source/algo/cp.c b/agbx/source/algo/cp.c
index 347b55d..0eb506c 100644
--- a/agbx/source/algo/cp.c
+++ b/agbx/source/algo/cp.c
@@ -1,14 +1,14 @@
/*
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/algo.h>
-void ax_cp(void const * const _src,ax_i20 const _num,void * const _dest) {
+void ax_cp(void const * const _src,ax_i02 const _num,void * const _dest) {
unsigned char const * src = _src;
unsigned char * dest = _dest;
unsigned char const * const aftersrc = src + _num;
diff --git a/agbx/source/bs/done.c b/agbx/source/bs/done.c
index e302244..0bb0a3c 100644
--- a/agbx/source/bs/done.c
+++ b/agbx/source/bs/done.c
@@ -1,7 +1,7 @@
/*
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>
@@ -24,7 +24,7 @@ void ax_done(ax_err const _err) {
err[0x8u] = 0x0u;
err[0x9u] = 0x1u;
err[0xAu] = 0x0u;
- for (ax_i10 pos = 0x0u;pos != 0x9600u;pos += 0xF0u) {
+ for (ax_i01 pos = 0x0u;pos != 0x9600u;pos += 0xF0u) {
ax_setpx1(0x600'0000u,pos, err[0x0u]);
ax_setpx1(0x600'0000u,pos + 0x1u,err[0x1u]);
ax_setpx1(0x600'0000u,pos + 0x2u,err[0x2u]);
diff --git a/agbx/source/bs/get.s b/agbx/source/bs/get.s
index 7068aaf..a936f73 100644
--- a/agbx/source/bs/get.s
+++ b/agbx/source/bs/get.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,7 +15,7 @@
.thumb_func
ax_get10:
- ldrh r0,[r0] @ ax_i10 val = *(ax_i10 *)addr;
+ ldrh r0,[r0] @ ax_i01 val = *(ax_i01 *)addr;
bx lr @ return val;
.endfunc
@@ -24,7 +24,7 @@ ax_get10:
.thumb_func
ax_get20:
- ldr r0,[r0] @ ax_i20 val = *(ax_i20 *)addr;
+ ldr r0,[r0] @ ax_i02 val = *(ax_i02 *)addr;
bx lr @ return val;
.endfunc
diff --git a/agbx/source/bs/set.s b/agbx/source/bs/set.s
index 18e7218..1719be6 100644
--- a/agbx/source/bs/set.s
+++ b/agbx/source/bs/set.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,7 +15,7 @@
.thumb_func
ax_set10:
- strh r1,[r0] @ *(ax_i10 *)addr = val;
+ strh r1,[r0] @ *(ax_i01 *)addr = val;
bx lr @ return;
.endfunc
@@ -24,7 +24,7 @@ ax_set10:
.thumb_func
ax_set20:
- str r1,[r0] @ *(ax_i20 *)addr = val;
+ str r1,[r0] @ *(ax_i02 *)addr = val;
bx lr @ return;
.endfunc
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;}
diff --git a/agbx/source/key/getkeymap.s b/agbx/source/key/getkeymap.s
index 42bb611..2751c9f 100644
--- a/agbx/source/key/getkeymap.s
+++ b/agbx/source/key/getkeymap.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,8 +14,8 @@
ax_getkeymap:
@ Load the keys:
- ldr r0,.addr @ ax_i20 addr = 0x4000130u;
- ldrh r0,[r0] @ ax_keymap keymap = *(ax_i10 *)addr;
+ ldr r0,.addr @ ax_i02 addr = 0x4000130u;
+ ldrh r0,[r0] @ ax_keymap keymap = *(ax_i01 *)addr;
bx lr @ return keymap;
diff --git a/agbx/source/priv/init.s b/agbx/source/priv/init.s
index 49ada46..1c32c4e 100644
--- a/agbx/source/priv/init.s
+++ b/agbx/source/priv/init.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