From 2c8f55a22b2dc25bc82d3dab0aebe04e61e82d9f Mon Sep 17 00:00:00 2001 From: XProger Date: Fri, 21 Jan 2022 04:24:52 +0300 Subject: [PATCH] #368 GBA TEX_2PX akill texturing, fix FTA/GTA unaligned VRAM write --- src/platform/gba/rasterizeFTA.s | 21 +++++++++++++++------ src/platform/gba/rasterizeGTA.s | 15 ++++++++++++--- src/platform/gba/transformMesh.s | 8 -------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/platform/gba/rasterizeFTA.s b/src/platform/gba/rasterizeFTA.s index 4a8b7ec..23d3713 100644 --- a/src/platform/gba/rasterizeFTA.s +++ b/src/platform/gba/rasterizeFTA.s @@ -60,13 +60,14 @@ SP_RDX = 8 SP_RDT = 12 .macro PUT_PIXELS +#ifndef TEX_2PX tex indexA, t add t, dtdx tex indexB, t add t, dtdx - // cheap non-accurate alpha test, skip pixels pair if one or both are transparent + // cheap non-accurate alpha test, skip pixels pair if one or both are transparent ands indexA, #255 andnes indexB, #255 orrne indexB, indexA, indexB, lsl #8 // indexB = indexA | (indexB << 8) @@ -75,6 +76,14 @@ SP_RDT = 12 orrne indexA, indexB, lsl #8 strneh indexA, [tmp] add tmp, #2 +#else + tex indexA, t + add t, dtdx, lsl #1 + cmp indexA, #0 + ldrneb indexA, [LMAP, indexA] + strneb indexA, [tmp] + add tmp, #2 +#endif .endm .global rasterizeFTA_asm @@ -215,12 +224,11 @@ rasterizeFTA_asm: ldrb indexA, [TILE, indexA] cmp indexA, #0 - ldrneb indexB, [tmp, #-1] // read pal index from VRAM (byte) + ldrneb indexB, [tmp, #-1]! // read pal index from VRAM (byte) ldrneb indexA, [LMAP, indexA] orrne indexB, indexA, lsl #8 - strneh indexB, [tmp] - - add tmp, #1 + strneh indexB, [tmp], #2 + addeq tmp, #1 add t, dtdx subs width, #1 // width-- @@ -240,7 +248,8 @@ rasterizeFTA_asm: ldrneb indexA, [LMAP, indexA] ldrneb indexB, [tmp, width] orrne indexB, indexA, indexB, lsl #8 - strneh indexB, [tmp, width] + addne indexA, tmp, width + strneh indexB, [indexA, #-1] subs width, #1 // width-- beq .scanline_end // if (width == 0) diff --git a/src/platform/gba/rasterizeGTA.s b/src/platform/gba/rasterizeGTA.s index 487c45a..17b4012 100644 --- a/src/platform/gba/rasterizeGTA.s +++ b/src/platform/gba/rasterizeGTA.s @@ -88,13 +88,14 @@ SP_RDT = 20 bic LMAP, g, #255 add g, dgdx +#ifndef TEX_2PX tex indexA, t add t, dtdx tex indexB, t add t, dtdx - // cheap non-accurate alpha test, skip pixels pair if one or both are transparent + // cheap non-accurate alpha test, skip pixels pair if one or both are transparent ands indexA, #255 andnes indexB, #255 orrne indexB, indexA, indexB, lsl #8 // indexB = indexA | (indexB << 8) @@ -102,6 +103,14 @@ SP_RDT = 20 ldrneb indexB, [LMAP, indexB, lsr #8] orrne indexA, indexB, lsl #8 strneh indexA, [ptr] +#else + tex indexA, t + add t, dtdx, lsl #1 + cmp indexA, #0 + ldrneb indexA, [LMAP, indexA] + strneb indexA, [ptr] +#endif + add ptr, #2 .endm @@ -270,9 +279,9 @@ rasterizeGTA_asm: bic LMAP, g, #255 ldrb indexA, [LMAP, indexA] - ldrb indexB, [ptr, #-1] // read pal index from VRAM (byte) + ldrb indexB, [ptr, #-1]! // read pal index from VRAM (byte) orr indexB, indexA, lsl #8 - strh indexB, [ptr] + strh indexB, [ptr], #1 .skip_left: add ptr, #1 diff --git a/src/platform/gba/transformMesh.s b/src/platform/gba/transformMesh.s index 6bf7f5c..a1240a6 100644 --- a/src/platform/gba/transformMesh.s +++ b/src/platform/gba/transformMesh.s @@ -121,18 +121,10 @@ transformMesh_asm: add y, y, #(FRAME_HEIGHT >> 1) // store the result -#if 1 - // 2+2+2+2 = 8 ticks strh x, [res], #2 strh y, [res], #2 strh z, [res], #2 strh vg, [res], #2 -#else - // 1+1+3 = 5 ticks SLOWER! WTF? - orr x, x, y, lsl #16 - orr z, z, vg, lsl #16 - stmia res!, {x, z} -#endif subs count, #1 bne .loop