Ticket #8632: diff

File diff, 3.9 KB (added by SF/robinwatts, 13 years ago)

New ARM PocketPCHalf implementation, plus C changes to call it

  • CEScaler.cpp

     
    128128        }
    129129}
    130130
     131#ifdef ARM
     132extern "C" {
     133  void PocketPCHalfARM(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, int mask, int round);
     134  // Rounding constants and masks used for different pixel formats
     135  int roundingconstants[] = { 0x00200802, 0x00201002 };
     136  int redbluegreenMasks[] = { 0x03E07C1F, 0x07E0F81F };
     137}
     138#endif
    131139
    132140void PocketPCHalf(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
     141#ifdef ARM
     142     PocketPCHalfARM(srcPtr, srcPitch, dstPtr, dstPitch, width, height, redbluegreenMasks[maskUsed],roundingconstants[maskUsed]);
     143#else
    133144        uint8 *work;
    134145        int i;
    135146        uint16 srcPitch16 = (uint16)(srcPitch / sizeof(uint16));
     
    151162                srcPtr += 2 * srcPitch;
    152163                dstPtr += dstPitch;
    153164        }
     165#endif
    154166}
    155167
    156168
  • ARMscaler.s

     
     1@ ScummVM Scumm Interpreter
     2@ Copyright (C) 2007 The ScummVM project
     3@
     4@ This program is free software; you can redistribute it and/or
     5@ modify it under the terms of the GNU General Public License
     6@ as published by the Free Software Foundation; either version 2
     7@ of the License, or (at your option) any later version.
     8@
     9@ This program is distributed in the hope that it will be useful,
     10@ but WITHOUT ANY WARRANTY; without even the implied warranty of
     11@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12@ GNU General Public License for more details.
     13@
     14@ You should have received a copy of the GNU General Public License
     15@ along with this program; if not, write to the Free Software
     16@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
     17@
     18@ $URL$
     19@ $Id$
     20@
     21@ @author Robin Watts (robin@wss.co.uk)
     22
     23        .text
     24
     25        .global PocketPCHalfARM
     26
     27        @ ARM implementation of PocketPCHalf scaler.
     28        @ Scales a width x height block of 16bpp pixels from srcPtr to
     29        @ dstPtr. srcPitch and dstPitch identify how to reach subsequent
     30        @ lines. redblueMask and round allow for one routine to do both
     31        @ 565 and 555 formats.
     32PocketPCHalfARM:
     33        @ r0 = srcPtr
     34        @ r1 = srcPitch
     35        @ r2 = dstPtr
     36        @ r3 = dstPitch
     37        MOV     r12,r13
     38        STMFD   r13!,{r4-r9,r14}
     39        LDMIA   r12,{r4-r7}
     40        @ r4 = width
     41        @ r5 = height
     42        @ r6 = redblueMask
     43        @ r7 = round
     44
     45        SUB     r3,r3,r4                @ dstPitch -= width
     46        SUBS    r5,r5,#2                @ while ((height-=2) >= 0)
     47        BLT     end
     48height_loop:
     49width_loop:
     50        @ Must not assume that we are word aligned - would be far too easy!
     51        LDRH    r8,[r0],r1              @ r8 = A = srcPtr[0]
     52        LDRH    r9,[r0],#2              @ r9 = C = srcPtr[dstPitch]
     53        LDRH    r12,[r0],-r1            @ r12= D = srcPtr[dstPitch+2]
     54        LDRH    r14,[r0],#2             @ r14= B = srcPtr[2]
     55
     56        ORR     r8, r8, r8, LSL #16     @ r8 = b | g | r | b | g | r
     57        ORR     r9, r9, r9, LSL #16     @ r9 = b | g | r | b | g | r
     58        ORR     r12,r12,r12,LSL #16     @ r12= b | g | r | b | g | r
     59        ORR     r14,r14,r14,LSL #16     @ r14= b | g | r | b | g | r
     60        AND     r8, r8, r6              @ r8 = 0 | g | 0 | b | 0 | r
     61        AND     r9, r9, r6              @ r9 = 0 | g | 0 | b | 0 | r
     62        AND     r12,r12,r6              @ r12= 0 | g | 0 | b | 0 | r
     63        AND     r14,r14,r6              @ r14= 0 | g | 0 | b | 0 | r
     64        ADD     r8, r8, r9
     65        ADD     r8, r8, r12
     66        ADD     r8, r8, r14
     67        ADD     r8, r8, r7              @ r8 = summed pixels + rounding
     68        AND     r8, r6, r8, LSR #2      @ r8 = 0 | g | 0 | b | 0 | r
     69        ORR     r8, r8, r8, LSR #16     @ r8 = 0 | g | 0 | b | g | r
     70
     71        STRH    r8,[r2],#2              @ *dstPtr++
     72
     73        SUBS    r4,r4,#2
     74        BGT     width_loop
     75
     76        LDR     r4,[r13,#4*7]           @ reload r4 = width
     77        ADD     r2,r2,r3                @ dstPtr += dstPitch
     78        ADD     r0,r0,r1,LSL #1         @ srcPtr += 2*srcPitch
     79        SUB     r0,r0,r4,LSL #1         @ srcPtr -= 2*width
     80
     81        SUBS    r5,r5,#2
     82        BGE     height_loop
     83
     84end:
     85        LDMFD   r13!,{r4-r9,PC}