diff options
Diffstat (limited to 'agbx/source/gfx')
-rw-r--r-- | agbx/source/gfx/flip.c | 17 | ||||
-rw-r--r-- | agbx/source/gfx/flip.s | 47 | ||||
-rw-r--r-- | agbx/source/gfx/setpx.c | 2 |
3 files changed, 48 insertions, 18 deletions
diff --git a/agbx/source/gfx/flip.c b/agbx/source/gfx/flip.c deleted file mode 100644 index 92b8939..0000000 --- a/agbx/source/gfx/flip.c +++ /dev/null @@ -1,17 +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/. -*/ - -#include <agbx/priv.h> - -#include <agbx/gfx.h> - -agbx_i20 agbx_flip(void) { - agbx_i10 dispcnt = agbx_get10(0x400'0000u); - dispcnt ^= 0b10000u; - agbx_set10(0x400'0000u,dispcnt); - if (dispcnt & 0x10000u) {return 0x600'A000u;} - return 0x600'0000u; -} diff --git a/agbx/source/gfx/flip.s b/agbx/source/gfx/flip.s new file mode 100644 index 0000000..c2f4336 --- /dev/null +++ b/agbx/source/gfx/flip.s @@ -0,0 +1,47 @@ +@ 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/. + +.syntax unified + +.cpu arm7tdmi +.thumb + +.globl agbx_flip + +.func + +.thumb_func + +agbx_flip: + ldr r0,.dispcntaddr + ldrh r1,[r0] @ Get the current value of dispcnt. + movs r2,#0b10000 + eors r1,r2 @ XOR bit five. + strh r1,[r0] @ Save dispcnt. + movs r0,#0x10 + tst r1,r0 @ Check what video bank we should return the address of. + beq .vbnk0 +.vbnk1: + ldr r0,.vbnk1addr + bx lr +.vbnk0: + ldr r0,.vbnk0addr + bx lr + +.endfunc + +.align + +.dispcntaddr: + .long 0x4000000 + +.align + +.vbnk0addr: + .long 0x6000000 + +.align + +.vbnk1addr: + .long 0x600A000 diff --git a/agbx/source/gfx/setpx.c b/agbx/source/gfx/setpx.c index b2c5c2d..d7d3110 100644 --- a/agbx/source/gfx/setpx.c +++ b/agbx/source/gfx/setpx.c @@ -20,7 +20,7 @@ void agbx_setpx1(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_i8 const _col) { 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) + __agbx_set10(addr,col); } void agbx_setpx2(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_i10 const _col) { |