Path: blob/master/libmupen64plus/mupen64plus-video-glide64mk2/src/Glide64/TexConv.h
2 views
/*1* Glide64 - Glide video plugin for Nintendo 64 emulators.2* Copyright (c) 2002 Dave20013* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/1920//****************************************************************21//22// Glide64 - Glide Plugin for Nintendo 64 emulators23// Project started on December 29th, 200124//25// Authors:26// Dave2001, original author, founded the project in 2001, left it in 200227// Gugaman, joined the project in 2002, left it in 200228// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 200229// Hiroshi 'KoolSmoky' Morii, joined the project in 200730//31//****************************************************************32//33// To modify Glide64:34// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.35// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.36//37//****************************************************************3839static inline void texConv_ARGB1555_ARGB4444(uint8_t *src, uint8_t *dst, int size)40{41uint32_t *v3;42uint32_t *v4;43int v5;44uint32_t v6;45uint32_t v7;4647v3 = (uint32_t *)src;48v4 = (uint32_t *)dst;49v5 = size;50do51{52v6 = *v3;53++v3;54v7 = v6;55*v4 = ((v7 & 0x1E001E) >> 1) | ((v6 & 0x3C003C0) >> 2) | ((v6 & 0x78007800) >> 3) | ((v6 & 0x80008000) >> 3) | ((v6 & 0x80008000) >> 2) | ((v6 & 0x80008000) >> 1) | (v6 & 0x80008000);56++v4;57--v5;58}59while ( v5 );60}6162static inline void texConv_AI88_ARGB4444(uint8_t *src, uint8_t *dst, int size)63{64uint32_t *v3;65uint32_t *v4;66int v5;67uint32_t v6;68uint32_t v7;6970v3 = (uint32_t *)src;71v4 = (uint32_t *)dst;72v5 = size;73do74{75v6 = *v3;76++v3;77v7 = v6;78*v4 = (16 * (v7 & 0xF000F0) >> 8) | (v7 & 0xF000F0) | (16 * (v7 & 0xF000F0)) | (v6 & 0xF000F000);79++v4;80--v5;81}82while ( v5 );83}8485static inline void texConv_AI44_ARGB4444(uint8_t *src, uint8_t *dst, int size)86{87uint32_t *v3;88uint32_t *v4;89int v5;90uint32_t v6;91uint32_t *v7;9293v3 = (uint32_t *)src;94v4 = (uint32_t *)dst;95v5 = size;96do97{98v6 = *v3;99++v3;100*v4 = ((((uint16_t)v6 << 8) & 0xFF00 & 0xF00u) >> 8) | ((((uint16_t)v6 << 8) & 0xFF00 & 0xF00u) >> 4) | (uint16_t)(((uint16_t)v6 << 8) & 0xFF00) | (((v6 << 16) & 0xF000000) >> 8) | (((v6 << 16) & 0xF000000) >> 4) | ((v6 << 16) & 0xFF000000);101v7 = v4 + 1;102*v7 = (((v6 >> 8) & 0xF00) >> 8) | (((v6 >> 8) & 0xF00) >> 4) | ((v6 >> 8) & 0xFF00) | ((v6 & 0xF000000) >> 8) | ((v6 & 0xF000000) >> 4) | (v6 & 0xFF000000);103v4 = v7 + 1;104--v5;105}106while ( v5 );107}108109static inline void texConv_A8_ARGB4444(uint8_t *src, uint8_t *dst, int size)110{111uint32_t *v3;112uint32_t *v4;113int v5;114uint32_t v6;115uint32_t v7;116uint32_t *v8;117118v3 = (uint32_t *)src;119v4 = (uint32_t *)dst;120v5 = size;121do122{123v6 = *v3;124++v3;125v7 = v6;126*v4 = ((v6 & 0xF0) << 8 >> 12) | (uint8_t)(v6 & 0xF0) | (16 * (uint8_t)(v6 & 0xF0) & 0xFFFFFFF) | ((uint8_t)(v6 & 0xF0) << 8) | (16 * (uint16_t)(v6 & 0xF000) & 0xFFFFF) | (((uint16_t)(v6 & 0xF000) << 8) & 0xFFFFFF) | (((uint16_t)(v6 & 0xF000) << 12) & 0xFFFFFFF) | ((uint16_t)(v6 & 0xF000) << 16);127v8 = v4 + 1;128*v8 = ((v7 & 0xF00000) >> 20) | ((v7 & 0xF00000) >> 16) | ((v7 & 0xF00000) >> 12) | ((v7 & 0xF00000) >> 8) | ((v6 & 0xF0000000) >> 12) | ((v6 & 0xF0000000) >> 8) | ((v6 & 0xF0000000) >> 4) | (v6 & 0xF0000000);129v4 = v8 + 1;130--v5;131}132while ( v5 );133}134135void TexConv_ARGB1555_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)136{137int size = (width * height) >> 1; // Hiroshi Morii <[email protected]>138// 2 pixels are converted in one loop139// NOTE: width * height must be a multiple of 2140texConv_ARGB1555_ARGB4444(src, dst, size);141}142143void TexConv_AI88_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)144{145int size = (width * height) >> 1; // Hiroshi Morii <[email protected]>146// 2 pixels are converted in one loop147// NOTE: width * height must be a multiple of 2148texConv_AI88_ARGB4444(src, dst, size);149}150151void TexConv_AI44_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)152{153int size = (width * height) >> 2; // Hiroshi Morii <[email protected]>154// 4 pixels are converted in one loop155// NOTE: width * height must be a multiple of 4156texConv_AI44_ARGB4444(src, dst, size);157}158159void TexConv_A8_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)160{161int size = (width * height) >> 2; // Hiroshi Morii <[email protected]>162// 4 pixels are converted in one loop163// NOTE: width * height must be a multiple of 4164texConv_A8_ARGB4444(src, dst, size);165}166167168169