diff options
Diffstat (limited to 'agbx/source/bs')
-rw-r--r-- | agbx/source/bs/done.c | 34 | ||||
-rw-r--r-- | agbx/source/bs/get.c | 40 | ||||
-rw-r--r-- | agbx/source/bs/set.c | 13 |
3 files changed, 87 insertions, 0 deletions
diff --git a/agbx/source/bs/done.c b/agbx/source/bs/done.c new file mode 100644 index 0000000..afac799 --- /dev/null +++ b/agbx/source/bs/done.c @@ -0,0 +1,34 @@ +/* + 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> + +void agbx_done(agbx_err const _err) { + if (_err == agbx_err_ok) { + __asm__ ( + "swi 0x3\n" + ); + __builtin_unreachable(); + } + /* Display the barcode-like error message: */ + agbx_set10(0x4000000u,0x403u); + agbx_i10 err[0x8u]; + for (agbx_i8 pos = 0x0u;pos != 0x8u;++pos) {err[pos] = (agbx_i8)_err >> pos & 0x1u ? 0xFFFFu : 0x0u;} + for (agbx_i10 pos = 0x0u;pos != 0x9600u;pos += 0xF0u) { + agbx_setpx2(pos, err[0x0u]); + agbx_setpx2(pos + 0x1u,err[0x1u]); + agbx_setpx2(pos + 0x2u,err[0x2u]); + agbx_setpx2(pos + 0x3u,err[0x3u]); + agbx_setpx2(pos + 0x4u,err[0x4u]); + agbx_setpx2(pos + 0x5u,err[0x5u]); + agbx_setpx2(pos + 0x6u,err[0x6u]); + agbx_setpx2(pos + 0x7u,err[0x7u]); + } + __asm__ ( + "swi 0x2\n" + ); + for (;;) {} +} diff --git a/agbx/source/bs/get.c b/agbx/source/bs/get.c new file mode 100644 index 0000000..38da5af --- /dev/null +++ b/agbx/source/bs/get.c @@ -0,0 +1,40 @@ +/* + 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> + +agbx_i10 agbx_get10(agbx_i20 const _addr) { + agbx_i10 val; + __asm__ ( \ + "ldrh %0,[%1]" + : "=r" (val) + : "r" (_addr) + : "memory" + ); + return val; +} + +agbx_i20 agbx_get20(agbx_i20 const _addr) { + agbx_i20 val; + __asm__ ( \ + "ldr %0,[%1]" + : "=r" (val) + : "r" (_addr) + : "memory" + ); + return val; +} + +agbx_i8 agbx_get8(agbx_i20 const _addr) { + agbx_i8 val; + __asm__ ( \ + "ldrb %0,[%1]" + : "=r" (val) + : "r" (_addr) + : "memory" + ); + return val; +} diff --git a/agbx/source/bs/set.c b/agbx/source/bs/set.c new file mode 100644 index 0000000..8aa9976 --- /dev/null +++ b/agbx/source/bs/set.c @@ -0,0 +1,13 @@ +/* + 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> + +void agbx_set10(agbx_i20 const _addr,agbx_i10 const _val) {__agbx_set10(_addr,_val)} + +void agbx_set20(agbx_i20 const _addr,agbx_i20 const _val) {__agbx_set20(_addr,_val)} + +void agbx_set8(agbx_i20 const _addr,agbx_i8 const _val) {__agbx_set8(_addr,_val)} |