Initial commit
This commit is contained in:
1915
engines/ags/plugins/ags_pal_render/ags_pal_render.cpp
Normal file
1915
engines/ags/plugins/ags_pal_render/ags_pal_render.cpp
Normal file
File diff suppressed because it is too large
Load Diff
279
engines/ags/plugins/ags_pal_render/ags_pal_render.h
Normal file
279
engines/ags/plugins/ags_pal_render/ags_pal_render.h
Normal file
@@ -0,0 +1,279 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* of the License, or(at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AGS_PLUGINS_AGS_PAL_RENDER_AGS_PAL_RENDER_H
|
||||
#define AGS_PLUGINS_AGS_PAL_RENDER_AGS_PAL_RENDER_H
|
||||
|
||||
#include "ags/plugins/ags_plugin.h"
|
||||
#include "ags/plugins/serializer.h"
|
||||
|
||||
namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSPalRender {
|
||||
|
||||
class AGSPalRender : public PluginBase {
|
||||
SCRIPT_HASH(AGSPalRender)
|
||||
private:
|
||||
void syncGame(Serializer &s);
|
||||
public:
|
||||
AGSPalRender() : PluginBase() {}
|
||||
virtual ~AGSPalRender() {}
|
||||
|
||||
const char *AGS_GetPluginName() override;
|
||||
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
|
||||
void AGS_EngineShutdown() override;
|
||||
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
|
||||
|
||||
/**
|
||||
* @defgroup PALInternal
|
||||
* @{
|
||||
*/
|
||||
|
||||
void LoadCLUT(ScriptMethodParams ¶ms);
|
||||
void CycleRemap(ScriptMethodParams ¶ms);
|
||||
void GetColor565(ScriptMethodParams ¶ms);
|
||||
void GetLuminosityFromPalette(ScriptMethodParams ¶ms);
|
||||
void AGSFastSin(ScriptMethodParams ¶ms);
|
||||
void AGSFastCos(ScriptMethodParams ¶ms);
|
||||
void AGSFastRoot(ScriptMethodParams ¶ms);
|
||||
void GetRemappedSlot(ScriptMethodParams ¶ms);
|
||||
void ResetRemapping(ScriptMethodParams ¶ms);
|
||||
void GetModifiedBackgroundImage(ScriptMethodParams ¶ms);
|
||||
void WriteObjectivePalette(ScriptMethodParams ¶ms);
|
||||
void ReadObjectivePaletteR(ScriptMethodParams ¶ms);
|
||||
void ReadObjectivePaletteB(ScriptMethodParams ¶ms);
|
||||
void ReadObjectivePaletteG(ScriptMethodParams ¶ms);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @defgroup LensDistort
|
||||
* @{
|
||||
*/
|
||||
|
||||
void SetLensPos(ScriptMethodParams ¶ms);
|
||||
void GetLensX(ScriptMethodParams ¶ms);
|
||||
void GetLensY(ScriptMethodParams ¶ms);
|
||||
void SetLensDrawn(ScriptMethodParams ¶ms);
|
||||
void GetLensDrawn(ScriptMethodParams ¶ms);
|
||||
void SetLensOffsetClamp(ScriptMethodParams ¶ms);
|
||||
void GetLensOffsetClamp(ScriptMethodParams ¶ms);
|
||||
void GetLensLevel(ScriptMethodParams ¶ms);
|
||||
void SetLensLevel(ScriptMethodParams ¶ms);
|
||||
void LensInitialize(ScriptMethodParams ¶ms);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @defgroup Translucence
|
||||
* @{
|
||||
*/
|
||||
|
||||
void CreateTranslucentOverlay(ScriptMethodParams ¶ms);
|
||||
void DeleteTranslucentOverlay(ScriptMethodParams ¶ms);
|
||||
void MoveTranslucentOverlay(ScriptMethodParams ¶ms);
|
||||
void GetTranslucentOverlayX(ScriptMethodParams ¶ms);
|
||||
void GetTranslucentOverlayY(ScriptMethodParams ¶ms);
|
||||
void GetTranslucentOverlaySprite(ScriptMethodParams ¶ms);
|
||||
void GetTranslucentOverlayLevel(ScriptMethodParams ¶ms);
|
||||
void GetTranslucentOverlayEnabled(ScriptMethodParams ¶ms);
|
||||
void GetTranslucentOverlayAlpha(ScriptMethodParams ¶ms);
|
||||
void SetTranslucentOverlayAlpha(ScriptMethodParams ¶ms);
|
||||
void SetTranslucentOverlayEnabled(ScriptMethodParams ¶ms);
|
||||
void DrawTransSprite(ScriptMethodParams ¶ms);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @defgroup Starfield
|
||||
* @{
|
||||
*/
|
||||
|
||||
void GetStarfieldOverscan(ScriptMethodParams ¶ms);
|
||||
void SetStarfieldOverscan(ScriptMethodParams ¶ms);
|
||||
void GetStarfieldOriginX(ScriptMethodParams ¶ms);
|
||||
void GetStarfieldOriginY(ScriptMethodParams ¶ms);
|
||||
void SetStarfieldDepthMultiplier(ScriptMethodParams ¶ms);
|
||||
void GetStarfieldDepthMultiplier(ScriptMethodParams ¶ms);
|
||||
void GetStarfieldMaxStars(ScriptMethodParams ¶ms);
|
||||
void SetStarSpriteScaleBoost(ScriptMethodParams ¶ms);
|
||||
void GetStarSpriteScaleBoost(ScriptMethodParams ¶ms);
|
||||
void SetStarMaxRadius(ScriptMethodParams ¶ms);
|
||||
void GetStarMaxRadius(ScriptMethodParams ¶ms);
|
||||
void GetStarX(ScriptMethodParams ¶ms);
|
||||
void GetStarY(ScriptMethodParams ¶ms);
|
||||
void GetStarZ(ScriptMethodParams ¶ms);
|
||||
void SetStarPosition(ScriptMethodParams ¶ms);
|
||||
void RotateStar(ScriptMethodParams ¶ms);
|
||||
void SetStarColor(ScriptMethodParams ¶ms);
|
||||
void GetStarColor(ScriptMethodParams ¶ms);
|
||||
void SetStarSprite(ScriptMethodParams ¶ms);
|
||||
void GetStarSprite(ScriptMethodParams ¶ms);
|
||||
void SetStarSpriteRange(ScriptMethodParams ¶ms);
|
||||
void InitializeStars(ScriptMethodParams ¶ms);
|
||||
void IterateStars(ScriptMethodParams ¶ms);
|
||||
void DrawStars(ScriptMethodParams ¶ms);
|
||||
void SetStarsOriginPoint(ScriptMethodParams ¶ms);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @defgroup Plasma
|
||||
* @{
|
||||
*/
|
||||
|
||||
void DoFire(ScriptMethodParams ¶ms);
|
||||
void SetPlasmaType(ScriptMethodParams ¶ms);
|
||||
void ResetPlasmaSettings(ScriptMethodParams ¶ms);
|
||||
void DrawPlasma(ScriptMethodParams ¶ms);
|
||||
void SetPlasmaRootType(ScriptMethodParams ¶ms);
|
||||
void GetPlasmaRootType(ScriptMethodParams ¶ms);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @defgroup Reflections
|
||||
* @{
|
||||
*/
|
||||
|
||||
void SetReflections(ScriptMethodParams ¶ms);
|
||||
void IsReflectionsOn(ScriptMethodParams ¶ms);
|
||||
void SetCharacterReflected(ScriptMethodParams ¶ms);
|
||||
void GetCharacterReflected(ScriptMethodParams ¶ms);
|
||||
void SetObjectReflected(ScriptMethodParams ¶ms);
|
||||
void GetObjectReflected(ScriptMethodParams ¶ms);
|
||||
void ReplaceCharacterReflectionView(ScriptMethodParams ¶ms);
|
||||
void SetObjectReflectionIgnoreScaling(ScriptMethodParams ¶ms);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @defgroup raycast
|
||||
* @{
|
||||
*/
|
||||
|
||||
void MakeTextures(ScriptMethodParams ¶ms);
|
||||
void Raycast_Render(ScriptMethodParams ¶ms);
|
||||
void MoveForward(ScriptMethodParams ¶ms);
|
||||
void MoveBackward(ScriptMethodParams ¶ms);
|
||||
void RotateLeft(ScriptMethodParams ¶ms);
|
||||
void RotateRight(ScriptMethodParams ¶ms);
|
||||
void Init_Raycaster(ScriptMethodParams ¶ms);
|
||||
void QuitCleanup(ScriptMethodParams ¶ms);
|
||||
void LoadMap(ScriptMethodParams ¶ms);
|
||||
void Ray_InitSprite(ScriptMethodParams ¶ms);
|
||||
void Ray_SetPlayerPosition(ScriptMethodParams ¶ms);
|
||||
void Ray_GetPlayerX(ScriptMethodParams ¶ms);
|
||||
void Ray_GetPlayerY(ScriptMethodParams ¶ms);
|
||||
void Ray_GetPlayerAngle(ScriptMethodParams ¶ms);
|
||||
void Ray_SetPlayerAngle(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_GetWallHotspot(ScriptMethodParams ¶ms);
|
||||
void Ray_GetWallTexture(ScriptMethodParams ¶ms);
|
||||
void Ray_GetWallSolid(ScriptMethodParams ¶ms);
|
||||
void Ray_GetWallIgnoreLighting(ScriptMethodParams ¶ms);
|
||||
void Ray_GetWallAlpha(ScriptMethodParams ¶ms);
|
||||
void Ray_GetWallBlendType(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_SelectTile(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_GetHotspotAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetObjectAt(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_DrawTile(ScriptMethodParams ¶ms);
|
||||
void Ray_DrawOntoTile(ScriptMethodParams ¶ms);
|
||||
void Ray_SetNoClip(ScriptMethodParams ¶ms);
|
||||
void Ray_GetNoClip(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteInteractObj(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteInteractObj(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpritePosition(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteVertOffset(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteVertOffset(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteX(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteY(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_SetWallHotspot(ScriptMethodParams ¶ms);
|
||||
void Ray_SetWallTextures(ScriptMethodParams ¶ms);
|
||||
void Ray_SetWallSolid(ScriptMethodParams ¶ms);
|
||||
void Ray_SetWallIgnoreLighting(ScriptMethodParams ¶ms);
|
||||
void Ray_SetWallAlpha(ScriptMethodParams ¶ms);
|
||||
void Ray_SetWallBlendType(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_GetMoveSpeed(ScriptMethodParams ¶ms);
|
||||
void Ray_SetMoveSpeed(ScriptMethodParams ¶ms);
|
||||
void Ray_GetRotSpeed(ScriptMethodParams ¶ms);
|
||||
void Ray_SetRotSpeed(ScriptMethodParams ¶ms);
|
||||
void Ray_GetWallAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetLightAt(ScriptMethodParams ¶ms);
|
||||
void Ray_SetLightAt(ScriptMethodParams ¶ms);
|
||||
void Ray_SetWallAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetPlaneY(ScriptMethodParams ¶ms);
|
||||
void Ray_SetPlaneY(ScriptMethodParams ¶ms);
|
||||
void Ray_GetDistanceAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteAngle(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteAngle(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteView(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteView(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteFrame(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteFrame(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_GetTileX_At(ScriptMethodParams ¶ms);
|
||||
void Ray_GetTileY_At(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_SetSkyBox(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSkyBox(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_SetAmbientLight(ScriptMethodParams ¶ms);
|
||||
void Ray_GetAmbientLight(ScriptMethodParams ¶ms);
|
||||
void Ray_SetAmbientColor(ScriptMethodParams ¶ms);
|
||||
|
||||
|
||||
void Ray_GetSpriteAlpha(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteAlpha(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpritePic(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpritePic(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_GetSpriteScaleX(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteScaleX(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteScaleY(ScriptMethodParams ¶ms);
|
||||
void Ray_SetSpriteScaleY(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_SetSpriteBlendType(ScriptMethodParams ¶ms);
|
||||
void Ray_GetSpriteBlendType(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_SetFloorAt(ScriptMethodParams ¶ms);
|
||||
void Ray_SetCeilingAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetCeilingAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetFloorAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetLightingAt(ScriptMethodParams ¶ms);
|
||||
void Ray_SetLightingAt(ScriptMethodParams ¶ms);
|
||||
void Ray_GetAmbientWeight(ScriptMethodParams ¶ms);
|
||||
|
||||
void Ray_HasSeenTile(ScriptMethodParams ¶ms);
|
||||
|
||||
/**@}*/
|
||||
};
|
||||
|
||||
} // namespace AGSPalRender
|
||||
} // namespace Plugins
|
||||
} // namespace AGS3
|
||||
|
||||
#endif
|
||||
187
engines/ags/plugins/ags_pal_render/pal_render.h
Normal file
187
engines/ags/plugins/ags_pal_render/pal_render.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* of the License, or(at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AGS_PLUGINS_AGS_PAL_RENDER_PAL_RENDER_H
|
||||
#define AGS_PLUGINS_AGS_PAL_RENDER_PAL_RENDER_H
|
||||
|
||||
#include "ags/lib/allegro.h"
|
||||
#include "ags/plugins/ags_plugin.h"
|
||||
#include "ags/plugins/plugin_base.h"
|
||||
#include "common/algorithm.h"
|
||||
|
||||
namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSPalRender {
|
||||
|
||||
struct PALSTRUCT {
|
||||
byte r;
|
||||
byte b;
|
||||
byte g;
|
||||
};
|
||||
|
||||
extern IAGSEngine *engine;
|
||||
extern unsigned char clut[65536];
|
||||
extern unsigned char cycle_remap [256];
|
||||
extern const int alphamultiply [4096];
|
||||
extern PALSTRUCT objectivepal[256];
|
||||
|
||||
// this class exists solely to take advantage of g++'s
|
||||
// -fvisibility-inlines-hidden option, so that these
|
||||
// methods can be inlined without any trace or complaint
|
||||
class Mix {
|
||||
public:
|
||||
//unsigned char MixColorAlpha (unsigned char fg,unsigned char bg,unsigned char alpha);
|
||||
//unsigned char MixColorAdditive (unsigned char fg,unsigned char bg,unsigned char alpha);
|
||||
static unsigned char MixColorAlpha(unsigned char fg, unsigned char bg, unsigned char alpha, int use_objpal = 0) {
|
||||
unsigned char rfg = cycle_remap[fg]; //Automatic remapping of palette slots.
|
||||
//unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere.
|
||||
AGSColor *palette = engine->GetPalette();
|
||||
int i = 0;
|
||||
//int out_r = (palette[fg].r>>1) * alpha + (palette[bg].r>>1) * (255 - alpha);
|
||||
//int out_g = palette[fg].g * alpha + palette[bg].g * (255 - alpha);
|
||||
//int out_b = (palette[fg].b>>1) * alpha + (palette[bg].b>>1) * (255 - alpha);
|
||||
int out_r, out_g, out_b;
|
||||
if (use_objpal == 0) {
|
||||
out_r = (objectivepal[rfg].r >> 1) *alpha + (palette[bg].r >> 1) *(255 - alpha);
|
||||
out_g = objectivepal[rfg].g * alpha + palette[bg].g * (255 - alpha);
|
||||
out_b = (objectivepal[rfg].b >> 1) *alpha + (palette[bg].b >> 1) *(255 - alpha);
|
||||
} else {
|
||||
out_r = (objectivepal[rfg].r >> 1) *alpha + (objectivepal[bg].r >> 1) *(255 - alpha);
|
||||
out_g = objectivepal[rfg].g * alpha + objectivepal[bg].g * (255 - alpha);
|
||||
out_b = (objectivepal[rfg].b >> 1) *alpha + (objectivepal[bg].b >> 1) *(255 - alpha);
|
||||
}
|
||||
//char ralpha = MAX(0,MIN(63,alpha>>2));
|
||||
//unsigned char invralpha = 64-ralpha;
|
||||
//if (ralpha > alpha) engine->AbortGame ("oops");
|
||||
//int out_r = alphamultiply[((palette[fg].r>>1)<<6) +ralpha] + alphamultiply[((palette[bg].r>>1)<<6) +(invralpha)];
|
||||
//int out_g = alphamultiply[((palette[fg].g) <<6) +ralpha] + alphamultiply[((palette[bg].g) <<6) +(invralpha)];
|
||||
//int out_b = alphamultiply[((palette[fg].b>>1)<<6) +ralpha] + alphamultiply[((palette[bg].b>>1)<<6) +(invralpha)];
|
||||
out_r = (out_r + 1 + (out_r >> 8)) >> 8;
|
||||
out_g = (out_g + 1 + (out_g >> 8)) >> 8;
|
||||
out_b = (out_b + 1 + (out_b >> 8)) >> 8;
|
||||
//out_r = (out_r + 1 + (out_r >> 6)) >> 6;
|
||||
//out_g = (out_g + 1 + (out_g >> 6)) >> 6;
|
||||
//out_b = (out_b + 1 + (out_b >> 6)) >> 6;
|
||||
i = ((out_r << 11) | (out_g << 5) | out_b);
|
||||
unsigned char *clutp = clut;
|
||||
//unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one.
|
||||
return cycle_remap[*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
|
||||
//engine->ReleaseBitmapSurface (clutspr);
|
||||
}
|
||||
|
||||
static unsigned char MixColorLightLevel(unsigned char fg, unsigned char intensity) {
|
||||
unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots.
|
||||
int i = 0;
|
||||
//int dark_r = (((palette[fg].r>>1) * (intensity))>>8);
|
||||
//int dark_b = (((palette[fg].b>>1) * (intensity))>>8);
|
||||
//int dark_g = (((palette[fg].g) * (intensity))>>8);
|
||||
int dark_r = (((objectivepal[rfg].r >> 1) * (intensity)) >> 8);
|
||||
int dark_b = (((objectivepal[rfg].b >> 1) * (intensity)) >> 8);
|
||||
int dark_g = (((objectivepal[rfg].g) * (intensity)) >> 8);
|
||||
i = ((dark_r << 11) | (dark_g << 5) | dark_b);
|
||||
unsigned char *clutp = clut;
|
||||
return cycle_remap [*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
|
||||
}
|
||||
|
||||
static unsigned char MixColorAdditive(unsigned char fg, unsigned char bg, unsigned char alpha, int use_objpal = 0) {
|
||||
unsigned char rfg = cycle_remap[fg]; //Automatic remapping of palette slots.
|
||||
//unsigned char rbg = cycle_remap[bg]; //Saves on typing elsewhere.
|
||||
//BITMAP *clutspr = engine->GetSpriteGraphic (clutslot);
|
||||
//if (!clutspr) engine->AbortGame ("MixColorAlpha: Can't load CLUT sprite into memory.");
|
||||
//uint8 *clutarray = engine->GetRawBitmapSurface (clutspr);
|
||||
AGSColor *palette = engine->GetPalette();
|
||||
int i = 0;
|
||||
int add_r, add_b, add_g = 0;
|
||||
//char ralpha = MAX(0,MIN(63,alpha>>2));
|
||||
//add_r = (((palette[fg].r>>1) * (alpha))>>8);
|
||||
//add_b = (((palette[fg].b>>1) * (alpha))>>8);
|
||||
//add_g = (((palette[fg].g) * (alpha))>>8);
|
||||
add_r = (((objectivepal[rfg].r >> 1) * (alpha)) >> 8);
|
||||
add_b = (((objectivepal[rfg].b >> 1) * (alpha)) >> 8);
|
||||
add_g = (((objectivepal[rfg].g) * (alpha)) >> 8);
|
||||
//int a_g = MAX(0,MIN(63,alpha>>2));
|
||||
//add_r = ((alphamultiply[(palette[fg].r>>1)<<6)+ralpha])>>6);
|
||||
//add_b = ((alphamultiply[(palette[fg].b>>1)<<6)+ralpha])>>6);
|
||||
//add_g = ((alphamultiply[(palette[fg].g) <<6)+ralpha])>>6);
|
||||
//int out_r = MIN(31,(palette[bg].r>>1) + add_r);
|
||||
//int out_g = MIN(63, palette[bg].g + add_g);
|
||||
//int out_b = MIN(31,(palette[bg].b>>1) + add_b);
|
||||
int out_r, out_g, out_b;
|
||||
if (use_objpal == 0) {
|
||||
out_r = MIN(31, (palette[bg].r >> 1) + add_r);
|
||||
out_g = MIN(63, palette[bg].g + add_g);
|
||||
out_b = MIN(31, (palette[bg].b >> 1) + add_b);
|
||||
} else {
|
||||
out_r = MIN(31, (objectivepal [bg].r >> 1) + add_r);
|
||||
out_g = MIN(63, objectivepal [bg].g + add_g);
|
||||
out_b = MIN(31, (objectivepal [bg].b >> 1) + add_b);
|
||||
}
|
||||
i = ((out_r << 11) | (out_g << 5) | out_b);
|
||||
unsigned char *clutp = clut;
|
||||
unsigned char result = cycle_remap [*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
|
||||
//unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one.
|
||||
//engine->ReleaseBitmapSurface (clutspr);
|
||||
return result;
|
||||
}
|
||||
|
||||
static unsigned char MixColorMultiply(unsigned char fg, unsigned char bg, unsigned char alpha, int use_objpal = 0) {
|
||||
unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots.
|
||||
unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere.
|
||||
AGSColor *palette = engine->GetPalette();
|
||||
int i = 0;
|
||||
int mul_r, mul_b, mul_g = 0;
|
||||
int out_r, out_g, out_b = 0;
|
||||
if (use_objpal == 0) {
|
||||
mul_r = ((objectivepal[rfg].r >> 1) * (palette[rbg].r >> 1)) / 64;
|
||||
mul_b = ((objectivepal[rfg].b >> 1) * (palette[rbg].b >> 1)) / 64;
|
||||
mul_g = ((objectivepal[rfg].g * palette[rbg].g) / 64);
|
||||
out_r = ((palette[rbg].r >> 1) * (63 - (alpha / 4)) + (mul_r * (alpha / 4))) / 63;
|
||||
out_g = (palette[rbg].g * (63 - (alpha / 4)) + (mul_g * (alpha / 4))) / 63;
|
||||
out_b = ((palette[rbg].b >> 1) * (63 - (alpha / 4)) + (mul_b * (alpha / 4))) / 63;
|
||||
} else {
|
||||
mul_r = ((objectivepal[rfg].r >> 1) * (objectivepal[rbg].r >> 1)) / 64;
|
||||
mul_b = ((objectivepal[rfg].b >> 1) * (objectivepal[rbg].b >> 1)) / 64;
|
||||
mul_g = ((objectivepal[rfg].g * objectivepal[rbg].g) / 64);
|
||||
|
||||
out_r = ((objectivepal[rbg].r >> 1) * (63 - (alpha / 4)) + (mul_r * (alpha / 4))) / 63;
|
||||
out_g = (objectivepal[rbg].g * (63 - (alpha / 4)) + (mul_g * (alpha / 4))) / 63;
|
||||
out_b = ((objectivepal[rbg].b >> 1) * (63 - (alpha / 4)) + (mul_b * (alpha / 4))) / 63;
|
||||
}
|
||||
i = ((out_r << 11) | (out_g << 5) | out_b);
|
||||
unsigned char *clutp = clut;
|
||||
unsigned char result = cycle_remap [*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
|
||||
//unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one.
|
||||
//engine->ReleaseBitmapSurface (clutspr);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
void GetColor565(ScriptMethodParams ¶ms);
|
||||
|
||||
unsigned short root(unsigned short x);
|
||||
float FastSin(float x);
|
||||
float FastCos(float x);
|
||||
|
||||
} // namespace AGSPalRender
|
||||
} // namespace Plugins
|
||||
} // namespace AGS3
|
||||
|
||||
#endif
|
||||
1569
engines/ags/plugins/ags_pal_render/raycast.cpp
Normal file
1569
engines/ags/plugins/ags_pal_render/raycast.cpp
Normal file
File diff suppressed because it is too large
Load Diff
108
engines/ags/plugins/ags_pal_render/raycast.h
Normal file
108
engines/ags/plugins/ags_pal_render/raycast.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* of the License, or(at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AGS_PLUGINS_AGS_PAL_RENDER_RAYCAST_H
|
||||
#define AGS_PLUGINS_AGS_PAL_RENDER_RAYCAST_H
|
||||
|
||||
#include "ags/plugins/ags_pal_render/pal_render.h"
|
||||
|
||||
namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSPalRender {
|
||||
|
||||
#define MAP_WIDTH 64
|
||||
#define MAP_HEIGHT 64
|
||||
|
||||
struct Sprite {
|
||||
double x;
|
||||
double y;
|
||||
int texture;
|
||||
byte alpha;
|
||||
int blendmode;
|
||||
double uDivW;
|
||||
double uDivH;
|
||||
double vMove;
|
||||
double hMove;
|
||||
int8 objectinteract;
|
||||
int view;
|
||||
int frame;
|
||||
int angle;
|
||||
};
|
||||
|
||||
struct wallType {
|
||||
int texture[4];
|
||||
int solid[4];
|
||||
int ignorelighting[4];
|
||||
int alpha[4];
|
||||
int blendtype[4];
|
||||
int mask[4];
|
||||
byte hotspotinteract;
|
||||
};
|
||||
|
||||
|
||||
extern bool raycastOn;
|
||||
extern double posX;
|
||||
extern double posY; //x and y start position
|
||||
extern double dirX;
|
||||
extern double dirY; //initial direction vector
|
||||
extern double planeX;
|
||||
extern double planeY; //the 2d raycaster version of camera plane
|
||||
extern double moveSpeed; //the constant value is in squares/second
|
||||
extern double rotSpeed; //the constant value is in radians/second
|
||||
extern unsigned char worldMap[MAP_WIDTH][MAP_HEIGHT];
|
||||
extern unsigned char lightMap[MAP_WIDTH][MAP_HEIGHT];
|
||||
extern int ceilingMap[MAP_WIDTH][MAP_HEIGHT];
|
||||
extern int floorMap[MAP_WIDTH][MAP_HEIGHT];
|
||||
extern int heightMap[MAP_WIDTH][MAP_HEIGHT];
|
||||
extern unsigned char seenMap[MAP_WIDTH][MAP_HEIGHT];
|
||||
extern int textureSlot;
|
||||
extern int ambientlight;
|
||||
|
||||
#define numSprites 256
|
||||
extern Sprite sprite[numSprites];
|
||||
|
||||
|
||||
#define texWidth 64
|
||||
#define texHeight 64
|
||||
#define MAX_TEXTURES 512
|
||||
extern unsigned char texture[][texWidth * texHeight];
|
||||
|
||||
extern bool heightmapOn;
|
||||
|
||||
|
||||
extern wallType wallData[256];
|
||||
|
||||
//arrays used to sort the sprites
|
||||
extern unsigned char **transcolorbuffer;
|
||||
extern unsigned char **transalphabuffer;
|
||||
extern double **transzbuffer;
|
||||
extern bool *transslicedrawn;
|
||||
extern int *transwallblendmode;
|
||||
extern double **ZBuffer;
|
||||
extern double *distTable;
|
||||
extern short *interactionmap;
|
||||
extern int skybox;
|
||||
|
||||
} // namespace AGSPalRender
|
||||
} // namespace Plugins
|
||||
} // namespace AGS3
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user