diff options
Diffstat (limited to 'agbx')
-rw-r--r-- | agbx/GNUmakefile | 6 | ||||
-rw-r--r-- | agbx/include-private/agbx/priv.h | 29 | ||||
-rw-r--r-- | agbx/include-private/ax/priv.h | 29 | ||||
-rw-r--r-- | agbx/include/agbx/bs.h | 42 | ||||
-rw-r--r-- | agbx/include/agbx/gfx.h | 53 | ||||
-rw-r--r-- | agbx/include/agbx/key.h | 33 | ||||
-rw-r--r-- | agbx/include/ax/algo.h (renamed from agbx/include/agbx/algo.h) | 8 | ||||
-rw-r--r-- | agbx/include/ax/bs.h | 42 | ||||
-rw-r--r-- | agbx/include/ax/gfx.h | 38 | ||||
-rw-r--r-- | agbx/include/ax/key.h | 33 | ||||
-rw-r--r-- | agbx/source/algo/cp.c | 6 | ||||
-rw-r--r-- | agbx/source/bs/done.c | 42 | ||||
-rw-r--r-- | agbx/source/bs/get.s | 18 | ||||
-rw-r--r-- | agbx/source/bs/set.s | 18 | ||||
-rw-r--r-- | agbx/source/gfx/clrscrn.c | 22 | ||||
-rw-r--r-- | agbx/source/gfx/flip.s | 14 | ||||
-rw-r--r-- | agbx/source/gfx/getpx.s | 8 | ||||
-rw-r--r-- | agbx/source/gfx/getvbnk.s | 14 | ||||
-rw-r--r-- | agbx/source/gfx/plot.c | 22 | ||||
-rw-r--r-- | agbx/source/gfx/rd.c | 22 | ||||
-rw-r--r-- | agbx/source/gfx/setpx.c | 22 | ||||
-rw-r--r-- | agbx/source/gfx/vsync.s | 10 | ||||
-rw-r--r-- | agbx/source/key/getkeymap.s | 8 | ||||
-rw-r--r-- | agbx/source/priv/init.s | 12 |
24 files changed, 268 insertions, 283 deletions
diff --git a/agbx/GNUmakefile b/agbx/GNUmakefile index ede1e96..f32c914 100644 --- a/agbx/GNUmakefile +++ b/agbx/GNUmakefile @@ -30,9 +30,9 @@ CFLAGS := \ # HEADERS HDRS := \ - include/agbx/bs.h \ - include/agbx/gfx.h \ - include-private/agbx/priv.h + include/ax/bs.h \ + include/ax/gfx.h \ + include-private/ax/priv.h # BINARIES diff --git a/agbx/include-private/agbx/priv.h b/agbx/include-private/agbx/priv.h deleted file mode 100644 index 1534ff3..0000000 --- a/agbx/include-private/agbx/priv.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - 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 !defined(__agbx_hdr_priv) -#define __agbx_hdr_priv - -#include <agbx/bs.h> - -#define __agbx_get10(_addr) (*(agbx_i10 volatile *)_addr) - -#define __agbx_get20(_addr) (*(agbx_i20 volatile *)_addr) - -#define __agbx_get8(_addr) (*(agbx_i8 volatile *)_addr) - -#define __agbx_set10(_addr,_val) ((void)(*(agbx_i10 volatile *)_addr = _val)) - -#define __agbx_set20(_addr,_val) ((void)(*(agbx_i20 volatile *)_addr = _val)) - -#define __agbx_set8(_addr,_val) ((void)(*(agbx_i8 volatile *)_addr = _val)) - -#define __agbx_setpx2(_vaddr,_px,_col) { \ - agbx_i20 const addr = _vaddr + _px * 0x2u; /* We multiply it by two as each pixel takes up two bytes. */ \ - __agbx_set10(addr,_col); \ -} - -#endif diff --git a/agbx/include-private/ax/priv.h b/agbx/include-private/ax/priv.h new file mode 100644 index 0000000..fdbf18b --- /dev/null +++ b/agbx/include-private/ax/priv.h @@ -0,0 +1,29 @@ +/* + 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 !defined(__ax_hdr_priv) +#define __ax_hdr_priv + +#include <ax/bs.h> + +#define __ax_get10(_addr) (*(ax_i10 volatile *)_addr) + +#define __ax_get20(_addr) (*(ax_i20 volatile *)_addr) + +#define __ax_get8(_addr) (*(ax_i8 volatile *)_addr) + +#define __ax_set10(_addr,_val) ((void)(*(ax_i10 volatile *)_addr = _val)) + +#define __ax_set20(_addr,_val) ((void)(*(ax_i20 volatile *)_addr = _val)) + +#define __ax_set8(_addr,_val) ((void)(*(ax_i8 volatile *)_addr = _val)) + +#define __ax_setpx2(_vaddr,_px,_col) { \ + ax_i20 const addr = _vaddr + _px * 0x2u; /* We multiply it by two as each pixel takes up two bytes. */ \ + __ax_set10(addr,_col); \ +} + +#endif diff --git a/agbx/include/agbx/bs.h b/agbx/include/agbx/bs.h deleted file mode 100644 index 7d38d73..0000000 --- a/agbx/include/agbx/bs.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - 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 !defined(__agbx_hdr_bs) -#define __agbx_hdr_bs - -/* C23 compatibility: */ -#define constexpr static const -#define typeof __typeof__ - -typedef unsigned short agbx_i10; -typedef unsigned int agbx_i20; -typedef unsigned long long agbx_i40; -typedef unsigned char agbx_i8; - -typedef enum { - agbx_err_ok = 0x0u, - agbx_err_badaddr, - agbx_err_badalgn, - agbx_err_badcol, - agbx_err_badmd, - agbx_err_pos2big, - agbx_err_px2big, - agbx_err_max = 0xFFu, -} agbx_err; - -constexpr agbx_i40 agbx_ver = 0x4u; - -[[noreturn]] void agbx_done(agbx_err err); - -[[nodiscard]] agbx_i10 agbx_get10(agbx_i20 addr); -[[nodiscard]] agbx_i20 agbx_get20(agbx_i20 addr); -[[nodiscard]] agbx_i8 agbx_get8( agbx_i20 addr); - -void agbx_set10(agbx_i20 addr,agbx_i10 val); -void agbx_set20(agbx_i20 addr,agbx_i20 val); -void agbx_set8( agbx_i20 addr,agbx_i8 val); - -#endif diff --git a/agbx/include/agbx/gfx.h b/agbx/include/agbx/gfx.h deleted file mode 100644 index 07e74e6..0000000 --- a/agbx/include/agbx/gfx.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - 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 !defined(__agbx_hdr_gfx) -#define __agbx_hdr_gfx - -#include <agbx/bs.h> - -agbx_i20 agbx_flip( void); -agbx_i20 agbx_getvbnk(void); -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); - -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); - -void agbx_cir3(agbx_i8 x, agbx_i8 y,agbx_i8 r); -void agbx_cir4(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y,agbx_i8 r); -void agbx_cir5(agbx_i20 vaddr,agbx_i8 x,agbx_i8 y,agbx_i8 r); - -#if false -void agbx_setpx1(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_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. */ - agbx_i20 const addr = _vaddr + _px - (_px & 0x1u) * 0x1u; - agbx_i10 col; - if (_px & 0x1u) {col = (agbx_i10)agbx_get8(addr) | (agbx_i10)_col << 0x8u;} - else {col = (agbx_i10)agbx_get8(addr + 0x1u) << 0x8u | (agbx_i10)_col;} - __agbx_set10(addr,col); -} - -void agbx_setpx2(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_i10 const _col) { - __agbx_setpx2(_vaddr,_px,_col) -} -#endif - -#endif diff --git a/agbx/include/agbx/key.h b/agbx/include/agbx/key.h deleted file mode 100644 index 973dd90..0000000 --- a/agbx/include/agbx/key.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - 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 !defined(__agbx_hdr_key) -#define __agbx_hdr_key - -#include <agbx/bs.h> - -typedef enum { - agbx_key_a = 0x0u, - agbx_key_b = 0x1u, - agbx_key_l = 0x9u, - agbx_key_pade = 0x4u, - agbx_key_padn = 0x6u, - agbx_key_pads = 0x7u, - agbx_key_padw = 0x5u, - agbx_key_r = 0x8u, - agbx_key_sel = 0x2u, - agbx_key_start = 0x3u, -} agbx_key; - -typedef struct { - agbx_i10 _keys; -} agbx_keymap; - -#define agbx_chkkey(_map,_key) (!(bool)(_map._keys >> (agbx_i10)_key & 0x1u)) - -agbx_keymap agbx_getkeymap(void); - -#endif diff --git a/agbx/include/agbx/algo.h b/agbx/include/ax/algo.h index c117e97..e7c7549 100644 --- a/agbx/include/agbx/algo.h +++ b/agbx/include/ax/algo.h @@ -4,11 +4,11 @@ If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#if !defined(__agbx_hdr_algo) -#define __agbx_hdr_algo +#if !defined(__ax_hdr_algo) +#define __ax_hdr_algo -#include <agbx/bs.h> +#include <ax/bs.h> -void agbx_cp(void const * src,agbx_i20 num,void * dest); +void ax_cp(void const * src,ax_i20 num,void * dest); #endif diff --git a/agbx/include/ax/bs.h b/agbx/include/ax/bs.h new file mode 100644 index 0000000..9fb851a --- /dev/null +++ b/agbx/include/ax/bs.h @@ -0,0 +1,42 @@ +/* + 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 !defined(__ax_hdr_bs) +#define __ax_hdr_bs + +/* C23 compatibility: */ +#define constexpr static const +#define typeof __typeof__ + +typedef unsigned short ax_i10; +typedef unsigned int ax_i20; +typedef unsigned long long ax_i40; +typedef unsigned char ax_i8; + +typedef enum { + ax_err_ok = 0x0u, + ax_err_badaddr, + ax_err_badalgn, + ax_err_badcol, + ax_err_badmd, + ax_err_pos2big, + ax_err_px2big, + ax_err_max = 0xFFu, +} ax_err; + +constexpr ax_i40 ax_ver = 0x6u; + +[[noreturn]] void ax_done(ax_err err); + +[[nodiscard]] ax_i10 ax_get10(ax_i20 addr); +[[nodiscard]] ax_i20 ax_get20(ax_i20 addr); +[[nodiscard]] ax_i8 ax_get8( ax_i20 addr); + +void ax_set10(ax_i20 addr,ax_i10 val); +void ax_set20(ax_i20 addr,ax_i20 val); +void ax_set8( ax_i20 addr,ax_i8 val); + +#endif diff --git a/agbx/include/ax/gfx.h b/agbx/include/ax/gfx.h new file mode 100644 index 0000000..d534806 --- /dev/null +++ b/agbx/include/ax/gfx.h @@ -0,0 +1,38 @@ +/* + 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 !defined(__ax_hdr_gfx) +#define __ax_hdr_gfx + +#include <ax/bs.h> + +ax_i20 ax_flip( void); +ax_i20 ax_getvbnk(void); +void ax_vsync( void); + +void ax_setpx1(ax_i20 vaddr,ax_i10 px,ax_i8 col); +void ax_setpx2(ax_i20 vaddr,ax_i10 px,ax_i10 col); + +ax_i8 ax_getpx1(ax_i20 vaddr,ax_i10 px); +ax_i10 ax_getpx2(ax_i20 vaddr,ax_i10 px); + +void ax_clrscrn3(ax_i10 col); +void ax_clrscrn4(ax_i20 vaddr,ax_i8 col); +void ax_clrscrn5(ax_i20 vaddr,ax_i10 col); + +void ax_plot3(ax_i8 x, ax_i8 y,ax_i10 col); +void ax_plot4(ax_i20 vaddr,ax_i8 x,ax_i8 y, ax_i8 col); +void ax_plot5(ax_i20 vaddr,ax_i8 x,ax_i8 y, ax_i10 col); + +ax_i10 ax_rd3(ax_i8 x, ax_i8 y); +ax_i8 ax_rd4(ax_i20 vaddr,ax_i8 x,ax_i8 y); +ax_i10 ax_rd5(ax_i20 vaddr,ax_i8 x,ax_i8 y); + +void ax_cir3(ax_i8 x, ax_i8 y,ax_i8 r); +void ax_cir4(ax_i20 vaddr,ax_i8 x,ax_i8 y,ax_i8 r); +void ax_cir5(ax_i20 vaddr,ax_i8 x,ax_i8 y,ax_i8 r); + +#endif diff --git a/agbx/include/ax/key.h b/agbx/include/ax/key.h new file mode 100644 index 0000000..76517f7 --- /dev/null +++ b/agbx/include/ax/key.h @@ -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/. +*/ + +#if !defined(__ax_hdr_key) +#define __ax_hdr_key + +#include <ax/bs.h> + +typedef enum { + ax_key_a = 0x0u, + ax_key_b = 0x1u, + ax_key_l = 0x9u, + ax_key_pade = 0x4u, + ax_key_padn = 0x6u, + ax_key_pads = 0x7u, + ax_key_padw = 0x5u, + ax_key_r = 0x8u, + ax_key_sel = 0x2u, + ax_key_start = 0x3u, +} ax_key; + +typedef struct { + ax_i10 _keys; +} ax_keymap; + +#define ax_chkkey(_map,_key) (!(bool)(_map._keys >> (ax_i10)_key & 0x1u)) + +ax_keymap ax_getkeymap(void); + +#endif diff --git a/agbx/source/algo/cp.c b/agbx/source/algo/cp.c index 651abd8..347b55d 100644 --- a/agbx/source/algo/cp.c +++ b/agbx/source/algo/cp.c @@ -4,11 +4,11 @@ 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 <ax/priv.h> -#include <agbx/algo.h> +#include <ax/algo.h> -void agbx_cp(void const * const _src,agbx_i20 const _num,void * const _dest) { +void ax_cp(void const * const _src,ax_i20 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 64130e3..e302244 100644 --- a/agbx/source/bs/done.c +++ b/agbx/source/bs/done.c @@ -4,38 +4,38 @@ 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 <ax/priv.h> -#include <agbx/gfx.h> +#include <ax/gfx.h> -void agbx_done(agbx_err const _err) { - if (_err == agbx_err_ok) { +void ax_done(ax_err const _err) { + if (_err == ax_err_ok) { __asm__ ( "svc 0x3\n" ); __builtin_unreachable(); } /* Display the barcode-like error message: */ - agbx_set10(0x400'0000u,0x404u); - agbx_set10(0x500'0000u,0x0u); - agbx_set10(0x500'0002u,0b11111u); - agbx_i8 err[0xBu]; - for (agbx_i8 pos = 0x0u;pos != 0x8u;++pos) {err[pos] = (agbx_i8)_err >> pos & 0x1u;} + ax_set10(0x400'0000u,0x404u); + ax_set10(0x500'0000u,0x0u); + ax_set10(0x500'0002u,0b11111u); + ax_i8 err[0xBu]; + for (ax_i8 pos = 0x0u;pos != 0x8u;++pos) {err[pos] = (ax_i8)_err >> pos & 0x1u;} err[0x8u] = 0x0u; err[0x9u] = 0x1u; err[0xAu] = 0x0u; - for (agbx_i10 pos = 0x0u;pos != 0x9600u;pos += 0xF0u) { - agbx_setpx1(0x600'0000u,pos, err[0x0u]); - agbx_setpx1(0x600'0000u,pos + 0x1u,err[0x1u]); - agbx_setpx1(0x600'0000u,pos + 0x2u,err[0x2u]); - agbx_setpx1(0x600'0000u,pos + 0x3u,err[0x3u]); - agbx_setpx1(0x600'0000u,pos + 0x4u,err[0x4u]); - agbx_setpx1(0x600'0000u,pos + 0x5u,err[0x5u]); - agbx_setpx1(0x600'0000u,pos + 0x6u,err[0x6u]); - agbx_setpx1(0x600'0000u,pos + 0x7u,err[0x7u]); - agbx_setpx1(0x600'0000u,pos + 0x8u,err[0x8u]); - agbx_setpx1(0x600'0000u,pos + 0x9u,err[0x9u]); - agbx_setpx1(0x600'0000u,pos + 0xAu,err[0xAu]); + for (ax_i10 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]); + ax_setpx1(0x600'0000u,pos + 0x3u,err[0x3u]); + ax_setpx1(0x600'0000u,pos + 0x4u,err[0x4u]); + ax_setpx1(0x600'0000u,pos + 0x5u,err[0x5u]); + ax_setpx1(0x600'0000u,pos + 0x6u,err[0x6u]); + ax_setpx1(0x600'0000u,pos + 0x7u,err[0x7u]); + ax_setpx1(0x600'0000u,pos + 0x8u,err[0x8u]); + ax_setpx1(0x600'0000u,pos + 0x9u,err[0x9u]); + ax_setpx1(0x600'0000u,pos + 0xAu,err[0xAu]); } __asm__ ( "svc 0x2\n" diff --git a/agbx/source/bs/get.s b/agbx/source/bs/get.s index b827dec..7068aaf 100644 --- a/agbx/source/bs/get.s +++ b/agbx/source/bs/get.s @@ -7,15 +7,15 @@ .cpu arm7tdmi .thumb -.globl agbx_get10 -.globl agbx_get20 -.globl agbx_get8 +.globl ax_get10 +.globl ax_get20 +.globl ax_get8 .func .thumb_func -agbx_get10: - ldrh r0,[r0] @ agbx_i10 val = *(agbx_i10 *)addr; +ax_get10: + ldrh r0,[r0] @ ax_i10 val = *(ax_i10 *)addr; bx lr @ return val; .endfunc @@ -23,8 +23,8 @@ agbx_get10: .func .thumb_func -agbx_get20: - ldr r0,[r0] @ agbx_i20 val = *(agbx_i20 *)addr; +ax_get20: + ldr r0,[r0] @ ax_i20 val = *(ax_i20 *)addr; bx lr @ return val; .endfunc @@ -32,8 +32,8 @@ agbx_get20: .func .thumb_func -agbx_get8: - ldrb r0,[r0] @ agbx_i8 val = *(agbx_i8 *)addr; +ax_get8: + ldrb r0,[r0] @ ax_i8 val = *(ax_i8 *)addr; bx lr @ return val; .endfunc diff --git a/agbx/source/bs/set.s b/agbx/source/bs/set.s index 85e6372..18e7218 100644 --- a/agbx/source/bs/set.s +++ b/agbx/source/bs/set.s @@ -7,15 +7,15 @@ .cpu arm7tdmi .thumb -.globl agbx_set10 -.globl agbx_set20 -.globl agbx_set8 +.globl ax_set10 +.globl ax_set20 +.globl ax_set8 .func .thumb_func -agbx_set10: - strh r1,[r0] @ *(agbx_i10 *)addr = val; +ax_set10: + strh r1,[r0] @ *(ax_i10 *)addr = val; bx lr @ return; .endfunc @@ -23,8 +23,8 @@ agbx_set10: .func .thumb_func -agbx_set20: - str r1,[r0] @ *(agbx_i20 *)addr = val; +ax_set20: + str r1,[r0] @ *(ax_i20 *)addr = val; bx lr @ return; .endfunc @@ -32,8 +32,8 @@ agbx_set20: .func .thumb_func -agbx_set8: - strb r1,[r0] @ *(agbx_i8 *)addr = val; +ax_set8: + strb r1,[r0] @ *(ax_i8 *)addr = val; bx lr @ return; .endfunc diff --git a/agbx/source/gfx/clrscrn.c b/agbx/source/gfx/clrscrn.c index 157498c..997d825 100644 --- a/agbx/source/gfx/clrscrn.c +++ b/agbx/source/gfx/clrscrn.c @@ -4,21 +4,21 @@ 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 <ax/priv.h> -#include <agbx/gfx.h> +#include <ax/gfx.h> -void agbx_clrscrn3(agbx_i10 const _col) { - agbx_i20 const val = _col | _col << 0x8u | _col << 0x10u | _col << 0x18u; - for (agbx_i20 addr = 0x400'0000u;addr != 0x401'2C00u;addr += 0x4u) {agbx_set20(addr,val);} +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 agbx_clrscrn4(agbx_i20 const _vaddr,agbx_i8 const _col) { - agbx_i20 const val = _col | _col << 0x8u | _col << 0x10u | _col << 0x18u; - for (agbx_i20 addr = _vaddr;addr != _vaddr + 0x9600u;addr += 0x4u) {agbx_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 agbx_clrscrn5(agbx_i20 const _vaddr,agbx_i10 const _col) { - agbx_i20 const val = _col | _col << 0x10u; - for (agbx_i20 addr = _vaddr;addr != _vaddr + 0xA000u;addr += 0x4u) {agbx_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);} } diff --git a/agbx/source/gfx/flip.s b/agbx/source/gfx/flip.s index 32171d1..95f59a6 100644 --- a/agbx/source/gfx/flip.s +++ b/agbx/source/gfx/flip.s @@ -7,27 +7,27 @@ .cpu arm7tdmi .thumb -.extern __agbx_getvbnk +.extern __ax_getvbnk -.globl agbx_flip +.globl ax_flip .func .thumb_func -agbx_flip: +ax_flip: @ Get the current value of dispcnt: - ldr r0,.dispcntaddr @ agbx_i20 dispcntaddr = 0x4000000u; - ldrh r1,[r0] @ agbx_i10 dispcnt = *(agbx_i10 *)dispcntaddr; + ldr r0,.dispcntaddr @ ax_i20 dispcntaddr = 0x4000000u; + ldrh r1,[r0] @ ax_i10 dispcnt = *(ax_i10 *)dispcntaddr; @ XOR bit five: movs r2,0b10000 eors r1,r2 @ dispcnt ^= 0b10000u; @ Save dispcnt: - strh r1,[r0] @ *(agbx_i10 *)dispcntaddr = dispcnt; + strh r1,[r0] @ *(ax_i10 *)dispcntaddr = dispcnt; @ Get the address of the video bank: - b __agbx_getvbnk @ agbx_i20 vaddr = __agbx_getvbnk(); + b __ax_getvbnk @ ax_i20 vaddr = __ax_getvbnk(); bx lr @ return vaddr; diff --git a/agbx/source/gfx/getpx.s b/agbx/source/gfx/getpx.s index f5a976f..0bdcef4 100644 --- a/agbx/source/gfx/getpx.s +++ b/agbx/source/gfx/getpx.s @@ -7,13 +7,13 @@ .cpu arm7tdmi .thumb -.globl agbx_getpx1 -.globl agbx_getpx2 +.globl ax_getpx1 +.globl ax_getpx2 .func .thumb_func -agbx_getpx1: +ax_getpx1: adds r0,r1 @ Get the address of the pixel by adding the offset to the video address. ldrh r0,[r0] bx lr @@ -23,7 +23,7 @@ agbx_getpx1: .func .thumb_func -agbx_getpx2: +ax_getpx2: adds r0,r1 @ Get the address of the pixel by adding the offset to the video address. adds r0,r1 @ Add the offset twice as each pixel takes up two bytes. ldrh r0,[r0] diff --git a/agbx/source/gfx/getvbnk.s b/agbx/source/gfx/getvbnk.s index f2e22ae..1c6a64e 100644 --- a/agbx/source/gfx/getvbnk.s +++ b/agbx/source/gfx/getvbnk.s @@ -7,19 +7,19 @@ .cpu arm7tdmi .thumb -.globl __agbx_getvbnk -.globl agbx_getvbnk +.globl __ax_getvbnk +.globl ax_getvbnk .func .thumb_func -agbx_getvbnk: +ax_getvbnk: @ Get the current value of dispcnt: - ldr r0,.dispcntaddr @ agbx_i20 dispcntaddr = 0x4000000u; - ldrh r1,[r0] @ agbx_i10 dispcnt = *(agbx_i10 *)dispcntaddr; + ldr r0,.dispcntaddr @ ax_i20 dispcntaddr = 0x4000000u; + ldrh r1,[r0] @ ax_i10 dispcnt = *(ax_i10 *)dispcntaddr; @ Get the address: - b __agbx_getvbnk @ agbx_i20 vaddr = __agbx_getvbnk(); + b __ax_getvbnk @ ax_i20 vaddr = __ax_getvbnk(); bx lr @ return vaddr; @@ -28,7 +28,7 @@ agbx_getvbnk: .func .thumb_func -__agbx_getvbnk: @ Takes the value of dispcnt in r1. +__ax_getvbnk: @ Takes the value of dispcnt in r1. @ Check if the fifth bit is set: movs r0,0b10000 tst r1,r0 diff --git a/agbx/source/gfx/plot.c b/agbx/source/gfx/plot.c index a19a2f1..f12c39b 100644 --- a/agbx/source/gfx/plot.c +++ b/agbx/source/gfx/plot.c @@ -4,21 +4,21 @@ 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 <ax/priv.h> -#include <agbx/gfx.h> +#include <ax/gfx.h> -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) +void ax_plot3(ax_i8 const _x,ax_i8 const _y,ax_i10 const _col) { + ax_i10 const px = _y * 0xF0u + _x; + __ax_setpx2(0x600'0000u,px,_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); +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; + ax_setpx1(_vaddr,px,_col); } -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) +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; + __ax_setpx2(_vaddr,px,_col) } diff --git a/agbx/source/gfx/rd.c b/agbx/source/gfx/rd.c index 94dd676..e53a3fe 100644 --- a/agbx/source/gfx/rd.c +++ b/agbx/source/gfx/rd.c @@ -4,21 +4,21 @@ 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 <ax/priv.h> -#include <agbx/gfx.h> +#include <ax/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); +ax_i10 ax_rd3(ax_i8 const _x,ax_i8 const _y) { + ax_i10 const px = _y * 0xF0u + _x; + return ax_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); +ax_i8 ax_rd4(ax_i20 const _vaddr,ax_i8 const _x,ax_i8 const _y) { + ax_i10 const px = _y * 0xF0u + _x; + return ax_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); +ax_i10 ax_rd5(ax_i20 const _vaddr,ax_i8 const _x,ax_i8 const _y) { + ax_i10 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 322784e..c82c980 100644 --- a/agbx/source/gfx/setpx.c +++ b/agbx/source/gfx/setpx.c @@ -4,16 +4,16 @@ 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 <ax/priv.h> -#include <agbx/gfx.h> +#include <ax/gfx.h> -void agbx_setpx1(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_i8 const _col) { +void ax_setpx1(ax_i20 const _vaddr,ax_i10 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; - agbx_i20 addr = _vaddr + _px - odd; - agbx_i10 precol = __agbx_get10(addr); - agbx_i10 col = _col; + ax_i20 addr = _vaddr + _px - odd; + ax_i10 precol = __ax_get10(addr); + ax_i10 col = _col; if (odd) { precol &= 0b11111111u; col <<= 0x8u; @@ -21,11 +21,11 @@ void agbx_setpx1(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_i8 const _col) { else { precol &= 0b1111111100000000u; } - agbx_i10 const newcol = precol | col; - __agbx_set10(addr,newcol); + ax_i10 const newcol = precol | col; + __ax_set10(addr,newcol); } -void agbx_setpx2(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_i10 const _col) { - agbx_i20 const addr = _vaddr + _px; - __agbx_set10(addr,_col); +void ax_setpx2(ax_i20 const _vaddr,ax_i10 const _px,ax_i10 const _col) { + ax_i20 const addr = _vaddr + _px; + __ax_set10(addr,_col); } diff --git a/agbx/source/gfx/vsync.s b/agbx/source/gfx/vsync.s index 2e6ac3f..7ecd7fb 100644 --- a/agbx/source/gfx/vsync.s +++ b/agbx/source/gfx/vsync.s @@ -7,19 +7,19 @@ .cpu arm7tdmi .thumb -.globl agbx_vsync +.globl ax_vsync .func .thumb_func -agbx_vsync: +ax_vsync: @ Set the constants: - ldr r0,.vcountaddr @ agbx_i20 vcountaddr = 0x4000006u; - movs r1,0xA0 @ agbx_i20 numhline = 0xA0; + ldr r0,.vcountaddr @ ax_i20 vcountaddr = 0x4000006u; + movs r1,0xA0 @ ax_i20 numhline = 0xA0; .loop: @ Check the scanline counter: - ldrh r2,[r0] @ agbx_i20 vcount = *(agbx_i10 *)vcountaddr; + ldrh r2,[r0] @ ax_i20 vcount = *(ax_i10 *)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 38c6dbe..42bb611 100644 --- a/agbx/source/key/getkeymap.s +++ b/agbx/source/key/getkeymap.s @@ -7,15 +7,15 @@ .cpu arm7tdmi .thumb -.globl agbx_getkeymap +.globl ax_getkeymap .func .thumb_func -agbx_getkeymap: +ax_getkeymap: @ Load the keys: - ldr r0,.addr @ agbx_i20 addr = 0x4000130u; - ldrh r0,[r0] @ agbx_keymap keymap = *(agbx_i10 *)addr; + ldr r0,.addr @ ax_i20 addr = 0x4000130u; + ldrh r0,[r0] @ ax_keymap keymap = *(ax_i10 *)addr; bx lr @ return keymap; diff --git a/agbx/source/priv/init.s b/agbx/source/priv/init.s index b9f1f45..49ada46 100644 --- a/agbx/source/priv/init.s +++ b/agbx/source/priv/init.s @@ -7,19 +7,19 @@ .cpu arm7tdmi .thumb -.extern agbx_done -.extern agbx_main +.extern ax_done +.extern ax_main -.globl __agbx_init +.globl __ax_init .func .thumb_func -__agbx_init: +__ax_init: @ Call main: - bl agbx_main + bl ax_main @ Call done: - bl agbx_done @ The return value is already in r0, so there's no need to move it. + bl ax_done @ The return value is already in r0, so there's no need to move it. .endfunc |