diff options
Diffstat (limited to 'agbx')
-rw-r--r-- | agbx/GNUmakefile | 1 | ||||
-rw-r--r-- | agbx/include-private/agbx/priv.h | 2 | ||||
-rw-r--r-- | agbx/include/agbx/bs.h | 6 | ||||
-rw-r--r-- | agbx/include/agbx/key.h | 33 | ||||
-rw-r--r-- | agbx/source/bs/done.c | 2 | ||||
-rw-r--r-- | agbx/source/gfx/plot.c | 2 | ||||
-rw-r--r-- | agbx/source/gfx/setpx.c | 2 | ||||
-rw-r--r-- | agbx/source/key/getkeymap.c | 15 |
8 files changed, 60 insertions, 3 deletions
diff --git a/agbx/GNUmakefile b/agbx/GNUmakefile index 618b9d6..f0f2bdf 100644 --- a/agbx/GNUmakefile +++ b/agbx/GNUmakefile @@ -52,6 +52,7 @@ OBJS := \ source/bs/set.o \ source/gfx/plot.o \ source/gfx/setpx.o \ + source/key/getkeymap.o \ source/priv/init.o LIB := libagbx.a diff --git a/agbx/include-private/agbx/priv.h b/agbx/include-private/agbx/priv.h index 39c73f6..867ec07 100644 --- a/agbx/include-private/agbx/priv.h +++ b/agbx/include-private/agbx/priv.h @@ -7,7 +7,7 @@ #if !defined(__agbx_hdr_priv) #define __agbx_hdr_priv -#include <agbx/gfx.h> +#include <agbx/bs.h> #define __agbx_set10(_addr,_val) { \ __asm__ ( \ diff --git a/agbx/include/agbx/bs.h b/agbx/include/agbx/bs.h index 630c50b..ab2afd1 100644 --- a/agbx/include/agbx/bs.h +++ b/agbx/include/agbx/bs.h @@ -4,12 +4,13 @@ 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_base) -#define __agbx_hdr_base +#if !defined(__agbx_hdr_bs) +#define __agbx_hdr_bs /* C23 compatibility: */ #define constexpr static const #define nullptr ((void *)0x0u) +#define typeof __typeof__ typedef unsigned short agbx_i10; typedef unsigned int agbx_i20; @@ -22,6 +23,7 @@ typedef enum { agbx_err_ok, agbx_err_pos2big, agbx_err_px2big, + agbx_err_max = 0xFFu, } agbx_err; constexpr agbx_i40 agbx_ver = 0x0u; diff --git a/agbx/include/agbx/key.h b/agbx/include/agbx/key.h new file mode 100644 index 0000000..973dd90 --- /dev/null +++ b/agbx/include/agbx/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(__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/source/bs/done.c b/agbx/source/bs/done.c index afac799..81fd7c5 100644 --- a/agbx/source/bs/done.c +++ b/agbx/source/bs/done.c @@ -6,6 +6,8 @@ #include <agbx/priv.h> +#include <agbx/gfx.h> + void agbx_done(agbx_err const _err) { if (_err == agbx_err_ok) { __asm__ ( diff --git a/agbx/source/gfx/plot.c b/agbx/source/gfx/plot.c index 5a65972..2146c54 100644 --- a/agbx/source/gfx/plot.c +++ b/agbx/source/gfx/plot.c @@ -6,6 +6,8 @@ #include <agbx/priv.h> +#include <agbx/gfx.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);} diff --git a/agbx/source/gfx/setpx.c b/agbx/source/gfx/setpx.c index ace2463..563fd3b 100644 --- a/agbx/source/gfx/setpx.c +++ b/agbx/source/gfx/setpx.c @@ -6,6 +6,8 @@ #include <agbx/priv.h> +#include <agbx/gfx.h> + void agbx_setpx1(agbx_i10 const _px,agbx_i8 const _col) { #if defined(__agbx_dbg) agbx_i10 const dispcnt = agbx_get10(0x4000000u); diff --git a/agbx/source/key/getkeymap.c b/agbx/source/key/getkeymap.c new file mode 100644 index 0000000..457bf42 --- /dev/null +++ b/agbx/source/key/getkeymap.c @@ -0,0 +1,15 @@ +/* + 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/key.h> + +agbx_keymap agbx_getkeymap(void) { + agbx_keymap map; + map._keys = agbx_get10(0x4000130u); + return map; +} |