diff options
Diffstat (limited to 'agbx/source/gfx')
-rw-r--r-- | agbx/source/gfx/flip.s | 13 | ||||
-rw-r--r-- | agbx/source/gfx/getpx.s | 2 | ||||
-rw-r--r-- | agbx/source/gfx/getvbnk.s | 11 | ||||
-rw-r--r-- | agbx/source/gfx/setpx.c | 21 | ||||
-rw-r--r-- | agbx/source/gfx/vsync.s | 21 |
5 files changed, 35 insertions, 33 deletions
diff --git a/agbx/source/gfx/flip.s b/agbx/source/gfx/flip.s index 019289d..32171d1 100644 --- a/agbx/source/gfx/flip.s +++ b/agbx/source/gfx/flip.s @@ -12,25 +12,24 @@ .globl agbx_flip .func - .thumb_func agbx_flip: @ Get the current value of dispcnt: - ldr r0,.dispcntaddr - ldrh r1,[r0] + ldr r0,.dispcntaddr @ agbx_i20 dispcntaddr = 0x4000000u; + ldrh r1,[r0] @ agbx_i10 dispcnt = *(agbx_i10 *)dispcntaddr; @ XOR bit five: movs r2,0b10000 - eors r1,r2 + eors r1,r2 @ dispcnt ^= 0b10000u; @ Save dispcnt: - strh r1,[r0] + strh r1,[r0] @ *(agbx_i10 *)dispcntaddr = dispcnt; @ Get the address of the video bank: - b __agbx_getvbnk + b __agbx_getvbnk @ agbx_i20 vaddr = __agbx_getvbnk(); - bx lr + bx lr @ return vaddr; .endfunc diff --git a/agbx/source/gfx/getpx.s b/agbx/source/gfx/getpx.s index f583b56..f5a976f 100644 --- a/agbx/source/gfx/getpx.s +++ b/agbx/source/gfx/getpx.s @@ -11,7 +11,6 @@ .globl agbx_getpx2 .func - .thumb_func agbx_getpx1: @@ -22,7 +21,6 @@ agbx_getpx1: .endfunc .func - .thumb_func agbx_getpx2: diff --git a/agbx/source/gfx/getvbnk.s b/agbx/source/gfx/getvbnk.s index 6898266..f2e22ae 100644 --- a/agbx/source/gfx/getvbnk.s +++ b/agbx/source/gfx/getvbnk.s @@ -11,30 +11,27 @@ .globl agbx_getvbnk .func - .thumb_func agbx_getvbnk: @ Get the current value of dispcnt: - ldr r0,.dispcntaddr - ldrh r1,[r0] + ldr r0,.dispcntaddr @ agbx_i20 dispcntaddr = 0x4000000u; + ldrh r1,[r0] @ agbx_i10 dispcnt = *(agbx_i10 *)dispcntaddr; @ Get the address: - b __agbx_getvbnk + b __agbx_getvbnk @ agbx_i20 vaddr = __agbx_getvbnk(); - bx lr + bx lr @ return vaddr; .endfunc .func - .thumb_func __agbx_getvbnk: @ Takes the value of dispcnt in r1. @ Check if the fifth bit is set: movs r0,0b10000 tst r1,r0 - beq .vbnk1 .vbnk0: diff --git a/agbx/source/gfx/setpx.c b/agbx/source/gfx/setpx.c index e478603..322784e 100644 --- a/agbx/source/gfx/setpx.c +++ b/agbx/source/gfx/setpx.c @@ -10,13 +10,22 @@ 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); + bool const odd = _px & 0x1u; + agbx_i20 addr = _vaddr + _px - odd; + agbx_i10 precol = __agbx_get10(addr); + agbx_i10 col = _col; + if (odd) { + precol &= 0b11111111u; + col <<= 0x8u; + } + else { + precol &= 0b1111111100000000u; + } + agbx_i10 const newcol = precol | col; + __agbx_set10(addr,newcol); } void agbx_setpx2(agbx_i20 const _vaddr,agbx_i10 const _px,agbx_i10 const _col) { - __agbx_setpx2(_vaddr,_px,_col) + agbx_i20 const addr = _vaddr + _px; + __agbx_set10(addr,_col); } diff --git a/agbx/source/gfx/vsync.s b/agbx/source/gfx/vsync.s index 5bfbe06..2e6ac3f 100644 --- a/agbx/source/gfx/vsync.s +++ b/agbx/source/gfx/vsync.s @@ -10,29 +10,28 @@ .globl agbx_vsync .func - .thumb_func agbx_vsync: @ Set the constants: - ldr r0,.scancnt @ Address of the scanline counter register. - movs r1,0xA0 @ Number of horizontal lines; + ldr r0,.vcountaddr @ agbx_i20 vcountaddr = 0x4000006u; + movs r1,0xA0 @ agbx_i20 numhline = 0xA0; .loop: @ Check the scanline counter: - ldr r2,[r0] @ Load the counter. - cmp r2,r1 @ Check if it has reached the bottom. - beq .ret @ Return if so. + ldrh r2,[r0] @ agbx_i20 vcount = *(agbx_i10 *)vcountaddr; + cmp r2,r1 + beq .ret @ if (vcount == numhline) {goto ret;} + + b .loop @ goto loop; .ret: @ Return: - bx lr + bx lr @ return; .endfunc .align -.scancnt: - .long 0x4000000 - -.align +.vcountaddr: + .long 0x4000006 |