diff options
Diffstat (limited to 'agbx/include-private')
-rw-r--r-- | agbx/include-private/agbx/priv.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/agbx/include-private/agbx/priv.h b/agbx/include-private/agbx/priv.h new file mode 100644 index 0000000..39c73f6 --- /dev/null +++ b/agbx/include-private/agbx/priv.h @@ -0,0 +1,49 @@ +/* + 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/gfx.h> + +#define __agbx_set10(_addr,_val) { \ + __asm__ ( \ + "strh %1,[%0]" \ + : \ + : "r" (_addr),"r" (_val) \ + : "memory" \ + ); \ +} + +#define __agbx_set20(_addr,_val) { \ + __asm__ ( \ + "str %1,[%0]" \ + : \ + : "r" (_addr),"r" (_val) \ + : "memory" \ + ); \ +} + +#define __agbx_set8(_addr,_val) { \ + __asm__ ( \ + "strb %1,[%0]" \ + : \ + : "r" (_addr),"r" (_val) \ + : "memory" \ + ); \ +} + +#define __agbx_setpx1(_px,_col) { \ + agbx_i20 const addr = 0x6000000u + _px; \ + __agbx_set8(addr,_col); \ +} + +#define __agbx_setpx2(_px,_col) { \ + agbx_i20 const addr = 0x6000000u + _px * 0x2u; /* We multiply it by two as each pixel takes up two bytes. */ \ + __agbx_set10(addr,_col); \ +} + +#endif |