📄 convert565to555.cpp
字号:
/*****************************************************************************\
* Copyright (c), Future Entertainment World / Seoul, Republic of Korea *
* All Rights Reserved. *
* *
* This document contains proprietary and confidential information. No *
* parts of this document or the computer program it embodies may be in *
* any way copied, duplicated, reproduced, translated into a different *
* programming language, or distributed to any person, company, or *
* corporation without the prior written consent of Future Entertainment World *
\*****************************************************************************/
#include "stdafx.h"
#include <ddraw.h>
#include "dragon.h"
#include "Hong_Sprite.h"
#include "Convert565to555.h"
extern TPixelInfo _PixelInfo;
int convert565to555(Spr *sp)
{
int FFFFCheak=0;
int ConvertCount;
int i;
WORD *p;
int tt;
if( _PixelInfo.BitMaskR != 0x7C00 )
{
return 0;
}
if( sp->xl == 0 ) return -1;
if( sp->yl == 0 ) return -2;
if( sp->size == 0 ) return -3;
p = (WORD *)sp->img;
while(1)
{
AGAIN_:
tt = 0;
if(*p == 0xFFFF)
{
tt = *p;
FFFFCheak++;
p++;
if(FFFFCheak == sp->yl ) break;
}
if( tt == 0xffff ) goto AGAIN_;
p++; //捧疙祸 扒呈 顿扁
ConvertCount=*p; //祸 肮荐 眉农
p++; //眉农饶 器牢磐 捞悼
for(i=0; i < ConvertCount;i+=2)
{
*p=((*p)&0xFFC0)>>1 | ((*p)&0x1F);
p++;
}
if(*p == 0xFFFF)
{
FFFFCheak++;
p++;
if(FFFFCheak == sp->yl ) break;
}
}
return 0;
}
int convert565to555_LoadSprite(Spr *sp)
{
int FFFFCheak=0;
int ConvertCount;
int i;
WORD *p;
int tt;
if( _PixelInfo.BitMaskR != 0x7C00 )
{
return 0;
}
if( sp->xl == 0 ) return -1;
if( sp->yl == 0 ) return -2;
if( sp->size == 0 ) return -3;
p = (WORD *)sp->img;
while(1)
{
AGAIN_:
tt = 0;
if(*p == 0xFFFF)
{
tt = *p;
FFFFCheak++;
p++;
if(FFFFCheak == sp->yl ) break;
}
if( tt == 0xffff ) goto AGAIN_;
p++; //捧疙祸 扒呈 顿扁
ConvertCount=*p; //祸 肮荐 眉农
p++; //眉农饶 器牢磐 捞悼
for(i=0; i < ConvertCount;i+=2)
{
*p=((*p)&0xFFC0)>>1 | ((*p)&0x1F);
p++;
}
if(*p == 0xFFFF)
{
FFFFCheak++;
p++;
if(FFFFCheak == sp->yl ) break;
}
}
return 0;
}
void convert565to555RawTile( char *img )
{
int i;
WORD *p;
if( _PixelInfo.BitMaskR != 0x7C00 ) return;
p = (WORD *)img;
for( i = 0 ; i < TILE_SIZE * TILE_SIZE ; i ++)
{
*p=((*p)&0xFFC0)>>1 | ((*p)&0x1F);
p++;
}
}
// 胶橇扼捞飘 尝府 墨乔茄促.
// 林狼 荤亲篮 img 狼 皋葛府 墨乔甫 狼侥秦具 茄促.
void CopySprToSpr( Spr *target, const Spr *source )
{
target->xl = source->xl;
target->yl = source->yl;
target->ox = source->ox;
target->oy = source->oy;
target->size = source->size;
target->img = new char[target->size];
memcpy( target->img, source->img, target->size );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -