?? object.cpp
字號(hào):
/*****************************************************************************\
* 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 <stdio.h>
#include <io.h>
#include "object.h"
#include "map.h"
#include "Hong_Sub.h"
#include "convert565to555.h"
#include "Hong_Sprite.h"
#include "Hong_Light.h"
#include "Tool.h"
#include "Item.h"
///////////////////////////////////////////////////////////////////////////////
//
MAPOBJECTIMAGE MoImage[ MAX_MAPOBJECTIMAGE * 10];
WORD TotalMapObjectID;
WORD TotalMapObject;
MAPOBJECT Mo[ MAX_MAPOBJECT_];
MAPOBJECTIMAGE TempMoImage;
//////////// SoundUp lkh 眠啊 ////////////
extern void ObjectSoundPlay(void);
///////////////////////////////////////////////////////////////////////////////
//
int OldSoundNo, OldSoundFrame, OldSoundDealy;
extern void changemapobjectname( char *oldname, char *newname ); // map.cpp
extern void changesourcename( char *oldname, char *newname ); // map.cpp
int LoadMapObjectCSP( int id , LPMAPOBJECTIMAGE mi )
{
FILE *fp;
char filename[ FILENAME_MAX];
char tempmapobject[ FILENAME_MAX];
short ox, oy;
int i;
if( id == 1447 ) {
_asm nop;
}
if( mi->spr[0].img != NULL ) return 0;
changemapobjectname( MapName, tempmapobject );
int lev = id / 1000;
if( lev == 1 ) lev = 0;
for( i = 0 ; i < ITEM_FRAME_MAX_ ; i ++ )
{
#ifdef _MAPOBJECT_DIRECTORY_CHANGE_
{
if( i == 0 ) sprintf( filename, "./object/%d/%04d.csp", lev , id );
else sprintf( filename, "./object/%d/%04d%02d.csp", lev , id, i );
}
#else
{
if( i == 0 ) sprintf( filename, "./object/%s/%04d.csp", tempmapobject , id );
else sprintf( filename, "./object/%s/%04d%02d.csp", tempmapobject , id, i );
}
#endif
fp = Fopen( filename, "rb" );
if( fp == NULL ) return i;
fread( &mi->spr[i].xl, sizeof( short ), 1, fp);
fread( &mi->spr[i].yl, sizeof( short ), 1, fp);
// fseek( fp, 2, SEEK_CUR ); //&mi->spr[0].ox, sizeof( short ), 1, fp);
// fseek( fp, 2, SEEK_CUR ); // fread( &mi->spr[0].oy, sizeof( short ), 1, fp);
fread( &mi->spr[i].ox, sizeof( short ), 1, fp);
fread( &mi->spr[i].oy, sizeof( short ), 1, fp);
// mi->spr[0].ox = lpObjectImage->wOriginx;
// mi->spr[0].oy = lpObjectImage->wOriginy;
fread( &mi->spr[i].size, sizeof( unsigned int ), 1, fp);
mi->spr[i].img = NULL;
MemAlloc( mi->spr[i].img, mi->spr[i].size );
fread( mi->spr[i].img, mi->spr[i].size, 1, fp);
convert565to555( &mi->spr[i] );
fclose(fp);
}
return i;
sprintf( filename, "./object/%04d.org", id );
fp = Fopen( filename, "rb" );
if( fp )
{
fseek( fp, 4, SEEK_SET );
fread( &ox, 2,1, fp );
fread( &oy, 2,1, fp );
mi->spr[0].ox = ox;
mi->spr[0].oy = oy;
fclose(fp);
}
}
/*
ftp://ftp1.bora.net/pub/sw/game_sw/e2soft/DragonRajaBeta_001216.zip
ftp://ftp1.bora.net/pub/sw/game_sw/e2soft/DragonRajaBeta_001216_2.exe
int LoadMapObjectCSP( int id , LPMAPOBJECTIMAGE mi )
{
FILE *fp;
char filename[ FILENAME_MAX];
char tempmapobject[ FILENAME_MAX];
short ox, oy;
int i;
if( mi->spr[0].img != NULL ) return 0;
changemapobjectname( MapName, tempmapobject );
int lev = id / 1000;
if( lev == 1 ) lev = 0;
for( i = 0 ; i < ITEM_FRAME_MAX_ ; i ++)
{
#ifdef _MAPOBJECT_DIRECTORY_CHANGE_
{
if( i == 0 ) sprintf( filename, "./object/%d/%04d.csp", lev , id );
else sprintf( filename, "./object/%d/%04d%02d.csp", lev , id, i );
}
#else
{
if( i == 0 ) sprintf( filename, "./object/%s/%04d.csp", tempmapobject , id );
else sprintf( filename, "./object/%s/%04d%02d.csp", tempmapobject , id, i );
}
#endif
fp = Fopen( filename, "rb" );
if( fp == NULL ) return i;
fread( &mi->spr[i].xl, sizeof( short ), 1, fp);
fread( &mi->spr[i].yl, sizeof( short ), 1, fp);
// fseek( fp, 2, SEEK_CUR ); //&mi->spr[0].ox, sizeof( short ), 1, fp);
// fseek( fp, 2, SEEK_CUR ); // fread( &mi->spr[0].oy, sizeof( short ), 1, fp);
fread( &mi->spr[i].ox, sizeof( short ), 1, fp);
fread( &mi->spr[i].oy, sizeof( short ), 1, fp);
// mi->spr[0].ox = lpObjectImage->wOriginx;
// mi->spr[0].oy = lpObjectImage->wOriginy;
fread( &mi->spr[i].size, sizeof( unsigned int ), 1, fp);
mi->spr[i].img = NULL;
MemAlloc( mi->spr[i].img, mi->spr[i].size );
fread( mi->spr[i].img, mi->spr[i].size, 1, fp);
convert565to555( &mi->spr[i] );
fclose(fp);
}
return i;
sprintf( filename, "./object/%04d.org", id );
fp = Fopen( filename, "rb" );
if( fp )
{
fseek( fp, 4, SEEK_SET );
fread( &ox, 2,1, fp );
fread( &oy, 2,1, fp );
mi->spr[0].ox = ox;
mi->spr[0].oy = oy;
fclose(fp);
}
}
*/
void DisplayMapObject( LPMAPOBJECT mo )
{
int mx = mo->x + mo->offx - Mapx;
int my = mo->y + mo->offy - Mapy;
int fspflag = 0;
Spr *sp, *fsp;
sp = &MoImage[ mo->id-1].spr[ mo->curframe];
if( MapNumber == 2 )
{
if( 4040 <= mo->id && mo->id <= 4043 ) { PutCompressedImageWaveTile( mx, my, sp ); goto END_; }
if( 4045 == mo->id ) { PutCompressedImageWaveTile( mx, my, sp ); goto END_; }
}
fsp = &MoImage[ mo->id-1].spr[0];
// 020305 YGI
// 叼棄飄 拳擱闌 嘛闌 鞘夸啊 絕促.
if( !GetSysInfo( SI_NOT_CONNECT_MODE ) && mo->objectoritem == ITEMTYPE_COLOSSUS_STONE ) goto END_;
switch( mo->animationType )
{
case OBJECTANI_NO :
case OBJECTANI_RETURNLOOP :
case OBJECTANI_LOOP :
case OBJECTANI_TOGGLE_ANI : switch( mo->attr1 & 0x0003)
{
case OBJECTSPRITE_NORMAL : PutCompressedImage( mx, my, sp ); break;
case OBJECTSPRITE_TRANS : PutCompressedImageFX( mx, my, sp, mo->attr1 >>3, 1 ); break;
case OBJECTSPRITE_ALPHA :
if( mo->light && DayLightControl >= 31 )
{
}
else
{
PutCompressedImageFX( mx, my, sp, mo->attr1 >>3, 2 ); break;
}
}
break;
case OBJECTANI_1_RETURNLOOP :
case OBJECTANI_1_LOOP : PutCompressedImage( mx, my, fsp );
fspflag = 1;
// Light甫 啊瘤絆 樂促擱..
if( mo->light && DayLightControl >= 31 )
{
}
else
{
switch( mo->attr1 & 0x0003 )
{
case OBJECTSPRITE_NORMAL : PutCompressedImage( mx, my, sp ); break;
case OBJECTSPRITE_TRANS : PutCompressedImageFX( mx, my, sp, mo->attr1 >>3, 1 ); break;
case OBJECTSPRITE_ALPHA : PutCompressedImageFX( mx, my, sp, mo->attr1 >>3, 2 ); break;
}
}
break;
}
#ifdef _DEBUG
if( mo->attr2 && GetSysInfo( SI_GAME_MAKE_MODE ) )
{
// Box_( mx - fsp->ox, my - fsp->oy, fsp->xl, fsp->yl );
Line( mo->dx0[0] + mo->x , mo->dy0[0] + mo->y , mo->dx1[1] + mo->x , mo->dy1[1] + mo->y , RGB16( 0x00,0xff,0x00 ));
}
#endif
END_:
int i,j;
int tsx, tsy, tex, tey;
int sx = mx - sp->ox + Mapx;
int sy = my - sp->oy + Mapy;
int ex = sx+sp->xl + TILE_SIZE - 1;
int ey = sy+sp->yl + TILE_SIZE - 1;
if( fspflag )
{
tsx = mx - fsp->ox + Mapx;
tsy = my - fsp->oy + Mapy;
tex = sx+fsp->xl + TILE_SIZE - 1;
tey = sy+fsp->yl + TILE_SIZE - 1;
if( tsx < sx ) sx = tsx; if( tsy < sy ) sy = tsy;
if( tex > ex ) ex = tex; if( tey > ey ) ey = tey;
}
ex += (( ex - sx )/2);
sx /= TILE_SIZE;
sy /= TILE_SIZE;
ex /= TILE_SIZE;
ey /= TILE_SIZE;
my += Mapy;
if( sx < 0 ) sx = 0;
if( sy < 0 ) sy = 0;
if( ex >= g_Map.file.wWidth ) ex = g_Map.file.wWidth;
if( ey >= g_Map.file.wHeight ) ey = g_Map.file.wHeight;
for( i = sx ; i < ex ; i ++ )
for( j = sy ; j < ey ; j ++ )
{
int front = TileMap[ i][ j].front;
if( front )
if( TileMap[ i][ j].frontoffset * TILE_SIZE >= (DWORD )mo->y )
{
if( Sou[ front].xl == -1 ) PutTile( i*TILE_SIZE - Mapx, j*TILE_SIZE - Mapy, Sou[front].img, g_DestBackBuf );
else PutCompressedImage( i*TILE_SIZE - Mapx, j*TILE_SIZE - Mapy, &Sou[ front] );
}
}
}
/*
if( mo->attr2 )
{
if( Determinant( mo->x + mo->dx0[0], mo->y + mo->dy0[0],
mo->x + mo->dx1[0], mo->y + mo->dy1[0], i * TILE_SIZE, TileMap[ i][ j].frontoffset * TILE_SIZE ) > 0 )
{
if( Sou[ front].xl == -1 ) PutTile( i*TILE_SIZE - Mapx, j*TILE_SIZE - Mapy, Sou[front].img, g_DestBackBuf );
else PutCompressedImage( i*TILE_SIZE - Mapx, j*TILE_SIZE - Mapy, &Sou[ front] );
}
}
else
{
if( TileMap[ i][ j].frontoffset * TILE_SIZE >= mo->y )
{
if( Sou[ front].xl == -1 ) PutTile( i*TILE_SIZE - Mapx, j*TILE_SIZE - Mapy, Sou[front].img, g_DestBackBuf );
else PutCompressedImage( i*TILE_SIZE - Mapx, j*TILE_SIZE - Mapy, &Sou[ front] );
}
}
*/
void DisplayMapObjectAfter( LPMAPOBJECT mo, int selected )
{
int mx = mo->x + mo->offx - Mapx;
int my = mo->y + mo->offy - Mapy;
Spr *sp, *fsp;
fsp = &MoImage[ mo->id-1].spr[0];
sp = &MoImage[ mo->id-1].spr[ mo->curframe];
if( selected )
{
PutCompressedImageBlendRGB( mx, my, sp, ReturnBlendRGB( 0xff,0,0 ));
}
int x = mo->x;
int y = mo->y;
Line( x-5, y, x+5, y, RGB16( 0xff, 0x1f, 0x1f));
Line( x, y-5, x, y+5, RGB16( 0xff, 0x1f, 0x1f));
if( MapNumber == 2 ) // firedun1....
{
if( (4040 <= mo->id && mo->id <= 4043) || mo->id == 4045 ) { return; }
}
switch( mo->animationType )
{
case OBJECTANI_NO :
case OBJECTANI_RETURNLOOP :
case OBJECTANI_LOOP :
case OBJECTANI_TOGGLE_ANI : switch( mo->attr1 )
{
case OBJECTSPRITE_NORMAL : break;
case OBJECTSPRITE_TRANS : break;
case OBJECTSPRITE_ALPHA : break;
}
break;
case OBJECTANI_1_RETURNLOOP :
case OBJECTANI_1_LOOP : /*PutCompressedImage( mx, my, fsp );*/
switch( mo->attr1 )
{
case OBJECTSPRITE_NORMAL : /*PutCompressedImage( mx, my, sp ); */break;
case OBJECTSPRITE_TRANS : /*PutCompressedImageFX( mx, my, sp, 20, 1 ); */break;
case OBJECTSPRITE_ALPHA : /*PutCompressedImageFX( mx, my, sp, 20, 2 ); */break;
}
break;
}
if( mo->attr2 )
{
Line(mo->dx0[ mo->curframe] + mo->x , mo->dy0[ mo->curframe] + mo->y,
mo->dx1[ mo->curframe] + mo->x , mo->dy1[ mo->curframe] + mo->y, RGB16( 0x00,0xff,0x00 ));
}
}
void CheckMapObject( LPMAPOBJECT mo )
{
if( --mo->delay < 0 ) { mo->delay = 3; }
else return;
int totalframe = MoImage[ mo->id-1].nFrameCount;
switch( mo->animationType )
{
case OBJECTANI_NO : if( mo->curframe < 0 || mo->curframe >= totalframe )
{
mo->curframe = 0;
}
break;
case OBJECTANI_RETURNLOOP : if( mo->anidir )
{
mo->curframe ++;
if( mo->curframe >= totalframe ) { mo->anidir = !mo->anidir; mo->curframe = totalframe-1; }
}
else
{
mo->curframe --;
if( mo->curframe < 0 ) { mo->anidir = !mo->anidir; mo->curframe = 0; }
}
break;
case OBJECTANI_LOOP : mo->curframe ++;
if( mo->curframe >= totalframe ) { mo->curframe = 0; }
break;
case OBJECTANI_TOGGLE_ANI : mo->curframe = 0;
break;
case OBJECTANI_1_RETURNLOOP : if( mo->anidir )
{
mo->curframe ++;
if( mo->curframe >= totalframe ) { mo->anidir = !mo->anidir; mo->curframe = totalframe-1; }
}
else
{
mo->curframe --;
if( mo->curframe < 1 ) { mo->anidir = !mo->anidir; mo->curframe = 1; }
}
break;
case OBJECTANI_1_LOOP : mo->curframe ++;
if( mo->curframe >= totalframe ) { mo->curframe = 1; }
break;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
int TempMoImageID[ 2000];
#include "menuset.h" // 021030 YGI
////////////////////// SoundUp lkh 薦瀝 ///////////////////////
// newtoi == true 撈擱 葷款靛何盒撈甸絹埃巴闌 富茄促.
int LoadTOI( char *filename )
{
FILE *fp = 0; // 021030 YGI
char szFilePath[ FILENAME_MAX];
char temptoiname[ FILENAME_MAX];
WORD i,j;
int no;
int count = 0;
int ox, oy;
short id;
MAPOBJECT_old moold;
MAPOBJECT mo;
bool newtoi;
CharUpper( filename );
changemapobjectname( filename, temptoiname );
if( g_Menu_Variable.m_pEventObjcet )
{
sprintf( szFilePath, "./object/%s/%s", temptoiname, g_Menu_Variable.m_pEventObjcet->object_toi );
fp = Fopen( szFilePath, "rb" );
}
if( !fp )
{
sprintf( szFilePath, "./object/%s/%s.toi2", temptoiname, filename );
fp = Fopen( szFilePath, "rb" );
}
if( fp )
{
fread ( &TotalMapObject, 2,1, fp );
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -