📄 hong_light.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 <Math.h>
#include <stdio.h>
#include "Dragon.h"
#include "GameProc.h"
#include "Char.h"
#include "Hong_Sprite.h"
#include "Map.h"
#include "Hangul.h"
#include "Hong_Sub.h"
#include "Tool.h"
#include "MouseCursor.h"
#include "Effect.h"
#include "Hong_Light.h"
extern CHARACTERLIST g_CharacterList;
int LightT[LIGHT_ROW][LIGHT_COL] = {0,};
int LightTableX = 0;
int LightTableY = 0;
int DayLightControl = 31;
char *BrightSprBuf[ 21][2] = {0,};
int LightCount = 0;
LIGHT Light[ LIGHT_MAX_]= {0,};
LIGHT g_OutLight[ MAX_OUTLIGHT_]= {0,};
char BrightBuf[ (GAME_SCREEN_XSIZE/2) * (GAME_SCREEN_YSIZE/2) ]= {0};
WORD rgbTable[32 * 65536] = {0,};
void MakergbTable( void )
{
WORD c;
BYTE j;
WORD i;
int t;
if( _PixelInfo.BitMaskR == 0x7C00 ) // 555
{
for( t = 0, i = 0 ; t < 65536 ; t++, i ++)
{
for( j = 0 ; j < 32 ; j ++)
{
_asm {
xor eax,eax;
mov ax,i;
ror eax,10;
shl ax,11;
rol eax,5;
shl ax,6;
rol eax,5;
xor ebx, ebx;
mov bl, j;
imul eax,ebx;
shr eax,5;
and eax,0x03e0fc1f;
ror eax,5;
shr ax,6;
ror eax,5;
shr ax,11;
rol eax,10;
mov c,ax;
}
rgbTable[j * 65536 + i] = c;
}
}
}
else // 565
{
for( t = 0, i = 0 ; t < 65536 ; t++, i ++)
{
for( j = 0 ; j < 32 ; j ++)
{
_asm {
xor eax,eax;
mov ax,i;
ror eax,11;
shl ax,10;
rol eax,6;
shl ax,5;
rol eax,5;
xor ebx, ebx;
mov bl, j;
imul eax,ebx;
shr eax,5;
and eax,0x03e0fc1f;
ror eax,5;
shr ax,5;
ror eax,6;
shr ax,10;
rol eax,11;
mov c,ax;
}
rgbTable[j * 65536 + i] = c;
}
}
}
}
void PutMapBright( LPVOID dest, LPVOID alpha)
{
DWORD k = 1280,j;
LPVOID Dtmp = (LPVOID)(dest);
j = SCREEN_WIDTH;
_asm{
push es;
push ds;
pop es;
xor ebx,ebx;
xor eax,eax;
xor ecx,ecx;
mov cx, GAME_SCREEN_YSIZE
mov esi, alpha
loop_1:
mov edi,Dtmp;
push cx
xor eax,eax;
mov cx,SCREEN_WIDTH; //load data num
loop_alpha:
xor eax,eax;
mov eax,[edi];
shr eax,5;
mov bl, byte ptr[ esi];
inc esi;
imul eax,ebx;
mov [edi],eax;
add edi,4;
loop loop_alpha;
pop cx
dec cx
jz exit_1;
mov eax,Dtmp;
add eax,k;
mov Dtmp,eax;
jmp loop_1;
exit_1:
pop es;
};
}
void PutMapBright2( LPVOID dest, LPVOID alpha)
{
DWORD k = (GAME_SCREEN_XSIZE*2),j;
LPVOID Dtmp = (LPVOID)(dest);
j = SCREEN_WIDTH;
_asm{
push es;
push ds;
pop es;
xor ebx,ebx;
xor eax,eax;
xor ecx,ecx;
mov cx, (GAME_SCREEN_YSIZE/2)
mov esi, alpha
loop_1:
mov edi,Dtmp;
push cx
mov cx,(GAME_SCREEN_XSIZE/2); //load data num
loop_alpha:
movzx dx, byte ptr[ esi];
cmp dl, 31
jz skip_1;
shl edx, 16
movzx eax, word ptr [edi+2];
add edx, eax;
shl edx, 1;
mov ax, word ptr [offset rgbTable + edx ];
shl eax, 16
movzx dx, byte ptr[ esi];
shl edx, 16
mov bx,[edi];
add edx, ebx;
shl edx, 1;
mov ax, word ptr [offset rgbTable + edx ];
mov [edi],eax;
skip_1:
add edi,4;
inc esi
dec cx;
jnz loop_alpha;
//--------------
sub esi, (GAME_SCREEN_XSIZE/2) // 1 扼牢狼 单捞鸥甫 啊瘤绊 滴锅嘛阑巴捞扁锭巩.
mov edx,Dtmp;
add edx,k;
mov Dtmp,edx;
mov edi,Dtmp;
mov cx,(GAME_SCREEN_XSIZE/2); //load data num
loop_alpha2:
movzx dx, byte ptr[ esi];
cmp dl, 31
jz skip_2;
xor eax,eax;
shl edx, 16
mov ax,[edi+2];
add edx, eax;
shl edx, 1;
mov ax, word ptr [offset rgbTable + edx ];
shl eax, 16
movzx dx, byte ptr[ esi];
shl edx, 16
mov bx,[edi];
add edx, ebx;
shl edx, 1;
mov ax, word ptr [offset rgbTable + edx ];
mov [edi],eax;
skip_2:
add edi,4;
inc esi
dec cx
jnz loop_alpha2;
//------------------
pop cx
dec cx
jz exit_1;
mov edx,Dtmp;
add edx,k;
mov Dtmp,edx;
jmp loop_1;
exit_1:
pop es;
};
}
void LoadBrightDataSub( char *filename, char **buf0, char **buf1 )
{
FILE *fp;
DWORD xl, yl;
BYTE *p0, *p1;
fp = Fopen( filename, "rb" );
fseek(fp, 1, SEEK_SET );
fread( &xl, sizeof( DWORD ), 1, fp );
fread( &yl, sizeof( DWORD ), 1, fp );
MemAlloc(*buf0, (xl * yl) + 8 );
MemAlloc(*buf1, (xl * yl) + 8 );
*(DWORD *)(*buf0) = xl;
*(DWORD *)(*buf0 + 4 ) = yl;
fseek( fp, 8, SEEK_CUR );
fread( *buf0 + 8, xl * yl , 1, fp );
memcpy( *buf1, *buf0, xl * yl + 8 );
p0 = (BYTE *)*buf0;
p1 = (BYTE *)*buf1;
for( DWORD i = 8 ; i < xl * yl; i ++)
{
*( p0 + i ) = *( p0 + i ) / 8;
*( p1 + i ) = *( p1 + i ) / 9;
}
fclose(fp);
}
void LoadBrightData( void )
{
char temp[ FILENAME_MAX];
for( int i = 0 ; i < 21 ; i ++)
{
sprintf( temp, "./data/lig%03d.spr", i );
LoadBrightDataSub( temp, &BrightSprBuf[ i][0], &BrightSprBuf[ i][1] );
}
}
void PutBright( int x, int y, char *light )
{
int xl, yl;
int lx, rx, ty, by;
char *sou;
int i,j;
char *p;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -