From f1dc4901519a5c95815eac28c46010fe5a6f78d9 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 15 Sep 2009 22:44:07 +0000 Subject: [PATCH 01/27] - Fixed: The MBFParamStates array leaked memory. SVN r1839 (trunk) --- src/d_dehacked.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index f63978190..d21ac079d 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -149,7 +149,7 @@ static TArray WeaponNames; // List of states that are hacked to use a codepointer struct MBFParamState { - FState * state; + FState *state; int pointer; }; static TArray MBFParamStates; @@ -1610,7 +1610,7 @@ static void SetPointer(FState *state, PSymbol *sym, int frame = 0) { if (!symname.CompareNoCase(MBFCodePointers[i].name)) { - MBFParamState * newstate = new MBFParamState; + MBFParamState *newstate = new MBFParamState; newstate->state = state; newstate->pointer = i; MBFParamStates.Push(newstate); @@ -2495,6 +2495,7 @@ static void UnloadDehSupp () for (unsigned int i=0; i < MBFParamStates.Size(); i++) { SetDehParams(MBFParamStates[i]->state, MBFParamStates[i]->pointer); + delete MBFParamStates[i]; } MBFParamStates.Clear(); MBFParamStates.ShrinkToFit(); From 7b23effc023432a23d6a43af11092208e9aca4ae Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 15 Sep 2009 23:31:28 +0000 Subject: [PATCH 02/27] - Now that I think about it, why is MBFParamStates an array of pointers, anyway? SVN r1840 (trunk) --- src/d_dehacked.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index d21ac079d..1ac3ff287 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -152,7 +152,7 @@ struct MBFParamState FState *state; int pointer; }; -static TArray MBFParamStates; +static TArray MBFParamStates; // Data on how to correctly modify the codepointers struct CodePointerAlias { @@ -1610,9 +1610,9 @@ static void SetPointer(FState *state, PSymbol *sym, int frame = 0) { if (!symname.CompareNoCase(MBFCodePointers[i].name)) { - MBFParamState *newstate = new MBFParamState; - newstate->state = state; - newstate->pointer = i; + MBFParamState newstate; + newstate.state = state; + newstate.pointer = i; MBFParamStates.Push(newstate); break; // No need to cycle through the rest of the list. } @@ -2494,8 +2494,7 @@ static void UnloadDehSupp () // Handle MBF params here, before the required arrays are cleared for (unsigned int i=0; i < MBFParamStates.Size(); i++) { - SetDehParams(MBFParamStates[i]->state, MBFParamStates[i]->pointer); - delete MBFParamStates[i]; + SetDehParams(MBFParamStates[i].state, MBFParamStates[i].pointer); } MBFParamStates.Clear(); MBFParamStates.ShrinkToFit(); From c7a6b796f93046ec9f2e459a8ee58fa0e34548f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 16 Sep 2009 05:44:24 +0000 Subject: [PATCH 03/27] - fixed: The linetarget CCMD duplicated all of the info CCMD. - fixed: PrintActorInfo crashed due to some incomplete implementation. SVN r1845 (trunk) --- docs/rh-log.txt | 4 ++++ src/c_cmds.cpp | 1 - src/p_3dfloors.cpp | 10 ++++++---- src/p_3dfloors.h | 3 ++- src/p_mobj.cpp | 2 -- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 9c064977c..75c7fd572 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +September 16, 2009 (Changes by Graf Zahl) +- fixed: The linetarget CCMD duplicated all of the info CCMD. +- fixed: PrintActorInfo crashed due to some incomplete implementation. + September 15, 2009 (Changes by Graf Zahl) - added PinkSilver's A_Respawn enhancement patch. - added RandomSpawner update from Gez's experimental build. diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 3cddb6d52..ed27e2d27 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -778,7 +778,6 @@ CCMD(linetarget) linetarget->GetClass()->TypeName.GetChars(), linetarget->health, linetarget->SpawnHealth()); - PrintMiscActorInfo(linetarget); } else Printf("No target found\n"); } diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 29b3295e0..d1509c649 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -74,14 +74,14 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag ffloor->bottom.plane = &sec2->floorplane; ffloor->bottom.texture = &sec2->planes[sector_t::floor].Texture; ffloor->bottom.texheight = &sec2->planes[sector_t::floor].TexZ; - ffloor->bottom.isceiling = false; + ffloor->bottom.isceiling = sector_t::floor; } else { ffloor->bottom.plane = &sec2->ceilingplane; ffloor->bottom.texture = &sec2->planes[sector_t::ceiling].Texture; ffloor->bottom.texheight = &sec2->planes[sector_t::ceiling].TexZ; - ffloor->bottom.isceiling = true; + ffloor->bottom.isceiling = sector_t::ceiling; } if (!(flags&FF_FIX)) @@ -90,7 +90,7 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag ffloor->top.texture = &sec2->planes[sector_t::ceiling].Texture; ffloor->top.texheight = &sec2->planes[sector_t::ceiling].TexZ; ffloor->toplightlevel = &sec2->lightlevel; - ffloor->top.isceiling = true; + ffloor->top.isceiling = sector_t::ceiling; } else // FF_FIX is a special case to patch rendering holes { @@ -98,7 +98,7 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag ffloor->top.texture = &sec2->planes[sector_t::floor].Texture; ffloor->top.texheight = &sec2->planes[sector_t::floor].TexZ; ffloor->toplightlevel = &sec->lightlevel; - ffloor->top.isceiling = false; + ffloor->top.isceiling = sector_t::floor; ffloor->top.model = sec; } @@ -117,12 +117,14 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag // fortunately this plane won't be rendered - otherwise this wouldn't work... ffloor->bottom.plane=&sec->floorplane; ffloor->bottom.model=sec; + ffloor->bottom.isceiling = sector_t::floor; } } ffloor->flags = flags; ffloor->master = master; ffloor->alpha = transluc; + ffloor->top.vindex = ffloor->bottom.vindex = -1; // The engine cannot handle sloped translucent floors. Sorry if (ffloor->top.plane->a || ffloor->top.plane->b || ffloor->bottom.plane->a || ffloor->bottom.plane->b) diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 6ae29e3c3..dfaf5a5eb 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -73,7 +73,8 @@ struct F3DFloor const FTextureID * texture; const fixed_t * texheight; sector_t * model; - bool isceiling; + int isceiling; + int vindex; }; planeref bottom; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 670672ec7..f3313e778 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5503,11 +5503,9 @@ void PrintMiscActorInfo(AActor * query) FIXED2FLOAT(query->wallbouncefactor), query->BounceFlags); for (flagi = 0; flagi < 31; flagi++) if (query->BounceFlags & 1<alpha), query->renderflags); - /* for (flagi = 0; flagi < 31; flagi++) if (query->renderflags & 1< Date: Wed, 16 Sep 2009 15:54:04 +0000 Subject: [PATCH 04/27] - Added some pieces of MBF's friendly AI. - Cleaned up A_LookEx code and merged most of it with the base functions. The major difference was a common piece of code that was repeated 5 times throughout the code so I moved it into a subfunction. - Changed P_BlockmapSearch to pass a user parameter to its callback so that A_LookEx does not need to store its info inside the actor itself. SVN r1846 (trunk) --- docs/rh-log.txt | 6 + src/CMakeLists.txt | 1 - src/actor.h | 10 +- src/g_doom/a_bossbrain.cpp | 2 +- src/g_doom/a_scriptedmarine.cpp | 2 +- src/g_hexen/a_dragon.cpp | 2 +- src/g_hexen/a_firedemon.cpp | 2 +- src/g_hexen/a_magestaff.cpp | 4 +- src/p_enemy.cpp | 500 ++++++++++++++---- src/p_enemy.h | 21 +- src/p_enemy_a_lookex.cpp | 904 -------------------------------- src/p_interaction.cpp | 16 +- src/p_local.h | 2 +- src/p_maputl.cpp | 16 +- zdoom.vcproj | 754 +++++++++++++------------- 15 files changed, 825 insertions(+), 1417 deletions(-) delete mode 100644 src/p_enemy_a_lookex.cpp diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 75c7fd572..89fc05c25 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,10 @@ September 16, 2009 (Changes by Graf Zahl) +- Added some pieces of MBF's friendly AI. +- Cleaned up A_LookEx code and merged most of it with the base functions. + The major difference was a common piece of code that was repeated 5 times + throughout the code so I moved it into a subfunction. +- Changed P_BlockmapSearch to pass a user parameter to its callback so that + A_LookEx does not need to store its info inside the actor itself. - fixed: The linetarget CCMD duplicated all of the info CCMD. - fixed: PrintActorInfo crashed due to some incomplete implementation. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f7b8dd1ae..ee106ffb0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -589,7 +589,6 @@ add_executable( zdoom WIN32 p_doors.cpp p_effect.cpp p_enemy.cpp - p_enemy_a_lookex.cpp p_floor.cpp p_interaction.cpp p_lights.cpp diff --git a/src/actor.h b/src/actor.h index deb9bfd45..d2ecf4ef9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -216,7 +216,7 @@ enum MF3_NOBLOCKMONST = 0x00100000, // Can cross ML_BLOCKMONSTERS lines MF3_CRASHED = 0x00200000, // Actor entered its crash state MF3_FULLVOLDEATH = 0x00400000, // DeathSound is played full volume (for missiles) - /* = 0x00800000, */ + MF3_AVOIDMELEE = 0x00800000, // Avoids melee attacks (same as MBF's monster_backing but must be explicitly set) /* = 0x01000000, */ MF3_FOILINVUL = 0x02000000, // Actor can hurt MF2_INVULNERABLE things MF3_NOTELEOTHER = 0x04000000, // Monster is unaffected by teleport other artifact @@ -810,14 +810,6 @@ public: AActor *BlockingMobj; // Actor that blocked the last move line_t *BlockingLine; // Line that blocked the last move - // [KS] These temporary-use properties are needed to allow A_LookEx to pass its parameters to - // LookFor*InBlock in P_BlockmapSearch so that friendly enemies and monsters that look for - // other monsters can find their targets properly. If there's a cleaner way of doing this, - // feel free to remove these and use that method instead. - fixed_t LookExMinDist; // Minimum sight distance - fixed_t LookExMaxDist; // Maximum sight distance - angle_t LookExFOV; // Field of Vision - // a linked list of sectors where this object appears struct msecnode_t *touching_sectorlist; // phares 3/14/98 diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp index 2fc203e1d..7764f2ecd 100644 --- a/src/g_doom/a_bossbrain.cpp +++ b/src/g_doom/a_bossbrain.cpp @@ -238,7 +238,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) { newmobj->CopyFriendliness (eye, false); } - if (newmobj->SeeState != NULL && P_LookForPlayers (newmobj, true)) + if (newmobj->SeeState != NULL && P_LookForPlayers (newmobj, true, NULL)) newmobj->SetState (newmobj->SeeState); if (!(newmobj->ObjectFlags & OF_EuthanizeMe)) diff --git a/src/g_doom/a_scriptedmarine.cpp b/src/g_doom/a_scriptedmarine.cpp index fbae607ca..9f6f54051 100644 --- a/src/g_doom/a_scriptedmarine.cpp +++ b/src/g_doom/a_scriptedmarine.cpp @@ -168,7 +168,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_Refire) { if (self->MissileState && pr_m_refire() < 160) { // Look for a new target most of the time - if (P_LookForPlayers (self, true) && P_CheckMissileRange (self)) + if (P_LookForPlayers (self, true, NULL) && P_CheckMissileRange (self)) { // Found somebody new and in range, so don't stop shooting return; } diff --git a/src/g_hexen/a_dragon.cpp b/src/g_hexen/a_dragon.cpp index 8ef10e245..0c5ea81b5 100644 --- a/src/g_hexen/a_dragon.cpp +++ b/src/g_hexen/a_dragon.cpp @@ -213,7 +213,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) } else { - P_LookForPlayers (self, true); + P_LookForPlayers (self, true, NULL); } } diff --git a/src/g_hexen/a_firedemon.cpp b/src/g_hexen/a_firedemon.cpp index 884a12f27..d0366fdf0 100644 --- a/src/g_hexen/a_firedemon.cpp +++ b/src/g_hexen/a_firedemon.cpp @@ -145,7 +145,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) if(!self->target || !(self->target->flags&MF_SHOOTABLE)) { // Invalid target - P_LookForPlayers (self,true); + P_LookForPlayers (self,true, NULL); return; } diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index 85b51d330..76610f693 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -19,7 +19,7 @@ void A_DropBloodscourgePieces (AActor *); void A_MStaffAttack (AActor *actor); void A_MStaffPalette (AActor *actor); -static AActor *FrontBlockCheck (AActor *mo, int index); +static AActor *FrontBlockCheck (AActor *mo, int index, void *); static divline_t BlockCheckLine; //========================================================================== @@ -254,7 +254,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffTrack) // //============================================================================ -static AActor *FrontBlockCheck (AActor *mo, int index) +static AActor *FrontBlockCheck (AActor *mo, int index, void *) { FBlockNode *link; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index a321955a2..9937eefa5 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -62,6 +62,7 @@ static FRandom pr_look2 ("LookyLooky"); static FRandom pr_look3 ("IGotHooky"); static FRandom pr_slook ("SlooK"); static FRandom pr_dropoff ("Dropoff"); +static FRandom pr_defect ("Defect"); static FRandom pr_skiptarget("SkipTarget"); @@ -219,20 +220,20 @@ void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash) bool AActor::CheckMeleeRange () { - AActor *pl; + AActor *pl = target; + fixed_t dist; - if (!target) + if (!pl) return false; - pl = target; dist = P_AproxDistance (pl->x - x, pl->y - y); if (dist >= meleerange + pl->radius) return false; // [RH] If moving toward goal, then we've reached it. - if (target == goal) + if (pl == goal) return true; // [RH] Don't melee things too far above or below actor. @@ -243,6 +244,10 @@ bool AActor::CheckMeleeRange () if (pl->z + pl->height < z) return false; } + + // killough 7/18/98: friendly monsters don't attack other friends + if (IsFriend(pl)) + return false; if (!P_CheckSight (this, pl, 0)) return false; @@ -279,6 +284,12 @@ bool P_CheckMeleeRange2 (AActor *actor) { // Attacker is higher return false; } + else if (actor->IsFriend(mo)) + { + // killough 7/18/98: friendly monsters don't attack other friends + return false; + } + if (!P_CheckSight(actor, mo)) { return false; @@ -303,12 +314,34 @@ bool P_CheckMissileRange (AActor *actor) { // the target just hit the enemy, so fight back! actor->flags &= ~MF_JUSTHIT; - return true; + + // killough 7/18/98: no friendly fire at corpses + // killough 11/98: prevent too much infighting among friends + // Cleaned up and made readable + if (!(actor->flags & MF_FRIENDLY)) return true; + if (actor->target->health <= 0) return false; + if (!actor->IsFriend(actor->target)) return true; + if (actor->target->player != NULL) + { + return (pr_defect() >128); + } + else + { + return !(actor->target->flags & MF_JUSTHIT) && pr_defect() >128; + } } if (actor->reactiontime) return false; // do not attack yet - + + // killough 7/18/98: friendly monsters don't attack other friendly + // monsters or players (except when attacked, and then only once) + if (actor->IsFriend(actor->target)) + return false; + + if (actor->flags & MF_FRIENDLY && P_HitFriend(actor)) + return false; + // OPTIMIZE: get this from a global checksight // [RH] What? dist = P_AproxDistance (actor->x-actor->target->x, @@ -357,7 +390,7 @@ bool P_HitFriend(AActor * self) if (self->flags&MF_FRIENDLY && self->target != NULL) { angle_t angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y); - fixed_t dist = P_AproxDistance (self->x-self->target->x, self->y-self->target->y); + fixed_t dist = P_AproxDistance (self->x - self->target->x, self->y - self->target->y); P_AimLineAttack (self, angle, dist, &linetarget, 0, true); if (linetarget != NULL && linetarget != self->target) { @@ -739,6 +772,10 @@ void P_NewChaseDir(AActor * actor) fixed_t deltax; fixed_t deltay; +#ifdef MBF_STUFF + actor->strafecount = 0; +#endif + if ((actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal!=NULL) { deltax = actor->goal->x - actor->x; @@ -831,7 +868,59 @@ void P_NewChaseDir(AActor * actor) return; } } + +#if 0 + // Move away from friends when too close, except + // in certain situations (e.g. a crowded lift) + + // MBF code for friends. Cannot be done in ZDoom but left here as a reminder for later implementation. + + if (actor->flags & target->flags & MF_FRIEND && + distfriend << FRACBITS > dist && + !P_IsOnLift(target) && !P_IsUnderDamage(actor)) + deltax = -deltax, deltay = -deltay; + else +#endif + +#ifdef MBF_STUFF + // MBF's monster_backing option. Made an actor flag instead. Also cleaned the code up to make it readable. + // Todo: implement the movement logic + if (target->health > 0 && !actor->IsFriend(target)) + { // Live enemy target + + if (actor->flags3 & MF3_AVOIDMELEE) + { + bool ismeleeattacker = false; + if (target->player == NULL) + { + ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->radius)*2); + } + else if (target->player->ReadyWeapon != NULL) + { + // melee range of player weapon is a parameter of the action function and cannot be checked here. + // Add a new weapon property? + ismeleeattacker = (target->player->ReadyWeapon->WeaponFlags & WIF_BOT_MELEE && dist < MELEERANGE*3); + } + if (ismeleeattacker) + { + actor->strafecount = pr_enemystrafe() & 15; + deltax = -deltax, deltay = -deltay; + } + } + } +#endif + + P_DoNewChaseDir(actor, deltax, deltay); + +#ifdef MBF_STUFF + // If strafing, set movecount to strafecount so that old Doom + // logic still works the same, except in the strafing part + + if (actor->strafecount) + actor->movecount = actor->strafecount; +#endif + } @@ -996,6 +1085,58 @@ void P_RandomChaseDir (AActor *actor) actor->movedir = DI_NODIR; // cannot move } +//--------------------------------------------------------------------------- +// +// P_IsVisible +// +// killough 9/9/98: whether a target is visible to a monster +// Extended to handle all A_LookEx related checking, too. +// +//--------------------------------------------------------------------------- + +bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params) +{ + fixed_t maxdist; + fixed_t mindist; + angle_t fov; + + if (params != NULL) + { + maxdist = params->maxdist; + mindist = params->mindist; + fov = params->fov; + } + else + { + mindist = maxdist = 0; + fov = allaround? 0 : ANGLE_180; + } + + fixed_t dist = P_AproxDistance (other->x - lookee->x, other->y - lookee->y); + + if (maxdist && dist > maxdist) + return false; // [KS] too far + + if (mindist && dist < mindist) + return false; // [KS] too close + + if (fov && fov < ANGLE_MAX) + { + angle_t an = R_PointToAngle2 (lookee->x, lookee->y, other->x, other->y) - lookee->angle; + + if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) + { + // if real close, react anyway + // [KS] but respect minimum distance rules + if (mindist || dist > MELEERANGE) + return false; // outside of fov + } + } + + // P_CheckSight is by far the most expensive operation in here so let's do it last. + return P_CheckSight(lookee, other, 2); +} + //--------------------------------------------------------------------------- // // FUNC P_LookForMonsters @@ -1061,8 +1202,9 @@ bool P_LookForMonsters (AActor *actor) // //============================================================================ -AActor *LookForTIDinBlock (AActor *lookee, int index) +AActor *LookForTIDInBlock (AActor *lookee, int index, void *extparams) { + FLookExParams *params = (FLookExParams *)extparams; FBlockNode *block; AActor *link; AActor *other; @@ -1104,25 +1246,8 @@ AActor *LookForTIDinBlock (AActor *lookee, int index) if (!(lookee->flags3 & MF3_NOSIGHTCHECK)) { - if (!P_CheckSight (lookee, other, 2)) + if (!P_IsVisible(lookee, other, true, params)) continue; // out of sight - /* - if (!allaround) - { - angle_t an = R_PointToAngle2 (actor->x, actor->y, - other->x, other->y) - - actor->angle; - - if (an > ANG90 && an < ANG270) - { - fixed_t dist = P_AproxDistance (other->x - actor->x, - other->y - actor->y); - // if real close, react anyway - if (dist > MELEERANGE) - continue; // behind back - } - } - */ } return other; @@ -1138,12 +1263,13 @@ AActor *LookForTIDinBlock (AActor *lookee, int index) // //============================================================================ -bool P_LookForTID (AActor *actor, INTBOOL allaround) +bool P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params) { AActor *other; bool reachedend = false; + bool chasegoal = params? (!(params->flags & LOF_DONTCHASEGOAL)) : true; - other = P_BlockmapSearch (actor, 0, LookForTIDinBlock); + other = P_BlockmapSearch (actor, 0, LookForTIDInBlock, params); if (other != NULL) { @@ -1198,24 +1324,8 @@ bool P_LookForTID (AActor *actor, INTBOOL allaround) if (!(actor->flags3 & MF3_NOSIGHTCHECK)) { - if (!P_CheckSight (actor, other, 2)) + if (!P_IsVisible (actor, other, !!allaround, params)) continue; // out of sight - - if (!allaround) - { - angle_t an = R_PointToAngle2 (actor->x, actor->y, - other->x, other->y) - - actor->angle; - - if (an > ANG90 && an < ANG270) - { - fixed_t dist = P_AproxDistance (other->x - actor->x, - other->y - actor->y); - // if real close, react anyway - if (dist > MELEERANGE) - continue; // behind back - } - } } // [RH] Need to be sure the reactiontime is 0 if the monster is @@ -1231,7 +1341,7 @@ bool P_LookForTID (AActor *actor, INTBOOL allaround) if (actor->target == NULL) { // [RH] use goal as target - if (actor->goal != NULL) + if (actor->goal != NULL && chasegoal) { actor->target = actor->goal; return true; @@ -1256,18 +1366,19 @@ bool P_LookForTID (AActor *actor, INTBOOL allaround) //============================================================================ // -// LookForTIDinBlock +// LookForEnemiesinBlock // // Finds a non-friendly monster in a mapblock. It can also use targets of // friendlies in this mapblock to find non-friendlies in other mapblocks. // //============================================================================ -AActor *LookForEnemiesInBlock (AActor *lookee, int index) +AActor *LookForEnemiesInBlock (AActor *lookee, int index, void *extparam) { FBlockNode *block; AActor *link; AActor *other; + FLookExParams *params = (FLookExParams *)extparam; for (block = blocklinks[index]; block != NULL; block = block->NextActor) { @@ -1330,25 +1441,11 @@ AActor *LookForEnemiesInBlock (AActor *lookee, int index) } } - if (other == NULL || !P_CheckSight (lookee, other, 2)) + // [KS] Hey, shouldn't there be a check for MF3_NOSIGHTCHECK here? + + if (other == NULL || !P_IsVisible (lookee, other, true, params)) continue; // out of sight - /* - if (!allaround) - { - angle_t an = R_PointToAngle2 (actor->x, actor->y, - other->x, other->y) - - actor->angle; - - if (an > ANG90 && an < ANG270) - { - fixed_t dist = P_AproxDistance (other->x - actor->x, - other->y - actor->y); - // if real close, react anyway - if (dist > MELEERANGE) - continue; // behind back - } - } - */ + return other; } @@ -1363,11 +1460,11 @@ AActor *LookForEnemiesInBlock (AActor *lookee, int index) // //============================================================================ -bool P_LookForEnemies (AActor *actor, INTBOOL allaround) +bool P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params) { AActor *other; - other = P_BlockmapSearch (actor, 10, LookForEnemiesInBlock); + other = P_BlockmapSearch (actor, 10, LookForEnemiesInBlock, params); if (other != NULL) { @@ -1415,18 +1512,17 @@ bool P_LookForEnemies (AActor *actor, INTBOOL allaround) ================ */ -bool P_LookForPlayers (AActor *actor, INTBOOL allaround) +bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) { int c; int stop; int pnum; player_t* player; - angle_t an; - fixed_t dist; + bool chasegoal = params? (!(params->flags & LOF_DONTCHASEGOAL)) : true; if (actor->TIDtoHate != 0) { - if (P_LookForTID (actor, allaround)) + if (P_LookForTID (actor, allaround, params)) { return true; } @@ -1437,10 +1533,43 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround) } else if (actor->flags & MF_FRIENDLY) { - if (!deathmatch) // [SP] If you don't see any enemies in deathmatch, look for players. - return P_LookForEnemies (actor, allaround); - else if ( P_LookForEnemies (actor, allaround) ) - return true; + bool result = P_LookForEnemies (actor, allaround, params); + +#ifdef MBF_FRIENDS + if (!result && (actor->flags & MF_FRIEND_MBF)) + { // killough 9/9/98: friendly monsters go about players differently + + // Go back to a player, no matter whether it's visible or not + for (int anyone=0; anyone<=1; anyone++) + { + for (int c=0; cIsFriend(players[c].mo) && + (anyone || P_IsVisible(actor, players[c].mo, allaround))) + { + actor->target = players[c].mo; + + // killough 12/98: + // get out of refiring loop, to avoid hitting player accidentally + + if (actor->MissileState != NULL) + { + actor->SetStateNF(actor->SeeState); + actor->flags &= ~MF_JUSTHIT; + } + + return true; + } + } + } + } +#endif + // [SP] If you don't see any enemies in deathmatch, look for players (but only when friend to a specific player.) + if (actor->FriendPlayer == 0) return false; + if (result || !deathmatch) return true; + + } // [SP] if false, and in deathmatch, intentional fall-through if (!(gameinfo.gametype & (GAME_DoomStrifeChex)) && @@ -1478,7 +1607,8 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround) if (actor->target == NULL) { // [RH] use goal as target - if (actor->goal != NULL) + // [KS] ...unless we're ignoring goals and we don't already have one + if (actor->goal != NULL && chasegoal) { actor->target = actor->goal; return true; @@ -1512,7 +1642,7 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround) if (player->health <= 0) continue; // dead - if (!P_CheckSight (actor, player->mo, 2)) + if (!P_IsVisible (actor, player->mo, allaround, params)) continue; // out of sight // [SP] Deathmatch fixes - if we have MF_FRIENDLY we're definitely in deathmatch @@ -1525,23 +1655,6 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround) continue; // This is my master. } - if (!allaround) - { - an = R_PointToAngle2 (actor->x, - actor->y, - player->mo->x, - player->mo->y) - - actor->angle; - - if (an > ANG90 && an < ANG270) - { - dist = P_AproxDistance (player->mo->x - actor->x, - player->mo->y - actor->y); - // if real close, react anyway - if (dist > MELEERANGE) - continue; // behind back - } - } if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) || player->mo->flags3 & MF3_GHOST) { @@ -1630,7 +1743,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) { // If we find a valid target here, the wandering logic should *not* // be activated! It would cause the seestate to be set twice. - if (P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND)) + if (P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND, NULL)) goto seeyou; // Let the self wander around aimlessly looking for a fight @@ -1657,7 +1770,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) } } - if (!P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND)) + if (!P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND, NULL)) return; // go into chase state @@ -1687,6 +1800,193 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) } +//========================================================================== +// +// A_LookEx (int flags, fixed minseedist, fixed maxseedist, fixed maxheardist, fixed fov, state wakestate) +// [KS] Borrowed the A_Look code to make a parameterized version. +// +//========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) +{ + ACTION_PARAM_START(6); + ACTION_PARAM_INT(flags, 0); + ACTION_PARAM_FIXED(minseedist, 1); + ACTION_PARAM_FIXED(maxseedist, 2); + ACTION_PARAM_FIXED(maxheardist, 3); + ACTION_PARAM_ANGLE(fov, 4); + ACTION_PARAM_STATE(seestate, 5); + + AActor *targ = NULL; // Shuts up gcc + fixed_t dist; + FLookExParams params = {fov, minseedist, maxseedist, maxheardist, flags, seestate }; + + if (self->flags5 & MF5_INCONVERSATION) + return; + + // [RH] Set goal now if appropriate + if (self->special == Thing_SetGoal && self->args[0] == 0) + { + NActorIterator iterator (NAME_PatrolPoint, self->args[1]); + self->special = 0; + self->goal = iterator.Next (); + self->reactiontime = self->args[2] * TICRATE + level.maptime; + if (self->args[3] == 0) self->flags5 &=~ MF5_CHASEGOAL; + else self->flags5 |= MF5_CHASEGOAL; + } + + self->threshold = 0; // any shot will wake up + + if (self->TIDtoHate != 0) + { + targ = self->target; + } + else + { + if (!(flags & LOF_NOSOUNDCHECK)) + { + targ = self->LastHeard; + if (targ != NULL) + { + // [RH] If the soundtarget is dead, don't chase it + if (targ->health <= 0) + { + targ = NULL; + } + else + { + dist = P_AproxDistance (targ->x - self->x, + targ->y - self->y); + + // [KS] If the target is too far away, don't respond to the sound. + if (maxheardist && dist > maxheardist) + { + targ = NULL; + self->LastHeard = NULL; + } + } + } + } + + if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) + { + return; + } + } + + // [RH] Andy Baker's stealth monsters + if (self->flags & MF_STEALTH) + { + self->visdir = -1; + } + + if (targ && (targ->flags & MF_SHOOTABLE)) + { + if (self->IsFriend (targ)) // be a little more precise! + { + if (!(self->flags4 & MF4_STANDSTILL)) + { + if (!(flags & LOF_NOSIGHTCHECK)) + { + // If we find a valid target here, the wandering logic should *not* + // be activated! If would cause the seestate to be set twice. + if (P_LookForPlayers(self, true, ¶ms)) + goto seeyou; + } + + // Let the self wander around aimlessly looking for a fight + if (!(self->flags & MF_INCHASE)) + { + if (seestate) + { + self->SetState (seestate); + } + else + { + if (self->SeeState != NULL) + { + self->SetState (self->SeeState); + } + else + { + CALL_ACTION(A_Wander, self); + } + } + } + } + } + else + { + self->target = targ; //We already have a target? + + // [KS] The target can become ourselves in rare circumstances (like + // if we committed suicide), so if that's the case, just ignore it. + if (self->target == self) self->target = NULL; + + if (self->target != NULL) + { + if (self->flags & MF_AMBUSH) + { + dist = P_AproxDistance (self->target->x - self->x, + self->target->y - self->y); + if (P_CheckSight (self, self->target, 2) && + (!minseedist || dist > minseedist) && + (!maxseedist || dist < maxseedist)) + { + goto seeyou; + } + } + else + goto seeyou; + } + } + } + + if (!(flags & LOF_NOSIGHTCHECK)) + { + if (!P_LookForPlayers(self, true, ¶ms)) + return; + } + else + { + return; + } + + // go into chase state + seeyou: + // [RH] Don't start chasing after a goal if it isn't time yet. + if (self->target == self->goal) + { + if (self->reactiontime > level.maptime) + self->target = NULL; + } + else if (self->SeeSound && !(flags & LOF_NOSEESOUND)) + { + if (flags & LOF_FULLVOLSEESOUND) + { // full volume + S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NONE); + } + else + { + S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM); + } + } + + if (self->target && !(self->flags & MF_INCHASE)) + { + if (seestate) + { + self->SetState (seestate); + } + else + { + self->SetState (self->SeeState); + } + } +} + +// [KS] *** End additions by me *** + //========================================================================== // // A_Wander @@ -1770,7 +2070,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2) } else { - if (!P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND)) + if (!P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND, NULL)) goto nosee; self->SetState (self->SeeState); self->flags4 |= MF4_INCOMBAT; @@ -1916,7 +2216,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi // hurt our old one temporarily. actor->threshold = 0; } - if (P_LookForPlayers (actor, true) && actor->target != actor->goal) + if (P_LookForPlayers (actor, true, NULL) && actor->target != actor->goal) { // got a new target actor->flags &= ~MF_INCHASE; return; @@ -2088,7 +2388,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi lookForBetter = true; } AActor * oldtarget = actor->target; - gotNew = P_LookForPlayers (actor, true); + gotNew = P_LookForPlayers (actor, true, NULL); if (lookForBetter) { actor->flags3 |= MF3_NOSIGHTCHECK; diff --git a/src/p_enemy.h b/src/p_enemy.h index f111f9d08..ae259806a 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -25,6 +25,25 @@ enum dirtype_t extern fixed_t xspeed[8], yspeed[8]; +enum LO_Flags +{ + LOF_NOSIGHTCHECK = 1, + LOF_NOSOUNDCHECK = 2, + LOF_DONTCHASEGOAL = 4, + LOF_NOSEESOUND = 8, + LOF_FULLVOLSEESOUND = 16, +}; + +struct FLookExParams +{ + angle_t fov; + fixed_t mindist; + fixed_t maxdist; + fixed_t maxheardist; + int flags; + FState *seestate; +}; + void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks); bool P_HitFriend (AActor *self); void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash=false); @@ -32,9 +51,9 @@ bool P_CheckMeleeRange2 (AActor *actor); bool P_Move (AActor *actor); bool P_TryWalk (AActor *actor); void P_NewChaseDir (AActor *actor); -bool P_LookForPlayers (AActor *actor, INTBOOL allaround); AInventory *P_DropItem (AActor *source, const PClass *type, int special, int chance); void P_TossItem (AActor *item); +bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params); DECLARE_ACTION(A_Look) DECLARE_ACTION(A_Wander) diff --git a/src/p_enemy_a_lookex.cpp b/src/p_enemy_a_lookex.cpp deleted file mode 100644 index 4c68fcbf2..000000000 --- a/src/p_enemy_a_lookex.cpp +++ /dev/null @@ -1,904 +0,0 @@ -#include - -#include "templates.h" -#include "m_random.h" -#include "i_system.h" -#include "doomdef.h" -#include "p_local.h" -#include "p_lnspec.h" -#include "s_sound.h" -#include "g_game.h" -#include "doomstat.h" -#include "r_state.h" -#include "c_cvars.h" -#include "p_enemy.h" -#include "a_sharedglobal.h" -#include "a_action.h" -#include "thingdef/thingdef.h" -#include "g_level.h" - -#include "gi.h" - -bool P_LookForMonsters (AActor *actor); - -static FRandom pr_look2 ("LookyLookyEx"); -static FRandom pr_look3 ("IGotHookyEx"); -static FRandom pr_lookforplayers ("LookForPlayersEx"); -static FRandom pr_skiptarget("SkipTargetEx"); - - -// [KS] *** Start additions by me - p_enemy.cpp *** - -// LookForTIDinBlockEx -// LookForEnemiesInBlockEx -// P_NewLookTID (copied from P_LookForTID) -// P_NewLookPlayers (copied from P_LookForPlayers) -// Takes FOV and sight distances into account when acquiring a target. -// TODO: Not sure if using actor properties to pass parameters around indirectly is such a good idea. If there's a cleaner method, do it that way instead. -// ~Kate S. Last updated on 12/23/2007 - -AActor *LookForTIDinBlockEx (AActor *lookee, int index) -{ - FBlockNode *block; - AActor *link; - AActor *other; - fixed_t dist; - angle_t an; - - for (block = blocklinks[index]; block != NULL; block = block->NextActor) - { - link = block->Me; - - if (!(link->flags & MF_SHOOTABLE)) - continue; // not shootable (observer or dead) - - if (link == lookee) - continue; - - if (link->health <= 0) - continue; // dead - - if (link->flags2 & MF2_DORMANT) - continue; // don't target dormant things - - if (link->tid == lookee->TIDtoHate) - { - other = link; - } - else if (link->target != NULL && link->target->tid == lookee->TIDtoHate) - { - other = link->target; - if (!(other->flags & MF_SHOOTABLE) || - other->health <= 0 || - (other->flags2 & MF2_DORMANT)) - { - continue; - } - } - else - { - continue; - } - - if (!(lookee->flags3 & MF3_NOSIGHTCHECK)) - { - if (!P_CheckSight (lookee, other, 2)) - continue; // out of sight - - dist = P_AproxDistance (other->x - lookee->x, - other->y - lookee->y); - - if (lookee->LookExMaxDist && dist > lookee->LookExMaxDist) - continue; // [KS] too far - - if (lookee->LookExMinDist && dist < lookee->LookExMinDist) - continue; // [KS] too close - - if (lookee->LookExFOV && lookee->LookExFOV < ANGLE_MAX) - { - an = R_PointToAngle2 (lookee->x, - lookee->y, - other->x, - other->y) - - lookee->angle; - - if (an > (lookee->LookExFOV / 2) && an < (ANGLE_MAX - (lookee->LookExFOV / 2))) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (lookee->LookExMinDist || dist > MELEERANGE) - continue; // outside of fov - } - } - else - { - if(!(lookee->flags4 & MF4_LOOKALLAROUND) || (lookee->LookExFOV >= ANGLE_MAX)) // Just in case angle_t doesn't clamp stuff, because I can't be too sure. - { - an = R_PointToAngle2 (lookee->x, - lookee->y, - other->x, - other->y) - - lookee->angle; - - if (an > ANG90 && an < ANG270) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (lookee->LookExMinDist || dist > MELEERANGE) - continue; // behind back - } - } - } - } - - return other; - } - return NULL; -} - -AActor *LookForEnemiesInBlockEx (AActor *lookee, int index) -{ - FBlockNode *block; - AActor *link; - AActor *other; - fixed_t dist; - angle_t an; - - for (block = blocklinks[index]; block != NULL; block = block->NextActor) - { - link = block->Me; - - if (!(link->flags & MF_SHOOTABLE)) - continue; // not shootable (observer or dead) - - if (link == lookee) - continue; - - if (link->health <= 0) - continue; // dead - - if (link->flags2 & MF2_DORMANT) - continue; // don't target dormant things - - if (!(link->flags3 & MF3_ISMONSTER)) - continue; // don't target it if it isn't a monster (could be a barrel) - - other = NULL; - if (link->flags & MF_FRIENDLY) - { - if (deathmatch && - lookee->FriendPlayer != 0 && link->FriendPlayer != 0 && - lookee->FriendPlayer != link->FriendPlayer) - { - // This is somebody else's friend, so go after it - other = link; - } - else if (link->target != NULL && !(link->target->flags & MF_FRIENDLY)) - { - other = link->target; - if (!(other->flags & MF_SHOOTABLE) || - other->health <= 0 || - (other->flags2 & MF2_DORMANT)) - { - other = NULL;; - } - } - } - else - { - other = link; - } - - // [MBF] If the monster is already engaged in a one-on-one attack - // with a healthy friend, don't attack around 60% the time. - - // [GrafZahl] This prevents friendlies from attacking all the same - // target. - - if (other) - { - AActor *targ = other->target; - if (targ && targ->target == other && pr_skiptarget() > 100 && lookee->IsFriend (targ) && - targ->health*2 >= targ->SpawnHealth()) - { - continue; - } - } - - // [KS] Hey, shouldn't there be a check for MF3_NOSIGHTCHECK here? - - if (other == NULL || !P_CheckSight (lookee, other, 2)) - continue; // out of sight - - dist = P_AproxDistance (other->x - lookee->x, - other->y - lookee->y); - - if (lookee->LookExMaxDist && dist > lookee->LookExMaxDist) - continue; // [KS] too far - - if (lookee->LookExMinDist && dist < lookee->LookExMinDist) - continue; // [KS] too close - - if (lookee->LookExFOV && lookee->LookExFOV < ANGLE_MAX) - { - an = R_PointToAngle2 (lookee->x, - lookee->y, - other->x, - other->y) - - lookee->angle; - - if (an > (lookee->LookExFOV / 2) && an < (ANGLE_MAX - (lookee->LookExFOV / 2))) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (lookee->LookExMinDist || dist > MELEERANGE) - continue; // outside of fov - } - } - else - { - if(!(lookee->flags4 & MF4_LOOKALLAROUND) || (lookee->LookExFOV >= ANGLE_MAX)) // Just in case angle_t doesn't clamp stuff, because I can't be too sure. - { - an = R_PointToAngle2 (lookee->x, - lookee->y, - other->x, - other->y) - - lookee->angle; - - if (an > ANG90 && an < ANG270) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (lookee->LookExMinDist || dist > MELEERANGE) - continue; // behind back - } - } - } - - return other; - } - return NULL; -} - -bool P_NewLookTID (AActor *actor, angle_t fov, fixed_t mindist, fixed_t maxdist, bool chasegoal) -{ - AActor *other; - - actor->LookExMinDist = mindist; - actor->LookExMaxDist = maxdist; - actor->LookExFOV = fov; - other = P_BlockmapSearch (actor, 0, LookForTIDinBlockEx); - - bool reachedend = false; - fixed_t dist; - angle_t an; - - if (other != NULL) - { - if (!(actor->flags3 & MF3_NOSIGHTCHECK)) - { - dist = P_AproxDistance (other->x - actor->x, - other->y - actor->y); - - if (maxdist && dist > maxdist) - { - other = NULL; // [KS] too far - goto endcheck; - } - - if (mindist && dist < mindist) - { - other = NULL; // [KS] too close - goto endcheck; - } - - if (fov && fov < ANGLE_MAX) - { - an = R_PointToAngle2 (actor->x, - actor->y, - other->x, - other->y) - - actor->angle; - - if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (mindist || dist > MELEERANGE) - { - other = NULL; // outside of fov - goto endcheck; - } - } - } - else - { - if(!((actor->flags4 & MF4_LOOKALLAROUND) || (fov >= ANGLE_MAX))) // Just in case angle_t doesn't clamp stuff, because I can't be too sure. - { - an = R_PointToAngle2 (actor->x, - actor->y, - other->x, - other->y) - - actor->angle; - - if (an > ANG90 && an < ANG270) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (mindist || dist > MELEERANGE) - { - other = NULL; // behind back - goto endcheck; - } - } - } - } - } - } - - endcheck: - - if (other != NULL) - { - if (actor->goal && actor->target == actor->goal) - actor->reactiontime = 0; - - actor->target = other; - actor->LastLookActor = other; - return true; - } - - // The actor's TID could change because of death or because of - // Thing_ChangeTID. If it's not what we expect, then don't use - // it as a base for the iterator. - if (actor->LastLookActor != NULL && - actor->LastLookActor->tid != actor->TIDtoHate) - { - actor->LastLookActor = NULL; - } - - FActorIterator iterator (actor->TIDtoHate, actor->LastLookActor); - int c = (pr_look3() & 31) + 7; // Look for between 7 and 38 hatees at a time - while ((other = iterator.Next()) != actor->LastLookActor) - { - if (other == NULL) - { - if (reachedend) - { - // we have cycled through the entire list at least once - // so let's abort because even if we continue nothing can - // be found. - break; - } - reachedend = true; - continue; - } - - if (!(other->flags & MF_SHOOTABLE)) - continue; // not shootable (observer or dead) - - if (other == actor) - continue; // don't hate self - - if (other->health <= 0) - continue; // dead - - if (other->flags2 & MF2_DORMANT) - continue; // don't target dormant things - - if (--c == 0) - break; - - if (!(actor->flags3 & MF3_NOSIGHTCHECK)) - { - if (!P_CheckSight (actor, other, 2)) - continue; // out of sight - - dist = P_AproxDistance (other->x - actor->x, - other->y - actor->y); - - if (maxdist && dist > maxdist) - continue; // [KS] too far - - if (mindist && dist < mindist) - continue; // [KS] too close - - if (fov && fov < ANGLE_MAX) - { - an = R_PointToAngle2 (actor->x, - actor->y, - other->x, - other->y) - - actor->angle; - - if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (mindist || dist > MELEERANGE) - continue; // outside of fov - } - } - else - { - if(!((actor->flags4 & MF4_LOOKALLAROUND) || (fov >= ANGLE_MAX))) // Just in case angle_t doesn't clamp stuff, because I can't be too sure. - { - an = R_PointToAngle2 (actor->x, - actor->y, - other->x, - other->y) - - actor->angle; - - if (an > ANG90 && an < ANG270) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (mindist || dist > MELEERANGE) - continue; // behind back - } - } - } - } - - // [RH] Need to be sure the reactiontime is 0 if the monster is - // leaving its goal to go after something else. - if (actor->goal && actor->target == actor->goal) - actor->reactiontime = 0; - - actor->target = other; - actor->LastLookActor = other; - return true; - } - actor->LastLookActor = other; - if (actor->target == NULL) - { - // [RH] use goal as target - if (actor->goal != NULL && chasegoal) - { - actor->target = actor->goal; - return true; - } - // Use last known enemy if no hatee sighted -- killough 2/15/98: - if (actor->lastenemy != NULL && actor->lastenemy->health > 0) - { - if (!actor->IsFriend(actor->lastenemy)) - { - actor->target = actor->lastenemy; - actor->lastenemy = NULL; - return true; - } - else - { - actor->lastenemy = NULL; - } - } - } - return false; -} - -bool P_NewLookEnemies (AActor *actor, angle_t fov, fixed_t mindist, fixed_t maxdist, bool chasegoal) -{ - AActor *other; - - actor->LookExMinDist = mindist; - actor->LookExMaxDist = maxdist; - actor->LookExFOV = fov; - other = P_BlockmapSearch (actor, 10, LookForEnemiesInBlockEx); - - if (other != NULL) - { - if (actor->goal && actor->target == actor->goal) - actor->reactiontime = 0; - - actor->target = other; -// actor->LastLook.Actor = other; - return true; - } - - if (actor->target == NULL) - { - // [RH] use goal as target - if (actor->goal != NULL) - { - actor->target = actor->goal; - return true; - } - // Use last known enemy if no hatee sighted -- killough 2/15/98: - if (actor->lastenemy != NULL && actor->lastenemy->health > 0) - { - if (!actor->IsFriend(actor->lastenemy)) - { - actor->target = actor->lastenemy; - actor->lastenemy = NULL; - return true; - } - else - { - actor->lastenemy = NULL; - } - } - } - return false; -} - -bool P_NewLookPlayers (AActor *actor, angle_t fov, fixed_t mindist, fixed_t maxdist, bool chasegoal) -{ - int c; - int stop; - int pnum; - player_t* player; - angle_t an; - fixed_t dist; - - if (actor->TIDtoHate != 0) - { - if (P_NewLookTID (actor, fov, mindist, maxdist, chasegoal)) - { - return true; - } - if (!(actor->flags3 & MF3_HUNTPLAYERS)) - { - return false; - } - } - else if (actor->flags & MF_FRIENDLY) - { - if (!deathmatch) // [SP] If you don't see any enemies in deathmatch, look for players. - return P_NewLookEnemies (actor, fov, mindist, maxdist, chasegoal); - else if ( P_NewLookEnemies (actor, fov, mindist, maxdist, chasegoal) ) - return true; - } // [SP] if false, and in deathmatch, intentional fall-through - - if (!(gameinfo.gametype & (GAME_DoomStrifeChex)) && - !multiplayer && - players[0].health <= 0) - { // Single player game and player is dead; look for monsters - return P_LookForMonsters (actor); - } - - c = 0; - if (actor->TIDtoHate != 0) - { - pnum = pr_look2() & (MAXPLAYERS-1); - } - else - { - pnum = actor->LastLookPlayerNumber; - } - stop = (pnum - 1) & (MAXPLAYERS-1); - - for (;;) - { - pnum = (pnum + 1) & (MAXPLAYERS-1); - if (!playeringame[pnum]) - continue; - - if (actor->TIDtoHate == 0) - { - actor->LastLookPlayerNumber = pnum; - } - - if (++c == MAXPLAYERS-1 || pnum == stop) - { - // done looking - if (actor->target == NULL) - { - // [RH] use goal as target - // [KS] ...unless we're ignoring goals and we don't already have one - if (actor->goal != NULL && chasegoal) - { - actor->target = actor->goal; - return true; - } - // Use last known enemy if no players sighted -- killough 2/15/98: - if (actor->lastenemy != NULL && actor->lastenemy->health > 0) - { - if (!actor->IsFriend(actor->lastenemy)) - { - actor->target = actor->lastenemy; - actor->lastenemy = NULL; - return true; - } - else - { - actor->lastenemy = NULL; - } - } - } - return actor->target == actor->goal && actor->goal != NULL; - } - - player = &players[pnum]; - - if (!(player->mo->flags & MF_SHOOTABLE)) - continue; // not shootable (observer or dead) - - if (player->cheats & CF_NOTARGET) - continue; // no target - - if (player->health <= 0) - continue; // dead - - if (!P_CheckSight (actor, player->mo, 2)) - continue; // out of sight - - dist = P_AproxDistance (player->mo->x - actor->x, - player->mo->y - actor->y); - - if (maxdist && dist > maxdist) - continue; // [KS] too far - - if (mindist && dist < mindist) - continue; // [KS] too close - - // [SP] Deathmatch fixes - if we have MF_FRIENDLY we're definitely in deathmatch - // We're going to ignore our master, but go after his enemies. - if ( actor->flags & MF_FRIENDLY ) - { - if ( actor->FriendPlayer == 0 ) - continue; // I have no friends, I will ignore players. - if ( actor->FriendPlayer == player->mo->FriendPlayer ) - continue; // This is my master. - } - - if (fov) - { - an = R_PointToAngle2 (actor->x, - actor->y, - player->mo->x, - player->mo->y) - - actor->angle; - - if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (mindist || dist > MELEERANGE) - continue; // outside of fov - } - } - else - { - if(!((actor->flags4 & MF4_LOOKALLAROUND) || (fov >= ANGLE_MAX))) - { - an = R_PointToAngle2 (actor->x, - actor->y, - player->mo->x, - player->mo->y) - - actor->angle; - - if (an > ANG90 && an < ANG270) - { - // if real close, react anyway - // [KS] but respect minimum distance rules - if (mindist || dist > MELEERANGE) - continue; // behind back - } - } - } - if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) || - player->mo->flags3 & MF3_GHOST) - { - if ((P_AproxDistance (player->mo->x - actor->x, - player->mo->y - actor->y) > 2*MELEERANGE) - && P_AproxDistance (player->mo->velx, player->mo->vely) - < 5*FRACUNIT) - { // Player is sneaking - can't detect - return false; - } - if (pr_lookforplayers() < 225) - { // Player isn't sneaking, but still didn't detect - return false; - } - } - - // [RH] Need to be sure the reactiontime is 0 if the monster is - // leaving its goal to go after a player. - if (actor->goal && actor->target == actor->goal) - actor->reactiontime = 0; - - actor->target = player->mo; - return true; - } -} - -// -// ACTION ROUTINES -// - -// -// A_Look -// Stay in state until a player is sighted. -// [RH] Will also leave state to move to goal. -// -// A_LookEx (int flags, fixed minseedist, fixed maxseedist, fixed maxheardist, fixed fov, state wakestate) -// [KS] Borrowed the A_Look code to make a parameterized version. -// - -enum LO_Flags -{ - LOF_NOSIGHTCHECK = 1, - LOF_NOSOUNDCHECK = 2, - LOF_DONTCHASEGOAL = 4, - LOF_NOSEESOUND = 8, - LOF_FULLVOLSEESOUND = 16, -}; - -DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) -{ - ACTION_PARAM_START(6); - ACTION_PARAM_INT(flags, 0); - ACTION_PARAM_FIXED(minseedist, 1); - ACTION_PARAM_FIXED(maxseedist, 2); - ACTION_PARAM_FIXED(maxheardist, 3); - ACTION_PARAM_ANGLE(fov, 4); - ACTION_PARAM_STATE(seestate, 5); - - AActor *targ = NULL; // Shuts up gcc - fixed_t dist; - - if (self->flags5 & MF5_INCONVERSATION) - return; - - // [RH] Set goal now if appropriate - if (self->special == Thing_SetGoal && self->args[0] == 0) - { - NActorIterator iterator (NAME_PatrolPoint, self->args[1]); - self->special = 0; - self->goal = iterator.Next (); - self->reactiontime = self->args[2] * TICRATE + level.maptime; - if (self->args[3] == 0) self->flags5 &=~ MF5_CHASEGOAL; - else self->flags5 |= MF5_CHASEGOAL; - } - - self->threshold = 0; // any shot will wake up - - if (self->TIDtoHate != 0) - { - targ = self->target; - } - else - { - if (!(flags & LOF_NOSOUNDCHECK)) - { - targ = self->LastHeard; - if (targ != NULL) - { - // [RH] If the soundtarget is dead, don't chase it - if (targ->health <= 0) - { - targ = NULL; - } - else - { - dist = P_AproxDistance (targ->x - self->x, - targ->y - self->y); - - // [KS] If the target is too far away, don't respond to the sound. - if (maxheardist && dist > maxheardist) - { - targ = NULL; - self->LastHeard = NULL; - } - } - } - } - - if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) - { - return; - } - } - - // [RH] Andy Baker's stealth monsters - if (self->flags & MF_STEALTH) - { - self->visdir = -1; - } - - if (targ && (targ->flags & MF_SHOOTABLE)) - { - if (self->IsFriend (targ)) // be a little more precise! - { - if (!(self->flags4 & MF4_STANDSTILL)) - { - if (!(flags & LOF_NOSIGHTCHECK)) - { - // If we find a valid target here, the wandering logic should *not* - // be activated! If would cause the seestate to be set twice. - if (P_NewLookPlayers(self, fov, minseedist, maxseedist, !(flags & LOF_DONTCHASEGOAL))) - goto seeyou; - } - - // Let the self wander around aimlessly looking for a fight - if (!(self->flags & MF_INCHASE)) - { - if (seestate) - { - self->SetState (seestate); - } - else - { - if (self->SeeState != NULL) - { - self->SetState (self->SeeState); - } - else - { - CALL_ACTION(A_Wander, self); - } - } - } - } - } - else - { - self->target = targ; //We already have a target? - - // [KS] The target can become ourselves in rare circumstances (like - // if we committed suicide), so if that's the case, just ignore it. - if (self->target == self) self->target = NULL; - - if (self->target != NULL) - { - if (self->flags & MF_AMBUSH) - { - dist = P_AproxDistance (self->target->x - self->x, - self->target->y - self->y); - if (P_CheckSight (self, self->target, 2) && - (!minseedist || dist > minseedist) && - (!maxseedist || dist < maxseedist)) - { - goto seeyou; - } - } - else - goto seeyou; - } - } - } - - if (!(flags & LOF_NOSIGHTCHECK)) - { - if (!P_NewLookPlayers(self, fov, minseedist, maxseedist, !(flags & LOF_DONTCHASEGOAL))) - return; - } - else - { - return; - } - - // go into chase state - seeyou: - // [RH] Don't start chasing after a goal if it isn't time yet. - if (self->target == self->goal) - { - if (self->reactiontime > level.maptime) - self->target = NULL; - } - else if (self->SeeSound && !(flags & LOF_NOSEESOUND)) - { - if (flags & LOF_FULLVOLSEESOUND) - { // full volume - S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NONE); - } - else - { - S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM); - } - } - - if (self->target && !(self->flags & MF_INCHASE)) - { - if (seestate) - { - self->SetState (seestate); - } - else - { - self->SetState (self->SeeState); - } - } -} - -// [KS] *** End additions by me *** diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 03d489b8d..b508d8f55 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -882,6 +882,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage int painchance = 0; FState * woundstate = NULL; PainChanceList * pc = NULL; + bool justhit = false; if (target == NULL || !((target->flags & MF_SHOOTABLE) || (target->flags6 & MF6_VULNERABLE))) { // Shouldn't happen @@ -893,12 +894,6 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage { if (inflictor == NULL || !(inflictor->flags4 & MF4_SPECTRAL)) { - /* - if (target->MissileState != NULL) - { - target->SetState (target->MissileState); - } - */ return; } } @@ -1285,7 +1280,7 @@ dopain: { if (pr_lightning() < 96) { - target->flags |= MF_JUSTHIT; // fight back! + justhit = true; FState * painstate = target->FindState(NAME_Pain, mod); if (painstate != NULL) target->SetState (painstate); } @@ -1300,7 +1295,7 @@ dopain: } else { - target->flags |= MF_JUSTHIT; // fight back! + justhit = true; FState * painstate = target->FindState(NAME_Pain, mod); if (painstate != NULL) target->SetState (painstate); if (mod == NAME_PoisonCloud) @@ -1345,6 +1340,11 @@ dopain: } } } + + // killough 11/98: Don't attack a friend, unless hit by that friend. + if (justhit && (target->target == source || !target->target || !target->IsFriend(target->target))) + target->flags |= MF_JUSTHIT; // fight back! + } bool AActor::OkayToSwitchTarget (AActor *other) diff --git a/src/p_local.h b/src/p_local.h index 1ac7687e3..71a662fb7 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -320,7 +320,7 @@ public: #define PT_ADDLINES 1 #define PT_ADDTHINGS 2 -AActor *P_BlockmapSearch (AActor *origin, int distance, AActor *(*func)(AActor *, int)); +AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, int, void *), void *params = NULL); AActor *P_RoughMonsterSearch (AActor *mo, int distance); // diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 2d8e8a515..d4ea1bdf9 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -40,7 +40,7 @@ #include "r_state.h" #include "templates.h" -static AActor *RoughBlockCheck (AActor *mo, int index); +static AActor *RoughBlockCheck (AActor *mo, int index, void *); //========================================================================== @@ -1278,7 +1278,7 @@ AActor *P_RoughMonsterSearch (AActor *mo, int distance) return P_BlockmapSearch (mo, distance, RoughBlockCheck); } -AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, int)) +AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, int, void *), void *params) { int blockX; int blockY; @@ -1297,7 +1297,7 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in if (startX >= 0 && startX < bmapwidth && startY >= 0 && startY < bmapheight) { - if ( (target = check (mo, startY*bmapwidth+startX)) ) + if ( (target = check (mo, startY*bmapwidth+startX, params)) ) { // found a target right away return target; } @@ -1334,7 +1334,7 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in // Trace the first block section (along the top) for (; blockIndex <= firstStop; blockIndex++) { - if ( (target = check (mo, blockIndex)) ) + if ( (target = check (mo, blockIndex, params)) ) { return target; } @@ -1342,7 +1342,7 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in // Trace the second block section (right edge) for (blockIndex--; blockIndex <= secondStop; blockIndex += bmapwidth) { - if ( (target = check (mo, blockIndex)) ) + if ( (target = check (mo, blockIndex, params)) ) { return target; } @@ -1350,7 +1350,7 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in // Trace the third block section (bottom edge) for (blockIndex -= bmapwidth; blockIndex >= thirdStop; blockIndex--) { - if ( (target = check (mo, blockIndex)) ) + if ( (target = check (mo, blockIndex, params)) ) { return target; } @@ -1358,7 +1358,7 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in // Trace the final block section (left edge) for (blockIndex++; blockIndex > finalStop; blockIndex -= bmapwidth) { - if ( (target = check (mo, blockIndex)) ) + if ( (target = check (mo, blockIndex, params)) ) { return target; } @@ -1373,7 +1373,7 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in // //=========================================================================== -static AActor *RoughBlockCheck (AActor *mo, int index) +static AActor *RoughBlockCheck (AActor *mo, int index, void *) { FBlockNode *link; diff --git a/zdoom.vcproj b/zdoom.vcproj index 2b0c1b899..935090979 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - @@ -966,7 +962,7 @@ /> + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + @@ -1864,14 +1868,6 @@ Outputs="$(IntDir)/$(InputName).obj" /> - - - @@ -2061,14 +2057,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -2079,6 +2067,14 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + - - - + + + - - - @@ -5391,6 +5379,14 @@ AdditionalIncludeDirectories="src\win32;$(NoInherit)" /> + + + @@ -5669,7 +5665,7 @@ /> Date: Wed, 16 Sep 2009 15:57:08 +0000 Subject: [PATCH 05/27] - Gez's misc. bugs patch: * Moves the dog sound out of the Doom-specific sounds in SNDINFO to address this, * Renames the dog actor to MBFHelperDog to prevent name conflicts, * Adds APROP_Score to CheckActorProperty, * Completes the randomspawner update (the reason I moved the recursion counter out of special1 was that I found some projectiles had this set to them, for example in A_LichAttack, but I forgot to add transfer for them), * Provides centered sprites for beta plasma balls if this is deemed deserving correction. SVN r1847 (trunk) --- docs/rh-log.txt | 8 ++++++++ src/g_shared/a_pickups.cpp | 5 +---- src/g_shared/a_pickups.h | 2 +- src/g_shared/a_randomspawner.cpp | 2 ++ src/p_acs.cpp | 1 + wadsrc/static/actors/doom/dog.txt | 2 +- wadsrc/static/sndinfo.txt | 14 +++++++------- wadsrc/static/sprites/PLS1A0.png | Bin 329 -> 329 bytes wadsrc/static/sprites/PLS1B0.png | Bin 332 -> 332 bytes wadsrc/static/sprites/PLS1C0.png | Bin 329 -> 329 bytes wadsrc/static/sprites/PLS1D0.png | Bin 331 -> 331 bytes wadsrc/static/sprites/PLS1E0.png | Bin 843 -> 843 bytes wadsrc/static/sprites/PLS1F0.png | Bin 844 -> 844 bytes wadsrc/static/sprites/PLS1G0.png | Bin 581 -> 581 bytes wadsrc/static/sprites/PLS2A0.png | Bin 273 -> 273 bytes wadsrc/static/sprites/PLS2B0.png | Bin 261 -> 261 bytes wadsrc/static/sprites/PLS2C0.png | Bin 297 -> 297 bytes wadsrc/static/sprites/PLS2D0.png | Bin 253 -> 253 bytes wadsrc/static/sprites/PLS2E0.png | Bin 267 -> 267 bytes 19 files changed, 21 insertions(+), 13 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 89fc05c25..e8325e4a3 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,12 @@ September 16, 2009 (Changes by Graf Zahl) +- Gez's misc. bugs patch: +* Moves the dog sound out of the Doom-specific sounds in SNDINFO to address this, +* Renames the dog actor to MBFHelperDog to prevent name conflicts, +* Adds APROP_Score to CheckActorProperty, +* Completes the randomspawner update (the reason I moved the recursion counter out of + special1 was that I found some projectiles had this set to them, for example in + A_LichAttack, but I forgot to add transfer for them), +* Provides centered sprites for beta plasma balls if this is deemed deserving correction. - Added some pieces of MBF's friendly AI. - Cleaned up A_LookEx code and merged most of it with the base functions. The major difference was a common piece of code that was repeated 5 times diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 045e5bf92..e9d9e2003 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -1741,10 +1741,7 @@ IMPLEMENT_CLASS(AScoreItem) // // AScoreItem :: TryPickup // -// This function does nothing much. Theoretically, the player could have a -// score property which would be incremented by the score items' own score -// property (probably using the Amount property for that), but that is not -// needed for the moment. +// Adds the value (Amount) of the item to the toucher's Score property. // //=========================================================================== diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 6ccc8cd5e..8832161d1 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -477,7 +477,7 @@ public: // A score item is picked up without being added to the inventory. -// Contrarily to FakeInventory, it does nothing. +// It differs from FakeInventory by doing nothing more than increasing the player's score. class AScoreItem : public AInventory { DECLARE_CLASS (AScoreItem, AInventory) diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index b4b9176ae..a5ffa9251 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -111,6 +111,8 @@ class ARandomSpawner : public AActor newmobj->args[2] = args[2]; newmobj->args[3] = args[3]; newmobj->args[4] = args[4]; + newmobj->special1 = special1; + newmobj->special2 = special2; newmobj->SpawnFlags = SpawnFlags; newmobj->HandleSpawnFlags(); newmobj->tid = tid; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index e45f92752..3f24ad0ed 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2684,6 +2684,7 @@ int DLevelScript::CheckActorProperty (int tid, int property, int value) case APROP_Gravity: case APROP_SpawnHealth: case APROP_JumpZ: + case APROP_Score: return (GetActorProperty(tid, property) == value); // Boolean values need to compare to a binary version of value diff --git a/wadsrc/static/actors/doom/dog.txt b/wadsrc/static/actors/doom/dog.txt index ea1e72231..0feb393f5 100644 --- a/wadsrc/static/actors/doom/dog.txt +++ b/wadsrc/static/actors/doom/dog.txt @@ -1,4 +1,4 @@ -ACTOR Dog 888 +ACTOR MBFHelperDog 888 { Game Doom Health 500 diff --git a/wadsrc/static/sndinfo.txt b/wadsrc/static/sndinfo.txt index 2838be889..c8840310e 100644 --- a/wadsrc/static/sndinfo.txt +++ b/wadsrc/static/sndinfo.txt @@ -50,6 +50,13 @@ misc/icebreak icebrk1a // Retail Doom and Strife use 200. $rolloff * 200 1200 +// Marine's Best Friend -- not just for marines anymore! +dog/active dsdgact +dog/attack dsdgatk +dog/death dsdgdth +dog/pain dsdgpain +dog/sight dsdgsit + /****************************************************************************/ /* */ /* DOOM SOUNDS */ @@ -425,13 +432,6 @@ brain/cube dsboscub brain/cubeboom dsfirxpl $alias brain/spawn misc/teleport -// Marine's Best Friend -dog/active dsdgact -dog/attack dsdgatk -dog/death dsdgdth -dog/pain dsdgpain -dog/sight dsdgsit - //============================================================================ // diff --git a/wadsrc/static/sprites/PLS1A0.png b/wadsrc/static/sprites/PLS1A0.png index b1617e46cd4cbfdf9bf80fe4d3f78d97c5a16042..029d0bc75d1f903a2d912beb0b7842ad3f02e11b 100644 GIT binary patch delta 15 XcmX@fbdqU8D=Wty@pV%tcI^iMF#HCo delta 15 WcmX@fbdqU8D=W|Ls;r)gUHbts?*_sE diff --git a/wadsrc/static/sprites/PLS1B0.png b/wadsrc/static/sprites/PLS1B0.png index 40b628f13f01df44a78fd6166fb1a6ad0e44ef6b..d50f0d7d545e7ea06fce2e685849e0707fd61d27 100644 GIT binary patch delta 15 WcmX@ZbcSg{D=SB1dAsVwu0sGXa|S>F delta 15 WcmX@ZbcSg{D=SZ%l(Wsmu0sGUkOjX0 diff --git a/wadsrc/static/sprites/PLS1C0.png b/wadsrc/static/sprites/PLS1C0.png index b1617e46cd4cbfdf9bf80fe4d3f78d97c5a16042..029d0bc75d1f903a2d912beb0b7842ad3f02e11b 100644 GIT binary patch delta 15 XcmX@fbdqU8D=Wty@pV%tcI^iMF#HCo delta 15 WcmX@fbdqU8D=W|Ls;r)gUHbts?*_sE diff --git a/wadsrc/static/sprites/PLS1D0.png b/wadsrc/static/sprites/PLS1D0.png index 98dfeb0dcc28f4ca47a3c5f63e27d4fb008d362d..ed08ba37135f1b18c42d17fcd8f6e660e086fb7d 100644 GIT binary patch delta 15 WcmX@jbed^GD=SB1dAsVwu7dzCRt7x) delta 15 WcmX@jbed^GD=SZ%l(Wsmu7dz9a|OHr diff --git a/wadsrc/static/sprites/PLS1E0.png b/wadsrc/static/sprites/PLS1E0.png index dca03ceff306789d3211a0e57ede2e0b7c47f23a..a3a688631bb903190adcb37594454052ccb0090d 100644 GIT binary patch delta 16 YcmX@jcA9NM0jtQ@X+AGDmR@5506g0Vc>n+a delta 16 YcmX@jcA9NM0juf~51&gLORq5j061I*)c^nh diff --git a/wadsrc/static/sprites/PLS1F0.png b/wadsrc/static/sprites/PLS1F0.png index e43de905fed032ab923fa8f0de63b74f1fc0a227..dbacdc85aae939d4eece16f53073856b21291571 100644 GIT binary patch delta 16 YcmX@Zc7|<20jtQ@X+AGDmR@H906hB#d;kCd delta 16 YcmX@Zc7|<20juf~51&gLORqBl062UG*Z=?k diff --git a/wadsrc/static/sprites/PLS1G0.png b/wadsrc/static/sprites/PLS1G0.png index 5a2c9db1da4a8267581dada9c702926f9923ddaa..fef4459d2072a181c96e55001662107057910663 100644 GIT binary patch delta 16 XcmX@ga+GC4BCA-8MYzbuwEK(zFa!ma delta 16 XcmX@ga+GC4BCA$$xc20YY4;fcGrR^e diff --git a/wadsrc/static/sprites/PLS2A0.png b/wadsrc/static/sprites/PLS2A0.png index bc82af045788035af80ead0f1b17e44c5509a9d6..cab771a20cc4839fe632d9c274397eb8430c4273 100644 GIT binary patch delta 15 XcmbQpG?8h-L{|27KUA(xoK_70E>Z@S delta 15 XcmbQpG?8h-L{_c~o)H-nr&R+0Dvkxx diff --git a/wadsrc/static/sprites/PLS2B0.png b/wadsrc/static/sprites/PLS2B0.png index 5e187595307ec9a3d546c29522a8a5f90b804e70..324b02b18710e1f11c49c7e49181d95e572f9c1e 100644 GIT binary patch delta 15 WcmZo=YGs-GqITyH&y@uDK!Ol delta 15 XcmZ3Smgd#mb$uul4`L{5b$CGzMh= delta 15 WcmeBX>Smgd#VYXPwvX_{{5b$B=LP5h From 5822729943e5ae4c7bc13215f74922edc2e36bee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 16 Sep 2009 21:03:09 +0000 Subject: [PATCH 06/27] - Fixed: The deprecated flag handler for the old bounce flags needs to clear BOUNCE_MBF and BOUNCE_UseSeeSound, too, when clearing one of these flags. - Fixed: When adding the AVOIDMELEE code the code was accidentally changed so that friendly monsters could no longer acquire targets by themselves. - Renamed WIF_BOT_MELEE to WIF_MELEEWEAPON because it's no longer a bot only flag. - Added MBF's monster_backing feature as an actor flag: AVOIDMELEE. SVN r1848 (trunk) --- docs/rh-log.txt | 6 +++++ src/actor.h | 3 ++- src/b_bot.cpp | 1 - src/b_func.cpp | 2 +- src/b_move.cpp | 2 +- src/g_shared/a_pickups.h | 2 +- src/p_enemy.cpp | 23 +++++++++++-------- src/p_mobj.cpp | 1 + src/textures/tgatexture.cpp | 8 +++++-- src/thingdef/thingdef_data.cpp | 3 ++- src/thingdef/thingdef_properties.cpp | 6 ++--- src/version.h | 2 +- wadsrc/static/actors/heretic/hereticweaps.txt | 1 + 13 files changed, 38 insertions(+), 22 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index e8325e4a3..bd48ce1ce 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,10 @@ September 16, 2009 (Changes by Graf Zahl) +- Fixed: The deprecated flag handler for the old bounce flags needs to clear + BOUNCE_MBF and BOUNCE_UseSeeSound, too, when clearing one of these flags. +- Fixed: When adding the AVOIDMELEE code the code was accidentally changed so that + friendly monsters could no longer acquire targets by themselves. +- Renamed WIF_BOT_MELEE to WIF_MELEEWEAPON because it's no longer a bot only flag. +- Added MBF's monster_backing feature as an actor flag: AVOIDMELEE. - Gez's misc. bugs patch: * Moves the dog sound out of the Doom-specific sounds in SNDINFO to address this, * Renames the dog actor to MBFHelperDog to prevent name conflicts, diff --git a/src/actor.h b/src/actor.h index d2ecf4ef9..b490aeade 100644 --- a/src/actor.h +++ b/src/actor.h @@ -399,7 +399,7 @@ enum EBounceFlags // for them that are not present in ZDoom, so it is necessary to identify it properly. BOUNCE_MBF = 1<<12, // This in itself is not a valid mode, but replaces MBF's MF_BOUNCE flag. - BOUNCE_TypeMask = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff | BOUNCE_HereticType, + BOUNCE_TypeMask = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff | BOUNCE_HereticType | BOUNCE_MBF, // The three "standard" types of bounciness are: // HERETIC - Missile will only bounce off the floor once and then enter @@ -760,6 +760,7 @@ public: BYTE movedir; // 0-7 SBYTE visdir; SWORD movecount; // when 0, select a new dir + SWORD strafecount; // for MF3_AVOIDMELEE TObjPtr target; // thing being chased/attacked (or NULL) // also the originator for missiles TObjPtr lastenemy; // Last known enemy -- killough 2/15/98 diff --git a/src/b_bot.cpp b/src/b_bot.cpp index b03c067f7..3911264cd 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -136,7 +136,6 @@ void InitBotStuff() { "SkullRod", 27000000, 0, "HornRodFX1" }, { "SkullRodPowered", 27000000, 0, "HornRodFX2" }, { "PhoenixRod", 18350080, WIF_BOT_REACTION_SKILL_THING|WIF_BOT_EXPLOSIVE, "PhoenixFX1" }, - { "PhoenixRodPowered", 0, WIF_BOT_MELEE, "PhoenixFX2" }, { "Mace", 27000000, WIF_BOT_REACTION_SKILL_THING, "MaceFX2" }, { "MacePowered", 27000000, WIF_BOT_REACTION_SKILL_THING|WIF_BOT_EXPLOSIVE, "MaceFX4" }, { "FWeapHammer", 22000000, 0, "HammerMissile" }, diff --git a/src/b_func.cpp b/src/b_func.cpp index 5da2e8e2c..adaa755c2 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -175,7 +175,7 @@ void FCajunMaster::Dofire (AActor *actor, ticcmd_t *cmd) (actor->y + actor->vely) - (enemy->y + enemy->vely)); //FIRE EACH TYPE OF WEAPON DIFFERENT: Here should all the different weapons go. - if (actor->player->ReadyWeapon->WeaponFlags & WIF_BOT_MELEE) + if (actor->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON) { if ((actor->player->ReadyWeapon->ProjectileType != NULL)) { diff --git a/src/b_move.cpp b/src/b_move.cpp index 896ce9342..332160f1a 100644 --- a/src/b_move.cpp +++ b/src/b_move.cpp @@ -342,7 +342,7 @@ void FCajunMaster::TurnToAng (AActor *actor) if(actor->player->enemy) if(!actor->player->dest) //happens when running after item in combat situations, or normal, prevents weak turns - if(actor->player->ReadyWeapon->ProjectileType == NULL && !(actor->player->ReadyWeapon->WeaponFlags & WIF_BOT_MELEE)) + if(actor->player->ReadyWeapon->ProjectileType == NULL && !(actor->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON)) if(Check_LOS(actor, actor->player->enemy, SHOOTFOV+5*ANGLE_1)) maxturn = 3; } diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 8832161d1..b402fcf59 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -322,6 +322,7 @@ enum WIF_NO_AUTO_SWITCH = 0x00001000, // never switch to this weapon when it's picked up WIF_STAFF2_KICKBACK = 0x00002000, // the powered-up Heretic staff has special kickback WIF_NOAUTOAIM = 0x00004000, // this weapon never uses autoaim (useful for ballistic projectiles) + WIF_MELEEWEAPON = 0x00008000, // melee weapon. Used by bots and monster AI. WIF_CHEATNOTWEAPON = 0x08000000, // Give cheat considers this not a weapon (used by Sigil) @@ -329,7 +330,6 @@ enum WIF_BOT_REACTION_SKILL_THING = 1<<31, // I don't understand this WIF_BOT_EXPLOSIVE = 1<<30, // weapon fires an explosive - WIF_BOT_MELEE = 1<<29, // melee weapon WIF_BOT_BFG = 1<<28, // this is a BFG }; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 9937eefa5..d2a1e1c60 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -65,6 +65,7 @@ static FRandom pr_dropoff ("Dropoff"); static FRandom pr_defect ("Defect"); static FRandom pr_skiptarget("SkipTarget"); +static FRandom pr_enemystrafe("EnemyStrafe"); // movement interpolation is fine for objects that are moved by their own // velocity. But for monsters it is problematic. @@ -772,9 +773,7 @@ void P_NewChaseDir(AActor * actor) fixed_t deltax; fixed_t deltay; -#ifdef MBF_STUFF actor->strafecount = 0; -#endif if ((actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal!=NULL) { @@ -882,15 +881,16 @@ void P_NewChaseDir(AActor * actor) else #endif -#ifdef MBF_STUFF // MBF's monster_backing option. Made an actor flag instead. Also cleaned the code up to make it readable. // Todo: implement the movement logic + AActor *target = actor->target; if (target->health > 0 && !actor->IsFriend(target)) { // Live enemy target if (actor->flags3 & MF3_AVOIDMELEE) { bool ismeleeattacker = false; + fixed_t dist = P_AproxDistance(actor->x-target->x, actor->y-target->y); if (target->player == NULL) { ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->radius)*2); @@ -899,7 +899,7 @@ void P_NewChaseDir(AActor * actor) { // melee range of player weapon is a parameter of the action function and cannot be checked here. // Add a new weapon property? - ismeleeattacker = (target->player->ReadyWeapon->WeaponFlags & WIF_BOT_MELEE && dist < MELEERANGE*3); + ismeleeattacker = (target->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON && dist < MELEERANGE*3); } if (ismeleeattacker) { @@ -908,18 +908,14 @@ void P_NewChaseDir(AActor * actor) } } } -#endif - P_DoNewChaseDir(actor, deltax, deltay); -#ifdef MBF_STUFF // If strafing, set movecount to strafecount so that old Doom // logic still works the same, except in the strafing part if (actor->strafecount) actor->movecount = actor->strafecount; -#endif } @@ -1566,7 +1562,7 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) } #endif // [SP] If you don't see any enemies in deathmatch, look for players (but only when friend to a specific player.) - if (actor->FriendPlayer == 0) return false; + if (actor->FriendPlayer == 0) return result; if (result || !deathmatch) return true; @@ -2156,7 +2152,11 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi } // turn towards movement direction if not there yet - if (actor->movedir < 8) + if (actor->strafecount) + { + A_FaceTarget(actor); + } + else if (actor->movedir < 8) { actor->angle &= (angle_t)(7<<29); delta = actor->angle - (actor->movedir << 29); @@ -2404,6 +2404,9 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi // chase towards player // + if (actor->strafecount) + actor->strafecount--; + // class bosses don't do this when strafing if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove) { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f3313e778..326b5c962 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -240,6 +240,7 @@ void AActor::Serialize (FArchive &arc) << movedir << visdir << movecount + << strafecount << target << lastenemy << LastHeard diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index 595cef522..41bbb11b8 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -354,12 +354,14 @@ void FTGATexture::MakeTexture () int step_x = (hdr.bpp>>3); int Pitch = Width * step_x; + /* if (hdr.img_desc&32) { ptr += (Width-1) * step_x; step_x =- step_x; } - if (!(hdr.img_desc&64)) + */ + if (!(hdr.img_desc&32)) { ptr += (Height-1) * Pitch; Pitch = -Pitch; @@ -557,12 +559,14 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i int step_x = (hdr.bpp>>3); int Pitch = Width * step_x; + /* if (hdr.img_desc&32) { ptr += (Width-1) * step_x; step_x =- step_x; } - if (!(hdr.img_desc&64)) + */ + if (!(hdr.img_desc&32)) { ptr += (Height-1) * Pitch; Pitch = -Pitch; diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index c65cb5d21..5b207c854 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -141,6 +141,7 @@ static FFlagDef ActorFlags[]= DEFINE_FLAG(MF3, NOTARGET, AActor, flags3), DEFINE_FLAG(MF3, DONTGIB, AActor, flags3), DEFINE_FLAG(MF3, NOBLOCKMONST, AActor, flags3), + DEFINE_FLAG(MF3, AVOIDMELEE, AActor, flags3), DEFINE_FLAG(MF3, FULLVOLDEATH, AActor, flags3), DEFINE_FLAG(MF3, FOILINVUL, AActor, flags3), DEFINE_FLAG(MF3, NOTELEOTHER, AActor, flags3), @@ -295,7 +296,7 @@ static FFlagDef WeaponFlags[] = DEFINE_FLAG(WIF, POWERED_UP, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, STAFF2_KICKBACK, AWeapon, WeaponFlags), DEFINE_FLAG(WIF_BOT, EXPLOSIVE, AWeapon, WeaponFlags), - DEFINE_FLAG2(WIF_BOT_MELEE, MELEEWEAPON, AWeapon, WeaponFlags), + DEFINE_FLAG(WIF, MELEEWEAPON, AWeapon, WeaponFlags), DEFINE_FLAG(WIF_BOT, BFG, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, CHEATNOTWEAPON, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, NO_AUTO_SWITCH, AWeapon, WeaponFlags), diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index f04c6ba8c..4f29d272c 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -130,15 +130,15 @@ void HandleDeprecatedFlags(AActor *defaults, FActorInfo *info, bool set, int ind break; // the bounce flags will set the compatibility bounce modes to remain compatible case DEPF_HERETICBOUNCE: - defaults->BounceFlags &= ~BOUNCE_TypeMask; + defaults->BounceFlags &= ~(BOUNCE_TypeMask|BOUNCE_UseSeeSound); if (set) defaults->BounceFlags |= BOUNCE_HereticCompat; break; case DEPF_HEXENBOUNCE: - defaults->BounceFlags &= ~BOUNCE_TypeMask; + defaults->BounceFlags &= ~(BOUNCE_TypeMask|BOUNCE_UseSeeSound); if (set) defaults->BounceFlags |= BOUNCE_HexenCompat; break; case DEPF_DOOMBOUNCE: - defaults->BounceFlags &= ~BOUNCE_TypeMask; + defaults->BounceFlags &= ~(BOUNCE_TypeMask|BOUNCE_UseSeeSound); if (set) defaults->BounceFlags |= BOUNCE_DoomCompat; break; case DEPF_PICKUPFLASH: diff --git a/src/version.h b/src/version.h index 283bfd413..8896eb713 100644 --- a/src/version.h +++ b/src/version.h @@ -75,7 +75,7 @@ // SAVESIG should match SAVEVER. // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 1823 +#define MINSAVEVER 1848 #if SVN_REVISION_NUMBER < MINSAVEVER // Never write a savegame with a version lower than what we need diff --git a/wadsrc/static/actors/heretic/hereticweaps.txt b/wadsrc/static/actors/heretic/hereticweaps.txt index 93f1f56fb..993da1485 100644 --- a/wadsrc/static/actors/heretic/hereticweaps.txt +++ b/wadsrc/static/actors/heretic/hereticweaps.txt @@ -1034,6 +1034,7 @@ ACTOR PhoenixRodPowered : PhoenixRod native { Game Heretic +WEAPON.POWERED_UP + +WEAPON.MELEEWEAPON Weapon.SisterWeapon "PhoenixRod" Weapon.AmmoGive 0 From 35a4526c1df52e7cdf50df6e722b3f90f7ed3a81 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 16 Sep 2009 22:45:28 +0000 Subject: [PATCH 07/27] - Fixed: A_LookEx did not work for monsters having the MF_NOSECTOR flag. SVN r1849 (trunk) --- docs/rh-log.txt | 1 + src/p_enemy.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index bd48ce1ce..2272627fe 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,5 @@ September 16, 2009 (Changes by Graf Zahl) +- Fixed: A_LookEx did not work for monsters having the MF_NOSECTOR flag. - Fixed: The deprecated flag handler for the old bounce flags needs to clear BOUNCE_MBF and BOUNCE_UseSeeSound, too, when clearing one of these flags. - Fixed: When adding the AVOIDMELEE code the code was accidentally changed so that diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index d2a1e1c60..34ec66558 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1841,6 +1841,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) { if (!(flags & LOF_NOSOUNDCHECK)) { + targ = self->flags & MF_NOSECTOR)? self->Sector->SoundTarget : self->LastHeard; + targ = self->LastHeard; if (targ != NULL) { From f39c5c3b5adefa9929ec605d49e6572d2fd1cb00 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 16 Sep 2009 22:47:04 +0000 Subject: [PATCH 08/27] - Last commit did not work. SVN r1850 (trunk) --- src/p_enemy.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 34ec66558..b6919cb6d 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1842,8 +1842,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) if (!(flags & LOF_NOSOUNDCHECK)) { targ = self->flags & MF_NOSECTOR)? self->Sector->SoundTarget : self->LastHeard; - - targ = self->LastHeard; if (targ != NULL) { // [RH] If the soundtarget is dead, don't chase it From 555f41b0baa60e92122e840ad202ce2bacda52c6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 16 Sep 2009 23:21:16 +0000 Subject: [PATCH 09/27] damn SVN r1851 (trunk) --- src/p_enemy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index b6919cb6d..7e3bb0b26 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1841,7 +1841,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) { if (!(flags & LOF_NOSOUNDCHECK)) { - targ = self->flags & MF_NOSECTOR)? self->Sector->SoundTarget : self->LastHeard; + targ = (self->flags & MF_NOSECTOR)? self->Sector->SoundTarget : self->LastHeard; if (targ != NULL) { // [RH] If the soundtarget is dead, don't chase it From f3f209160e03e273c84f6587eb8598ccf9e7058d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Sep 2009 10:40:38 +0000 Subject: [PATCH 10/27] - Renamed plane flags from SECF_* to PLANEF_*. - Changed Heretic's plat raise type to use a flag to block further sector movement instead of keeping the dead thinker around. SVN r1853 (trunk) --- docs/rh-log.txt | 7 ++++++- src/p_buildmap.cpp | 4 ++-- src/p_ceiling.cpp | 2 +- src/p_doors.cpp | 4 ++-- src/p_floor.cpp | 17 +++++++++-------- src/p_linkedsectors.cpp | 3 ++- src/p_pillar.cpp | 2 +- src/p_plats.cpp | 7 +++++-- src/p_sectors.cpp | 9 +++++++++ src/p_spec.cpp | 4 ++-- src/p_udmf.cpp | 8 ++++---- src/r_bsp.cpp | 4 ++-- src/r_defs.h | 5 ++++- 13 files changed, 49 insertions(+), 27 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 2272627fe..fc665a50c 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +September 17, 2009 (Changes by Graf Zahl) +- Renamed plane flags from SECF_* to PLANEF_*. +- Changed Heretic's plat raise type to use a flag to block further sector movement + instead of keeping the dead thinker around to block the sector. + September 16, 2009 (Changes by Graf Zahl) - Fixed: A_LookEx did not work for monsters having the MF_NOSECTOR flag. - Fixed: The deprecated flag handler for the old bounce flags needs to clear @@ -16897,7 +16902,7 @@ November 14, 2000 into c_cvars.cpp. Virtual inline functions are not inlined and cause the function to be generated for every source file the class is used in. - Fixed bug with Transfer_CeilingLight special. I was or'ing CeilingLight - with SECF_ABSLIGHTING instead of CeilingFlags. + with PLANEF_ABSLIGHTING instead of CeilingFlags. November 11, 2000 - Slopes don't work in mirrors. :-( diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 4e44e1c26..a53491370 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -381,7 +381,7 @@ static void LoadSectors (sectortype *bsec) sec->SetXOffset(sector_t::floor, (bsec->floorxpanning << FRACBITS) + (32 << FRACBITS)); sec->SetYOffset(sector_t::floor, bsec->floorypanning << FRACBITS); sec->SetPlaneLight(sector_t::floor, SHADE2LIGHT (bsec->floorshade)); - sec->ChangeFlags(sector_t::floor, 0, SECF_ABSLIGHTING); + sec->ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); sec->SetPlaneTexZ(sector_t::ceiling, -(LittleLong(bsec->ceilingz) << 8)); sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling); @@ -399,7 +399,7 @@ static void LoadSectors (sectortype *bsec) sec->SetXOffset(sector_t::ceiling, (bsec->ceilingxpanning << FRACBITS) + (32 << FRACBITS)); sec->SetYOffset(sector_t::ceiling, bsec->ceilingypanning << FRACBITS); sec->SetPlaneLight(sector_t::ceiling, SHADE2LIGHT (bsec->ceilingshade)); - sec->ChangeFlags(sector_t::ceiling, 0, SECF_ABSLIGHTING); + sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); sec->lightlevel = (sec->GetPlaneLight(sector_t::floor) + sec->GetPlaneLight(sector_t::ceiling)) / 2; diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 4da11fd04..12f957b47 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -232,7 +232,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, sec = §ors[secnum]; manual_ceiling: // if ceiling already moving, don't start a second function on it - if (sec->ceilingdata) + if (sec->PlaneMoving(sector_t::ceiling)) { if (!manual) continue; diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 090065fb4..c77ded90d 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -394,7 +394,7 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, secnum = int(sec-sectors); // if door already has a thinker, use it - if (sec->ceilingdata) + if (sec->PlaneMoving(sector_t::ceiling)) { if (sec->ceilingdata->IsKindOf (RUNTIME_CLASS(DDoor))) { @@ -447,7 +447,7 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, { sec = §ors[secnum]; // if the ceiling already moving, don't start the door action - if (sec->ceilingdata) + if (sec->PlaneMoving(sector_t::ceiling)) continue; if (new DDoor (sec, type, speed, delay, lightTag)) diff --git a/src/p_floor.cpp b/src/p_floor.cpp index bd489d525..7ab77b026 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -377,7 +377,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, manual_floor: // ALREADY MOVING? IF SO, KEEP GOING... - if (sec->floordata) + if (sec->PlaneMoving(sector_t::floor)) { if (manual) continue; @@ -748,7 +748,7 @@ manual_stair: // ALREADY MOVING? IF SO, KEEP GOING... //jff 2/26/98 add special lockout condition to wait for entire //staircase to build before retriggering - if (sec->floordata || sec->stairlock) + if (sec->PlaneMoving(sector_t::floor) || sec->stairlock) { if (!manual) continue; @@ -800,7 +800,7 @@ manual_stair: // if sector's floor already moving, look for another //jff 2/26/98 special lockout condition for retriggering - if (tsec->floordata || tsec->stairlock) + if (tsec->PlaneMoving(sector_t::floor) || tsec->stairlock) { prev = sec; sec = tsec; @@ -833,7 +833,7 @@ manual_stair: // if sector's floor already moving, look for another //jff 2/26/98 special lockout condition for retriggering - if (tsec->floordata || tsec->stairlock) + if (tsec->PlaneMoving(sector_t::floor) || tsec->stairlock) continue; ok = true; @@ -917,7 +917,7 @@ bool EV_DoDonut (int tag, fixed_t pillarspeed, fixed_t slimespeed) s1 = §ors[secnum]; // s1 is pillar's sector // ALREADY MOVING? IF SO, KEEP GOING... - if (s1->floordata) + if (s1->PlaneMoving(sector_t::floor)) continue; rtn = true; @@ -925,7 +925,7 @@ bool EV_DoDonut (int tag, fixed_t pillarspeed, fixed_t slimespeed) if (!s2) // note lowest numbered line around continue; // pillar must be two-sided - if (s2->floordata) + if (s2->PlaneMoving(sector_t::floor)) continue; for (i = 0; i < s2->linecount; i++) @@ -1007,7 +1007,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype, sec = §ors[secnum]; // If either floor or ceiling is already activated, skip it - if (sec->floordata || sec->ceilingdata) //jff 2/22/98 + if (sec->PlaneMoving(sector_t::floor) || sec->ceilingdata) //jff 2/22/98 continue; // create and initialize new elevator thinker @@ -1225,7 +1225,8 @@ bool EV_StartWaggle (int tag, int height, int speed, int offset, while ((sectorIndex = P_FindSectorFromTag(tag, sectorIndex)) >= 0) { sector = §ors[sectorIndex]; - if ((!ceiling && sector->floordata) || (ceiling && sector->ceilingdata)) + if ((!ceiling && sector->PlaneMoving(sector_t::floor)) || + (ceiling && sector->PlaneMoving(sector_t::ceiling))) { // Already busy with another thinker continue; } diff --git a/src/p_linkedsectors.cpp b/src/p_linkedsectors.cpp index 4fa4a699d..b932eb0aa 100644 --- a/src/p_linkedsectors.cpp +++ b/src/p_linkedsectors.cpp @@ -300,7 +300,8 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype) int param = movetype; // can't be done if the control sector is moving. - if ((ceiling && control->ceilingdata) || (!ceiling && control->floordata)) return false; + if ((ceiling && control->PlaneMoving(sector_t::ceiling)) || + (!ceiling && control->PlaneMoving(sector_t::floor))) return false; // Make sure we have only valid combinations movetype &= LINK_FLAGMASK; diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index a9135cefb..f20dc1ef4 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -205,7 +205,7 @@ bool EV_DoPillar (DPillar::EPillar type, int tag, fixed_t speed, fixed_t height, { sector_t *sec = §ors[secnum]; - if (sec->floordata || sec->ceilingdata) + if (sec->PlaneMoving(sector_t::floor) || sec->PlaneMoving(sector_t::ceiling)) continue; fixed_t flor, ceil; diff --git a/src/p_plats.cpp b/src/p_plats.cpp index 9d64e1145..962447e49 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -91,7 +91,10 @@ void DPlat::Tick () switch (m_Type) { case platRaiseAndStayLockout: - break; + // Instead of keeping the dead thinker like Heretic did let's + // better use a flag to avoid problems elsewhere. For example, + // keeping the thinker would make tagwait wait indefinitely. + m_Sector->planes[sector_t::floor].Flags |= PLANEF_BLOCKED; case platRaiseAndStay: case platDownByValue: case platDownWaitUpStay: @@ -236,7 +239,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height, sec = §ors[secnum]; manual_plat: - if (sec->floordata) + if (sec->PlaneMoving(sector_t::floor)) { if (!manual) continue; diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index dd98faa25..0e3c88b78 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -761,3 +761,12 @@ void sector_t::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy) co ox = fixed_t(bestx); oy = fixed_t(besty); } + + +bool sector_t::PlaneMoving(int pos) +{ + if (pos == floor) + return (floordata != NULL || (planes[floor].Flags & PLANEF_BLOCKED)); + else + return (ceilingdata != NULL || (planes[ceiling].Flags & PLANEF_BLOCKED)); +} diff --git a/src/p_spec.cpp b/src/p_spec.cpp index e1d486869..8f092fc9d 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -692,12 +692,12 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor) if (copyFloor) { for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) - sectors[secnum].ChangeFlags(sector_t::floor, 0, SECF_ABSLIGHTING); + sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); } else { for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) - sectors[secnum].ChangeFlags(sector_t::ceiling, 0, SECF_ABSLIGHTING); + sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); } ChangeStatNum (STAT_LIGHTTRANSFER); } diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index b9c41b724..79b64a1de 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1125,13 +1125,13 @@ struct UDMFParser continue; case NAME_Lightfloorabsolute: - if (CheckBool(key)) sec->ChangeFlags(sector_t::floor, 0, SECF_ABSLIGHTING); - else sec->ChangeFlags(sector_t::floor, SECF_ABSLIGHTING, 0); + if (CheckBool(key)) sec->ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); + else sec->ChangeFlags(sector_t::floor, PLANEF_ABSLIGHTING, 0); continue; case NAME_Lightceilingabsolute: - if (CheckBool(key)) sec->ChangeFlags(sector_t::ceiling, 0, SECF_ABSLIGHTING); - else sec->ChangeFlags(sector_t::ceiling, SECF_ABSLIGHTING, 0); + if (CheckBool(key)) sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); + else sec->ChangeFlags(sector_t::ceiling, PLANEF_ABSLIGHTING, 0); continue; case NAME_Gravity: diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index bf09603e3..a1f6f6098 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -270,7 +270,7 @@ void R_ClearClipSegs (short left, short right) int GetFloorLight (const sector_t *sec) { - if (sec->GetFlags(sector_t::floor) & SECF_ABSLIGHTING) + if (sec->GetFlags(sector_t::floor) & PLANEF_ABSLIGHTING) { return sec->GetPlaneLight(sector_t::floor); } @@ -282,7 +282,7 @@ int GetFloorLight (const sector_t *sec) int GetCeilingLight (const sector_t *sec) { - if (sec->GetFlags(sector_t::ceiling) & SECF_ABSLIGHTING) + if (sec->GetFlags(sector_t::ceiling) & PLANEF_ABSLIGHTING) { return sec->GetPlaneLight(sector_t::ceiling); } diff --git a/src/r_defs.h b/src/r_defs.h index cf287de20..88f4e98a8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -299,7 +299,8 @@ inline FArchive &operator<< (FArchive &arc, secplane_t &plane) // Ceiling/floor flags enum { - SECF_ABSLIGHTING = 1 // floor/ceiling light is absolute, not relative + PLANEF_ABSLIGHTING = 1, // floor/ceiling light is absolute, not relative + PLANEF_BLOCKED = 2 // can not be moved anymore. }; // Internal sector flags @@ -605,6 +606,8 @@ struct sector_t return lightlevel; } + bool PlaneMoving(int pos); + // Member variables fixed_t CenterFloor () const { return floorplane.ZatPoint (soundorg[0], soundorg[1]); } From 2fbcc13652eb3ca1c671e1d155511c10a15d1bcb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Sep 2009 20:54:07 +0000 Subject: [PATCH 11/27] - Gez's latest cleanup patch. SVN r1854 (trunk) --- src/d_netinfo.cpp | 2 +- src/g_shared/a_artifacts.cpp | 33 ++++++++---------------------- src/p_mobj.cpp | 26 +++++++++-------------- src/thingdef/thingdef_data.cpp | 1 + wadsrc/static/actors/actor.txt | 2 +- wadsrc/static/actors/constants.txt | 7 ++++++- wadsrc/static/dehsupp.txt | 4 ++-- 7 files changed, 29 insertions(+), 46 deletions(-) diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index c395681ce..e31354a6e 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -839,6 +839,6 @@ CCMD (playerinfo) Printf ("PlayerClass: %s (%d)\n", ui->PlayerClass == -1 ? "Random" : PlayerClasses[ui->PlayerClass].Type->Meta.GetMetaString (APMETA_DisplayName), ui->PlayerClass); - PrintMiscActorInfo(players[i].mo); + if (argv.argc() > 2) PrintMiscActorInfo(players[i].mo); } } diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 9eb95c5e3..147511f55 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -565,7 +565,7 @@ IMPLEMENT_CLASS (APowerInvisibility) IMPLEMENT_CLASS (APowerShadow) // Invisibility flag combos -#define INVISIBILITY_FLAGS1 (MF_SHADOW | MF_STEALTH) +#define INVISIBILITY_FLAGS1 (MF_SHADOW) #define INVISIBILITY_FLAGS3 (MF3_GHOST) #define INVISIBILITY_FLAGS5 (MF5_CANTSEEK) @@ -590,24 +590,6 @@ void APowerInvisibility::InitEffect () flags5 &= ~(Owner->flags5 & INVISIBILITY_FLAGS5); Owner->flags5 |= flags5 & INVISIBILITY_FLAGS5; - // Finds out what's the normal alpha and render style for the owner. - // First assume it's what it currently is. - //OwnersNormalStyle = Owner->RenderStyle; - //OwnersNormalAlpha = Owner->alpha; - // Then look if there aren't active invis powerups and look what they're saying. - /*AInventory *item = Owner->Inventory; - while (item != NULL) - { - if (item->IsKindOf(RUNTIME_CLASS(APowerInvisibility)) && item != this) - { - OwnersNormalStyle = static_cast(item)->OwnersNormalStyle; - OwnersNormalAlpha = static_cast(item)->OwnersNormalAlpha; - item = NULL; // No need to look further - } - else item = item->Inventory; - } - Printf("Owner's normal style is found to be %i, normal alpha is found to be %i.\n", - OwnersNormalStyle, OwnersNormalAlpha>>FRACBITS);*/ DoEffect(); } } @@ -623,7 +605,7 @@ void APowerInvisibility::DoEffect () // Due to potential interference with other PowerInvisibility items // the effect has to be refreshed each tic. fixed_t ts = Strength * (special1 + 1); if (ts > FRACUNIT) ts = FRACUNIT; - Owner->alpha = clamp((/*OwnersNormalAlpha*/OPAQUE - ts), 0, OPAQUE); + Owner->alpha = clamp((OPAQUE - ts), 0, OPAQUE); switch (Mode) { case (NAME_Fuzzy): @@ -639,6 +621,7 @@ void APowerInvisibility::DoEffect () Owner->RenderStyle = STYLE_Stencil; break; case (NAME_None): + case (NAME_Cumulative): case (NAME_Translucent): Owner->RenderStyle = STYLE_Translucent; break; @@ -663,8 +646,8 @@ void APowerInvisibility::EndEffect () Owner->flags3 &= ~(flags3 & INVISIBILITY_FLAGS3); Owner->flags5 &= ~(flags5 & INVISIBILITY_FLAGS5); - Owner->RenderStyle = STYLE_Normal;//OwnersNormalStyle; - Owner->alpha = OPAQUE;//OwnersNormalAlpha; + Owner->RenderStyle = STYLE_Normal; + Owner->alpha = OPAQUE; // Check whether there are other invisibility items and refresh their effect. // If this isn't done there will be one incorrectly drawn frame when this @@ -693,15 +676,15 @@ int APowerInvisibility::AlterWeaponSprite (vissprite_t *vis) // Blink if the powerup is wearing off if (changed == 0 && EffectTics < 4*32 && !(EffectTics & 8)) { - vis->RenderStyle = STYLE_Normal;//OwnersNormalStyle; - vis->alpha = OPAQUE;//OwnersNormalAlpha; + vis->RenderStyle = STYLE_Normal; + vis->alpha = OPAQUE; return 1; } else if (changed == 1) { // something else set the weapon sprite back to opaque but this item is still active. fixed_t ts = Strength * (special1 + 1); if (ts > FRACUNIT) ts = FRACUNIT; - vis->alpha = clamp((/*OwnersNormalAlpha*/OPAQUE - ts), 0, OPAQUE); + vis->alpha = clamp((OPAQUE - ts), 0, OPAQUE); switch (Mode) { case (NAME_Fuzzy): diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 326b5c962..3f1874199 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5476,10 +5476,7 @@ void PrintMiscActorInfo(AActor * query) static const char * renderstyles[]= {"None", "Normal", "Fuzzy", "SoulTrans", "OptFuzzy", "Stencil", "Translucent", "Add", "Shaded", "TranslucentStencil"}; - /* - Printf("%s %x has the following flags:\n\tflags1: %x", - query->GetNameTag().GetChars(), query, query->flags); - */ + Printf("%s has the following flags:\n\tflags: %x", query->GetTag(), query->flags); for (flagi = 0; flagi < 31; flagi++) if (query->flags & 1<flags2); @@ -5497,23 +5494,20 @@ void PrintMiscActorInfo(AActor * query) Printf("\n\tflags6: %x", query->flags6); for (flagi = 0; flagi < 31; flagi++) if (query->flags6 & 1<bouncefactor), + Printf("\nIts bounce style and factors are %x and f:%f, w:%f; its bounce flags are:\n\tflagsb: %x", + query->BounceFlags, FIXED2FLOAT(query->bouncefactor), FIXED2FLOAT(query->wallbouncefactor), query->BounceFlags); - for (flagi = 0; flagi < 31; flagi++) - if (query->BounceFlags & 1<BounceFlags & 1<alpha), query->renderflags); - for (flagi = 0; flagi < 31; flagi++) - if (query->renderflags & 1<renderflags & 1<special]->name, query->args[0], query->args[1], - query->args[2], query->args[3], query->args[4], - query->special1, query->special2); + (query->special ? LineSpecialsInfo[query->special]->name : "None"), + query->args[0], query->args[1], query->args[2], query->args[3], + query->args[4], query->special1, query->special2); Printf("\nIts coordinates are x: %f, y: %f, z:%f, floor:%f, ceiling:%f.", FIXED2FLOAT(query->x), FIXED2FLOAT(query->y), FIXED2FLOAT(query->z), FIXED2FLOAT(query->floorz), FIXED2FLOAT(query->ceilingz)); diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 5b207c854..7c7ee2259 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -240,6 +240,7 @@ static FFlagDef ActorFlags[]= DEFINE_FLAG2(BOUNCE_Quiet, NOBOUNCESOUND, AActor, BounceFlags), DEFINE_FLAG2(BOUNCE_AllActors, BOUNCEONACTORS, AActor, BounceFlags), DEFINE_FLAG2(BOUNCE_ExplodeOnWater, EXPLODEONWATER, AActor, BounceFlags), + DEFINE_FLAG2(BOUNCE_MBF, MBFBOUNCER, AActor, BounceFlags), // Deprecated flags. Handling must be performed in HandleDeprecatedFlags DEFINE_DEPRECATED_FLAG(FIREDAMAGE), diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 8a0d78b3f..b644b3511 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -260,7 +260,7 @@ ACTOR Actor native //: Thinker action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0); action native A_SetArg(int pos, int value); action native A_SetUserVar(int pos, int value); - action native A_SetSpecial(int spec, int arg0, int arg1, int arg2, int arg3, int arg4); + action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0); States { diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index f69771f25..4761152be 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -63,9 +63,15 @@ const int MRF_UNDOBYDEATH = 512; const int MRF_UNDOBYDEATHFORCED = 1024; const int MRF_UNDOBYDEATHSAVES = 2048; +// Flags for A_RailAttack and A_CustomRailgun const int RGF_SILENT = 1; const int RGF_NOPIERCING = 2; +// Flags for A_Mushroom +const int MSF_Standard = 0; +const int MSF_Classic = 1; + +// Activation flags enum { THINGSPEC_Default = 0, @@ -77,7 +83,6 @@ enum THINGSPEC_ClearSpecial = 32, }; - // constants for A_PlaySound enum { diff --git a/wadsrc/static/dehsupp.txt b/wadsrc/static/dehsupp.txt index 25829b75f..51db22e91 100644 --- a/wadsrc/static/dehsupp.txt +++ b/wadsrc/static/dehsupp.txt @@ -414,7 +414,7 @@ StateMap DoomUnusedStates, TNT, 1, // [MBF] S_TNT1 967 Grenade, Grenade, 1, // [MBF] S_GRENADE 968 Grenade, Detonate, 3, // [MBF] S_DETONATE - S_DETONATE3 969-971 - Dog, Spawn, 27, // [MBF] S_DOGS_STND - S_DOGS_RAISE6 972-998 + MBFHelperDog, Spawn, 27, // [MBF] S_DOGS_STND - S_DOGS_RAISE6 972-998 BFG9000, OldFire, 43, // [MBF] S_OLDBFG1 - S_OLDBFG43 999-1041 PlasmaBall1, Spawn, 7, // [MBF] S_PLS1BALL - S_PLS1EXP5 1042-1048 PlasmaBall2, Spawn, 5, // [MBF] S_PLS2BALL - S_PLS2BALLX3 1049-1053 @@ -681,7 +681,7 @@ InfoNames PointPusher, PointPuller, // MBF additional actors: - Dog, + MBFHelperDog, PlasmaBall1, PlasmaBall2, EvilSceptre, From 5613c3e14f22928afcb2000dd2faee97ad0be450 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Sep 2009 20:58:43 +0000 Subject: [PATCH 12/27] - Fixed: Unmorphing while invulnerable was blocked. SVN r1855 (trunk) --- docs/rh-log.txt | 3 +++ src/g_shared/a_morph.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index fc665a50c..4130b3148 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ September 17, 2009 (Changes by Graf Zahl) +- Fixed: Unmorphing while invulnerable was blocked. +- Various cleanup changes. +- fixed Dog's class name in DEHSUPP. - Renamed plane flags from SECF_* to PLANEF_*. - Changed Heretic's plat raise type to use a flag to block further sector movement instead of keeping the dead thinker around to block the sector. diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index f319f5414..9ebec54ca 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -192,10 +192,11 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, bool force) return false; } - if ((pmo->flags2 & MF2_INVULNERABLE) && ((player != activator) || (!(player->MorphStyle & MORPH_WHENINVULNERABLE)))) - { // Immune when invulnerable unless this is something we initiated. - // If the WORLD is the initiator, the same player should be given - // as the activator; WORLD initiated actions should always succeed. + if ((pmo->flags2 & MF2_INVULNERABLE) // If the player is invulnerable + && ((player != activator) // and either did not decide to unmorph, + || (!((player->MorphStyle & MORPH_WHENINVULNERABLE) // or the morph style does not allow it + && (player->MorphStyle != MORPH_OLDEFFECTS))))) // (but standard morph styles always allow it), + { // Then the player is immune to the unmorph. return false; } From f646a89216140f7aba1995137f957fe2e04cb5f5 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 17 Sep 2009 22:59:20 +0000 Subject: [PATCH 13/27] - Size optimize PNG sprites. SVN r1856 (trunk) --- wadsrc/static/sprites/PLS1B0.png | Bin 332 -> 331 bytes wadsrc/static/sprites/PLS1E0.png | Bin 843 -> 842 bytes wadsrc/static/sprites/PLS1F0.png | Bin 844 -> 842 bytes wadsrc/static/sprites/PLS1G0.png | Bin 581 -> 579 bytes wadsrc/static/sprites/PLS2A0.png | Bin 273 -> 272 bytes wadsrc/static/sprites/PLS2B0.png | Bin 261 -> 260 bytes wadsrc/static/sprites/pista0.png | Bin 408 -> 407 bytes wadsrc/static/sprites/rsmka0.png | Bin 410 -> 406 bytes wadsrc/static/sprites/rsmkb0.png | Bin 412 -> 403 bytes wadsrc/static/sprites/rsmkc0.png | Bin 589 -> 575 bytes wadsrc/static/sprites/rsmkd0.png | Bin 409 -> 399 bytes wadsrc/static/sprites/sgrna1.png | Bin 258 -> 186 bytes wadsrc/static/sprites/sgrna7a3.png | Bin 263 -> 261 bytes 13 files changed, 0 insertions(+), 0 deletions(-) diff --git a/wadsrc/static/sprites/PLS1B0.png b/wadsrc/static/sprites/PLS1B0.png index d50f0d7d545e7ea06fce2e685849e0707fd61d27..ed08ba37135f1b18c42d17fcd8f6e660e086fb7d 100644 GIT binary patch delta 216 zcmV;}04M*<0?PuBERio817FWqkxCl`Qg3Z5k!d7(Q)&e?@(Rm{BiCh(fcxJ0@aMt8Z!yb*C%zk9X>a`u`+>g-QYsR9g;(LLgP zPPh_3z$G;+X%Y-GX|3i3b>9ku8fm*ljvfwnG6OdcKFWqMkWDPC{J`@-;w|2k%Lhih SBiG~r0000B!9wBrnb0cr&Zsunv=?)82$F?|@ZU(w= z4k(k7TlQuhYptOSU{v=py5f6P^QAhX2}S5@t|!$9i|5a`V$I%5*+SxTXbgxGb&klq z+hbusjQCQhmy(LoU3&-EW)X)dxwG{LYV_%nV0R3Ul&hVDlEl^1+c&x|Vma^wx}pb) TpRmad00000NkvXXu0mjfRhDId diff --git a/wadsrc/static/sprites/PLS1E0.png b/wadsrc/static/sprites/PLS1E0.png index a3a688631bb903190adcb37594454052ccb0090d..ac01390c584aca85e2f638e81d35f098d7dce845 100644 GIT binary patch delta 734 zcmV<40wMj&2FeDIcz?Y~L_t(|UTxE{a^p4>hSA$)Lg5k8rAnJ@ULeWNq~Fk9Puf_P z;?_1TX^S+LNl|Si(Nw`I%LP%Wu|@ErxTQq=4;3nM9M5FG_RQQ1%mDOX4EkIkuPR=D zj=a?O1D5}R0!ZznF(AFoYXF!%=elN6`)AYo)_sf|(0`LxqqrX?E94%21}MD9 zN6sIo{cw~r8?7O}k!RUd1wZ}rrr!?-ag%!Iy}S$qvfsY_?#D1bKaCtT)RDw9wo&-* z&D-~RW4CMVFAR>Peg1SkoDP!aF@c@!&CTVrnBdY*)2BFcsG9O&=N4y2DT->uE4P>q zcS#dv>|HrDAb$#qK-<*kZgD=ZxVvlXollK)^2c}|O*pk#dOy7cb`EHhjUuAn-d+!E zy0iw%xd0BLw{z;!U&PmgI+=Q)g(B4gR8B-Xs)kp?dJwM-36T&x399rUL785Swu63J z5Drr38>Q<`3gh#;kv$1VqO1@)$#uSSLewkp=RsT zCv(6M`DC>{nV8EfWc~m2(6v-kp`rSU`#d3#Ukl3m$Ugmp^>}^WxI|BS1Yi)p+340zpy*IqHdO@$v>Z>^nNR19I*MD&LO5LNaGJBh~EcE3Z2k4~$6j$Ii-$W;q$^dpw$Dl-sM$0#0I9@tZ zS@Ew3r0HdB*)~;f$XB2jQe;P2Y+Bzz&o}gvl5Q;ktrgL{rq=-=Qm=mE-=AaDuTwK@ QC;$Ke07*qoM6N<$g2Dc4O#lD@ delta 735 zcmV<50wDd$2FnJJcz?c0L_t(|UTxDqbK^u92Jp9IkoP0dQPD#90>I7CA4)DmOB|cD zi51%vG;t)$Ew&Z8P{rw1TewNA)w{)(w)Xi@tngj%4EKz>-@N~3R`g#O^tphXsCe@^ za<+aPu>BthfW#r10JgV11%TOcE^8)1?o=|}znsoqu+1F-3_S?7L{TRkq7mvq924C(!eQ8r^&p72N1q`VvP5RZ~9g&GPanMNy4;ZI-j) zK53$iohgS3M1MgMNS(UeEUy+7`&(OQT&k>>KPQK1%BjxM$Jq_AH$aeZb3fsi}-F(Co>1M5F}cF%Bi)Us^RUh9>g0(mi))Y236WgP^P!z-JqWq zgih*wD`f4ZP%eKM>+^7Ig|-AQxy<**67>rF^;ACm^nY&CZ9u(vmt72Dy_5y*^AAyY zz5o=FOV+#dDLhcnEF1^R>v%#S5_QT~{j34`v_|K)On6ubkT~RraOE~#k%U^a{YoO< zc12q5E?(L{tQP^h<8IxyGKPTV+sm?Osp=(Dsho>vhDt9Ys&n2dw5aOno|SC%6oR^>Wm8oUK+Exzjrwrah@+V0+**Qy z)6AOH-$NCAe2V>zutGedtulR|wQT9j1v==Z09XXzB#)x=X{7+Ypkv@`tVGMBFr2Im ziLCe}7PjeStXVfzuE diff --git a/wadsrc/static/sprites/PLS1F0.png b/wadsrc/static/sprites/PLS1F0.png index dbacdc85aae939d4eece16f53073856b21291571..ac01390c584aca85e2f638e81d35f098d7dce845 100644 GIT binary patch delta 734 zcmV<40wMj(2FeDIcz?Y~L_t(|UTxE{a^p4>hSA$)Lg5k8rAnJ@ULeWNq~Fk9Puf_P z;?_1TX^S+LNl|Si(Nw`I%LP%Wu|@ErxTQq=4;3nM9M5FG_RQQ1%mDOX4EkIkuPR=D zj=a?O1D5}R0!ZznF(AFoYXF!%=elN6`)AYo)_sf|(0`LxqqrX?E94%21}MD9 zN6sIo{cw~r8?7O}k!RUd1wZ}rrr!?-ag%!Iy}S$qvfsY_?#D1bKaCtT)RDw9wo&-* z&D-~RW4CMVFAR>Peg1SkoDP!aF@c@!&CTVrnBdY*)2BFcsG9O&=N4y2DT->uE4P>q zcS#dv>|HrDAb$#qK-<*kZgD=ZxVvlXollK)^2c}|O*pk#dOy7cb`EHhjUuAn-d+!E zy0iw%xd0BLw{z;!U&PmgI+=Q)g(B4gR8B-Xs)kp?dJwM-36T&x399rUL785Swu63J z5Drr38>Q<`3gh#;kv$1VqO1@)$#uSSLewkp=RsT zCv(6M`DC>{nV8EfWc~m2(6v-kp`rSU`#d3#Ukl3m$Ugmp^>}^WxI|BS1Yi)p+340zpy*IqHdO@$v>Z>^nNR19I*MD&LO5LNaGJBh~EcE3Z2k4~$6j$Ii-$W;q$^dpw$Dl-sM$0#0I9@tZ zS@Ew3r0HdB*)~;f$XB2jQe;P2Y+Bzz&o}gvl5Q;ktrgL{rq=-=Qm=mE-=AaDuTwK@ QC;$Ke07*qoM6N<$g2dcwP5=M^ delta 736 zcmV<60w4X#2FwPKcz?f1L_t(|UTxDcbK^u92H>w_koG6gQPINj2Y{QQKa^aCmN*t^ z6DzhUXyQngTWl+Gp^E5MTewNA)wji#w)Xu|Ncb*zhI>cdGw-*bW_IbnFz9muIZ^TE zbL4FOFl75b5CDloGy$x?Jq3W-aV~2nLGDyCJ-C?FcjhTFfPZgKM)4p>*2o>)91wVw zC(fT|gJ7I8D=A@J^QpD13V!+J&0r7=<0f^+Ir};c$bS3wyB~x2@;ow-5J$3(v5SIt zZ{EJo8@<~|ccpM7>GGG`a5hYu=LC9wP^0UQqP%N8OJCy1plZs;y;)uyr6{T~ug!86 z?vp0U*qJg^Ab;`-PwLd=W_h`&xck@E8J8;C$)A%$H04xh>BHd`9*v?tdp4oS_l#?K;_i-D^%f4SP$ckB1_%J#(GuSi&v&Me3pW+cM#>5Fl~L55dZ9`jUiNv;9gU z-u5LecjqtdAN|$>cE|m?ZDkAr%Xb%LGqE5+7E2>YSmQnB%B_C*{^#Yj`B#8?E=*fw zmLBHMZ-2l3CcOXE3J_UTyVN>nE{N+j+5-x4+L zI7+y2qp9+fsZ`FzGec!3BC2!VDzvET=#G_a^%R2oq-9f85J1cEl#Tju*@&Z<<=k3= zg44{J)!(7=K3>JaMpz*p&{mng%UZVdTs diff --git a/wadsrc/static/sprites/PLS1G0.png b/wadsrc/static/sprites/PLS1G0.png index fef4459d2072a181c96e55001662107057910663..df4e1f6d425030ae4c2b2a8bad7dc6efd1b729ce 100644 GIT binary patch delta 484 zcmVHht|E5x7!Q+>Q*-lJXba+j4S=u`2vrSC zJ2r)|!ybhJ(_k36DXP#&83fi`!baanMKRE3F10a>0nl=Sfxaa{fC*y{p3rjVP`ny7 zww@C#kl~Sj5*ZwUGr%zS28>C-S+kwog929BFt6GzeWIN)5O^FucRlGZSjHBI$#jkW zu!51raXF2h9e;A1MGOkxvwP!w7=?{6KNj`$a$Idu3~pycA3s+*mIb5GcOIX=WrM=? zQjSbRVvr4?H@=?YfUx3D8t=UBRR(tpZR}a2B9|pIU4xE876BkJb@WMNNKym=n@el{ zsqDI6;;^P^Hh>syc2xHpUf#j0%S9Dq6>e^}!92g43S9wUVEFU<>1=dX8Ad6w`PlFG zZ!=$Z8G+b17CE(7UU-gydLYAHJg}bNv-^PxYjNn*ltf&@L^84>Y_3yuS=DvK3!Pon aUxfcX4vspjUI>-|0000Hht|5X7u~V5*NdFmLFZ4dQcZCdU90UsBZ2OR!`DQGyrf6asiexrT5lWuiPY zkX+9R4Kd(s%WgFevB=p4}l|X2< zfpN#CA?&cLFklJ{m8(WARA~l*HJ7l_2U4RLC=-`T&1?WPpJ1SGP7q*1?ZG3OZyXx0 zs%q&u!2%iXSWL>`2%G_isW+e|0cXv2bPozx&4y`JuIUryjDf)2@V4tof50-fI4tk1 zezk&;#c@8>&VLR$P9g?{kIB7pK2%{N%(q!RJswwE6obndvFQ6s$7aDO^quR&hip*z zyp$v3kQih`7RLL191vFAN#TX3y_&(zOsPGqDsr=AqHEA`$SeRP#*W@73`rV6z~<7L zze@Pp4{=yiG#Nltn;os68y;W4tILln#%j2^+6MFRVqaPa00YDCU-xIDvzlR)CN{78 z{r-94-EKx8HjYJ3<%vfgVxS$6;U*qfkMP#LKn>gC(5WbixP*yhWJTC~PSIsmUy5gX cTekR-e?1P4I#EZAxBvhE07*qoM6N<$f+X|f8vpDfG`XMZwYt&jO?oRtc$j!JILpw99F;?E zg=yu?Yaaj-S6i77T2P9{WxLz#OicQ-Z!EA~_Xxhn1#%Sp2m~}Jq6Q_Fzy9OD6OvE^ UR25;n6#xJL07*qoM6N<$f|!p%s{jB1 diff --git a/wadsrc/static/sprites/PLS2B0.png b/wadsrc/static/sprites/PLS2B0.png index 324b02b18710e1f11c49c7e49181d95e572f9c1e..b0206474c05bd0c29f7388588eaa68b21bf5bddd 100644 GIT binary patch delta 152 zcmV;J0B8S&0)zsPJP`l@|9gA?o161<7iRzf|BpM7O&bK)nmsd-Y$SAFNklD@=l_k%>>N!`EOWgrRhi)si?#f_Y>} zHopmtY!lA!-ZlC2ZY?8c8rRNZL1ErgCeB*nZGen}zC9llWdjG*uiM)I0000 delta 153 zcmV;K0A~M$0)+yQJQ0sO|9gA?o161<7iRzf{{R4yO&bJnXe$ztY$SDHNklD%)J6=VYp!W$fR00000NkvXX Hu0mjf0#-k@ diff --git a/wadsrc/static/sprites/pista0.png b/wadsrc/static/sprites/pista0.png index d7790c683a2cfb0e6bb6318a45af42affa1482ff..b3d9cd09a5831dadb93984064d0c877f46592bbc 100644 GIT binary patch delta 260 zcmV+f0sH=#1D6AkN-%d{KUY^*KQ9*x7Y9>6FI!t%KPwwwOE)7UBSSMAXHzp{V`Fb` zZ;OkIgKJAiM@Nx;8w1PB%aNEK1o*i;p^>^If22u7K~#8NmB~eN!!Q&8(2ru7AqZve z{f}2St9VA6yzPUV;EJlMBIi=FjWEfh{eIXqcum$Vcgb3t9K$W{X*m*f=H*vc$H&uYU?l?pBCvAYe|BC~<=?uP>TMj` zIvxtNjz67mq2%0cV;sx3_c1=TTD;)L`VgQfhkVFdKFvd5xZ5A)S_m}R8*!%q0000< KMNUMnLSTZH9C331 delta 260 zcmV+f0sH=!1DFGlN;5w%7k6JjS65dH7Y9>6FI!t%KPww&Q!`&nHzOk>Lo*v=V`E20 zN6X90i;IhcYfEo$Z;^T%k(eF?IVayuk-8**rAb6VRCr#M$wiI>F%$sNkLG3w<1pU; zc(JldkGz?;Dybm*()q)pbH*7Iv%75G*Ka!^xTCtR$+@bstuV=x{l0Emyie9wCK(A4 zSI8`AY&#lKojs%{KKr z-3SHRq@TfeP;wr&DfQ*I_bEMhT71Fx%^^Th4Dk@P{4`F1;oolXOb9%~C>^W-0000< KMNUMnLSTXrMscM8 diff --git a/wadsrc/static/sprites/rsmka0.png b/wadsrc/static/sprites/rsmka0.png index 5e2f4de85d3e5c4f718ff9860ac387d8d8e3210e..cee476cd1086713c7b80826b28bb55b0fd7372ff 100644 GIT binary patch delta 295 zcmV+?0oeYU1C|4jcz+2=L_t(|UQLg&YQr!Ph6ROCYLBH45a^x<=-3pphWHJN!A}q+ z570PD=g7*`sg`va3LP3G4F!+7hw7SB zmcrq`g)nPX)c~OdKOyYOQbsg2M02|@8}JykT2mNLd&R-`*eXdMd-^G>wWFSsibv<& z^GgF3oLxyEcQ;*BLUUtV%CP)%{`eqQl7lmjHowisi%Kmy40nx+aWUhyfj~f-7WXqj tMnB-_HLgPE*&raZk%SZ+lm{)&&p(J_j0qNIs~`XX002ovPDHLkV1f~Ng_QsR delta 299 zcmV+`0o4AM1DXSncz+E^L_t(|+D(wLYQr!Ph7Ss%)E-M8Ake)J(6I?*4e=WkgP$Ny z9-wiY&XJX=Q*G-q6go6W8VnwF57kp_2Wyc&?!W(j9RNUJV0@JO8DmwAF(}j+?@#+r zf4kqVdfp$rUv?h65WwVez_10dD*GBa=$jVqsD+36bR#16I)C)wj3s*MYtCrJ$fxnH zdbiFET_rw5DU$*jHCk>6>Npl2Rfb+%9^(Qnxk_%inJ!0}qHU>^fV>w+Va-CwAYZ6VPMVcve%{BBa xdR*izv>i^~{Uj(dc39O;Fj6zD%2j#){0E3)j0xXvZqNV#002ovPDHLkV1n*=hT{ML diff --git a/wadsrc/static/sprites/rsmkb0.png b/wadsrc/static/sprites/rsmkb0.png index fab531acf5e94ac454cd44dfae1ed5e07755f276..cc7046ac63823b24944fb3112a233d25cd13ce88 100644 GIT binary patch delta 298 zcmV+_0oDGT1Cs-ga(@g-L_t(|UWJe`PQ@?~L>B>ta}3}F@Q)CMHq9?WjU2=U?2-Z{ zODZ=(va591b4oUG1P%>PZr;i>Yne8bcU0oNFZKE#SK?(sC*GDmAJXT!{gb9+yM&98 z3h;7%9RkDUJ0GMXPjZqEzH8~yRihE-gb45GDm@LF!Hj5ZB7eGg2}5HM#h)Limgt0` z?k7OJwvLFVp>C!mb)&Y6c=dkM*z~!qd)(#^C!6NCr9&bi47c~atbg5~kFWYpn<*jW z0Y=>$V}X=CuwfoG18(ywvS5Ck0@jH%Qbvi7>+W;*3Se#F)Sgg49BpcSxP|r z3#*ih9OV2lOCbAFa{-mm$)ONK*TS{0tQJP%#Nz6Pp2r>;k$;mm1aS2d$Hs6HK0i4z za^$fdoJgi~ZSpJJST~MD&h};&uHJ7OLmzXV5w~FLv2Vn zmwn48WPpT4Q7p->qSRKrSj@YNwE5$prY&#d;CBgCt}l+^jLbxQNs|Bo002ovPDHLk FV1h5nlC1y$ diff --git a/wadsrc/static/sprites/rsmkc0.png b/wadsrc/static/sprites/rsmkc0.png index 2811d62430296ee2f590acec618c4dda4d9dd12e..17b121bf96cc07256e40638a4b0a764dcd7fd686 100644 GIT binary patch delta 468 zcmV;_0W1E^1iu83b$_)A5!2Dr={;gX=rNU^j_)#nn=6J@ur*pvK7U+MDu0SzW8x3zY@pkrOIwK) zU`1_{>`J8HRVf#EuuZft!A-W|r{!)ZiX<%oK>XUBA2PM7i_+E@qq<#xTj-EP`A=FbY)w=}4dlz%s_0 zMrD~M1k4A0d{gX%U5#LED}IUzapY5U9lTJVCWSA5Et@Z8cz}N-zw~||`r5hx0000< KMNUMnLSTYY&*Sg_ delta 482 zcmV<80UiFo1kD7Hb$`Q2L_t(|+HI4uZnH2Hg*`--sGp?jRG~;2*%?tPUZ8+@03b}i z^b4>ub*L0wvvk6-voNqYez{(g6i6Bm44;qBz4zpX5In{ZvNAonIn)>rZ_FRsTZ&>j z)0NfwGhJPNiq)-?blH6ARCwUX^%{eSxfr95dQK6^Dr&(!Iv zutdjKfCbe>uuhS_2>ZPrUl;Bs1vBV^?WVa6Pl7N70RFMw|B9&=l^d2yDN(JP(?q+# z-Heol&19^_e|J+O7Fn!5=XQ%AWLAvBkf%w^6IPcJxNNRs|IZVgxM zycVcas*9x-(eH5ji)e-Ic8%mmc1hTQ{6sW%s|t+bxUI*~pk$VcIH|%$cI-l1m49Qo ztghTO!$z9Xm*@6UXG!(uhFGo~>GRk(6%h-z?t%oDn4u6WfKLMU5j4 z;8@O(g(YNQE9Pa$5~14fP#C+BVzclTKY!NyF^S@49}6AuEx31k1k`I95S4(C6f{f* zgi1DtG9YcBVa1oPm>u;7Q~{HP1ciSAB>{W#OOh>AT<1{`AAgQEBCA?Qx37OM)}LzQ4$0a?Pre;?d`cLIdMb+?NEN(T4{;%)~Ll#d1g!DNVp zYzPk!2;S_=04Z&56+d&vWVc>RQOJ`~7}$Iw1((oY6y{_>g@3D;NcLsLie*)6)!OBu zwQ(;ytG?e|Nqo*`gmAmGfkoTJV_yM(olx=+ApnR{utDkuq@^9#L!9N+*!y-XN}jiM zkSpk6lN#hTqQ%>N`l@>0OgEeKWm=-g{l))y*w+76Pq`_CB_-9UT*=G|&@?MXckkCd wzRpP*O)wmYKNb->i_@%07*qoM6N<$g3P{-F#rGn diff --git a/wadsrc/static/sprites/sgrna1.png b/wadsrc/static/sprites/sgrna1.png index 39e11ce563477c1923e28b88896213d2cdb68334..2ef3bbdf5edff9fe313ba41f1d7d18612b1a0205 100644 GIT binary patch delta 151 zcmZo-+Qm3Qf|G@rfq}tHaq*6cisJPu0X`wFK)$-Vy0x{nv$J!4e!jlG{_*3-moH!L z@9%&6_HAKdVQFdU6*u*N0o5^<1o;IsI6S+N2ILrcx;TbZ#3d&Lge4^;l${qz*iaBU z`-H-pq**5vRNjRg*$^6dWMZTC38#j}#DyBn43(?da^{4KHv{!Dc)I$ztYdacXaWFj COEaMW delta 223 zcmV<503iRm0fGXM7zqdl0002Q559|$As2tONkl$QZ zF-ETILRB$s+g4RYM84HDO#p1$_BYuyP3^i45y4uEh;W`KDJAm(c%H`qRaF77){;^( Z0Kd15Li2k}e(nGO002ovPDHLkV1m^fT}=Q0 diff --git a/wadsrc/static/sprites/sgrna7a3.png b/wadsrc/static/sprites/sgrna7a3.png index 5c619d44273fbcd625b7bb1fa8125b7ad0f49bd7..83cc8dcfc0f557398835f517e5a9796b4af00a65 100644 GIT binary patch delta 121 zcmV-<0EYjE0)+yQlX6{2L_t(|UNy=`7Jxtq1JKZ>+x7lemBHs0EGXA0*3;SlXPE6L_t(|UNy=`76UN|15nZ2JuS)ouNtu5{1r$7M8r%?&01q& zW&&8V>-~B1rbPJlv(|bX-|M>XIQmHtRn5LOajh{E5hgA1a7d{X%rS~1m% Date: Fri, 18 Sep 2009 05:46:15 +0000 Subject: [PATCH 14/27] - Added Gez's real morph fix. SVN r1857 (trunk) --- src/g_game.cpp | 2 +- src/g_heretic/a_hereticartifacts.cpp | 2 +- src/g_raven/a_artitele.cpp | 3 ++- src/g_shared/a_morph.cpp | 12 +++++++----- src/g_shared/a_morph.h | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 34b98c607..8555db2c4 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1230,7 +1230,7 @@ void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory if (p->morphTics) { // Undo morph - P_UndoPlayerMorph (p, p, true); + P_UndoPlayerMorph (p, p, 0, true); } // Clears the entire inventory and gives back the defaults for starting a game diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index d9c08ec1a..1b7a79966 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -24,7 +24,7 @@ bool AArtiTomeOfPower::Use (bool pickup) { if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYTOMEOFPOWER)) { // Attempt to undo chicken - if (!P_UndoPlayerMorph (Owner->player, Owner->player)) + if (!P_UndoPlayerMorph (Owner->player, Owner->player, MORPH_UNDOBYTOMEOFPOWER)) { // Failed if (!(Owner->player->MorphStyle & MORPH_FAILNOTELEFRAG)) { diff --git a/src/g_raven/a_artitele.cpp b/src/g_raven/a_artitele.cpp index 11350338e..9828f9581 100644 --- a/src/g_raven/a_artitele.cpp +++ b/src/g_raven/a_artitele.cpp @@ -45,7 +45,8 @@ bool AArtiTeleport::Use (bool pickup) bool canlaugh = true; if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE)) { // Teleporting away will undo any morph effects (pig) - if (!P_UndoPlayerMorph (Owner->player, Owner->player) && (Owner->player->MorphStyle & MORPH_FAILNOLAUGH)) + if (!P_UndoPlayerMorph (Owner->player, Owner->player, MORPH_UNDOBYCHAOSDEVICE) + && (Owner->player->MorphStyle & MORPH_FAILNOLAUGH)) { canlaugh = false; } diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index 9ebec54ca..f12c36aef 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -173,7 +173,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i // //---------------------------------------------------------------------------- -bool P_UndoPlayerMorph (player_t *activator, player_t *player, bool force) +bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, bool force) { AWeapon *beastweap; APlayerPawn *mo; @@ -192,10 +192,12 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, bool force) return false; } - if ((pmo->flags2 & MF2_INVULNERABLE) // If the player is invulnerable - && ((player != activator) // and either did not decide to unmorph, - || (!((player->MorphStyle & MORPH_WHENINVULNERABLE) // or the morph style does not allow it - && (player->MorphStyle != MORPH_OLDEFFECTS))))) // (but standard morph styles always allow it), + bool DeliberateUnmorphIsOkay = !!(player->MorphStyle & unmorphflag); + + if ((pmo->flags2 & MF2_INVULNERABLE) // If the player is invulnerable + && ((player != activator) // and either did not decide to unmorph, + || (!((player->MorphStyle & MORPH_WHENINVULNERABLE) // or the morph style does not allow it + || (DeliberateUnmorphIsOkay))))) // (but standard morph styles always allow it), { // Then the player is immune to the unmorph. return false; } diff --git a/src/g_shared/a_morph.h b/src/g_shared/a_morph.h index 7ae83aed4..1ddbf863d 100644 --- a/src/g_shared/a_morph.h +++ b/src/g_shared/a_morph.h @@ -17,7 +17,7 @@ enum MORPH_UNDOBYCHAOSDEVICE = 0x00000008, // Player unmorphs upon activating a Chaos Device MORPH_FAILNOTELEFRAG = 0x00000010, // Player stays morphed if unmorph by Tome of Power fails MORPH_FAILNOLAUGH = 0x00000020, // Player doesn't laugh if unmorph by Chaos Device fails - MORPH_WHENINVULNERABLE = 0x00000040, // Player can morph (or scripted unmorph) when invulnerable but ONLY if doing it to themselves + MORPH_WHENINVULNERABLE = 0x00000040, // Player can morph when invulnerable but ONLY if doing it to themselves MORPH_LOSEACTUALWEAPON = 0x00000080, // Player loses specified morph weapon only (not "whichever they have when unmorphing") MORPH_NEWTIDBEHAVIOUR = 0x00000100, // Actor TID is by default transferred from the old actor to the new actor MORPH_UNDOBYDEATH = 0x00000200, // Actor unmorphs when killed and (unless MORPH_UNDOBYDEATHSAVES) stays dead @@ -32,7 +32,7 @@ class AMorphedMonster; bool P_MorphPlayer (player_t *activator, player_t *player, const PClass *morphclass, int duration = 0, int style = 0, const PClass *enter_flash = NULL, const PClass *exit_flash = NULL); -bool P_UndoPlayerMorph (player_t *activator, player_t *player, bool force = false); +bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag = 0, bool force = false); bool P_MorphMonster (AActor *actor, const PClass *morphclass, int duration = 0, int style = 0, const PClass *enter_flash = NULL, const PClass *exit_flash = NULL); bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force = false); From b8eb530a0d72c50bb88951ed25579c9575c20e2a Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 20 Sep 2009 03:50:05 +0000 Subject: [PATCH 15/27] - Fixed: Wall drawing handled fixed light levels improperly (but did not completely ignore them, either). - Separated light level fixing out of player_t's fixedcolormap parameter. Using a fixed light level (e.g. PowerTorch) will no longer wipe out colored lighting. - Moved the blending rectangle drawing into a separate discrete stage, since doing it while copying the 3D view window to the display now blends underneath the weapon instead of on top of it. - Consolidated the special colormaps into a single 2D table. - Tweaked the special colormaps slightly to make the true color results more closely match the paletted approximations. - fb_d3d9_shaders.h was getting unwieldy, so I moved the shaders out of the executable and into zdoom.pk3. Shaders are still precompiled so I don't need to pull in a dependancy on D3DX. - Added a few more shaders to accomodate drawing weapons with all the in-game lighting models. These are accessed with the new DrawTexture tags DTA_SpecialColormap and DTA_ColormapStyle. - Player weapon sprites are now drawn using Direct3D and receive all the benefits thereof. SVN r1858 (trunk) --- docs/rh-log.txt | 21 + src/d_main.cpp | 2 + src/d_player.h | 3 +- src/g_game.cpp | 3 +- src/g_shared/a_artifacts.cpp | 24 +- src/p_mobj.cpp | 3 +- src/p_user.cpp | 26 +- src/r_blend.h | 4 +- src/r_draw.cpp | 2 +- src/r_main.cpp | 38 +- src/r_main.h | 7 +- src/r_plane.cpp | 4 +- src/r_segs.cpp | 51 +- src/r_things.cpp | 216 +++-- src/r_things.h | 1 + src/textures/multipatchtexture.cpp | 8 +- src/v_draw.cpp | 10 + src/v_palette.cpp | 108 +-- src/v_palette.h | 37 +- src/v_video.cpp | 14 + src/v_video.h | 10 +- src/win32/fb_d3d9.cpp | 340 ++++++-- src/win32/fb_d3d9_shaders.h | 665 --------------- src/win32/fb_d3d9_wipe.cpp | 10 +- src/win32/win32iface.h | 48 +- wadsrc/static/shaders/d3d/build.bat | 10 + wadsrc/static/shaders/d3d/shaders.ps | 116 +++ wadsrc/static/shaders/d3d/sm14/BurnWipe.pso | Bin 0 -> 228 bytes .../shaders/d3d/sm14/InGameColormap.pso | Bin 0 -> 208 bytes .../shaders/d3d/sm14/InGameColormapDesat.pso | Bin 0 -> 320 bytes .../shaders/d3d/sm14/InGameColormapInv.pso | Bin 0 -> 268 bytes .../d3d/sm14/InGameColormapInvDesat.pso | Bin 0 -> 336 bytes .../shaders/d3d/sm14/InGameColormapPal.pso | Bin 0 -> 336 bytes .../d3d/sm14/InGameColormapPalDesat.pso | Bin 0 -> 432 bytes .../shaders/d3d/sm14/InGameColormapPalInv.pso | Bin 0 -> 380 bytes .../d3d/sm14/InGameColormapPalInvDesat.pso | Bin 0 -> 448 bytes .../static/shaders/d3d/sm14/NormalColor.pso | Bin 0 -> 180 bytes .../shaders/d3d/sm14/NormalColorInv.pso | Bin 0 -> 240 bytes .../shaders/d3d/sm14/NormalColorPal.pso | Bin 0 -> 308 bytes .../shaders/d3d/sm14/NormalColorPalInv.pso | Bin 0 -> 352 bytes wadsrc/static/shaders/d3d/sm14/RedToAlpha.pso | Bin 0 -> 212 bytes .../static/shaders/d3d/sm14/RedToAlphaInv.pso | Bin 0 -> 256 bytes .../shaders/d3d/sm14/SpecialColormap.pso | Bin 0 -> 248 bytes .../shaders/d3d/sm14/SpecialColormapInv.pso | Bin 0 -> 264 bytes .../shaders/d3d/sm14/SpecialColormapPal.pso | Bin 0 -> 372 bytes .../d3d/sm14/SpecialColormapPalInv.pso | Bin 0 -> 388 bytes .../static/shaders/d3d/sm14/VertexColor.pso | Bin 0 -> 116 bytes wadsrc/static/shaders/d3d/sm14/build.bat | 27 + wadsrc/static/shaders/d3d/sm20/BurnWipe.pso | Bin 0 -> 300 bytes .../shaders/d3d/sm20/GammaCorrection.pso | Bin 0 -> 328 bytes .../shaders/d3d/sm20/InGameColormap.pso | Bin 0 -> 256 bytes .../shaders/d3d/sm20/InGameColormapDesat.pso | Bin 0 -> 368 bytes .../shaders/d3d/sm20/InGameColormapInv.pso | Bin 0 -> 316 bytes .../d3d/sm20/InGameColormapInvDesat.pso | Bin 0 -> 384 bytes .../shaders/d3d/sm20/InGameColormapPal.pso | Bin 0 -> 396 bytes .../d3d/sm20/InGameColormapPalDesat.pso | Bin 0 -> 492 bytes .../shaders/d3d/sm20/InGameColormapPalInv.pso | Bin 0 -> 440 bytes .../d3d/sm20/InGameColormapPalInvDesat.pso | Bin 0 -> 508 bytes .../static/shaders/d3d/sm20/NormalColor.pso | Bin 0 -> 252 bytes .../shaders/d3d/sm20/NormalColorInv.pso | Bin 0 -> 312 bytes .../shaders/d3d/sm20/NormalColorPal.pso | Bin 0 -> 392 bytes .../shaders/d3d/sm20/NormalColorPalInv.pso | Bin 0 -> 436 bytes wadsrc/static/shaders/d3d/sm20/RedToAlpha.pso | Bin 0 -> 272 bytes .../static/shaders/d3d/sm20/RedToAlphaInv.pso | Bin 0 -> 328 bytes .../shaders/d3d/sm20/SpecialColormap.pso | Bin 0 -> 300 bytes .../shaders/d3d/sm20/SpecialColormapInv.pso | Bin 0 -> 316 bytes .../shaders/d3d/sm20/SpecialColormapPal.pso | Bin 0 -> 424 bytes .../d3d/sm20/SpecialColormapPalInv.pso | Bin 0 -> 440 bytes .../static/shaders/d3d/sm20/VertexColor.pso | Bin 0 -> 124 bytes wadsrc/static/shaders/d3d/sm20/build.bat | 27 + wadsrc/static/shaders/d3d/sm30/BurnWipe.pso | Bin 0 -> 300 bytes .../shaders/d3d/sm30/GammaCorrection.pso | Bin 0 -> 328 bytes .../shaders/d3d/sm30/InGameColormap.pso | Bin 0 -> 256 bytes .../shaders/d3d/sm30/InGameColormapDesat.pso | Bin 0 -> 368 bytes .../shaders/d3d/sm30/InGameColormapInv.pso | Bin 0 -> 316 bytes .../d3d/sm30/InGameColormapInvDesat.pso | Bin 0 -> 384 bytes .../shaders/d3d/sm30/InGameColormapPal.pso | Bin 0 -> 396 bytes .../d3d/sm30/InGameColormapPalDesat.pso | Bin 0 -> 492 bytes .../shaders/d3d/sm30/InGameColormapPalInv.pso | Bin 0 -> 440 bytes .../d3d/sm30/InGameColormapPalInvDesat.pso | Bin 0 -> 508 bytes .../static/shaders/d3d/sm30/NormalColor.pso | Bin 0 -> 240 bytes .../shaders/d3d/sm30/NormalColorInv.pso | Bin 0 -> 300 bytes .../shaders/d3d/sm30/NormalColorPal.pso | Bin 0 -> 380 bytes .../shaders/d3d/sm30/NormalColorPalInv.pso | Bin 0 -> 424 bytes wadsrc/static/shaders/d3d/sm30/RedToAlpha.pso | Bin 0 -> 240 bytes .../static/shaders/d3d/sm30/RedToAlphaInv.pso | Bin 0 -> 300 bytes .../shaders/d3d/sm30/SpecialColormap.pso | Bin 0 -> 300 bytes .../shaders/d3d/sm30/SpecialColormapInv.pso | Bin 0 -> 316 bytes .../shaders/d3d/sm30/SpecialColormapPal.pso | Bin 0 -> 424 bytes .../d3d/sm30/SpecialColormapPalInv.pso | Bin 0 -> 440 bytes .../static/shaders/d3d/sm30/VertexColor.pso | Bin 0 -> 124 bytes wadsrc/static/shaders/d3d/sm30/build.bat | 27 + zdoom.vcproj | 758 +++++++++--------- 93 files changed, 1260 insertions(+), 1360 deletions(-) delete mode 100644 src/win32/fb_d3d9_shaders.h create mode 100644 wadsrc/static/shaders/d3d/build.bat create mode 100644 wadsrc/static/shaders/d3d/shaders.ps create mode 100644 wadsrc/static/shaders/d3d/sm14/BurnWipe.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormap.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormapDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormapInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormapInvDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormapPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormapPalDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormapPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/InGameColormapPalInvDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/NormalColor.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/NormalColorInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/NormalColorPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/NormalColorPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/RedToAlpha.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/RedToAlphaInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/SpecialColormap.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/SpecialColormapInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/SpecialColormapPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/SpecialColormapPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/VertexColor.pso create mode 100644 wadsrc/static/shaders/d3d/sm14/build.bat create mode 100644 wadsrc/static/shaders/d3d/sm20/BurnWipe.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/GammaCorrection.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormap.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormapDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormapInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormapInvDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormapPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormapPalDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormapPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/InGameColormapPalInvDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/NormalColor.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/NormalColorInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/NormalColorPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/NormalColorPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/RedToAlpha.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/RedToAlphaInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/SpecialColormap.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/SpecialColormapInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/SpecialColormapPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/SpecialColormapPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/VertexColor.pso create mode 100644 wadsrc/static/shaders/d3d/sm20/build.bat create mode 100644 wadsrc/static/shaders/d3d/sm30/BurnWipe.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/GammaCorrection.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormap.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormapDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormapInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormapInvDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormapPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormapPalDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormapPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/InGameColormapPalInvDesat.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/NormalColor.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/NormalColorInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/NormalColorPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/NormalColorPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/RedToAlpha.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/RedToAlphaInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/SpecialColormap.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/SpecialColormapInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/SpecialColormapPal.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/SpecialColormapPalInv.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/VertexColor.pso create mode 100644 wadsrc/static/shaders/d3d/sm30/build.bat diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4130b3148..f934e63cf 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,24 @@ +September 19, 2009 +- Fixed: Wall drawing handled fixed light levels improperly (but did not + completely ignore them, either). +- Separated light level fixing out of player_t's fixedcolormap parameter. + Using a fixed light level (e.g. PowerTorch) will no longer wipe out + colored lighting. +- Moved the blending rectangle drawing into a separate discrete stage, since + doing it while copying the 3D view window to the display now blends + underneath the weapon instead of on top of it. +- Consolidated the special colormaps into a single 2D table. +- Tweaked the special colormaps slightly to make the true color results more + closely match the paletted approximations. +- fb_d3d9_shaders.h was getting unwieldy, so I moved the shaders out of the + executable and into zdoom.pk3. Shaders are still precompiled so I don't need + to pull in a dependancy on D3DX. +- Added a few more shaders to accomodate drawing weapons with all the in-game + lighting models. These are accessed with the new DrawTexture tags + DTA_SpecialColormap and DTA_ColormapStyle. +- Player weapon sprites are now drawn using Direct3D and receive all the + benefits thereof. + September 17, 2009 (Changes by Graf Zahl) - Fixed: Unmorphing while invulnerable was blocked. - Various cleanup changes. diff --git a/src/d_main.cpp b/src/d_main.cpp index 7c0a13aca..6221c7298 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -681,6 +681,8 @@ void D_Display () SB_state = screen->GetPageCount(); BorderNeedRefresh = screen->GetPageCount(); } + R_DrawRemainingPlayerSprites(); + screen->DrawBlendingRect(); if (automapactive) { int saved_ST_Y = ST_Y; diff --git a/src/d_player.h b/src/d_player.h index 7c7becbe3..fa936b552 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -303,7 +303,8 @@ public: TObjPtr poisoner; // NULL for non-player actors TObjPtr attacker; // who did damage (NULL for floors) int extralight; // so gun flashes light up areas - int fixedcolormap; // can be set to REDCOLORMAP, etc. + short fixedcolormap; // can be set to REDCOLORMAP, etc. + short fixedlightlevel; pspdef_t psprites[NUMPSPRITES]; // view sprites (gun, etc) int morphTics; // player is a chicken/pig if > 0 BYTE MorphedPlayerClass; // [MH] (for SBARINFO) class # for this player instance when morphed diff --git a/src/g_game.cpp b/src/g_game.cpp index 8555db2c4..43587bb08 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1195,7 +1195,8 @@ void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory p->mo->RenderStyle = STYLE_Normal; p->mo->alpha = FRACUNIT; p->extralight = 0; // cancel gun flashes - p->fixedcolormap = 0; // cancel ir goggles + p->fixedcolormap = NOFIXEDCOLORMAP; // cancel ir goggles + p->fixedlightlevel = -1; p->damagecount = 0; // no palette changes p->bonuscount = 0; p->poisoncount = 0; diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 147511f55..5b7f016cf 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -205,7 +205,7 @@ void APowerup::DoEffect () (BlendColor == GREENCOLOR && Owner->player->fixedcolormap == GREENCOLORMAP) || (BlendColor == BLUECOLOR && Owner->player->fixedcolormap == BLUECOLORMAP)) { - Owner->player->fixedcolormap = 0; + Owner->player->fixedcolormap = NOFIXEDCOLORMAP; } } } @@ -471,7 +471,7 @@ void APowerInvulnerable::EndEffect () if (Owner->player != NULL) { - Owner->player->fixedcolormap = 0; + Owner->player->fixedcolormap = NOFIXEDCOLORMAP; } } @@ -711,7 +711,7 @@ int APowerInvisibility::AlterWeaponSprite (vissprite_t *vis) if ((vis->alpha < TRANSLUC25 && special1 > 0) || (vis->alpha == 0)) { vis->alpha = clamp((OPAQUE - Strength), 0, OPAQUE); - vis->colormap = InverseColormap; + vis->colormap = SpecialColormaps[INVERSECOLORMAP]; } return -1; // This item is valid so another one shouldn't reset the translucency } @@ -830,11 +830,11 @@ void APowerLightAmp::DoEffect () { if (EffectTics > BLINKTHRESHOLD || (EffectTics & 8)) { - Owner->player->fixedcolormap = 1; + Owner->player->fixedlightlevel = 1; } else { - Owner->player->fixedcolormap = 0; + Owner->player->fixedlightlevel = -1; } } } @@ -849,7 +849,7 @@ void APowerLightAmp::EndEffect () { if (Owner != NULL && Owner->player != NULL && Owner->player->fixedcolormap < NUMCOLORMAPS) { - Owner->player->fixedcolormap = 0; + Owner->player->fixedlightlevel = -1; } } @@ -894,22 +894,22 @@ void APowerTorch::DoEffect () { if (NewTorch != 0) { - if (Owner->player->fixedcolormap + NewTorchDelta > 7 - || Owner->player->fixedcolormap + NewTorchDelta < 1 - || NewTorch == Owner->player->fixedcolormap) + if (Owner->player->fixedlightlevel + NewTorchDelta > 7 + || Owner->player->fixedlightlevel + NewTorchDelta < 0 + || NewTorch == Owner->player->fixedlightlevel) { NewTorch = 0; } else { - Owner->player->fixedcolormap += NewTorchDelta; + Owner->player->fixedlightlevel += NewTorchDelta; } } else { NewTorch = (pr_torch() & 7) + 1; - NewTorchDelta = (NewTorch == Owner->player->fixedcolormap) ? - 0 : ((NewTorch > Owner->player->fixedcolormap) ? 1 : -1); + NewTorchDelta = (NewTorch == Owner->player->fixedlightlevel) ? + 0 : ((NewTorch > Owner->player->fixedlightlevel) ? 1 : -1); } } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 3f1874199..b070adef1 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3899,7 +3899,8 @@ APlayerPawn *P_SpawnPlayer (FMapThing *mthing, bool tempplayer) p->MorphStyle = 0; p->MorphExitFlash = NULL; p->extralight = 0; - p->fixedcolormap = 0; + p->fixedcolormap = NOFIXEDCOLORMAP; + p->fixedlightlevel = -1; p->viewheight = mobj->ViewHeight; p->inconsistant = 0; p->attacker = NULL; diff --git a/src/p_user.cpp b/src/p_user.cpp index 703b37867..014d837d4 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2508,9 +2508,27 @@ void player_t::Serialize (FArchive &arc) << poisoncount << poisoner << attacker - << extralight - << fixedcolormap - << morphTics + << extralight; + if (SaveVersion < 1858) + { + int fixedmap; + arc << fixedmap; + fixedcolormap = NOFIXEDCOLORMAP; + fixedlightlev = -1; + if (fixedmap >= NUMCOLORMAPS) + { + fixedcolormap = fixedmap - NUMCOLORMAPS; + } + else if (fixedmap > 0) + { + fixedlightlev = fixedmap; + } + } + else + { + arc << fixedcolormap << fixedlightlev; + } + arc << morphTics << MorphedPlayerClass << MorphStyle << MorphExitFlash @@ -2532,7 +2550,7 @@ void player_t::Serialize (FArchive &arc) << ConversationPC << ConversationNPCAngle << ConversationFaceTalker; - + for (i = 0; i < MAXPLAYERS; i++) arc << frags[i]; for (i = 0; i < NUMPSPRITES; i++) diff --git a/src/r_blend.h b/src/r_blend.h index fbc478c12..132d09507 100644 --- a/src/r_blend.h +++ b/src/r_blend.h @@ -114,10 +114,10 @@ union FRenderStyle BYTE DestAlpha; // Of ERenderAlpha type BYTE Flags; }; - DWORD AsDWORD; + uint32 AsDWORD; inline FRenderStyle &operator= (ERenderStyle legacy); - operator DWORD() const { return AsDWORD; } + operator uint32() const { return AsDWORD; } bool operator==(const FRenderStyle &o) const { return AsDWORD == o.AsDWORD; } void CheckFuzz(); bool IsVisible(fixed_t alpha) const throw(); diff --git a/src/r_draw.cpp b/src/r_draw.cpp index c9bb8fbec..12cf3c51f 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2205,7 +2205,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, hcolfunc_post4 = rt_shaded4cols; dc_color = fixedcolormap ? fixedcolormap[APART(color)] : basecolormap->Maps[APART(color)]; dc_colormap = (basecolormap = &ShadeFakeColormap[16-alpha])->Maps; - if (fixedlightlev && !fixedcolormap) + if (fixedlightlev >= 0 && fixedcolormap == NULL) { dc_colormap += fixedlightlev; } diff --git a/src/r_main.cpp b/src/r_main.cpp index d20ec9670..00dfe8353 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1159,45 +1159,23 @@ void R_SetupFrame (AActor *actor) } fixedcolormap = NULL; - fixedlightlev = 0; + fixedlightlev = -1; - if (player != NULL && camera == player->mo && player->fixedcolormap) + if (player != NULL && camera == player->mo) { - if (player->fixedcolormap < NUMCOLORMAPS) + if (player->fixedcolormap >= 0 && player->fixedcolormap < NUM_SPECIALCOLORMAPS) { - fixedlightlev = player->fixedcolormap*256; - fixedcolormap = NormalLight.Maps; + fixedcolormap = SpecialColormaps[player->fixedcolormap]; } - else switch (player->fixedcolormap) + else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS) { - case INVERSECOLORMAP: - fixedcolormap = InverseColormap; - break; - - case REDCOLORMAP: - fixedcolormap = RedColormap; - break; - - case GREENCOLORMAP: - fixedcolormap = GreenColormap; - break; - - case BLUECOLORMAP: - fixedcolormap = BlueColormap; - break; - - case GOLDCOLORMAP: - fixedcolormap = GoldColormap; - break; - - default: - break; + fixedlightlev = player->fixedlightlevel * 256; } } // [RH] Inverse light for shooting the Sigil - else if (extralight == INT_MIN) + if (fixedcolormap == NULL && extralight == INT_MIN) { - fixedcolormap = InverseColormap; + fixedcolormap = SpecialColormaps[INVERSECOLORMAP]; extralight = 0; } diff --git a/src/r_main.h b/src/r_main.h index 0952219fe..f6948a545 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -30,6 +30,7 @@ #include "d_player.h" #include "r_data.h" #include "r_state.h" +#include "v_palette.h" // @@ -88,12 +89,6 @@ extern bool r_dontmaplines; // 16 discrete light levels. The terminology I use is borrowed from Build. // -#define INVERSECOLORMAP 32 -#define GOLDCOLORMAP 33 -#define REDCOLORMAP 34 -#define GREENCOLORMAP 35 -#define BLUECOLORMAP 36 - // The size of a single colormap, in bits #define COLORMAPSHIFT 8 diff --git a/src/r_plane.cpp b/src/r_plane.cpp index b2dc9ac40..69af40223 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1407,7 +1407,7 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool masked) planeheight = abs (FixedMul (pl->height.d, -pl->height.ic) - viewz); GlobVis = FixedDiv (r_FloorVisibility, planeheight); - if (fixedlightlev) + if (fixedlightlev >= 0) ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; else if (fixedcolormap) ds_colormap = fixedcolormap, plane_shade = false; @@ -1545,7 +1545,7 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool masked) if (pl->height.c > 0) planelightfloat = -planelightfloat; - if (fixedlightlev) + if (fixedlightlev >= 0) ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; else if (fixedcolormap) ds_colormap = fixedcolormap, plane_shade = false; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 7fb5800c9..e58d042ab 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -154,7 +154,7 @@ CVAR(Bool, r_fogboundary, true, 0) inline bool IsFogBoundary (sector_t *front, sector_t *back) { - return r_fogboundary && !fixedcolormap && front->ColorMap->Fade && + return r_fogboundary && fixedcolormap == NULL && front->ColorMap->Fade && front->ColorMap->Fade != back->ColorMap->Fade && (front->GetTexture(sector_t::ceiling) != skyflatnum || back->GetTexture(sector_t::ceiling) != skyflatnum); } @@ -179,7 +179,7 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText if (maskedtexturecol[dc_x] != FIXED_MAX) { // calculate lighting - if (!fixedcolormap) + if (fixedcolormap == NULL && fixedlightlev < 0) { dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } @@ -298,9 +298,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } } - if (fixedlightlev) + if (fixedlightlev >= 0) dc_colormap = basecolormap->Maps + fixedlightlev; - else if (fixedcolormap) + else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; if (!(curline->linedef->flags & ML_WRAP_MIDTEX) && @@ -453,7 +453,8 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t x = x1; //while ((umost[x] > dmost[x]) && (x <= x2)) x++; - if (fixedcolormap) + bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); + if (fixed) { palookupoffse[0] = dc_colormap; palookupoffse[1] = dc_colormap; @@ -470,7 +471,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t assert (y1ve[0] < viewheight); assert (y2ve[0] <= viewheight); - if (!fixedcolormap) + if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); } @@ -505,7 +506,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t continue; } - if (!fixedcolormap) + if (!fixed) { for (z = 0; z < 4; ++z) { @@ -563,7 +564,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t assert (y1ve[0] < viewheight); assert (y2ve[0] <= viewheight); - if (!fixedcolormap) + if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); } @@ -700,7 +701,8 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe x = startx = x1; p = x + dc_destorg; - if (fixedcolormap) + bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); + if (fixed) { palookupoffse[0] = dc_colormap; palookupoffse[1] = dc_colormap; @@ -715,7 +717,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe y2ve[0] = dwal[x];//min(dwal[x],dmost[x]); if (y2ve[0] <= y1ve[0]) continue; - if (!fixedcolormap) + if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); } @@ -748,7 +750,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe continue; } - if (!fixedcolormap) + if (!fixed) { for (z = 0; z < 4; ++z) { @@ -804,7 +806,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe y2ve[0] = dwal[x]; if (y2ve[0] <= y1ve[0]) continue; - if (!fixedcolormap) + if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); } @@ -872,7 +874,8 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, x = startx = x1; p = x + dc_destorg; - if (fixedcolormap) + bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); + if (fixed) { palookupoffse[0] = dc_colormap; palookupoffse[1] = dc_colormap; @@ -887,7 +890,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, y2ve[0] = dwal[x];//min(dwal[x],dmost[x]); if (y2ve[0] <= y1ve[0]) continue; - if (!fixedcolormap) + if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); } @@ -920,7 +923,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, continue; } - if (!fixedcolormap) + if (!fixed) { for (z = 0; z < 4; ++z) { @@ -979,7 +982,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, y2ve[0] = dwal[x]; if (y2ve[0] <= y1ve[0]) continue; - if (!fixedcolormap) + if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); } @@ -1016,9 +1019,9 @@ void R_RenderSegLoop () fixed_t xscale, yscale; fixed_t xoffset = rw_offset; - if (fixedlightlev) + if (fixedlightlev >= 0) dc_colormap = basecolormap->Maps + fixedlightlev; - else if (fixedcolormap) + else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; // clip wall to the floor and ceiling @@ -1087,7 +1090,7 @@ void R_RenderSegLoop () { rw_offset = rw_offset_mid; } - if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights) + if (fixedcolormap != NULL || !frontsector->ExtraLights) { wallscan (x1, x2-1, walltop, wallbottom, swall, lwall, yscale); } @@ -1126,7 +1129,7 @@ void R_RenderSegLoop () { rw_offset = rw_offset_top; } - if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights) + if (fixedcolormap != NULL || !frontsector->ExtraLights) { wallscan (x1, x2-1, walltop, wallupper, swall, lwall, yscale); } @@ -1168,7 +1171,7 @@ void R_RenderSegLoop () { rw_offset = rw_offset_bottom; } - if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights) + if (fixedcolormap != NULL || !frontsector->ExtraLights) { wallscan (x1, x2-1, walllower, wallbottom, swall, lwall, yscale); } @@ -1434,7 +1437,7 @@ void R_NewWall (bool needlights) PrepWall (swall, lwall, sidedef->TexelLength * lwallscale); - if (!fixedcolormap) + if (fixedcolormap == NULL && fixedlightlev < 0) { wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel) + r_actualextralight); @@ -2421,9 +2424,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, bool calclighting = false; rw_light = rw_lightleft + (x1 - WallSX1) * rw_lightstep; - if (fixedlightlev) + if (fixedlightlev >= 0) dc_colormap = basecolormap->Maps + fixedlightlev; - else if (fixedcolormap) + else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) dc_colormap = basecolormap->Maps; diff --git a/src/r_things.cpp b/src/r_things.cpp index ffc9ed3dd..552241be2 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -50,6 +50,7 @@ #include "r_plane.h" #include "r_segs.h" #include "v_palette.h" +#include "r_translate.h" extern fixed_t globaluclip, globaldclip; @@ -74,6 +75,10 @@ fixed_t pspritexiscale; fixed_t sky1scale; // [RH] Sky 1 scale factor fixed_t sky2scale; // [RH] Sky 2 scale factor +vissprite_t *VisPSprites[NUMPSPRITES]; +int VisPSpritesX1[NUMPSPRITES]; +FDynamicColormap *VisPSpritesBaseColormap[NUMPSPRITES]; + static int spriteshade; TArray ParticlesInSubsec; @@ -1430,50 +1435,40 @@ void R_ProjectSprite (AActor *thing, int fakeside) if (vis->RenderStyle.Flags & STYLEF_FadeToBlack) { if (invertcolormap) - { - // Fade to white + { // Fade to white mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255,255,255), mybasecolormap->Desaturate); invertcolormap = false; } else - { - // Fade to black + { // Fade to black mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0,0,0), mybasecolormap->Desaturate); } } // get light level - if (fixedlightlev) - { - if (invertcolormap) - { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); - } - vis->colormap = mybasecolormap->Maps + fixedlightlev; - } - else if (fixedcolormap) - { - // fixed map + if (fixedcolormap != NULL) + { // fixed map vis->colormap = fixedcolormap; } - else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) - { - // full bright - if (invertcolormap) - { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); - } - vis->colormap = mybasecolormap->Maps; - } else { - // diminished light if (invertcolormap) { mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); } - vis->colormap = mybasecolormap->Maps + (GETPALOOKUP ( - (fixed_t)DivScale12 (r_SpriteVisibility, tz), spriteshade) << COLORMAPSHIFT); + if (fixedlightlev >= 0) + { + vis->colormap = mybasecolormap->Maps + fixedlightlev; + } + else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) + { // full bright + vis->colormap = mybasecolormap->Maps; + } + else + { // diminished light + vis->colormap = mybasecolormap->Maps + (GETPALOOKUP ( + (fixed_t)DivScale12 (r_SpriteVisibility, tz), spriteshade) << COLORMAPSHIFT); + } } } @@ -1522,7 +1517,10 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ WORD flip; FTexture* tex; vissprite_t* vis; - vissprite_t avis; + static vissprite_t avis[NUMPSPRITES]; + bool noaccel; + + assert(pspnum >= 0 && pspnum < NUMPSPRITES); // decide which patch to use if ( (unsigned)psp->state->sprite >= (unsigned)sprites.Size ()) @@ -1550,7 +1548,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ tx -= tex->GetScaledLeftOffset() << FRACBITS; x1 = (centerxfrac + FixedMul (tx, pspritexscale)) >>FRACBITS; - + VisPSpritesX1[pspnum] = x1; // off the right side if (x1 > viewwidth) @@ -1564,7 +1562,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ return; // store information in a vissprite - vis = &avis; + vis = &avis[pspnum]; vis->renderflags = owner->renderflags; vis->floorclip = 0; @@ -1619,6 +1617,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ if (vis->x1 > x1) vis->startfrac += vis->xiscale*(vis->x1-x1); + noaccel = false; if (pspnum <= ps_flash) { vis->alpha = owner->alpha; @@ -1639,67 +1638,92 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ if (vis->RenderStyle.Flags & STYLEF_FadeToBlack) { if (invertcolormap) - { - // Fade to white + { // Fade to white mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255,255,255), mybasecolormap->Desaturate); invertcolormap = false; } else - { - // Fade to black + { // Fade to black mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0,0,0), mybasecolormap->Desaturate); } } - if (fixedlightlev) - { - if (invertcolormap) - { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); - } - vis->colormap = mybasecolormap->Maps + fixedlightlev; - } - else if (fixedcolormap) - { - // fixed color + if (fixedcolormap != NULL) + { // fixed color vis->colormap = fixedcolormap; } - else if (!foggy && psp->state->GetFullbright()) - { - // full bright - if (invertcolormap) - { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); - } - vis->colormap = mybasecolormap->Maps; // [RH] use basecolormap - } else { - // local light if (invertcolormap) { mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); } - vis->colormap = mybasecolormap->Maps + (GETPALOOKUP (0, spriteshade) << COLORMAPSHIFT); + if (fixedlightlev >= 0) + { + vis->colormap = mybasecolormap->Maps + fixedlightlev; + } + else if (!foggy && psp->state->GetFullbright()) + { // full bright + vis->colormap = mybasecolormap->Maps; // [RH] use basecolormap + } + else + { // local light + vis->colormap = mybasecolormap->Maps + (GETPALOOKUP (0, spriteshade) << COLORMAPSHIFT); + } } if (camera->Inventory != NULL) { + lighttable_t *oldcolormap = vis->colormap; camera->Inventory->AlterWeaponSprite (vis); + if (vis->colormap != oldcolormap) + { + // The colormap has changed. Is it one we can easily identify? + // If not, then don't bother trying to identify it for + // hardware accelerated drawing. + if (vis->colormap < SpecialColormaps[0] || vis->colormap >= SpecialColormaps[NUM_SPECIALCOLORMAPS]) + { + noaccel = true; + } + // Has the basecolormap changed? If so, we can't hardware accelerate it, + // since we don't know what it is anymore. + else if (vis->colormap < mybasecolormap->Maps || + vis->colormap >= mybasecolormap->Maps + NUMCOLORMAPS*256) + { + noaccel = true; + } + } } + VisPSpritesBaseColormap[pspnum] = mybasecolormap; } else { + VisPSpritesBaseColormap[pspnum] = basecolormap; vis->RenderStyle = STYLE_Normal; } - + + // Check for hardware-assisted 2D. If it's available, and this sprite is not + // fuzzy, don't draw it until after the switch to 2D mode. + if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) + { + FRenderStyle style = vis->RenderStyle; + style.CheckFuzz(); + if (style.BlendOp != STYLEOP_Fuzz) + { + VisPSprites[pspnum] = vis; + return; + } + } R_DrawVisSprite (vis); } +//========================================================================== // // R_DrawPlayerSprites // +//========================================================================== + void R_DrawPlayerSprites (void) { int i; @@ -1708,7 +1732,7 @@ void R_DrawPlayerSprites (void) sector_t* sec; static sector_t tempsec; int floorlight, ceilinglight; - + if (!r_drawplayersprites || !camera->player || (players[consoleplayer].cheats & CF_CHASECAM)) @@ -1766,6 +1790,80 @@ void R_DrawPlayerSprites (void) } } +//========================================================================== +// +// R_DrawRemainingPlayerSprites +// +// Called from D_Display to draw sprites that were not drawn by +// R_DrawPlayerSprites(). +// +//========================================================================== + +void R_DrawRemainingPlayerSprites() +{ + for (int i = 0; i < NUMPSPRITES; ++i) + { + vissprite_t *vis; + + vis = VisPSprites[i]; + VisPSprites[i] = NULL; + + if (vis != NULL) + { + FDynamicColormap *colormap = VisPSpritesBaseColormap[i]; + bool flip = vis->xiscale < 0; + FSpecialColormapParameters *special = NULL; + PalEntry overlay = 0; + FColormapStyle colormapstyle; + bool usecolormapstyle = false; + + if (vis->colormap >= SpecialColormaps[0] && vis->colormap < SpecialColormaps[NUM_SPECIALCOLORMAPS]) + { + ptrdiff_t specialmap = (vis->colormap - SpecialColormaps[0]) >> 8; + if (SpecialColormapParms[specialmap].Inverted) + { + vis->RenderStyle.Flags ^= STYLEF_InvertSource; + } + special = &SpecialColormapParms[specialmap]; + } + else if (colormap->Color == PalEntry(255,255,255) && + colormap->Desaturate == 0) + { + overlay = colormap->Fade; + overlay.a = BYTE(((vis->colormap - colormap->Maps) >> 8) * 255 / NUMCOLORMAPS); + } + else + { + usecolormapstyle = true; + colormapstyle.Color = colormap->Color; + colormapstyle.Fade = colormap->Fade; + colormapstyle.Desaturate = colormap->Desaturate; + colormapstyle.FadeLevel = ((vis->colormap - colormap->Maps) >> 8) / float(NUMCOLORMAPS); + } + screen->DrawTexture(vis->pic, + viewwindowx + VisPSpritesX1[i], + viewwindowy + viewheight/2 - MulScale32(vis->texturemid, vis->yscale) - 1, + DTA_DestWidth, FixedMul(vis->pic->GetWidth(), vis->xscale), + DTA_DestHeight, FixedMul(vis->pic->GetHeight(), vis->yscale), + DTA_Translation, TranslationToTable(vis->Translation), + DTA_FlipX, flip, + DTA_TopOffset, 0, + DTA_LeftOffset, 0, + DTA_ClipLeft, viewwindowx, + DTA_ClipTop, viewwindowy, + DTA_ClipRight, viewwindowx + viewwidth, + DTA_ClipBottom, viewwindowy + viewheight, + DTA_Alpha, vis->alpha, + DTA_RenderStyle, vis->RenderStyle, + DTA_FillColor, vis->FillColor, + DTA_SpecialColormap, special, + DTA_ColorOverlay, overlay, + DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL, + TAG_DONE); + } + } +} + @@ -2423,7 +2521,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, vis->floorclip = 0; vis->heightsec = heightsec; - if (fixedlightlev) + if (fixedlightlev >= 0) { vis->colormap = map + fixedlightlev; } diff --git a/src/r_things.h b/src/r_things.h index a3614c063..9ae796ce9 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -102,6 +102,7 @@ void R_InitSprites (); void R_DeinitSprites (); void R_ClearSprites (); void R_DrawMasked (); +void R_DrawRemainingPlayerSprites (); void R_ClipVisSprite (vissprite_t *vis, int xl, int xh); diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 2079f2448..86bab74f8 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -426,16 +426,16 @@ BYTE *GetBlendMap(PalEntry blend, BYTE *blendwork) switch (blend.a==0 ? blend.r : -1) { case BLEND_INVERSEMAP: - return InverseColormap; + return SpecialColormaps[INVERSECOLORMAP]; case BLEND_GOLDMAP: - return GoldColormap; + return SpecialColormaps[GOLDCOLORMAP]; case BLEND_REDMAP: - return RedColormap; + return SpecialColormaps[REDCOLORMAP]; case BLEND_GREENMAP: - return GreenColormap; + return SpecialColormaps[GREENCOLORMAP]; case BLEND_ICEMAP: return TranslationToTable(TRANSLATION(TRANSLATION_Standard, 7))->Remap; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 659a2f502..90fb4beff 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -341,6 +341,8 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l parms->style.BlendOp = 255; // Dummy "not set" value parms->masked = true; parms->bilinear = false; + parms->specialcolormap = NULL; + parms->colormapstyle = NULL; parms->x = x << FRACBITS; parms->y = y << FRACBITS; @@ -580,6 +582,14 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l case DTA_RenderStyle: parms->style.AsDWORD = va_arg (tags, DWORD); break; + + case DTA_SpecialColormap: + parms->specialcolormap = va_arg (tags, FSpecialColormapParameters *); + break; + + case DTA_ColormapStyle: + parms->colormapstyle = va_arg (tags, FColormapStyle *); + break; } tag = va_arg (tags, DWORD); } diff --git a/src/v_palette.cpp b/src/v_palette.cpp index 921093433..d0d50efaa 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -61,15 +61,29 @@ extern "C" { FDynamicColormap NormalLight; } FPalette GPalette; -BYTE InverseColormap[256]; -BYTE GoldColormap[256]; -// [BC] New Skulltag colormaps. -BYTE RedColormap[256]; -BYTE GreenColormap[256]; -BYTE BlueColormap[256]; +BYTE SpecialColormaps[NUM_SPECIALCOLORMAPS][256]; BYTE DesaturateColormap[31][256]; -static void FreeSpecialLights();; +FSpecialColormapParameters SpecialColormapParms[NUM_SPECIALCOLORMAPS] = +{ + // Doom invulnerability is an inverted grayscale. + // Strife uses it when firing the Sigil + { { 1, 1, 1 }, true }, + + // Heretic invulnerability is a golden shade. + { { 1.5, 0.75, 0 }, false }, + + // [BC] Build the Doomsphere colormap. It is red! + { { 1.5, 0, 0 }, false }, + + // [BC] Build the Guardsphere colormap. It's a greenish-white kind of thing. + { { 1.25, 1.5, 1 }, false }, + + // Build a blue colormap. + { { 0, 0, 1.5 }, false }, +}; + +static void FreeSpecialLights(); FColorMatcher ColorMatcher; @@ -385,66 +399,30 @@ void InitPalette () // NormalLight.Maps is set by R_InitColormaps() // build special maps (e.g. invulnerability) - int intensity; + double intensity; - // Doom invulnerability is an inverted grayscale. - // Strife uses it when firing the Sigil - shade = InverseColormap; - - for (c = 0; c < 256; c++) + for (int i = 0; i < countof(SpecialColormapParms); ++i) { - intensity = (65535 - - (GPalette.BaseColors[c].r * 77 + - GPalette.BaseColors[c].g * 143 + - GPalette.BaseColors[c].b * 37)) >> 8; - shade[c] = ColorMatcher.Pick (intensity, intensity, intensity); - } + double r, g, b; + bool inv; - // Heretic invulnerability is a golden shade. - shade = GoldColormap; - - for (c = 0; c < 256; c++) - { - intensity = GPalette.BaseColors[c].r * 77 + - GPalette.BaseColors[c].g * 143 + - GPalette.BaseColors[c].b * 37; - shade[c] = ColorMatcher.Pick ( - MIN (255, (intensity+intensity/2)>>8), intensity>>8, 0); - } - - // [BC] Build the Doomsphere colormap. It is red! - shade = RedColormap; - for (c = 0; c < 256; c++) - { - intensity = ((GPalette.BaseColors[c].r * 77 + - GPalette.BaseColors[c].g * 143 + - GPalette.BaseColors[c].b * 37)); - shade[c] = ColorMatcher.Pick ( - MIN( 255, ( intensity + ( intensity / 2 )) >> 8 ), 0, 0 ); - } - - // [BC] Build the Guardsphere colormap. It's a greenish-white kind of thing. - shade = GreenColormap; - for (c = 0; c < 256; c++) - { - intensity = GPalette.BaseColors[c].r * 77 + - GPalette.BaseColors[c].g * 143 + - GPalette.BaseColors[c].b * 37; - shade[c] = ColorMatcher.Pick ( - MIN( 255, ( intensity + ( intensity / 2 )) >> 8 ), - MIN( 255, ( intensity + ( intensity / 2 )) >> 8 ), - intensity>>8 ); - } - - // Build a blue colormap. - shade = BlueColormap; - for (c = 0; c < 256; c++) - { - intensity = ((GPalette.BaseColors[c].r * 77 + - GPalette.BaseColors[c].g * 143 + - GPalette.BaseColors[c].b * 37)); - shade[c] = ColorMatcher.Pick (0, 0, - MIN( 255, ( intensity + ( intensity / 2 )) >> 8 )); + shade = SpecialColormaps[i]; + r = SpecialColormapParms[i].Colorize[0]; + g = SpecialColormapParms[i].Colorize[1]; + b = SpecialColormapParms[i].Colorize[2]; + inv = SpecialColormapParms[i].Inverted; + for (c = 0; c < 256; c++) + { + intensity = (GPalette.BaseColors[c].r * 77 + + GPalette.BaseColors[c].g * 143 + + GPalette.BaseColors[c].b * 37) / 256.0; + if (inv) + { + intensity = 255 - intensity; + } + shade[c] = ColorMatcher.Pick( + MIN(255, int(intensity*r)), MIN(255, int(intensity*g)), MIN(255, int(intensity*b))); + } } // desaturated colormaps @@ -453,7 +431,7 @@ void InitPalette () shade = DesaturateColormap[m]; for (c = 0; c < 256; c++) { - intensity = (GPalette.BaseColors[c].r * 77 + + int intensity = (GPalette.BaseColors[c].r * 77 + GPalette.BaseColors[c].g * 143 + GPalette.BaseColors[c].b * 37) / 255; diff --git a/src/v_palette.h b/src/v_palette.h index e723ba5c2..160ef6cea 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -79,18 +79,41 @@ struct FDynamicColormap FDynamicColormap *Next; }; -extern BYTE InverseColormap[256]; -extern BYTE GoldColormap[256]; -// [BC] New Skulltag colormaps. -extern BYTE RedColormap[256]; -extern BYTE GreenColormap[256]; -extern BYTE BlueColormap[256]; +// For hardware-accelerated weapon sprites in colored sectors +struct FColormapStyle +{ + PalEntry Color; + PalEntry Fade; + int Desaturate; + float FadeLevel; +}; + +// Special colormaps, like invulnerability. +enum +{ + NOFIXEDCOLORMAP = -1, + INVERSECOLORMAP, + GOLDCOLORMAP, + REDCOLORMAP, // [BC] New Skulltag colormaps. + GREENCOLORMAP, + BLUECOLORMAP, + + NUM_SPECIALCOLORMAPS +}; +struct FSpecialColormapParameters +{ + float Colorize[3]; + bool Inverted; +}; +extern FSpecialColormapParameters SpecialColormapParms[NUM_SPECIALCOLORMAPS]; +extern BYTE SpecialColormaps[NUM_SPECIALCOLORMAPS][256]; + + extern BYTE DesaturateColormap[31][256]; extern FPalette GPalette; extern "C" { extern FDynamicColormap NormalLight; } - // The color overlay to use for depleted items #define DIM_OVERLAY MAKEARGB(170,0,0,0) diff --git a/src/v_video.cpp b/src/v_video.cpp index 304a8ee44..a89e270fb 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1099,6 +1099,20 @@ bool DFrameBuffer::Begin2D (bool copy3d) return false; } +//========================================================================== +// +// DFrameBuffer :: DrawBlendingRect +// +// In hardware 2D modes, the blending rect needs to be drawn separately +// from transferring the 3D scene to video memory, because the weapon +// sprite is drawn on top of that. +// +//========================================================================== + +void DFrameBuffer::DrawBlendingRect() +{ +} + //========================================================================== // // DFrameBuffer :: CreateTexture diff --git a/src/v_video.h b/src/v_video.h index c6857d55a..6d9a6ee96 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -101,6 +101,8 @@ enum DTA_RenderStyle, // same as render style for actors DTA_ColorOverlay, // DWORD: ARGB to overlay on top of image; limited to black for software DTA_BilinearFilter, // bool: apply bilinear filtering to the image + DTA_SpecialColormap,// pointer to FSpecialColormapParameters (likely to be forever hardware-only) + DTA_ColormapStyle, // pointer to FColormapStyle (hardware-only) // For DrawText calls: DTA_TextLen, // stop after this many characters, even if \0 not hit @@ -225,6 +227,8 @@ public: INTBOOL masked; INTBOOL bilinear; FRenderStyle style; + struct FSpecialColormapParameters *specialcolormap; + struct FColormapStyle *colormapstyle; }; protected: @@ -349,12 +353,16 @@ public: // Begin 2D drawing operations. This is like Update, but it doesn't end // the scene, and it doesn't present the image yet. If you are going to // be covering the entire screen with 2D elements, then pass false to - // avoid copying the software bufferer to the screen. + // avoid copying the software buffer to the screen. // Returns true if hardware-accelerated 2D has been entered, false if not. virtual bool Begin2D(bool copy3d); // DrawTexture calls after Begin2D use native textures. + // Draws the blending rectangle over the viewwindow if in hardware- + // accelerated 2D mode. + virtual void DrawBlendingRect(); + // Create a native texture from a game texture. virtual FNativeTexture *CreateTexture(FTexture *gametex, bool wrapping); diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 6eb7da66f..a81c2ca7c 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -68,6 +68,7 @@ #include "win32iface.h" #include "doomstat.h" #include "v_palette.h" +#include "w_wad.h" // MACROS ------------------------------------------------------------------ @@ -168,6 +169,7 @@ enum BQF_WrapUV = 16, BQF_InvertSource = 32, BQF_DisableAlphaTest= 64, + BQF_Desaturated = 128, }; // Shaders for a buffered quad @@ -176,7 +178,9 @@ enum BQS_PalTex, BQS_Plain, BQS_RedToAlpha, - BQS_ColorOnly + BQS_ColorOnly, + BQS_SpecialColormap, + BQS_InGameColormap, }; // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -207,7 +211,35 @@ extern cycle_t BlitCycles; // PRIVATE DATA DEFINITIONS ------------------------------------------------ -#include "fb_d3d9_shaders.h" +const char *const D3DFB::ShaderNames[D3DFB::NUM_SHADERS] = +{ + "NormalColor.pso", + "NormalColorPal.pso", + "NormalColorInv.pso", + "NormalColorPalInv.pso", + + "RedToAlpha.pso", + "RedToAlphaInv.pso", + + "VertexColor.pso", + + "SpecialColormap.pso", + "SpecialColormapInv.pso", + "SpecialColorMapPal.pso", + "SpecialColorMapPalInv.pso", + + "InGameColormap.pso", + "InGameColormapDesat.pso", + "InGameColormapInv.pso", + "InGameColormapInvDesat.pso", + "InGameColormapPal.pso", + "InGameColormapPalDesat.pso", + "InGameColormapPalInv.pso", + "InGameColormapPalInvDesat.pso", + + "BurnWipe.pso", + "GammaCorrection.pso", +}; // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -221,6 +253,12 @@ CVAR(Bool, vid_hwaalines, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // CODE -------------------------------------------------------------------- +//========================================================================== +// +// D3DFB - Constructor +// +//========================================================================== + D3DFB::D3DFB (int width, int height, bool fullscreen) : BaseWinFB (width, height) { @@ -236,15 +274,10 @@ D3DFB::D3DFB (int width, int height, bool fullscreen) ScreenshotSurface = NULL; FinalWipeScreen = NULL; PaletteTexture = NULL; - PalTexShader = NULL; - InvPalTexShader = NULL; - PalTexBilinearShader = NULL; - PlainShader = NULL; - InvPlainShader = NULL; - RedToAlphaShader = NULL; - ColorOnlyShader = NULL; - GammaFixerShader = NULL; - BurnShader = NULL; + for (int i = 0; i < NUM_SHADERS; ++i) + { + Shaders[i] = NULL; + } FBFormat = D3DFMT_UNKNOWN; PalFormat = D3DFMT_UNKNOWN; VSync = vid_vsync; @@ -350,6 +383,12 @@ D3DFB::D3DFB (int width, int height, bool fullscreen) } } +//========================================================================== +// +// D3DFB - Destructor +// +//========================================================================== + D3DFB::~D3DFB () { ReleaseResources(); @@ -357,8 +396,15 @@ D3DFB::~D3DFB () delete[] QuadExtra; } +//========================================================================== +// +// D3DFB :: SetInitialState +// // Called after initial device creation and reset, when everything is set // to D3D's defaults. +// +//========================================================================== + void D3DFB::SetInitialState() { AlphaBlendEnabled = FALSE; @@ -398,9 +444,9 @@ void D3DFB::SetInitialState() D3DDevice->SetGammaRamp(0, 0, &ramp); } - // Used by the inverse color shaders - float ones[4] = { 1, 1, 1, 1 }; - D3DDevice->SetPixelShaderConstantF(6, ones, 1); + // This constant is used for grayscaling weights (.xyz) and color inversion (.w) + float weights[4] = { 77/256.f, 143/256.f, 37/256.f, 1 }; + D3DDevice->SetPixelShaderConstantF(PSCONST_Weights, weights, 1); // D3DRS_ALPHATESTENABLE defaults to FALSE // D3DRS_ALPHAREF defaults to 0 @@ -410,6 +456,12 @@ void D3DFB::SetInitialState() CurBorderColor = 0; } +//========================================================================== +// +// D3DFB :: FillPresentParameters +// +//========================================================================== + void D3DFB::FillPresentParameters (D3DPRESENT_PARAMETERS *pp, bool fullscreen, bool vsync) { memset (pp, 0, sizeof(*pp)); @@ -427,7 +479,13 @@ void D3DFB::FillPresentParameters (D3DPRESENT_PARAMETERS *pp, bool fullscreen, b } } -bool D3DFB::CreateResources () +//========================================================================== +// +// D3DFB :: CreateResources +// +//========================================================================== + +bool D3DFB::CreateResources() { Packs = NULL; if (!Windowed) @@ -444,56 +502,28 @@ bool D3DFB::CreateResources () LOG2 ("Resize window to %dx%d\n", sizew, sizeh); VidResizing = true; // Make sure the window has a border in windowed mode - SetWindowLong (Window, GWL_STYLE, WS_VISIBLE|WS_OVERLAPPEDWINDOW); - if (GetWindowLong (Window, GWL_EXSTYLE) & WS_EX_TOPMOST) + SetWindowLong(Window, GWL_STYLE, WS_VISIBLE|WS_OVERLAPPEDWINDOW); + if (GetWindowLong(Window, GWL_EXSTYLE) & WS_EX_TOPMOST) { // Direct3D 9 will apparently add WS_EX_TOPMOST to fullscreen windows, // and removing it is a little tricky. Using SetWindowLongPtr to clear it // will not do the trick, but sending the window behind everything will. - SetWindowPos (Window, HWND_BOTTOM, 0, 0, sizew, sizeh, + SetWindowPos(Window, HWND_BOTTOM, 0, 0, sizew, sizeh, SWP_DRAWFRAME | SWP_NOCOPYBITS | SWP_NOMOVE); - SetWindowPos (Window, HWND_TOP, 0, 0, 0, 0, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE); } else { - SetWindowPos (Window, NULL, 0, 0, sizew, sizeh, + SetWindowPos(Window, NULL, 0, 0, sizew, sizeh, SWP_DRAWFRAME | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOZORDER); } - I_RestoreWindowedPos (); + I_RestoreWindowedPos(); VidResizing = false; } - SM14 = false; - if (FAILED(D3DDevice->CreatePixelShader (PalTexShader20Def, &PalTexShader)) && - (SM14 = true, FAILED(D3DDevice->CreatePixelShader (PalTexShader14Def, &PalTexShader)))) + if (!LoadShaders()) { return false; } - if (FAILED(D3DDevice->CreatePixelShader (InvPalTexShader20Def, &InvPalTexShader)) && - (SM14 = true, FAILED(D3DDevice->CreatePixelShader (InvPalTexShader14Def, &InvPalTexShader)))) - { - return false; - } - if (FAILED(D3DDevice->CreatePixelShader (PlainShaderDef, &PlainShader)) || - FAILED(D3DDevice->CreatePixelShader (InvPlainShaderDef, &InvPlainShader)) || - FAILED(D3DDevice->CreatePixelShader (RedToAlphaDef, &RedToAlphaShader)) || - FAILED(D3DDevice->CreatePixelShader (ColorOnlyDef, &ColorOnlyShader))) - { - return false; - } - if (FAILED(D3DDevice->CreatePixelShader (GammaFixerDef, &GammaFixerShader))) - { -// Cannot print during screen creation. -// Printf ("Using Shader Model 1.4: Windowed mode gamma will not work.\n"); - GammaFixerShader = NULL; - } - if (FAILED(D3DDevice->CreatePixelShader(PalTexBilinearDef, &PalTexBilinearShader))) - { - PalTexBilinearShader = PalTexShader; - } - if (FAILED(D3DDevice->CreatePixelShader (BurnShaderDef, &BurnShader))) - { - BurnShader = NULL; - } if (!CreateFBTexture() || !CreatePaletteTexture()) { @@ -506,6 +536,62 @@ bool D3DFB::CreateResources () return true; } +//========================================================================== +// +// D3DFB :: LoadShaders +// +// Returns true if all required shaders were loaded. (Gamma and burn wipe +// are the only ones not considered "required".) +// +//========================================================================== + +bool D3DFB::LoadShaders() +{ + static const char *const models[] = { "30/", "20/", "14/" }; + FString shaderdir, shaderpath; + int model, i, lump; + + // We determine the best available model simply by trying them all in + // order of decreasing preference. + for (model = 0; model < countof(models); ++model) + { + shaderdir = "shaders/d3d/sm"; + shaderdir += models[model]; + for (i = 0; i < NUM_SHADERS; ++i) + { + shaderpath = shaderdir; + shaderpath += ShaderNames[i]; + lump = Wads.CheckNumForFullName(shaderpath); + if (lump >= 0) + { + FMemLump data = Wads.ReadLump(lump); + if (FAILED(D3DDevice->CreatePixelShader((DWORD *)data.GetMem(), &Shaders[i])) && + i != SHADER_GammaCorrection && i != SHADER_BurnWipe) + { + break; + } + } + } + if (i == NUM_SHADERS) + { // Success! + SM14 = (model == countof(models) - 1); + return true; + } + // Failure. Release whatever managed to load (which is probably nothing.) + for (i = 0; i < NUM_SHADERS; ++i) + { + SAFE_RELEASE( Shaders[i] ); + } + } + return false; +} + +//========================================================================== +// +// D3DFB :: ReleaseResources +// +//========================================================================== + void D3DFB::ReleaseResources () { I_SaveWindowedPos (); @@ -515,22 +601,10 @@ void D3DFB::ReleaseResources () SAFE_RELEASE( ScreenshotSurface ); SAFE_RELEASE( ScreenshotTexture ); SAFE_RELEASE( PaletteTexture ); - if (PalTexBilinearShader != NULL) + for (int i = 0; i < NUM_SHADERS; ++i) { - if (PalTexBilinearShader != PalTexShader) - { - PalTexBilinearShader->Release(); - } - PalTexBilinearShader = NULL; + SAFE_RELEASE( Shaders[i] ); } - SAFE_RELEASE( PalTexShader ); - SAFE_RELEASE( InvPalTexShader ); - SAFE_RELEASE( PlainShader ); - SAFE_RELEASE( InvPlainShader ); - SAFE_RELEASE( RedToAlphaShader ); - SAFE_RELEASE( ColorOnlyShader ); - SAFE_RELEASE( GammaFixerShader ); - SAFE_RELEASE( BurnShader ); if (ScreenWipe != NULL) { delete ScreenWipe; @@ -545,7 +619,14 @@ void D3DFB::ReleaseResources () GatheringWipeScreen = false; } +//========================================================================== +// +// D3DFB :: ReleaseDefaultPoolItems +// // Free resources created with D3DPOOL_DEFAULT. +// +//========================================================================== + void D3DFB::ReleaseDefaultPoolItems() { SAFE_RELEASE( FBTexture ); @@ -563,6 +644,12 @@ void D3DFB::ReleaseDefaultPoolItems() SAFE_RELEASE( IndexBuffer ); } +//========================================================================== +// +// D3DFB :: Reset +// +//========================================================================== + bool D3DFB::Reset () { D3DPRESENT_PARAMETERS d3dpp; @@ -881,7 +968,7 @@ void D3DFB::Update () } psgamma[2] = psgamma[1] = psgamma[0] = igamma; psgamma[3] = 1; - D3DDevice->SetPixelShaderConstantF(7, psgamma, 1); + D3DDevice->SetPixelShaderConstantF(PSCONST_Gamma, psgamma, 1); } if (NeedPalUpdate) @@ -971,7 +1058,7 @@ void D3DFB::Draw3DPart(bool copy3d) D3DDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, vid_hwaalines); assert(OldRenderTarget == NULL); if (TempRenderTexture != NULL && - ((Windowed && GammaFixerShader && TempRenderTexture != FinalWipeScreen) || GatheringWipeScreen || PixelDoubling)) + ((Windowed && Shaders[SHADER_GammaCorrection] && TempRenderTexture != FinalWipeScreen) || GatheringWipeScreen || PixelDoubling)) { IDirect3DSurface9 *targetsurf; if (SUCCEEDED(TempRenderTexture->GetSurfaceLevel(0, &targetsurf))) @@ -989,7 +1076,7 @@ void D3DFB::Draw3DPart(bool copy3d) SetTexture (0, FBTexture); SetPaletteTexture(PaletteTexture, 256, BorderColor); - SetPixelShader(PalTexShader); + SetPixelShader(Shaders[SHADER_NormalColorPal]); D3DDevice->SetFVF (D3DFVF_FBVERTEX); memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(D3DBLENDOP(0)); @@ -997,7 +1084,18 @@ void D3DFB::Draw3DPart(bool copy3d) if (copy3d) { FBVERTEX verts[4]; - CalcFullscreenCoords(verts, Accel2D, false, FlashColor0, FlashColor1); + D3DCOLOR color0, color1; + if (Accel2D) + { + color0 = 0; + color1 = 0xFFFFFFF; + } + else + { + color0 = FlashColor0; + color1 = FlashColor1; + } + CalcFullscreenCoords(verts, Accel2D, false, color0, color1); D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); } } @@ -1039,7 +1137,7 @@ void D3DFB::DoWindowedGamma() D3DDevice->SetRenderTarget(0, OldRenderTarget); D3DDevice->SetFVF(D3DFVF_FBVERTEX); SetTexture(0, TempRenderTexture); - SetPixelShader((Windowed && GammaFixerShader != NULL) ? GammaFixerShader : PlainShader); + SetPixelShader(Shaders[(Windowed && Shaders[SHADER_GammaCorrection]) ? SHADER_GammaCorrection : SHADER_NormalColor]); SetAlphaBlend(D3DBLENDOP(0)); EnableAlphaTest(FALSE); D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); @@ -2148,6 +2246,23 @@ bool D3DFB::Begin2D(bool copy3d) return true; } +//========================================================================== +// +// D3DFB :: DrawBlendingRect +// +// Call after Begin2D to blend the 3D view. +// +//========================================================================== + +void D3DFB::DrawBlendingRect() +{ + if (!In2D || !Accel2D) + { + return; + } + Dim(FlashColor, FlashAmount / 256.f, viewwindowx, viewwindowy, viewwidth, viewheight); +} + //========================================================================== // // D3DFB :: CreateTexture @@ -2278,7 +2393,7 @@ void D3DFB::EndLineBatch() VertexBuffer->Unlock(); if (VertexPos > 0) { - SetPixelShader(ColorOnlyShader); + SetPixelShader(Shaders[SHADER_VertexColor]); SetAlphaBlend(D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA); D3DDevice->SetStreamSource(0, VertexBuffer, 0, sizeof(FBVERTEX)); D3DDevice->DrawPrimitive(D3DPT_LINELIST, 0, VertexPos / 2); @@ -2357,7 +2472,7 @@ void D3DFB::DrawPixel(int x, int y, int palcolor, uint32 color) float(x), float(y), 0, 1, color }; EndBatch(); // Draw out any batched operations. - SetPixelShader(ColorOnlyShader); + SetPixelShader(Shaders[SHADER_VertexColor]); SetAlphaBlend(D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA); D3DDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 1, &pt, sizeof(FBVERTEX)); } @@ -2845,26 +2960,39 @@ void D3DFB::EndQuadBatch() // Set the pixel shader if (quad->ShaderNum == BQS_PalTex) { - if (!(quad->Flags & BQF_Bilinear)) - { - SetPixelShader((quad->Flags & BQF_InvertSource) ? InvPalTexShader : PalTexShader); - } - else - { - SetPixelShader(PalTexBilinearShader); - } + SetPixelShader(Shaders[(quad->Flags & BQF_InvertSource) ? + SHADER_NormalColorPalInv : SHADER_NormalColorPal]); } else if (quad->ShaderNum == BQS_Plain) { - SetPixelShader((quad->Flags & BQF_InvertSource) ? InvPlainShader : PlainShader); + SetPixelShader(Shaders[(quad->Flags & BQF_InvertSource) ? + SHADER_NormalColorInv : SHADER_NormalColor]); } else if (quad->ShaderNum == BQS_RedToAlpha) { - SetPixelShader(RedToAlphaShader); + SetPixelShader(Shaders[(quad->Flags & BQF_InvertSource) ? + SHADER_RedToAlphaInv : SHADER_RedToAlpha]); } else if (quad->ShaderNum == BQS_ColorOnly) { - SetPixelShader(ColorOnlyShader); + SetPixelShader(Shaders[SHADER_VertexColor]); + } + else if (quad->ShaderNum == BQS_SpecialColormap) + { + int select; + + select = !!(quad->Flags & BQF_InvertSource); + select |= !!(quad->Flags & BQF_Paletted) << 1; + SetPixelShader(Shaders[SHADER_SpecialColormap + select]); + } + else if (quad->ShaderNum == BQS_InGameColormap) + { + int select; + + select = !!(quad->Flags & BQF_Desaturated); + select |= !!(quad->Flags & BQF_InvertSource) << 1; + select |= !!(quad->Flags & BQF_Paletted) << 2; + SetPixelShader(Shaders[SHADER_InGameColormap + select]); } // Set the texture clamp addressing mode @@ -2983,7 +3111,47 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR & SetColorOverlay(parms.colorOverlay, alpha, color0, color1); - if (style.Flags & STYLEF_ColorIsFixed) + if (parms.specialcolormap != NULL) + { // Emulate an invulnerability or similar colormap. + if (style.Flags & STYLEF_InvertSource) + { + quad.Flags |= BQF_InvertSource; + } + if (fmt == D3DFMT_L8) + { + quad.Flags |= BQF_GamePalette; + } + quad.ShaderNum = BQS_SpecialColormap; + color0 = D3DCOLOR_COLORVALUE(parms.specialcolormap->Colorize[0]/2, + parms.specialcolormap->Colorize[1]/2, parms.specialcolormap->Colorize[2]/2, 1); + color1 = 0; + } + else if (parms.colormapstyle != NULL) + { // Emulate the fading from an in-game colormap (colorized, faded, and desaturated) + if (style.Flags & STYLEF_InvertSource) + { + quad.Flags |= BQF_InvertSource; + } + if (fmt == D3DFMT_L8) + { + quad.Flags |= BQF_GamePalette; + } + if (parms.colormapstyle->Desaturate != 0) + { + quad.Flags |= BQF_Desaturated; + } + quad.ShaderNum = BQS_InGameColormap; + color0 = D3DCOLOR_ARGB(parms.colormapstyle->Desaturate, + parms.colormapstyle->Color.r, + parms.colormapstyle->Color.g, + parms.colormapstyle->Color.b); + double fadelevel = parms.colormapstyle->FadeLevel; + color1 = D3DCOLOR_ARGB(DWORD((1 - fadelevel) * 255), + DWORD(parms.colormapstyle->Fade.r * fadelevel), + DWORD(parms.colormapstyle->Fade.g * fadelevel), + DWORD(parms.colormapstyle->Fade.b * fadelevel)); + } + else if (style.Flags & STYLEF_ColorIsFixed) { if (style.Flags & STYLEF_InvertSource) { // Since the source color is a constant, we can invert it now @@ -3187,7 +3355,7 @@ void D3DFB::SetPaletteTexture(IDirect3DTexture9 *texture, int count, D3DCOLOR bo if (SM14) { // Shader Model 1.4 only uses 256-color palettes. - SetConstant(2, 1.f, 0.5f / 256.f, 0, 0); + SetConstant(PSCONST_PaletteMod, 1.f, 0.5f / 256.f, 0, 0); if (border_color != 0 && CurBorderColor != border_color) { CurBorderColor = border_color; @@ -3208,13 +3376,14 @@ void D3DFB::SetPaletteTexture(IDirect3DTexture9 *texture, int count, D3DCOLOR bo // The constant register c2 is used to hold the multiplier in the // x part and the adder in the y part. float fcount = 1 / float(count); - SetConstant(2, pc * fcount, pal * fcount, 0, 0); + SetConstant(PSCONST_PaletteMod, pc * fcount, pal * fcount, 0, 0); } SetTexture(1, texture); } void D3DFB::SetPalTexBilinearConstants(PackingTexture *tex) { +#if 0 float con[8]; // Don't bother doing anything if the constants won't be used. @@ -3233,4 +3402,5 @@ void D3DFB::SetPalTexBilinearConstants(PackingTexture *tex) con[7] = con[3]; D3DDevice->SetPixelShaderConstantF(3, con, 2); +#endif } diff --git a/src/win32/fb_d3d9_shaders.h b/src/win32/fb_d3d9_shaders.h deleted file mode 100644 index 2e7292614..000000000 --- a/src/win32/fb_d3d9_shaders.h +++ /dev/null @@ -1,665 +0,0 @@ -#define HLSL_SOURCE_CODE 0 -#define SHADER_ASSEMBLY_CODE 0 - -// A paletted texture shader ------------------------------------------------ - -#if HLSL_SOURCE_CODE -sampler2D Image : register(s0); -sampler1D Palette : register(s1); -float4 PaletteMod : register(c2); - -float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR -{ - float index = tex2D (Image, texCoord).x; - index = index * PaletteMod.x + PaletteMod.y; - float4 rgb = tex1D (Palette, index); - return Flash + rgb * InvFlash; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000 -// -// fxc paltex.ps /Tps_1_4 /LD /VnPalTexShader14Def /Fhpaltex.h -// -// -// Parameters: -// -// sampler2D Image; -// sampler1D Palette; -// float4 PaletteMod; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// PaletteMod c2 1 -// Image s0 1 -// Palette s1 1 -// - - ps_1_4 - texld r0, t0 - mad r0.xy, r0.x, c2.x, c2.y - phase - texld r1, r0 - mad r0, r1, v1, v0 - -// approximately 4 instruction slots used (2 texture, 2 arithmetic) -#endif - -const DWORD PalTexShader14Def[] = -{ - 0xffff0104, 0x0039fffe, 0x42415443, 0x0000001c, 0x000000ab, 0xffff0104, - 0x00000003, 0x0000001c, 0x00000100, 0x000000a4, 0x00000058, 0x00000003, - 0x00000001, 0x00000060, 0x00000000, 0x00000070, 0x00010003, 0x00000001, - 0x00000078, 0x00000000, 0x00000088, 0x00020002, 0x00020001, 0x00000094, - 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001, - 0x00000000, 0x656c6150, 0x00657474, 0x000b0004, 0x00010001, 0x00000001, - 0x00000000, 0x656c6150, 0x4d657474, 0xab00646f, 0x00030001, 0x00040001, - 0x00000001, 0x00000000, 0x315f7370, 0x4d00345f, 0x6f726369, 0x74666f73, - 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072, 0x6c69706d, - 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00, 0x00000042, - 0x800f0000, 0xb0e40000, 0x00000004, 0x80030000, 0x80000000, 0xa0000002, - 0xa0550002, 0x0000fffd, 0x00000042, 0x800f0001, 0x80e40000, 0x00000004, - 0x800f0000, 0x80e40001, 0x90e40001, 0x90e40000, 0x0000ffff -}; - -#if SHADER_ASSEMBLY_CODE - ps_2_0 - dcl t0.xy - dcl v0 - dcl v1 - dcl_2d s0 - dcl_2d s1 - texld r0, t0, s0 - mad r0.xy, r0.x, c2.x, c2.y - texld r0, r0, s1 - mov r1, v1 - mad r0, r0, r1, v0 - mov oC0, r0 - -// approximately 6 instruction slots used (2 texture, 4 arithmetic) -#endif - -const DWORD PalTexShader20Def[] = -{ - 0xffff0200, 0x0039fffe, 0x42415443, 0x0000001c, 0x000000ab, 0xffff0200, - 0x00000003, 0x0000001c, 0x00000100, 0x000000a4, 0x00000058, 0x00000003, - 0x00000001, 0x00000060, 0x00000000, 0x00000070, 0x00010003, 0x00000001, - 0x00000078, 0x00000000, 0x00000088, 0x00020002, 0x00020001, 0x00000094, - 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001, - 0x00000000, 0x656c6150, 0x00657474, 0x000b0004, 0x00010001, 0x00000001, - 0x00000000, 0x656c6150, 0x4d657474, 0xab00646f, 0x00030001, 0x00040001, - 0x00000001, 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, - 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072, 0x6c69706d, - 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00, 0x0200001f, - 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, - 0x80000000, 0x900f0001, 0x0200001f, 0x90000000, 0xa00f0800, 0x0200001f, - 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, - 0x04000004, 0x80030000, 0x80000000, 0xa0000002, 0xa0550002, 0x03000042, - 0x800f0000, 0x80e40000, 0xa0e40801, 0x02000001, 0x800f0001, 0x90e40001, - 0x04000004, 0x800f0000, 0x80e40000, 0x80e40001, 0x90e40000, 0x02000001, - 0x800f0800, 0x80e40000, 0x0000ffff -}; - -// An inverted paletted texture shader -------------------------------------- - -#if HLSL_SOURCE_CODE -sampler2D Image : register(s0); -sampler1D Palette : register(s1); -float4 PaletteMod : register(c2); -float4 White : register(c6); // Preloaded with (1,1,1,0) - -float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR -{ - float index = tex2D (Image, texCoord).x; - index = index * PaletteMod.x + PaletteMod.y; - float4 rgb = tex1D (Palette, index); - rgb.xyz = White.xyz - rgb.xyz; - return Flash + rgb * InvFlash; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000 -// -// fxc paltex.ps /Tps_1_4 /LD /VnInvPalTexShader14Def /Fhinvpaltex.h -// -// -// Parameters: -// -// sampler2D Image; -// sampler1D Palette; -// float4 PaletteMod; -// float4 White; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// PaletteMod c2 1 -// White c6 1 -// Image s0 1 -// Palette s1 1 -// - - ps_1_4 - texld r0, t0 - mad r0.xy, r0.x, c2.x, c2.y - phase - texld r1, r0 - add r1.xyz, -r1, c6 - mad r0, r1, v1, v0 - -// approximately 5 instruction slots used (2 texture, 3 arithmetic) -#endif - -const DWORD InvPalTexShader14Def[] = -{ - 0xffff0104, 0x003ffffe, 0x42415443, 0x0000001c, 0x000000c5, 0xffff0104, - 0x00000004, 0x0000001c, 0x00000100, 0x000000be, 0x0000006c, 0x00000003, - 0x00000001, 0x00000074, 0x00000000, 0x00000084, 0x00010003, 0x00000001, - 0x0000008c, 0x00000000, 0x0000009c, 0x00020002, 0x00020001, 0x000000a8, - 0x00000000, 0x000000b8, 0x00060002, 0x00020001, 0x000000a8, 0x00000000, - 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001, 0x00000000, - 0x656c6150, 0x00657474, 0x000b0004, 0x00010001, 0x00000001, 0x00000000, - 0x656c6150, 0x4d657474, 0xab00646f, 0x00030001, 0x00040001, 0x00000001, - 0x00000000, 0x74696857, 0x73700065, 0x345f315f, 0x63694d00, 0x6f736f72, - 0x28207466, 0x44202952, 0x39584433, 0x61685320, 0x20726564, 0x706d6f43, - 0x72656c69, 0x312e3920, 0x37372e35, 0x30302e39, 0xab003030, 0x00000042, - 0x800f0000, 0xb0e40000, 0x00000004, 0x80030000, 0x80000000, 0xa0000002, - 0xa0550002, 0x0000fffd, 0x00000042, 0x800f0001, 0x80e40000, 0x00000002, - 0x80070001, 0x81e40001, 0xa0e40006, 0x00000004, 0x800f0000, 0x80e40001, - 0x90e40001, 0x90e40000, 0x0000ffff -}; - -#if SHADER_ASSEMBLY_CODE - ps_2_0 - dcl t0.xy - dcl v0 - dcl v1 - dcl_2d s0 - dcl_2d s1 - texld r0, t0, s0 - mad r0.xy, r0.x, c2.x, c2.y - texld r0, r0, s1 - add r0.xyz, -r0, c6 - mov r1, v1 - mad r0, r0, r1, v0 - mov oC0, r0 - -// approximately 7 instruction slots used (2 texture, 5 arithmetic) -#endif - -const DWORD InvPalTexShader20Def[] = -{ - 0xffff0200, 0x003ffffe, 0x42415443, 0x0000001c, 0x000000c5, 0xffff0200, - 0x00000004, 0x0000001c, 0x20000100, 0x000000be, 0x0000006c, 0x00000003, - 0x00020001, 0x00000074, 0x00000000, 0x00000084, 0x00010003, 0x00060001, - 0x0000008c, 0x00000000, 0x0000009c, 0x00020002, 0x000a0001, 0x000000a8, - 0x00000000, 0x000000b8, 0x00060002, 0x001a0001, 0x000000a8, 0x00000000, - 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001, 0x00000000, - 0x656c6150, 0x00657474, 0x000b0004, 0x00010001, 0x00000001, 0x00000000, - 0x656c6150, 0x4d657474, 0xab00646f, 0x00030001, 0x00040001, 0x00000001, - 0x00000000, 0x74696857, 0x73700065, 0x305f325f, 0x63694d00, 0x6f736f72, - 0x28207466, 0x48202952, 0x204c534c, 0x64616853, 0x43207265, 0x69706d6f, - 0x2072656c, 0x39312e39, 0x3934392e, 0x3131322e, 0xabab0031, 0x0200001f, - 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, - 0x80000000, 0x900f0001, 0x0200001f, 0x90000000, 0xa00f0800, 0x0200001f, - 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, - 0x04000004, 0x80030000, 0x80000000, 0xa0000002, 0xa0550002, 0x03000042, - 0x800f0000, 0x80e40000, 0xa0e40801, 0x03000002, 0x80070000, 0x81e40000, - 0xa0e40006, 0x02000001, 0x800f0001, 0x90e40001, 0x04000004, 0x800f0000, - 0x80e40000, 0x80e40001, 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, - 0x0000ffff -}; - -// A paletted texture shader that does bilinear filtering ------------------- - -#if HLSL_SOURCE_CODE -sampler2D Image : register(s0); -sampler2D Palette : register(s1); -float4 PaletteMod : register(c2); - -//#define texture_size_x 512.0f -//#define texture_size_y 256.0f -//#define texel_size_x 1.0f / 512.0f -//#define texel_size_y 1.0f / 256.0f - -// texture_size_x, texture_size_y, 0, texel_size_x -float4 size_a : register(c3); - -// 0, texel_size_y, texel_size_y, texel_size_x -float4 size_b : register(c4); - -float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR -{ - float2 f = frac (texCoord.xy * size_a/*float2(texture_size_x, texture_size_y)*/); - - float4 t00 = tex2D(Image, texCoord); - float4 t10 = tex2D(Image, texCoord + size_a.wz/*float2(texel_size_x, 0)*/); - - t00.x = t00.x * PaletteMod.x + PaletteMod.y; - t10.x = t10.x * PaletteMod.x + PaletteMod.y; - - float4 c00 = tex2D(Palette, t00); - float4 c10 = tex2D(Palette, t10); - - float4 cA = lerp(c00, c10, f.x); - - float4 t01 = tex2D(Image, texCoord + size_b.xy/*float2(0, texel_size_y)*/); - float4 t11 = tex2D(Image, texCoord + size_b.wz/*float2(texel_size_x, texel_size_y)*/); - - t01.x = t01.x * PaletteMod.x + PaletteMod.y; - t11.x = t11.x * PaletteMod.x + PaletteMod.y; - - float4 c01 = tex2D(Palette, t01); - float4 c11 = tex2D(Palette, t11); - - float4 cB = lerp(c01, c11, f.x); - - return Flash + lerp(cA, cB, f.y) * InvFlash; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) HLSL Shader Compiler 9.19.949.2111 -// -// fxc paltex_bilinear.ps /Tps_2_0 /VnPalTexBilinearDef /Fhpaltex_bilinear.h -// -// -// Parameters: -// -// sampler2D Image; -// sampler2D Palette; -// float4 PaletteMod; -// float4 size_a; -// float4 size_b; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// PaletteMod c2 1 -// size_a c3 1 -// size_b c4 1 -// Image s0 1 -// Palette s1 1 -// - - ps_2_0 - dcl t0.xy - dcl v0 - dcl v1 - dcl_2d s0 - dcl_2d s1 - add r0.xy, t0, c4 - add r1.xy, t0, c4.wzyx - add r2.xy, t0, c3.wzyx - texld r0, r0, s0 - texld r1, r1, s0 - texld r2, r2, s0 - texld r3, t0, s0 - mad r0.x, r0.x, c2.x, c2.y - mad r1.x, r1.x, c2.x, c2.y - mad r2.x, r2.x, c2.x, c2.y - mad r3.x, r3.x, c2.x, c2.y - texld r0, r0, s1 - texld r1, r1, s1 - texld r2, r2, s1 - texld r3, r3, s1 - mul r4.xy, t0, c3 - frc r4.xy, r4 - lrp r5, r4.x, r1, r0 - lrp r0, r4.x, r2, r3 - lrp r1, r4.y, r5, r0 - mov r0, v1 - mad r0, r1, r0, v0 - mov oC0, r0 - -// approximately 23 instruction slots used (8 texture, 15 arithmetic) -#endif - -const DWORD PalTexBilinearDef[] = -{ - 0xffff0200, 0x0042fffe, 0x42415443, 0x0000001c, 0x000000d1, 0xffff0200, - 0x00000005, 0x0000001c, 0x20000100, 0x000000ca, 0x00000080, 0x00000003, - 0x00020001, 0x00000088, 0x00000000, 0x00000098, 0x00010003, 0x00060001, - 0x00000088, 0x00000000, 0x000000a0, 0x00020002, 0x000a0001, 0x000000ac, - 0x00000000, 0x000000bc, 0x00030002, 0x000e0001, 0x000000ac, 0x00000000, - 0x000000c3, 0x00040002, 0x00120001, 0x000000ac, 0x00000000, 0x67616d49, - 0xabab0065, 0x000c0004, 0x00010001, 0x00000001, 0x00000000, 0x656c6150, - 0x00657474, 0x656c6150, 0x4d657474, 0xab00646f, 0x00030001, 0x00040001, - 0x00000001, 0x00000000, 0x657a6973, 0x7300615f, 0x5f657a69, 0x73700062, - 0x305f325f, 0x63694d00, 0x6f736f72, 0x28207466, 0x48202952, 0x204c534c, - 0x64616853, 0x43207265, 0x69706d6f, 0x2072656c, 0x39312e39, 0x3934392e, - 0x3131322e, 0xabab0031, 0x0200001f, 0x80000000, 0xb0030000, 0x0200001f, - 0x80000000, 0x900f0000, 0x0200001f, 0x80000000, 0x900f0001, 0x0200001f, - 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000002, - 0x80030000, 0xb0e40000, 0xa0e40004, 0x03000002, 0x80030001, 0xb0e40000, - 0xa01b0004, 0x03000002, 0x80030002, 0xb0e40000, 0xa01b0003, 0x03000042, - 0x800f0000, 0x80e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0x80e40001, - 0xa0e40800, 0x03000042, 0x800f0002, 0x80e40002, 0xa0e40800, 0x03000042, - 0x800f0003, 0xb0e40000, 0xa0e40800, 0x04000004, 0x80010000, 0x80000000, - 0xa0000002, 0xa0550002, 0x04000004, 0x80010001, 0x80000001, 0xa0000002, - 0xa0550002, 0x04000004, 0x80010002, 0x80000002, 0xa0000002, 0xa0550002, - 0x04000004, 0x80010003, 0x80000003, 0xa0000002, 0xa0550002, 0x03000042, - 0x800f0000, 0x80e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0x80e40001, - 0xa0e40801, 0x03000042, 0x800f0002, 0x80e40002, 0xa0e40801, 0x03000042, - 0x800f0003, 0x80e40003, 0xa0e40801, 0x03000005, 0x80030004, 0xb0e40000, - 0xa0e40003, 0x02000013, 0x80030004, 0x80e40004, 0x04000012, 0x800f0005, - 0x80000004, 0x80e40001, 0x80e40000, 0x04000012, 0x800f0000, 0x80000004, - 0x80e40002, 0x80e40003, 0x04000012, 0x800f0001, 0x80550004, 0x80e40005, - 0x80e40000, 0x02000001, 0x800f0000, 0x90e40001, 0x04000004, 0x800f0000, - 0x80e40001, 0x80e40000, 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, - 0x0000ffff -}; - -// A shader that doesn't look up colors from a palette. --------------------- -// Can be used for RGB textures. - -#if HLSL_SOURCE_CODE -sampler2D Image : register(s0); - -float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR -{ - float4 index = tex2D (Image, texCoord); - return Flash + index * InvFlash; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000 -// -// fxc plain.ps /Tps_1_1 /LD /VnPlainShaderDef /Fhplain.h -// -// -// Parameters: -// -// sampler2D Image; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// Image s0 1 -// - - ps_1_1 - tex t0 - mad r0, t0, v1, v0 - -// approximately 2 instruction slots used (1 texture, 1 arithmetic) -#endif - -const DWORD PlainShaderDef[] = -{ - 0xffff0101, 0x0022fffe, 0x42415443, 0x0000001c, 0x0000004f, 0xffff0101, - 0x00000001, 0x0000001c, 0x00000100, 0x00000048, 0x00000030, 0x00000003, - 0x00000001, 0x00000038, 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, - 0x00010001, 0x00000001, 0x00000000, 0x315f7370, 0x4d00315f, 0x6f726369, - 0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072, - 0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00, - 0x00000042, 0xb00f0000, 0x00000004, 0x800f0000, 0xb0e40000, 0x90e40001, - 0x90e40000, 0x0000ffff -}; - -// A shader that inverts the source's colors -------------------------------- - -#if HLSL_SOURCE_CODE -sampler2D Image : register(s0); -float4 White : register(c6); // Preloaded with (1,1,1,0) - -float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR -{ - float4 rgb = tex2D (Image, texCoord); - rgb.xyz = White.xyz - rgb.xyz; - return Flash + rgb * InvFlash; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000 -// -// fxc plain.ps /Tps_1_1 /LD /VnInvPlainShaderDef /Fhinvplain.h -// -// -// Parameters: -// -// sampler2D Image; -// float4 White; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// White c6 1 -// Image s0 1 -// - - ps_1_1 - tex t0 - add t0.xyz, -t0, c6 - mad r0, t0, v1, v0 - -// approximately 3 instruction slots used (1 texture, 2 arithmetic) -#endif - -const DWORD InvPlainShaderDef[] = -{ - 0xffff0101, 0x002dfffe, 0x42415443, 0x0000001c, 0x0000007b, 0xffff0101, - 0x00000002, 0x0000001c, 0x00000100, 0x00000074, 0x00000044, 0x00000003, - 0x00000001, 0x0000004c, 0x00000000, 0x0000005c, 0x00060002, 0x00020001, - 0x00000064, 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, - 0x00000001, 0x00000000, 0x74696857, 0xabab0065, 0x00030001, 0x00040001, - 0x00000001, 0x00000000, 0x315f7370, 0x4d00315f, 0x6f726369, 0x74666f73, - 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072, 0x6c69706d, - 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00, 0x00000042, - 0xb00f0000, 0x00000002, 0xb0070000, 0xb1e40000, 0xa0e40006, 0x00000004, - 0x800f0000, 0xb0e40000, 0x90e40001, 0x90e40000, 0x0000ffff -}; - -// A shader that copies the red component to the alpha component ------------ - -#if HLSL_SOURCE_CODE -sampler2D Image : register(s0); - -float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR -{ - float4 color = tex2D (Image, texCoord); - color.a = color.r; - return Flash + color * InvFlash; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000 -// -// fxc redtoalpha.ps /Tps_1_4 /LD /VnRedToAlphaDef /Fhredtoalpha.h -// -// -// Parameters: -// -// sampler2D Image; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// Image s0 1 -// - - ps_1_4 - texld r0, t0 - mad r1.xyz, r0, v1, v0 - + mad r1.w, r0.x, v1.w, v0.w - mov r0, r1 - -// approximately 3 instruction slots used (1 texture, 2 arithmetic) -#endif - -const DWORD RedToAlphaDef[] = -{ - 0xffff0104, 0x0022fffe, 0x42415443, 0x0000001c, 0x0000004f, 0xffff0104, - 0x00000001, 0x0000001c, 0x00000100, 0x00000048, 0x00000030, 0x00000003, - 0x00000001, 0x00000038, 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, - 0x00010001, 0x00000001, 0x00000000, 0x315f7370, 0x4d00345f, 0x6f726369, - 0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072, - 0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00, - 0x00000042, 0x800f0000, 0xb0e40000, 0x00000004, 0x80070001, 0x80e40000, - 0x90e40001, 0x90e40000, 0x40000004, 0x80080001, 0x80000000, 0x90ff0001, - 0x90ff0000, 0x00000001, 0x800f0000, 0x80e40001, 0x0000ffff -}; - -// A shader that just returns the first color component from the vertex ----- - -#if HLSL_SOURCE_CODE -float4 main (float4 color : COLOR0) : COLOR -{ - return color; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000 -// -// fxc coloronlyshader.ps /Tps_1_1 /LD /VnColorOnlyDef /Fhcoloronly.h -// - ps_1_1 - mov r0, v0 - -// approximately 1 instruction slot used -#endif - -const DWORD ColorOnlyDef[] = -{ - 0xffff0101, 0x0017fffe, 0x42415443, 0x0000001c, 0x00000023, 0xffff0101, - 0x00000000, 0x00000000, 0x00000100, 0x0000001c, 0x315f7370, 0x4d00315f, - 0x6f726369, 0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168, - 0x6f432072, 0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, - 0xababab00, 0x00000001, 0x800f0000, 0x90e40000, 0x0000ffff -}; - -// A shader that just corrects gamma for windowed mode ---------------------- - -#if HLSL_SOURCE_CODE -sampler2D Image : register(s0); -float4 Gamma : register(c7); - -float4 main (float2 texCoord : TEXCOORD0) : COLOR -{ - float4 color = tex2D (Image, texCoord); - color.xyz = pow(color.xyz, Gamma.xyz); - return color; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) HLSL Shader Compiler 9.19.949.2111 -// -// fxc gammafixer.ps /Tps_2_0 /VnGammaFixerDef /Fhgammafixer.h -// -// -// Parameters: -// -// float4 Gamma; -// sampler2D Image; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// Gamma c7 1 -// Image s0 1 -// - - ps_2_0 - dcl t0.xy - dcl_2d s0 - texld r0, t0, s0 - log r1.x, r0.x - log r1.y, r0.y - log r1.z, r0.z - mul r1.xyz, r1, c7 - exp r0.x, r1.x - exp r0.y, r1.y - exp r0.z, r1.z - mov oC0, r0 - -// approximately 9 instruction slots used (1 texture, 8 arithmetic) -#endif - -const DWORD GammaFixerDef[] = -{ - 0xffff0200, 0x002cfffe, 0x42415443, 0x0000001c, 0x0000007b, 0xffff0200, - 0x00000002, 0x0000001c, 0x20000100, 0x00000074, 0x00000044, 0x00070002, - 0x001e0001, 0x0000004c, 0x00000000, 0x0000005c, 0x00000003, 0x00020001, - 0x00000064, 0x00000000, 0x6d6d6147, 0xabab0061, 0x00030001, 0x00040001, - 0x00000001, 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, - 0x00000001, 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, - 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, - 0x2e392072, 0x392e3931, 0x322e3934, 0x00313131, 0x0200001f, 0x80000000, - 0xb0030000, 0x0200001f, 0x90000000, 0xa00f0800, 0x03000042, 0x800f0000, - 0xb0e40000, 0xa0e40800, 0x0200000f, 0x80010001, 0x80000000, 0x0200000f, - 0x80020001, 0x80550000, 0x0200000f, 0x80040001, 0x80aa0000, 0x03000005, - 0x80070001, 0x80e40001, 0xa0e40007, 0x0200000e, 0x80010000, 0x80000001, - 0x0200000e, 0x80020000, 0x80550001, 0x0200000e, 0x80040000, 0x80aa0001, - 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff -}; - -// The shader used by the burn effect screen wipe --------------------------- - -#if HLSL_SOURCE_CODE -sampler2D NewScreen : register(s0); -sampler2D Burn : register(s1); - -float4 main (float2 coord[2] : TEXCOORD0) : COLOR -{ - float4 color = tex2D(NewScreen, coord[0]); - float4 alpha = tex2D(Burn, coord[1]); - color.a = alpha.r * 2; - return color; -} -#elif SHADER_ASSEMBLY_CODE -// -// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000 -// -// fxc burn.ps /Tps_1_4 /VnBurnShaderDef /Fhburn.h /LD -// -// -// Parameters: -// -// sampler2D Burn; -// sampler2D NewScreen; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// NewScreen s0 1 -// Burn s1 1 -// - - ps_1_4 - texld r0, t0 - texld r1, t1 - add r0.w, r1.x, r1.x - + mov r0.xyz, r0 - -// approximately 3 instruction slots used (2 texture, 1 arithmetic) -#endif - -const DWORD BurnShaderDef[] = -{ - 0xffff0104, 0x0029fffe, 0x42415443, 0x0000001c, 0x0000006d, 0xffff0104, - 0x00000002, 0x0000001c, 0x00000100, 0x00000066, 0x00000044, 0x00010003, - 0x00000001, 0x0000004c, 0x00000000, 0x0000005c, 0x00000003, 0x00000001, - 0x0000004c, 0x00000000, 0x6e727542, 0xababab00, 0x000c0004, 0x00010001, - 0x00000001, 0x00000000, 0x5377654e, 0x65657263, 0x7370006e, 0x345f315f, - 0x63694d00, 0x6f736f72, 0x28207466, 0x44202952, 0x39584433, 0x61685320, - 0x20726564, 0x706d6f43, 0x72656c69, 0x312e3920, 0x37372e35, 0x30302e39, - 0xab003030, 0x00000042, 0x800f0000, 0xb0e40000, 0x00000042, 0x800f0001, - 0xb0e40001, 0x00000002, 0x80080000, 0x80000001, 0x80000001, 0x40000001, - 0x80070000, 0x80e40000, 0x0000ffff -}; diff --git a/src/win32/fb_d3d9_wipe.cpp b/src/win32/fb_d3d9_wipe.cpp index a6adab9ee..699407b85 100644 --- a/src/win32/fb_d3d9_wipe.cpp +++ b/src/win32/fb_d3d9_wipe.cpp @@ -164,7 +164,7 @@ bool D3DFB::WipeStartScreen(int type) // Create another texture to copy the final wipe screen to so // we can still gamma correct the wipe. Since this is just for // gamma correction, it's okay to fail (though not desirable.) - if (PixelDoubling || (GammaFixerShader != NULL && Windowed)) + if (PixelDoubling || (Shaders[SHADER_GammaCorrection] != NULL && Windowed)) { if (SUCCEEDED(TempRenderTexture->GetSurfaceLevel(0, &tsurf))) { @@ -384,7 +384,7 @@ bool D3DFB::Wiper_Crossfade::Run(int ticks, D3DFB *fb) fb->D3DDevice->SetFVF(D3DFVF_FBVERTEX); fb->SetTexture(0, fb->FinalWipeScreen); fb->SetAlphaBlend(D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA); - fb->SetPixelShader(fb->PlainShader); + fb->SetPixelShader(fb->Shaders[SHADER_NormalColor]); fb->D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); return Clock >= 32; @@ -442,7 +442,7 @@ bool D3DFB::Wiper_Melt::Run(int ticks, D3DFB *fb) fb->D3DDevice->SetFVF(D3DFVF_FBVERTEX); fb->SetTexture(0, fb->FinalWipeScreen); fb->SetAlphaBlend(D3DBLENDOP(0)); - fb->SetPixelShader(fb->PlainShader); + fb->SetPixelShader(fb->Shaders[SHADER_NormalColor]); fb->D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); int i, dy; @@ -504,7 +504,7 @@ D3DFB::Wiper_Burn::Wiper_Burn(D3DFB *fb) Density = 4; BurnTime = 0; memset(BurnArray, 0, sizeof(BurnArray)); - if (fb->BurnShader == NULL || FAILED(fb->D3DDevice->CreateTexture(WIDTH, HEIGHT, 1, + if (fb->Shaders[SHADER_BurnWipe] == NULL || FAILED(fb->D3DDevice->CreateTexture(WIDTH, HEIGHT, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &BurnTexture, NULL))) { BurnTexture = NULL; @@ -593,7 +593,7 @@ bool D3DFB::Wiper_Burn::Run(int ticks, D3DFB *fb) fb->SetTexture(0, fb->FinalWipeScreen); fb->SetTexture(1, BurnTexture); fb->SetAlphaBlend(D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA); - fb->SetPixelShader(fb->BurnShader); + fb->SetPixelShader(fb->Shaders[SHADER_BurnWipe]); fb->D3DDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); if (fb->SM14) { diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 2c6440c2c..59741597a 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -244,6 +244,7 @@ public: void ReleaseScreenshotBuffer(); void SetBlendingRect (int x1, int y1, int x2, int y2); bool Begin2D (bool copy3d); + void DrawBlendingRect (); FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping); FNativePalette *CreatePalette (FRemapTable *remap); void STACK_ARGS DrawTextureV (FTexture *img, int x, int y, uint32 tag, va_list tags); @@ -290,9 +291,49 @@ private: PackingTexture *Texture; }; + enum + { + PSCONST_PaletteMod = 2, + PSCONST_Weights = 6, + PSCONST_Gamma = 7, + }; + enum + { + SHADER_NormalColor, + SHADER_NormalColorPal, + SHADER_NormalColorInv, + SHADER_NormalColorPalInv, + + SHADER_RedToAlpha, + SHADER_RedToAlphaInv, + + SHADER_VertexColor, + + SHADER_SpecialColormap, + SHADER_SpecialColormapInv, + SHADER_SpecialColorMapPal, + SHADER_SpecialColorMapPalInv, + + SHADER_InGameColormap, + SHADER_InGameColormapDesat, + SHADER_InGameColormapInv, + SHADER_InGameColormapInvDesat, + SHADER_InGameColormapPal, + SHADER_InGameColormapPalDesat, + SHADER_InGameColormapPalInv, + SHADER_InGameColormapPalInvDesat, + + SHADER_BurnWipe, + SHADER_GammaCorrection, + + NUM_SHADERS + }; + static const char *const ShaderNames[NUM_SHADERS]; + void SetInitialState(); bool CreateResources(); void ReleaseResources(); + bool LoadShaders(); bool CreateFBTexture(); bool CreatePaletteTexture(); bool CreateGrayPaletteTexture(); @@ -386,12 +427,7 @@ private: int QuadBatchPos; enum { BATCH_None, BATCH_Quads, BATCH_Lines } BatchType; - IDirect3DPixelShader9 *PalTexShader, *PalTexBilinearShader, *InvPalTexShader; - IDirect3DPixelShader9 *PlainShader, *InvPlainShader; - IDirect3DPixelShader9 *RedToAlphaShader; - IDirect3DPixelShader9 *ColorOnlyShader; - IDirect3DPixelShader9 *GammaFixerShader; - IDirect3DPixelShader9 *BurnShader; + IDirect3DPixelShader9 *Shaders[NUM_SHADERS]; IDirect3DSurface9 *OldRenderTarget; IDirect3DTexture9 *InitialWipeScreen, *FinalWipeScreen; diff --git a/wadsrc/static/shaders/d3d/build.bat b/wadsrc/static/shaders/d3d/build.bat new file mode 100644 index 000000000..ced04cd77 --- /dev/null +++ b/wadsrc/static/shaders/d3d/build.bat @@ -0,0 +1,10 @@ +cd sm14 +call build.bat + +cd ..\sm20 +call build.bat + +cd ..\sm30 +call build.bat + +cd .. diff --git a/wadsrc/static/shaders/d3d/shaders.ps b/wadsrc/static/shaders/d3d/shaders.ps new file mode 100644 index 000000000..cf2899dcc --- /dev/null +++ b/wadsrc/static/shaders/d3d/shaders.ps @@ -0,0 +1,116 @@ +sampler2D Image : register(s0); +sampler1D Palette : register(s1); + +float4 PaletteMod : register(c2); +float4 Weights : register(c6); // RGB->Gray weighting { 77/256.0, 143/256.0, 37/256.0, 1 } +float4 Gamma : register(c7); + +float4 TextureLookup(float2 tex_coord) +{ +#if PALTEX + float index = tex2D(Image, tex_coord).x; + index = index * PaletteMod.x + PaletteMod.y; + return tex1D(Palette, index); +#else + return tex2D(Image, tex_coord); +#endif +} + +float4 Invert(float4 rgb) +{ +#if INVERT + rgb.rgb = Weights.www - rgb.xyz; +#endif + return rgb; +} + +float Grayscale(float4 rgb) +{ + return dot(rgb.rgb, Weights.rgb); +} + +float4 SampleTexture(float2 tex_coord) +{ + return Invert(TextureLookup(tex_coord)); +} + +// Normal color calculation for most drawing modes. + +float4 NormalColor(float2 tex_coord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR +{ + return Flash + SampleTexture(tex_coord) * InvFlash; +} + +// Copy the red channel to the alpha channel. Pays no attention to palettes. + +float4 RedToAlpha(float2 tex_coord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR +{ + float4 color = Invert(tex2D(Image, tex_coord)); + color.a = color.r; + return Flash + color * InvFlash; +} + +// Just return the value of c0. + +float4 VertexColor(float4 color : COLOR0) : COLOR +{ + return color; +} + +// Emulate one of the special colormaps. (Invulnerability, gold, etc.) + +float4 SpecialColormap(float2 tex_coord : TEXCOORD0, float4 icolor : COLOR0) : COLOR +{ + // We can't store values greater than 1.0 in a color register, so we multiply + // intensity by 2 and expect the caller to divide icolor by 2. + float4 color = SampleTexture(tex_coord); + float intensity = 2 * Grayscale(color); + color.rgb = icolor.rgb * intensity; + return color; +} + +// In-game colormap effect: fade to a particular color and multiply by another, with +// optional desaturation of the original color. Desaturation is packed into color.a. +// Fade level is packed int fade.a. Fade.rgb has been premultiplied by alpha. +float4 InGameColormap(float2 tex_coord : TEXCOORD0, float4 color : COLOR0, float4 fade : COLOR1) : COLOR +{ + float4 rgb = SampleTexture(tex_coord); + + // Desaturate +#if DESAT + float3 intensity; + float invdesat; + intensity.rgb = Grayscale(rgb) * color.a; + invdesat = Weights.w - color.a; + rgb.rgb = intensity + rgb * invdesat; +#endif + + // Fade + rgb.rgb = rgb.rgb * fade.aaa + fade.rgb; + + // Shade + rgb.rgb = rgb.rgb * color.rgb; + return rgb; +} + +// Windowed gamma correction. + +float4 GammaCorrection(float2 tex_coord : TEXCOORD0) : COLOR +{ + float4 color = tex2D(Image, tex_coord); + color.rgb = pow(color.rgb, Gamma.rgb); + return color; +} + +// The burn wipe effect. + +sampler2D NewScreen : register(s0); +sampler2D Burn : register(s1); + +float4 BurnWipe(float2 coord[2] : TEXCOORD0) : COLOR +{ + float4 color = tex2D(NewScreen, coord[0]); + float4 alpha = tex2D(Burn, coord[1]); + color.a = alpha.r * 2; + return color; +} diff --git a/wadsrc/static/shaders/d3d/sm14/BurnWipe.pso b/wadsrc/static/shaders/d3d/sm14/BurnWipe.pso new file mode 100644 index 0000000000000000000000000000000000000000..566e518b0d37c8cdce0d201ce8e040b181bb3a4a GIT binary patch literal 228 zcmZQ!{Qv*oe@zDG5Jx8&1_p*)AZ7uIF#%~1pMjBqAq_~m05LO=1LQLJ05J%}05LNV zBa1ne7UeOlUcH)yfd{M_BnJY1spY}RMX9NI352p8?4508$1(%nac&SO94d@XSq2Pi0uW znuUP}s0;)lprAP3Fy4g0H#4~?zc@dwL_s4+Q^Cd9CBjl6I3qD7wMfA^Ker$=2gtD0 zGc?sRH@DO?00N*4F4xEGCTod1_uTP4xrfo23DXv R15h3)-T+iH;s1XI1^~oKEj$1K literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/InGameColormapDesat.pso b/wadsrc/static/shaders/d3d/sm14/InGameColormapDesat.pso new file mode 100644 index 0000000000000000000000000000000000000000..2bafecca0f56d2eae3937a69541cd54e375c17f0 GIT binary patch literal 320 zcmX|*F>b;@5Jms4Hx5N4E#H*d~N@#u8ZA?Di#|;2Klp>SN#zO!JlTTTd#f;g+nv$^DBC#(CFg_xzRTERWlLaB(Kl=^TEu z@Z9de9S%LW!{8J7xLjRNf#PQVD^O#te{JY%jb4_%NNp6?mxq_orYBSM03NfD0k%8Dy;?fP~}{xv#{StZPLWC@^Bc`#8YpxCwk@nM9es zKHpmSVX#kP>Kq~e{wZF!)*Vd3?Kz60U1HXzb<=ITOWU07H=chso#=Q94{U6!)wOy( y+iJ4-L^k|fT}grGL;qKxsQYUH>Mnm;;F$`j8<{{KC^4hbJm+9u&$)9`3U~uhBsC2H literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/InGameColormapInvDesat.pso b/wadsrc/static/shaders/d3d/sm14/InGameColormapInvDesat.pso new file mode 100644 index 0000000000000000000000000000000000000000..286c765e2ff9e188e6ea0e67fea53af9c1cfd62c GIT binary patch literal 336 zcmYL@Jx;?w5QX2a7n1^s3sATu1r`yY$X$NiL<$WcL4g!S#3Yu89L4U^m>ZZIq<51; z?KxQ9*eIFR)9m+VW@n9Z?$_O5{4yL}0oYN7o@N$?0t%*>@>;}{S>m12@Y$lVXdGa& zo-Y&BwZR2_Ic>Zq>2g)%WREgOf0NI8vwJ+IAKNU?K8xV`sT;(1@mmx;ujY$n8;rB{ zCjH_i3VRP>zaNFS46dk0&C{19U=Q+Ng%0oT$A{aK2O8&6`xfr7?y;_6OCNTB_Rk)i j%v6S~*ssXaBmT*=;#Ufm!T{}_Qr4mH^Ljil12@#JY-iW9sAsz8HVo+Zs z;8Wz=JHU8Ve3YF&D)f`s&3)iHyRLxGgKeJ#Z$o=`agKhW`m$$NfL;*FMAm literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/InGameColormapPalDesat.pso b/wadsrc/static/shaders/d3d/sm14/InGameColormapPalDesat.pso new file mode 100644 index 0000000000000000000000000000000000000000..57892bae134e19a79b78442a4a2771ed8c9ea4fb GIT binary patch literal 432 zcmZusKTE?v9DSFbv7q1=aLA}ju&9)5we8|iDE>jW5^QV(DJe}pKn6#LxI1JNvN$@r z`9<)^&M9~xI}9*_ zM=^+J(&4Ab7wZ6T)^q=O=c{lLp{_M{ZG&_OrePB0c?6A}|NKchN3HB%HTPTGMDb#o zXIN*m-s}XE_->PC>3!}UTpW7itlFxF*pS9MQbw6Dm@hN$&%BpriEb@J<}}) z7{QAG>Xi<-6#eE2@Znke54&6@^AvThvF|6y4ACUXQ)5zS?ES~b#SFFbU)4NsbeCrH zg({mI}&GJ&gqTg FykG4mM^yj- literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/InGameColormapPalInvDesat.pso b/wadsrc/static/shaders/d3d/sm14/InGameColormapPalInvDesat.pso new file mode 100644 index 0000000000000000000000000000000000000000..7a3850318dc753577d73927889a46965d178c7d0 GIT binary patch literal 448 zcmZusJxjw-6g~McEhzX095U(>EGi{iY`ZuViXZ4!ij8d`C8fy^c!Hxt+#NCsSsWeR z{3H1r`aJhV5WyP`_ug|)&b`mIwEof&hL@*Lt-*Z!e)=)N3*|@4cH6R)bMk73TqtOQ68FV>!)|1 j<)552p8?4508$1(%nac&SO94d@XSq2Pi0uW znuUP}s0;)lprAP3Fy4g0H#4~?zc@dwL_s4+Q^Cd9CBjl6I3qD7wMfA^Ker$=2gtD0 qGc?sRH@DO?00N*Nat(|OPbL7xC;b17xl5QOLK>p4m9Nml707-ai=yJHiD%}&_uMqz{EdDE89u((p2BS9rxr%4)%fT%&ca3pJTaN$C3Ki~vQi+q5^mBKZa zmUj7({D!V?_A0@*JZ9$Yo7o+$ocnQ?7~WqEjsfgQO-(aO4F!BLWMr!;VHpK4WQzt` z@G1iFMg}~JeD@0Q>9zJB?Ru3g4C-3r$WM?Nf}12W)*5IW{-=-gIcnu!)x2-;VA93X z7FZY4-t-*fbhgQh{K_238ZpIvC08{}c)wcu0qu@QFGe0O5_Rnp&s_E%SE!=X>*0JXoqsu{- literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/RedToAlpha.pso b/wadsrc/static/shaders/d3d/sm14/RedToAlpha.pso new file mode 100644 index 0000000000000000000000000000000000000000..07e43e9f22749cdeea0af49fe4c992dd41b4680c GIT binary patch literal 212 zcmZQ!{Qv*oe52p8?4508$1(%nac&SO94d@XSq2Pi0uW znuUP}s0;)lprAP3Fy4g0H#4~?zc@dwL_s4+Q^Cd9CBjl6I3qD7wMfA^Ker$=2gtD0 zGc?sRH@DO?00N*3{NHi=?OqF2Sx@Cpcn&C>_1TK R{{)D={2(E00479Ez|%2 literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/RedToAlphaInv.pso b/wadsrc/static/shaders/d3d/sm14/RedToAlphaInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..5f87a11cdec594f4b5cccb43f30b38ece61d8316 GIT binary patch literal 256 zcmX|*!4APd7=&kQgM-8iIP}Otqd}xMv=<2%Bpf6n6iqa3v^SS}1CQX|i-+ObUho&K$$BB4n+e@!rjS7o=eo& z>+_qHADqrU3@At(qFP6+NF|O$1x@;*!2318GCl=9s!BtL zdO0=reiVd7PFW>t|31xK!<}FqowFoQE(Pyz2HY7t2a9jRljmoAk;G|qC1dHvR5wja p9}(z8W&c)pOW^%#lV@m4UpDc6)^}wVWdoQ2t&&09>HQ%D@C9VBFeCr~ literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/SpecialColormapInv.pso b/wadsrc/static/shaders/d3d/sm14/SpecialColormapInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..db027196e6d6775fb8c513f821f5a78467e68a26 GIT binary patch literal 264 zcmX|5y$ZrW7|YdKI|#mjLq{Dfii&jer;DJA3OWcPTD725Y&VxWx%vq1U3{oMhi9$@ zbA)`!g}YA|QhsFvqs3rY1#l;IW*Sv_2q2=kWFfbhP!-ms27?t1`z!&*m+jF*lISQi zS0~5P^N*(}q%V;AKfi{X)~180zq7KB{e?`$hVn!GZsi=1L-^8!{oh;i$EXj3dkq>FDZc^ZOSvb literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/SpecialColormapPal.pso b/wadsrc/static/shaders/d3d/sm14/SpecialColormapPal.pso new file mode 100644 index 0000000000000000000000000000000000000000..3cd83924c732fd1e169e9bdd96a8ddc8db544d59 GIT binary patch literal 372 zcmZusu}T9$6r8=RNkAb#U~#23he0J=7n3v=fuIrX!eQ3r;KGI6e!v!jjfEdzaiwsL zrKO!ea=)SL>|P}}%kbWt9cJH3VeO9{Vm!YX9Rm0wB{j+FW(eSuB_mtS2+iv7NVaI8 z1m^9Xp4>9Pm9MxZur)TP@+_}Q90U?|WrfPG@#OS5Osdo6Q* E0jBOmWdHyG literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm14/SpecialColormapPalInv.pso b/wadsrc/static/shaders/d3d/sm14/SpecialColormapPalInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..8cd7bc2608db187186e5fdb0bd77e1ea2d637ce8 GIT binary patch literal 388 zcmZusu}T9$6r8=Rmji|TfW?*C90rweT};wg1Vjzmg~Oc5!G#OC{eTq&8w)?c;!5Ef zOG`U{c*pGJd0932r{qaL|Y zJq+elRGt?>`?3BBi%kIHxW zIxn^e?qk@Q*?q&pQ0k(dFq#eh2LRs$=oxHU;|zSUjR_ON*F>Ow)|@a2fq{)SSpG5n zL{StCwCZiS+IWpm;WCY5J-nao_K_ELG2JfHWS^`LPUr2>nFL|rgqy`GPMuNmvD?0r z3|#No9rQidd+GJi=B13!ct!co<;HVZ_RpW63%OsPYiEM06sxMWz~=v|1U17DRCj@1xlM`1qmf+(Pgzz3+YD9t`LHM6$}w|=Vp9^K0?;I@uB89 zoSrec!{L7S+_^Is(wLiRV>o>uJOVgUpeLDZjT3NS`k*9S2s|OOKI4a~QG%VhH5i|1 zmZi8{1Umu_RmNAAt`_tiH0aq=#&(~C$t%9svt7Q=mk0l4-10}!B=RS}>3p&Chk3SL zZwUP$d<**BFbI2{4xa5gfZ_(%ivLjeioty)kG{U5t_zR%_#11ek|jB=*dd?Q17`$W fC7_iHT{Q1+3)WC2OLAPXLq6M{x8^DqPGeJ@wPhduJi3TB{VN6ytk9X%IUN0Rj=IVUscHeqi7mH}0 zCimp@uzRb%Jqy>Ny}s-Y$J7pz_!eC$e8(F({?K#0@nC=soB2Y*;Srs~<3mD300x}n<@@Bnb&{ryF#tyT-lSv7D03?nwC;$Ke literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/InGameColormapDesat.pso b/wadsrc/static/shaders/d3d/sm20/InGameColormapDesat.pso new file mode 100644 index 0000000000000000000000000000000000000000..78ba2c4ac5999400902f54394ae67f49fc78620b GIT binary patch literal 368 zcmYLD%}T>S7@SRFx(6Y55zNto1PN8_(bj{7cxeSMLMb-30ZU4go0s(s;v3}NOCM^V z!*zDW^jn5+X1<^O;2HB{t}uSSADsjEBtXw&vKn7N&GbO{gn);P*~Tm3A*6SPrE`GE zX0gh#-v>CQZ{J_Mqz;D&On)a@vm{vso6;){AAni^t_= zTYQiVlk_$j-lR!-HyGf;ehnyIbvW{<`R4*1Zy=*~J6he9tOsOD2f{K1^~5@(Jl}{HT0~=UhbH zW0(iKw+mH>m#AYf@Ab<7t^}B=B8}{Y0VnBGuN6O)?4pl4T96zKT>pUr)_sz zj_q`sO;qG+;Kr+-e_e>bT7mi1F$^>5XXl&jPoFT-gu|MGg7o)1M4|(_^a@f!#N;@a R&3rQUG2>1n`{O1A@CN&kIurl^ literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/InGameColormapInvDesat.pso b/wadsrc/static/shaders/d3d/sm20/InGameColormapInvDesat.pso new file mode 100644 index 0000000000000000000000000000000000000000..8387b5b80b51b6f0fcb75b24ad7bd89ff69e620c GIT binary patch literal 384 zcmYLD%}T>S7@Xb2bPq!ABABBE2@s51D2E~H!tZM#5c&jmp;@! zhwJQW>$eQw%zQulK^pUIt}uMQADjdDBtTCxS&c1FF+C6-As~@5+ju1;0(xhdI|mr8 zW{V8FosU!c_Wj07mM@l7N$nB-(O;L-WO|LK{B2W|#d{T9j=RxgI!U9+ayHL4(Xd#p z^AD1KoZQC!n>*Ew;F8JLQ6uMgU5LDn1c_HgSTAz zPNtN1xVT{}23)zb2tc$wsR0tbix@o_pwE#?J>_dk|xX3^{n(78Pgu11qlFnNjR$vPOOt8B5P=!elo*gucLsMqb{M6U%D+<5z|-EyY|{!W+h z{Ho=pP!G)4efBn6cunPiE5l}vfYU6vn@s#u!w{E`k|#2@0(-oCSV|=SL>P9 zA`!6gq6zRuZ*U9j;JslVnptG~8+JVprXkAG#GY0VP47(*hglZF#O{B5kW5eteX7ZN zz3#(kI?GZl(y>22!615ACTa4RxktCh?p1%-cZaiJ5-#0dGG9b7gO2B)d7V?=^UvFD z9I7h=IbXB>i=E;(7TClEY-iQ*LNM;?Z*e$VtzlOy3h|o^=JM5oT=5@G-j_LY)>t3u z8EWPNRW3NQrDwL;Gt$h~xvgUhmDT`MT`DVhR<3kwMh!A*6-r0wzKVSn8Q*2s=ST_s E04{`B=Kufz literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/InGameColormapPalInv.pso b/wadsrc/static/shaders/d3d/sm20/InGameColormapPalInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..acdd60934ebb4dd951699dbf5cb176a32265d1c3 GIT binary patch literal 440 zcmZvYu}Z^G6o&ts#5AaoT?8}g5+qcylh`f_Er?YdOR%vGq@*-?fD{}Z@&FDQ3t2ik zy7?k`4zGW1Q+4nrKmR#j&N=tyLX+}KUZQt@)jb68NrB9u)j5{H2Q8v>N&SBX_!*jv7tFFanZ?%S16}&gTI&)+kT4;FqTayXakm~}i fx@T!Zs-8L*s3@7!^BpyJ!&pbgGg@k&OiJJzjIB*< literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/InGameColormapPalInvDesat.pso b/wadsrc/static/shaders/d3d/sm20/InGameColormapPalInvDesat.pso new file mode 100644 index 0000000000000000000000000000000000000000..f9adfebdfd5a699dc5c0aec9162563770536fa4f GIT binary patch literal 508 zcmZutF-yZx5dK~o)1X3k5zMGdkWj@=V!J4`AlBkof{ksUC8fy^NWsw|?hYM=EFB%) z{3Gvo`25~$tcx!kclX_W-(3!tQs3$lo%^fyA%HI$h}m>H#}fFYo6>4D0Sg(ue$TWT z5djA;1_9paEq(&Kc(1SzgE_g}Tm{nzLgx>f{W_k-2Mf*TfE_(FFTBLtDYwxt_DZs7Z`kh1L$#lQ%%dqmj}B#QO`_69zJcP~Da&(StpRNw9} z^Zo5CR3V;X0B^f+djQr1SW`$c#{=+5W1>SSP%$UVSjPKvgu2$yWnG?6r1{R?jj_5O zvLsJVcXPNInSKxkW_Z~jqs;V@IKAE|9Lt_r&eXQ-`DB7Vo%upRr{=GX@~aj6bP3(4 j-1nCZ&bJNpwxYkvnL+1 literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/NormalColorInv.pso b/wadsrc/static/shaders/d3d/sm20/NormalColorInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..e18767e87b2a0751847781eb9020fd432c854e56 GIT binary patch literal 312 zcmYLEy$ZrG7`(=!9fa;8*ik`>6cru)85HWGf{P%cRSQbRc5~4;=p%G@@uB)0#!E#_ zIPSjt@+B7tDPOXV!MxWm1Go~PCrGNs9f(LnB1dQtaLH;d34uJl61JHGj8E&mhsQ%l zk-plWwebA?AqrXN2>s`u!h($ literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/NormalColorPal.pso b/wadsrc/static/shaders/d3d/sm20/NormalColorPal.pso new file mode 100644 index 0000000000000000000000000000000000000000..68a1f3fac03b91f32637b6e13418ea9733dbd30f GIT binary patch literal 392 zcmZus%SyvQ6g@KuQdGzf2xh69Afc6ZX}eKqL9Bwi8rrCZmV`D7m*dXmEc}2h+-1{` z%6D`;GmVc$?{GQip8Fg~W45M?!TnYL1VBXxHIHCpyaQi^N4nJnB%X-Ya=J%F-~ew< z0X~S5Pv8)rjdrt4UQ$$*k7HLY8vQm|q(za!$I(80l+92Hx4~zAXZd;(PcAT;PgmJG zdoIGWyYujRI39-M*JPHi!a=so=L?cv6kkTYP8`MEb{nVmEI{$%%^wf+4;T358m*vg zbS=pH?&|@2>kV3U>4PW3V+_TirNqPk8YNi6dnIQofm-kCUB8X(9BuR5W4SU0_y(t| BLqPxl literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/NormalColorPalInv.pso b/wadsrc/static/shaders/d3d/sm20/NormalColorPalInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..8276561f0ca5015b62818d119d61837dcf3dafc2 GIT binary patch literal 436 zcmZvYKTE?v7{;GVLM$p|7r~6W1PN8_B({q}3t|<=5^QV(DJe}pKnjiy`2Y?X3t2ik zy7@)&IXs`c#_Hf*Uf$<^_x{PfFr@sFm+0MJbq@i2(m-a>sWXT41XSw4Acxg`n>0u{g}F*J#xx=f=IVnd|gkSRZOAo*;naYO5htp-%ITP literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/RedToAlpha.pso b/wadsrc/static/shaders/d3d/sm20/RedToAlpha.pso new file mode 100644 index 0000000000000000000000000000000000000000..cd74d5586649502f99a1b0f90346e166ff820302 GIT binary patch literal 272 zcmYLDI|{-;6r8L9QwX_$VC=LB5~9S?*hEkSwHMK-0VQHQK)k^o!9IZy2KYwayBI}bqDEbxcb&4Ox9nh& ztj}qdZZA%2)^?)teC*8kt4(}%hUxK?97y`E*K_+_&-DV|M}x`SkTdE2=eGQE13xZd u*|+fZC7b^84y(K|U(k~qD5VLQ0#$vdXN@1tA_p}^R8qg;u3XTg6z~KbNHoX* literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/RedToAlphaInv.pso b/wadsrc/static/shaders/d3d/sm20/RedToAlphaInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..1aeadb9fb3156940f409752b6904e5e73b268672 GIT binary patch literal 328 zcmYLD&1%9x7@Yi|ITUg)h32SGLJ2C((b$7RylA19f=Ep@(2$Vi<|V#C9>Kd8A1cq` zI=gB0TZV6DzHfI2x)2xfg2~4?cml8|Ku>3r8V8_cdnXJ+gN~40))%3pL+=qAnRuWtPg|c+yxo-rwLzFSKPy(=>J{_&J5P)Br*wLYzB3J%p|jkrH&O0P(j<$2 zNqpBEx&F{|y|=*t&+==aVyg3<+x0)!aN{*B`xvPBHusw|tmeqehK8=xhYrM_wy2>r Zb92S6G&Hpd25!0Bm#Ed;Qtwql09R%3J4pZl literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/SpecialColormap.pso b/wadsrc/static/shaders/d3d/sm20/SpecialColormap.pso new file mode 100644 index 0000000000000000000000000000000000000000..b708ae7b4680588969f11f6bf62bd00392983c6c GIT binary patch literal 300 zcmYLDy^6v>7@Vw8Qwa8QU`hoE5^|#D=@lo$Mg*@*J+S ztLV23^TY7%2O;H6b}*WM4L<<<5nv`r%HtnMNZ&+>Fd*QQ)hr2t3bO{bIswMV^)A5W zVxq=ey~iwqaJNrl`VwKj@>9HWS6xiP%{hvr-^6ZB+xCw?^X=Jwy$#OxC_0|P1I55` zd(Pm~b=uUDY8LWCf)F;>3DXy@J+@d#NDW6tQQL zJG)x@mf_9J+u3~(QeNZ>CZD766M!EA^aPvII08A_8(|U#1Oj$dOG3b+*TP0Sz(>5^ zhB%!Xc%-k+wH9Ht-Q^jzNi^<$nyvg*7t`qLkYves?zU$g_dS>g?tHi2ga>z$#A&oA z8G3%-8@~FUKj`)FtiA>cZgu|Wc6s9^oMtuFD>r$kKEtUi222CC(nkxja}^n9(3N;oSBlo;JYecND2G`2GKYA literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/SpecialColormapPal.pso b/wadsrc/static/shaders/d3d/sm20/SpecialColormapPal.pso new file mode 100644 index 0000000000000000000000000000000000000000..5985d0ba5cc60ec1053c8aaea0a447af136182bb GIT binary patch literal 424 zcmZutKTE?v9DSF>G^o&B1T*RqBvi4J*e(h!h*ca*u(1uKq%`>e5gZ-z0UR<4Svq#? z<`>E5@O*d1KZAF9y!U(e?su1iA?1fWNB{Psw-4Z*06mMOYCHiOQcReHfPsvx#xr5k z5wP*19pII0a0+bWt?|~{v+3>qcvtga8ltK!?CK7p$zBI>m}Ma>?EL2slL;!JPqn!I zHSWV`I?GZl(y>22#xQzVCTa4RxraAL?&V-Ka7VLX5-#0-GG9b7Mc4CBz3z$c`DdLD z4%C%_oPV?W)vcn@1)O&Itp#;YKSi7QdIhI0`BwZ)*2vkYG;sGflM7}X1_T_nC$~{E ZqiT^0NR2Jsvqi1$Q5R%`=jyzaz$ZzSNxuL9 literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/SpecialColormapPalInv.pso b/wadsrc/static/shaders/d3d/sm20/SpecialColormapPalInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..eb523d2ef6d720ca38532cd04e7119265aff3dad GIT binary patch literal 440 zcmZvYF-yZh7>3_VViHv7E`k|#2@t;_kDMlgQ3)?I!EvJqPq{^g94ewQ0G_z?+giLQUV5Y#(F$a zCW(NJXH9??MuSse8?Oy})66E@`(anJa1x;`E$r$YL{obmCQ+V8u(0zVAEaZHLZ51J z{d?R;@no83m}jG4bc{j#ut>A?G4~E{j=anMuvE@6Pk`6ocf)Uzz@#a zZ5-5B1|#H@~s^DAkGnqqjqr$-5-x?`cLv9KK+}NQ8yFb)CoqE89Q;7` IlL;Uj0C&tCv;Y7A literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm20/build.bat b/wadsrc/static/shaders/d3d/sm20/build.bat new file mode 100644 index 000000000..e424d92a7 --- /dev/null +++ b/wadsrc/static/shaders/d3d/sm20/build.bat @@ -0,0 +1,27 @@ +fxc ..\shaders.ps /Tps_2_0 /O3 /ENormalColor -DPALTEX=0 -DINVERT=0 /FoNormalColor.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /ENormalColor -DPALTEX=0 -DINVERT=1 /FoNormalColorInv.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /ENormalColor -DPALTEX=1 -DINVERT=0 /FoNormalColorPal.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /ENormalColor -DPALTEX=1 -DINVERT=1 /FoNormalColorPalInv.pso + +fxc ..\shaders.ps /Tps_2_0 /O3 /ERedToAlpha -DINVERT=0 /FoRedToAlpha.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /ERedToAlpha -DINVERT=1 /FoRedToAlphaInv.pso + +fxc ..\shaders.ps /Tps_2_0 /O3 /EVertexColor /FoVertexColor.pso + +fxc ..\shaders.ps /Tps_2_0 /O3 /ESpecialColormap -DPALTEX=0 -DINVERT=0 /FoSpecialColormap.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /ESpecialColormap -DPALTEX=0 -DINVERT=1 /FoSpecialColormapInv.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /ESpecialColormap -DPALTEX=1 -DINVERT=0 /FoSpecialColormapPal.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /ESpecialColormap -DPALTEX=1 -DINVERT=1 /FoSpecialColormapPalInv.pso + +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=0 -DDESAT=0 /FoInGameColormap.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=0 -DDESAT=1 /FoInGameColormapDesat.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=1 -DDESAT=0 /FoInGameColormapInv.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=1 -DDESAT=1 /FoInGameColormapInvDesat.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=0 -DDESAT=0 /FoInGameColormapPal.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=0 -DDESAT=1 /FoInGameColormapPalDesat.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=1 -DDESAT=0 /FoInGameColormapPalInv.pso +fxc ..\shaders.ps /Tps_2_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=1 -DDESAT=1 /FoInGameColormapPalInvDesat.pso + +fxc ..\shaders.ps /Tps_2_0 /O3 /EBurnWipe /FoBurnWipe.pso + +fxc ..\shaders.ps /Tps_2_0 /O3 /EGammaCorrection /FoGammaCorrection.pso diff --git a/wadsrc/static/shaders/d3d/sm30/BurnWipe.pso b/wadsrc/static/shaders/d3d/sm30/BurnWipe.pso new file mode 100644 index 0000000000000000000000000000000000000000..0626821f7af6148b52f2b7a71675461cde675000 GIT binary patch literal 300 zcmZ8b%MQU%6r9_7bRqEr5?!*;NIk+*Sy+^XT1rHykf2h8o%#cxVBg>Bcev(yY@D0P znKN_ly#rm!r>vkm?l=ViR|3>DHZ|i0T-bVq4#AUwt8~_c&gt+l%Cxl?s5eyM^=ceZd9wF=TS~NYulS$S11+GkE%7hIAHH6A%tf>-Zu#+f*F^SVO z#^YhIW5A+xOw)M3rEj4^PaPenOVoFIDJ z^!=dg_d9_f^xAFIxlS1n+~BU5x832m`S7)pOTS=Ub1gI?*hiIq^Q-WEUsQPv^stWaRn-chvV?e;5R40kR4d+*BG~Cl{#wxhN#; sFXxsL%6?3~C)w(jy$}j9y(7#!2e@C& z76rE32#56L`(4jPxmY$ebx1^i{<@xCPA~9KzHX|zdTWx?$Ft-vpXAA8Ihz-oWK^xz zm~Vvd_wO2R=&e^ zHj%z%cr&wa_q_*Q%By_A?DJ#V2k=LLo?ucM1&}e#37ya&;4`cECImY49yxI5OB5>~8oniEJGdu$DL4cZM@HsX>&2UQugn&fG=+6rw5m7tD>{kKq zm(zKU?KZ?db^o>JIWOjmx?&y>;h(;$CKr=)JQT0%vMS%|_~h|4zRSj0JYGy^`8pnz z%T@7CGDy;^WN?`#>2<%4V~*YdG`BLI?~x1iIxe*AIHwz^Uc>ireW4?`M!H9Q=SBddqM1 zJ6zvxgLrV3VcxuXvoixn>u=q|@cw#m0-&aYoWo#pd;nX9N4ntz3Qvs2GP*-XaEN!y z0H2JCPte9!!`-gp*93L#;@GOC;qT&QlIICr9R0_S(>ZFf6I|B!mThJivvZ6W&+BxP zzT`n?au(c-rlVl`7SEG)Ficn3VoA^sqpPrg8HG`=+r=r@Isgi8TpHXa7PJ~Hg@SJ} zr?{k5^QV(DJe}pAc98^>D@z)LVm!b zH-9AG;X1nw>cLGOZ{Fw-(B|h0erGR&SFzDo`4Uwm}RmA3}ozTJ+n+Q z0ybVW1H7^ud<0r}Yq)pK+2r?W$WlPAdz^WeUNyCK$$R8$&=2$h z_2cqaGtLDy%%;aSrwcl7LNY@?$Om}HQOFN? z^yZKBJ6vBjK|Hv-!@PMjZ+3TJDD|x_F}%MT902&Dft*QK$JhX$bTQ4K2}or0^?IQh zWCSd{Y6f_tm)rtfytmwk<}7mizue6-n1`q;6MMRYXlrkSILxvTCU*bh$H@$p(6^e* zH|sHs=8G)FDxIEAPcV+2)=8Q?XYSG6v3ot5jNHj0n1yS1m@HROOwjlIbFY8qd;UeQ zheJMj2gv!GqQ+fffliA>F5zg*+X~oDS=ZE95D)ZN9BQ}BZA;FLM=%C;C?y{L)UYpW l$a9pPTC=gBO8!H_wi&Cu(d!)bs*vo?{k5^QV(DJg9}U<)2StalGN3jG0( z-u#jLgcsM@Bc0Wh1X4H^C%{0H~rIQ`^0bh zXRQ|YIr0V|c^hSLomikzVIi#wvzvn3$c)BdK}^7B5z>Lq1oU%`)b4X$^b>(Pvt2 literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/NormalColor.pso b/wadsrc/static/shaders/d3d/sm30/NormalColor.pso new file mode 100644 index 0000000000000000000000000000000000000000..b0e385fb77008c90344faf0486381faf93aa6f2e GIT binary patch literal 240 zcmXX=%L;-}6dWHxMBonu*{(Jc_Q00q#=r=wy+}_XQLGQBKe(UZ-rw>&y3H-mVVF7R z4tEX=DL--m|FB&30Bi|xr;*f*HxQ7q4OXMIm)>Zm h2(+zo^*hO;zvf(*%-89suNEd?(xcw^#}7hE;0qihE|vfQ literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/NormalColorInv.pso b/wadsrc/static/shaders/d3d/sm30/NormalColorInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..8dfc542fa04f07ed90f01e6a1f4cbfddb0efa2d8 GIT binary patch literal 300 zcmX|6!D_-#5S+ZEHi(eB2+h%g1c|ojQSCt?y);5Eg%C7qz>r{a>qY+{pOCx1mGAI% zUX<=**x6zC?JRUDZ*qXedN%I?_$5G1FsT|BpkVqSbV7rG$E@Oq5NJ{BV%sRdDhc-y zu2%yc>gwI&JBs&*B4@1=#=oBB!6+EwGv1uiJlz#`|LfIWdcJ4-hj1I6>_wVn@sVWe zxbM#N&2`+#c#IdWege*PRVv;l*I+%kb`}rL?IldBnm6_>_SdZIiuduHXH{QXkQIFj U&U3CV4bY(3^zzSIp_CH%19IUufB*mh literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/NormalColorPal.pso b/wadsrc/static/shaders/d3d/sm30/NormalColorPal.pso new file mode 100644 index 0000000000000000000000000000000000000000..d813d66146e2d42173593ea21b2c1e0a10ca4373 GIT binary patch literal 380 zcmZusJx{_=6g~H~8UiH!115CTr7;BwjKHD^Bt|rG!$zu*K-xeDN8A`Y_yany^>6ie z_&o2~!NL1-bI(2Z+>ZxG>u){4ILC)& zfFq;g6EyKvb9dY5Jw{o&Xj`?^{C%{Evn+;-)_?pgS)vrX!Dao|(*2^lxW;V#x=Z%S zTjpOrT=}=t`P84UqGi1EC&@NlZwQ7#*bjy`VGs^_J#={18F1jmxxr0hfmdTWs2X!i zj)qqljln`ZwqN(yTd`IZE_gD8IoO9n;pvZtbE)CIit|~oa;tCHe(tP{=UM|lbe}** literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/NormalColorPalInv.pso b/wadsrc/static/shaders/d3d/sm30/NormalColorPalInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..8ad0334958bf2e3fc34c479eeeafe912de36c721 GIT binary patch literal 424 zcmZut!AiqG6r4?BELF%|1as6&kXXf@#P(vL1+j|9671RrQc{|HKnor{JvP7xLqgbufQ6hOrokB?3)Ur@!m#>%yS6`d;jU9bc#xtt`5(C z)}xGP^E|^co19HfF^Zp7X_h|c{_)+3e={5p{qa1S%9Y@Uqjv z5wE-htofQk^ESDF*Ko168qRJ7T3)F=nhWxt8H>l%!!>Og-MA)+m$$z5$nfNb&#x literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/RedToAlpha.pso b/wadsrc/static/shaders/d3d/sm30/RedToAlpha.pso new file mode 100644 index 0000000000000000000000000000000000000000..749ad1aba9d383ae9d8ea0fbb7f8a4bcfe4b6bfb GIT binary patch literal 240 zcmXX=%L;-}6dWHxMBonu8MLU4h&|9{wlOGzY%fywfWpW=!2ZBbaPM#V9o^=Z=P=Bi zbB8+znh+l`z;eIvdjPfsxKl`S#v2GoHlYy;RJdeWt9yJ-P*pm*+{^ygBa0@Hjm`D& zOtbX#GDo|y8LY##8D8RJ@-&y}{c*ifc$PD_yqRM;?sSSiptgXVNrluMY6V84m0WE! jQwp?=(*K=g&|h<|OXjQe(^nTdpwq**A^)f)3L$_m5u+{E literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/RedToAlphaInv.pso b/wadsrc/static/shaders/d3d/sm30/RedToAlphaInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..600de5c801659544c2fd5258173e572dc8bed055 GIT binary patch literal 300 zcmX|6!D_-#5S+ZEK}5)13eCZT1ql*ksmE#$72-t;y%a<=CILgl8q@ehC4SS{J)U0p`gj z3~;#^=ulVh9zQ`GMtR0sCyamnn5{?aAr|rWlxFEZxBJUi`^#VX_A1)!f|ETp>IJcK*S=F?$Z?V5-U01x1=cu}OHX$qe V6rAT=T^gXlR@2KrYlTuu;09FDHOK$} literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/SpecialColormap.pso b/wadsrc/static/shaders/d3d/sm30/SpecialColormap.pso new file mode 100644 index 0000000000000000000000000000000000000000..d815257d5288b04648629ce9e941633dfc908c17 GIT binary patch literal 300 zcmX|6ONzok6s#nUX+&^82xh4uL82qN^s|_OxKY845Q1hjFcLA@xrsOM2-$nBoMYPR z7JNf8E36^JClw@JE1}$s`;nAY+;m7Gc1I&n)ppn6RlmV^=G{e7_9? zoX-tBQI~g(br6S9mXcdUhJSLTlgx0Bkqo literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/SpecialColormapPal.pso b/wadsrc/static/shaders/d3d/sm30/SpecialColormapPal.pso new file mode 100644 index 0000000000000000000000000000000000000000..fbd9c32306859fc0216e75e32535820675bf3b2c GIT binary patch literal 424 zcmZut!AiqG5Ph4(G*qE?5zJ99L1Gnq65ESH3t|0%it1ic_U4|-=|5MFe< zIONDXK*7H$HEt6Nv<&78CA?0hd5r~e->jlTeZyQ+aaa5VV-yrs79Rd+*ozv^)M!mp fxM(WQZo%^yD_z6YZt8Up&SJxBF{kHfN~M4wz*9!Q literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/SpecialColormapPalInv.pso b/wadsrc/static/shaders/d3d/sm30/SpecialColormapPalInv.pso new file mode 100644 index 0000000000000000000000000000000000000000..9c57af2dc3a7b5219f280fcf14138274f6260295 GIT binary patch literal 440 zcmZut!AiqG5Ph4(G*qE?5zJ99L1Gnq65ES~7Q`wZOR%vGq@*$OrV0qmUo) z*qc9+?{Iy)t>VGm4D;sAo7u_0l=4enqxW#rJp%Aa138OM#aICwx|n9t1Po;K>b%lS zG6FWIlBSJVJve;=Tv>2+xXFL`>CFs&4i literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/VertexColor.pso b/wadsrc/static/shaders/d3d/sm30/VertexColor.pso new file mode 100644 index 0000000000000000000000000000000000000000..46e56db6bc6d0029d4431d67cdba3e8894f1312a GIT binary patch literal 124 zcmZQz{{R2qe=!E<5Jx8&1_lOYAZ7rHfhaI&WMBY^7Zk@E#~U#CW+oTq7w4yyC};#} zDtPz=`zQowB&MVmDLCin7G&lC8J2oRW_p&UMtVjTCMFE>3=B+M3=9nn4Ez%qfouj2 LejxkF1dt5?dG8&; literal 0 HcmV?d00001 diff --git a/wadsrc/static/shaders/d3d/sm30/build.bat b/wadsrc/static/shaders/d3d/sm30/build.bat new file mode 100644 index 000000000..d0edc16b7 --- /dev/null +++ b/wadsrc/static/shaders/d3d/sm30/build.bat @@ -0,0 +1,27 @@ +fxc ..\shaders.ps /Tps_3_0 /O3 /ENormalColor -DPALTEX=0 -DINVERT=0 /FoNormalColor.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /ENormalColor -DPALTEX=0 -DINVERT=1 /FoNormalColorInv.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /ENormalColor -DPALTEX=1 -DINVERT=0 /FoNormalColorPal.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /ENormalColor -DPALTEX=1 -DINVERT=1 /FoNormalColorPalInv.pso + +fxc ..\shaders.ps /Tps_3_0 /O3 /ERedToAlpha -DINVERT=0 /FoRedToAlpha.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /ERedToAlpha -DINVERT=1 /FoRedToAlphaInv.pso + +fxc ..\shaders.ps /Tps_3_0 /O3 /EVertexColor /FoVertexColor.pso + +fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=0 -DINVERT=0 /FoSpecialColormap.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=0 -DINVERT=1 /FoSpecialColormapInv.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=1 -DINVERT=0 /FoSpecialColormapPal.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=1 -DINVERT=1 /FoSpecialColormapPalInv.pso + +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=0 -DDESAT=0 /FoInGameColormap.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=0 -DDESAT=1 /FoInGameColormapDesat.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=1 -DDESAT=0 /FoInGameColormapInv.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=1 -DDESAT=1 /FoInGameColormapInvDesat.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=0 -DDESAT=0 /FoInGameColormapPal.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=0 -DDESAT=1 /FoInGameColormapPalDesat.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=1 -DDESAT=0 /FoInGameColormapPalInv.pso +fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=1 -DINVERT=1 -DDESAT=1 /FoInGameColormapPalInvDesat.pso + +fxc ..\shaders.ps /Tps_3_0 /O3 /EBurnWipe /FoBurnWipe.pso + +fxc ..\shaders.ps /Tps_3_0 /O3 /EGammaCorrection /FoGammaCorrection.pso diff --git a/zdoom.vcproj b/zdoom.vcproj index 935090979..71cd5eaf0 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - @@ -1868,6 +1860,14 @@ Outputs="$(IntDir)/$(InputName).obj" /> + + + @@ -1936,10 +1936,6 @@ RelativePath=".\src\win32\fb_d3d9.cpp" > - - @@ -2032,6 +2028,10 @@ RelativePath=".\src\win32\resource.h" > + + @@ -2057,6 +2057,14 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -2067,14 +2075,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - + + + - - - + + + @@ -5379,14 +5387,6 @@ AdditionalIncludeDirectories="src\win32;$(NoInherit)" /> - - - @@ -5665,7 +5665,7 @@ /> Date: Sun, 20 Sep 2009 06:23:10 +0000 Subject: [PATCH 16/27] - Changed call to R_DrawRemainingPlayerSprites into a virtual function of DFrameBuffer because its implementation is specific to the software renderer and needs to be overridable. SVN r1859 (trunk) --- docs/rh-log.txt | 5 +++++ src/d_main.cpp | 2 +- src/v_video.cpp | 11 +++++++++++ src/v_video.h | 3 +++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index f934e63cf..005aa5e1e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +September 20, 2009 (Changes by Graf Zahl) +- Changed call to R_DrawRemainingPlayerSprites into a virtual function + of DFrameBuffer because its implementation is specific to the software + renderer and needs to be overridable. + September 19, 2009 - Fixed: Wall drawing handled fixed light levels improperly (but did not completely ignore them, either). diff --git a/src/d_main.cpp b/src/d_main.cpp index 6221c7298..801262790 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -681,7 +681,7 @@ void D_Display () SB_state = screen->GetPageCount(); BorderNeedRefresh = screen->GetPageCount(); } - R_DrawRemainingPlayerSprites(); + screen->DrawRemainingPlayerSprites(); screen->DrawBlendingRect(); if (automapactive) { diff --git a/src/v_video.cpp b/src/v_video.cpp index a89e270fb..acd481f68 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1258,6 +1258,17 @@ void DFrameBuffer::WriteSavePic (player_t *player, FILE *file, int width, int he delete pic; } +//=========================================================================== +// +// +// +//=========================================================================== + +void DFrameBuffer::DrawRemainingPlayerSprites() +{ + R_DrawRemainingPlayerSprites(); +} + FNativePalette::~FNativePalette() diff --git a/src/v_video.h b/src/v_video.h index 6d9a6ee96..3ce0e2849 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -348,6 +348,9 @@ public: // renders view to a savegame picture virtual void WriteSavePic (player_t *player, FILE *file, int width, int height); + // draws player sprites with hardware acceleration (only useful for software rendering) + virtual void DrawRemainingPlayerSprites(); + bool Accel2D; // If true, 2D drawing can be accelerated. // Begin 2D drawing operations. This is like Update, but it doesn't end From c285f38a02d8d21f0dc8debcae5d870c4c4a6095 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Sep 2009 13:15:36 +0000 Subject: [PATCH 17/27] - Fixed: When drawing with a special colormap the quad's flags weren't cleared which could cause crashes. - Added custom special colormaps to DECORATE. - Cleaned up special colormap code and removed lots of dependencies on the knowledge of the tables' contents. SVN r1860 (trunk) --- docs/rh-log.txt | 7 ++ src/colormatcher.h | 5 ++ src/g_shared/a_artifacts.cpp | 45 +++--------- src/g_shared/a_artifacts.h | 8 --- src/p_lnspec.cpp | 11 ++- src/r_main.cpp | 6 +- src/r_things.cpp | 15 ++-- src/tarray.h | 4 +- src/textures/bitmap.cpp | 104 ++++++--------------------- src/textures/bitmap.h | 11 ++- src/textures/multipatchtexture.cpp | 43 ++++++----- src/thingdef/thingdef_properties.cpp | 61 +++++++++------- src/v_draw.cpp | 2 +- src/v_palette.cpp | 88 ++++++++++++++++------- src/v_palette.h | 40 ++++++++--- src/v_video.h | 2 +- src/win32/fb_d3d9.cpp | 3 +- 17 files changed, 224 insertions(+), 231 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 005aa5e1e..8b26fa2e6 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,10 @@ +September 21, 2009 (Changes by Graf Zahl) +- Fixed: When drawing with a special colormap the quad's flags weren't cleared + which could cause crashes. +- Added custom special colormaps to DECORATE. +- Cleaned up special colormap code and removed lots of dependencies on the + knowledge of the tables' contents. + September 20, 2009 (Changes by Graf Zahl) - Changed call to R_DrawRemainingPlayerSprites into a virtual function of DFrameBuffer because its implementation is specific to the software diff --git a/src/colormatcher.h b/src/colormatcher.h index ca7992d6d..04b9f7198 100644 --- a/src/colormatcher.h +++ b/src/colormatcher.h @@ -43,6 +43,11 @@ public: void SetPalette (const DWORD *palette); BYTE Pick (int r, int g, int b); + BYTE Pick (PalEntry pe) + { + return Pick(pe.r, pe.g, pe.b); + } + FColorMatcher &operator= (const FColorMatcher &other); private: diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 5b7f016cf..fa2c1e59f 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -139,14 +139,7 @@ PalEntry APowerup::GetBlend () if (EffectTics <= BLINKTHRESHOLD && !(EffectTics & 8)) return 0; - if (BlendColor == INVERSECOLOR || - BlendColor == GOLDCOLOR || - // [BC] HAX! - BlendColor == REDCOLOR || - BlendColor == GREENCOLOR || - BlendColor == BLUECOLOR) - return 0; - + if (IsSpecialColormap(BlendColor)) return 0; return BlendColor; } @@ -175,37 +168,19 @@ void APowerup::DoEffect () if (EffectTics > 0) { - int oldcolormap = Owner->player->fixedcolormap; - if (EffectTics > BLINKTHRESHOLD || (EffectTics & 8)) + int Colormap = GetSpecialColormap(BlendColor); + + if (Colormap != NOFIXEDCOLORMAP) { - if (BlendColor == INVERSECOLOR) + if (EffectTics > BLINKTHRESHOLD || (EffectTics & 8)) { - Owner->player->fixedcolormap = INVERSECOLORMAP; + Owner->player->fixedcolormap = Colormap; } - else if (BlendColor == GOLDCOLOR) + else if (Owner->player->fixedcolormap == Colormap) { - Owner->player->fixedcolormap = GOLDCOLORMAP; + // only unset if the fixed colormap comes from this item + Owner->player->fixedcolormap = NOFIXEDCOLORMAP; } - else if (BlendColor == REDCOLOR) - { - Owner->player->fixedcolormap = REDCOLORMAP; - } - else if (BlendColor == GREENCOLOR) - { - Owner->player->fixedcolormap = GREENCOLORMAP; - } - else if (BlendColor == BLUECOLOR) - { - Owner->player->fixedcolormap = BLUECOLORMAP; - } - } - else if ((BlendColor == INVERSECOLOR && Owner->player->fixedcolormap == INVERSECOLORMAP) || - (BlendColor == GOLDCOLOR && Owner->player->fixedcolormap == GOLDCOLORMAP) || - (BlendColor == REDCOLOR && Owner->player->fixedcolormap == REDCOLORMAP) || - (BlendColor == GREENCOLOR && Owner->player->fixedcolormap == GREENCOLORMAP) || - (BlendColor == BLUECOLOR && Owner->player->fixedcolormap == BLUECOLORMAP)) - { - Owner->player->fixedcolormap = NOFIXEDCOLORMAP; } } } @@ -711,7 +686,7 @@ int APowerInvisibility::AlterWeaponSprite (vissprite_t *vis) if ((vis->alpha < TRANSLUC25 && special1 > 0) || (vis->alpha == 0)) { vis->alpha = clamp((OPAQUE - Strength), 0, OPAQUE); - vis->colormap = SpecialColormaps[INVERSECOLORMAP]; + vis->colormap = SpecialColormaps[INVERSECOLORMAP].Colormap; } return -1; // This item is valid so another one shouldn't reset the translucency } diff --git a/src/g_shared/a_artifacts.h b/src/g_shared/a_artifacts.h index 1272de60d..93352a719 100644 --- a/src/g_shared/a_artifacts.h +++ b/src/g_shared/a_artifacts.h @@ -3,14 +3,6 @@ #include "a_pickups.h" -#define INVERSECOLOR 0x00345678 -#define GOLDCOLOR 0x009abcde - -// [BC] More hacks! -#define REDCOLOR 0x00beefee -#define GREENCOLOR 0x00beefad -#define BLUECOLOR 0x00befeed - class player_t; // A powerup is a pseudo-inventory item that applies an effect to its diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index b34ed4878..17333f7d7 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -2532,7 +2532,10 @@ FUNC(LS_SetPlayerProperty) if (power != 4) { APowerup *item = static_cast(it->GiveInventoryType (powers[power])); - if (item != NULL && power == 0) item->BlendColor = INVERSECOLOR; + if (item != NULL && power == 0 && arg1 == 1) + { + item->BlendColor = MakeSpecialColormap(INVERSECOLORMAP); + } } else if (it->player - players == consoleplayer) { @@ -2568,7 +2571,11 @@ FUNC(LS_SetPlayerProperty) { // Give power if (power != 4) { - players[i].mo->GiveInventoryType (powers[power]); + APowerup *item = static_cast(players[i].mo->GiveInventoryType (powers[power])); + if (item != NULL && power == 0 && arg1 == 1) + { + item->BlendColor = MakeSpecialColormap(INVERSECOLORMAP); + } } else if (i == consoleplayer) { diff --git a/src/r_main.cpp b/src/r_main.cpp index 00dfe8353..ea3936768 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1163,9 +1163,9 @@ void R_SetupFrame (AActor *actor) if (player != NULL && camera == player->mo) { - if (player->fixedcolormap >= 0 && player->fixedcolormap < NUM_SPECIALCOLORMAPS) + if (player->fixedcolormap >= 0 && player->fixedcolormap < (int)SpecialColormaps.Size()) { - fixedcolormap = SpecialColormaps[player->fixedcolormap]; + fixedcolormap = SpecialColormaps[player->fixedcolormap].Colormap; } else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS) { @@ -1175,7 +1175,7 @@ void R_SetupFrame (AActor *actor) // [RH] Inverse light for shooting the Sigil if (fixedcolormap == NULL && extralight == INT_MIN) { - fixedcolormap = SpecialColormaps[INVERSECOLORMAP]; + fixedcolormap = SpecialColormaps[INVERSECOLORMAP].Colormap; extralight = 0; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 552241be2..e0e6a63cc 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1680,7 +1680,8 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ // The colormap has changed. Is it one we can easily identify? // If not, then don't bother trying to identify it for // hardware accelerated drawing. - if (vis->colormap < SpecialColormaps[0] || vis->colormap >= SpecialColormaps[NUM_SPECIALCOLORMAPS]) + if (vis->colormap < SpecialColormaps[0].Colormap || + vis->colormap >= SpecialColormaps[SpecialColormaps.Size()].Colormap) { noaccel = true; } @@ -1812,19 +1813,21 @@ void R_DrawRemainingPlayerSprites() { FDynamicColormap *colormap = VisPSpritesBaseColormap[i]; bool flip = vis->xiscale < 0; - FSpecialColormapParameters *special = NULL; + FSpecialColormap *special = NULL; PalEntry overlay = 0; FColormapStyle colormapstyle; bool usecolormapstyle = false; - if (vis->colormap >= SpecialColormaps[0] && vis->colormap < SpecialColormaps[NUM_SPECIALCOLORMAPS]) + if (vis->colormap >= SpecialColormaps[0].Colormap && + vis->colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap) { - ptrdiff_t specialmap = (vis->colormap - SpecialColormaps[0]) >> 8; - if (SpecialColormapParms[specialmap].Inverted) + // Yuck! There needs to be a better way to store colormaps in the vissprite... :( + ptrdiff_t specialmap = (vis->colormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap); + if (SpecialColormaps[specialmap].Inverted) { vis->RenderStyle.Flags ^= STYLEF_InvertSource; } - special = &SpecialColormapParms[specialmap]; + special = &SpecialColormaps[specialmap]; } else if (colormap->Color == PalEntry(255,255,255) && colormap->Desaturate == 0) diff --git a/src/tarray.h b/src/tarray.h index 72bbc5e61..92a6552e4 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -120,12 +120,12 @@ public: } } // Return a reference to an element - T &operator[] (unsigned int index) const + T &operator[] (size_t index) const { return Array[index]; } // Returns the value of an element - TT operator() (unsigned int index) const + TT operator() (size_t index) const { return Array[index]; } diff --git a/src/textures/bitmap.cpp b/src/textures/bitmap.cpp index c985e1494..913aa507e 100644 --- a/src/textures/bitmap.cpp +++ b/src/textures/bitmap.cpp @@ -35,6 +35,7 @@ #include "bitmap.h" #include "templates.h" #include "r_translate.h" +#include "v_palette.h" //=========================================================================== @@ -70,86 +71,6 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in } break; - case BLEND_INVERSEMAP: - // Doom's inverted invulnerability map - for(i=0;i(255 - TSrc::Gray(pin),0,255); - - TBlend::OpC(pout[TDest::RED], gray, a, inf); - TBlend::OpC(pout[TDest::GREEN], gray, a, inf); - TBlend::OpC(pout[TDest::BLUE], gray, a, inf); - TBlend::OpA(pout[TDest::ALPHA], a, inf); - } - pout+=4; - pin+=step; - } - break; - - case BLEND_GOLDMAP: - // Heretic's golden invulnerability map - for(i=0;i(gray+(gray>>1),0,255); - g=clamp(gray-(gray>>2),0,255); - - TBlend::OpC(pout[TDest::RED], r, a, inf); - TBlend::OpC(pout[TDest::GREEN], g, a, inf); - TBlend::OpC(pout[TDest::BLUE], 0, a, inf); - TBlend::OpA(pout[TDest::ALPHA], a, inf); - } - pout+=4; - pin+=step; - } - break; - - case BLEND_REDMAP: - // Skulltag's red Doomsphere map - for(i=0;i(gray+(gray>>1),0,255); - - TBlend::OpC(pout[TDest::RED], r, a, inf); - TBlend::OpC(pout[TDest::GREEN], 0, a, inf); - TBlend::OpC(pout[TDest::BLUE], 0, a, inf); - TBlend::OpA(pout[TDest::ALPHA], a, inf); - } - pout+=4; - pin+=step; - } - break; - - case BLEND_GREENMAP: - // Skulltag's Guardsphere map - for(i=0;i(gray+(gray>>1),0,255); - - TBlend::OpC(pout[TDest::RED], r, a, inf); - TBlend::OpC(pout[TDest::GREEN], r, a, inf); - TBlend::OpC(pout[TDest::BLUE], gray, a, inf); - TBlend::OpA(pout[TDest::ALPHA], a, inf); - } - pout+=4; - pin+=step; - } - break; - case BLEND_ICEMAP: // Create the ice translation table, based on Hexen's. // Since this is done in True Color the purplish tint is fully preserved - even in Doom! @@ -171,7 +92,28 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in break; default: - if (inf->blend >= BLEND_DESATURATE1 && inf->blend<=BLEND_DESATURATE31) + + if (inf->blend >= BLEND_SPECIALCOLORMAP1) + { + FSpecialColormap *cm = &SpecialColormaps[inf->blend - BLEND_SPECIALCOLORMAP1]; + for(i=0;i(255 - TSrc::Gray(pin),0,255); + + PalEntry pe = cm->GrayscaleToColor[gray]; + TBlend::OpC(pout[TDest::RED], pe.r , a, inf); + TBlend::OpC(pout[TDest::GREEN], pe.g, a, inf); + TBlend::OpC(pout[TDest::BLUE], pe.b, a, inf); + TBlend::OpA(pout[TDest::ALPHA], a, inf); + } + pout+=4; + pin+=step; + } + } + else if (inf->blend >= BLEND_DESATURATE1 && inf->blend<=BLEND_DESATURATE31) { // Desaturated light settings. fac=inf->blend-BLEND_DESATURATE1+1; diff --git a/src/textures/bitmap.h b/src/textures/bitmap.h index 5d9b58a6f..04bd580cd 100644 --- a/src/textures/bitmap.h +++ b/src/textures/bitmap.h @@ -262,13 +262,10 @@ enum ColorType enum EBlend { BLEND_NONE = 0, - BLEND_INVERSEMAP = 1, - BLEND_GOLDMAP = 2, - BLEND_REDMAP = 3, - BLEND_GREENMAP = 4, - BLEND_ICEMAP = 5, - BLEND_DESATURATE1 = 6, - BLEND_DESATURATE31 = 36, + BLEND_ICEMAP = 1, + BLEND_DESATURATE1 = 2, + BLEND_DESATURATE31 = 32, + BLEND_SPECIALCOLORMAP1 = 33, BLEND_MODULATE = -1, BLEND_OVERLAY = -2, }; diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 86bab74f8..a52bd2e37 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -425,23 +425,15 @@ BYTE *GetBlendMap(PalEntry blend, BYTE *blendwork) switch (blend.a==0 ? blend.r : -1) { - case BLEND_INVERSEMAP: - return SpecialColormaps[INVERSECOLORMAP]; - - case BLEND_GOLDMAP: - return SpecialColormaps[GOLDCOLORMAP]; - - case BLEND_REDMAP: - return SpecialColormaps[REDCOLORMAP]; - - case BLEND_GREENMAP: - return SpecialColormaps[GREENCOLORMAP]; - case BLEND_ICEMAP: return TranslationToTable(TRANSLATION(TRANSLATION_Standard, 7))->Remap; default: - if (blend.r >= BLEND_DESATURATE1 && blend.r <= BLEND_DESATURATE31) + if (blend.r >= BLEND_SPECIALCOLORMAP1) + { + return SpecialColormaps[blend.r - BLEND_SPECIALCOLORMAP1].Colormap; + } + else if (blend.r >= BLEND_DESATURATE1 && blend.r <= BLEND_DESATURATE31) { return DesaturateColormap[blend.r - BLEND_DESATURATE1]; } @@ -1044,22 +1036,29 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part) } else if (sc.Compare("Translation")) { + int match; + bComplex = true; if (part.Translation != NULL) delete part.Translation; part.Translation = NULL; part.Blend = 0; - static const char *maps[] = { "inverse", "gold", "red", "green", "ice", "desaturate", NULL }; + static const char *maps[] = { "inverse", "gold", "red", "green", "blue", NULL }; sc.MustGetString(); - int match = sc.MatchString(maps); + + match = sc.MatchString(maps); if (match >= 0) { - part.Blend.r = 1 + match; - if (part.Blend.r == BLEND_DESATURATE1) - { - sc.MustGetStringName(","); - sc.MustGetNumber(); - part.Blend.r += clamp(sc.Number-1, 0, 30); - } + part.Blend.r = BLEND_SPECIALCOLORMAP1 + match; + } + else if (sc.Compare("ICE")) + { + part.Blend.r = BLEND_ICEMAP; + } + else if (sc.Compare("DESATURATE")) + { + sc.MustGetStringName(","); + sc.MustGetNumber(); + part.Blend.r = BLEND_DESATURATE1 + clamp(sc.Number-1, 0, 30); } else { diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 4f29d272c..0c579efa2 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1556,7 +1556,8 @@ DEFINE_CLASS_PROPERTY(weapon, S, WeaponPiece) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory) { - PROP_INT_PARM(i, 0); + static const char *specialcolormapnames[] = { + "INVERSEMAP", "GOLDMAP", "REDMAP", "GREENMAP", "BLUEMAP", NULL }; int alpha; PalEntry * pBlendColor; @@ -1582,30 +1583,11 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory) { PROP_STRING_PARM(name, 1); - if (!stricmp(name, "INVERSEMAP")) + // We must check the old special colormap names for compatibility + int v = MatchString(name, specialcolormapnames); + if (v >= 0) { - *pBlendColor = INVERSECOLOR; - return; - } - else if (!stricmp(name, "GOLDMAP")) - { - *pBlendColor = GOLDCOLOR; - return; - } - // [BC] Yay, more hacks. - else if (!stricmp(name, "REDMAP" )) - { - *pBlendColor = REDCOLOR; - return; - } - else if (!stricmp(name, "GREENMAP" )) - { - *pBlendColor = GREENCOLOR; - return; - } - else if (!stricmp(name, "BLUEMAP")) - { - *pBlendColor = BLUECOLOR; + *pBlendColor = MakeSpecialColormap(v); return; } @@ -1623,6 +1605,37 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory) else *pBlendColor = 0; } +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY_PREFIX(powerup, colormap, FFFI, Inventory) +{ + PalEntry * pBlendColor; + + if (info->Class->IsDescendantOf(RUNTIME_CLASS(APowerup))) + { + pBlendColor = &((APowerup*)defaults)->BlendColor; + } + else if (info->Class->IsDescendantOf(RUNTIME_CLASS(APowerupGiver))) + { + pBlendColor = &((APowerupGiver*)defaults)->BlendColor; + } + else + { + I_Error("\"powerup.colormap\" requires an actor of type \"Powerup\"\n"); + return; + } + + PROP_FLOAT_PARM(r, 0); + PROP_FLOAT_PARM(g, 1); + PROP_FLOAT_PARM(b, 2); + PROP_INT_PARM(inv, 3); + + + + *pBlendColor = MakeSpecialColormap(AddSpecialColormap(r, g, b, !!inv)); +} + //========================================================================== // //========================================================================== diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 90fb4beff..05cd73c5c 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -584,7 +584,7 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l break; case DTA_SpecialColormap: - parms->specialcolormap = va_arg (tags, FSpecialColormapParameters *); + parms->specialcolormap = va_arg (tags, FSpecialColormap *); break; case DTA_ColormapStyle: diff --git a/src/v_palette.cpp b/src/v_palette.cpp index d0d50efaa..85570caa0 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -61,10 +61,16 @@ extern "C" { FDynamicColormap NormalLight; } FPalette GPalette; -BYTE SpecialColormaps[NUM_SPECIALCOLORMAPS][256]; +TArray SpecialColormaps; BYTE DesaturateColormap[31][256]; -FSpecialColormapParameters SpecialColormapParms[NUM_SPECIALCOLORMAPS] = +struct FSpecialColormapParameters +{ + float Colorize[3]; + bool Inverted; +}; + +static FSpecialColormapParameters SpecialColormapParms[] = { // Doom invulnerability is an inverted grayscale. // Strife uses it when firing the Sigil @@ -355,10 +361,57 @@ static bool FixBuildPalette (BYTE *opal, int lump, bool blood) return true; } +int AddSpecialColormap(double r, double g, double b, bool inv) +{ + for(unsigned i=0; iColorize[0] = float(r); + cm->Colorize[1] = float(g); + cm->Colorize[2] = float(b); + cm->Inverted = inv; + + for (int c = 0; c < 256; c++) + { + double intensity = (GPalette.BaseColors[c].r * 77 + + GPalette.BaseColors[c].g * 143 + + GPalette.BaseColors[c].b * 37) / 256.0; + if (inv) + { + intensity = 255 - intensity; + } + + PalEntry pe = PalEntry( MIN(255, int(intensity*r)), + MIN(255, int(intensity*g)), + MIN(255, int(intensity*b))); + + cm->Colormap[c] = ColorMatcher.Pick(pe); + + // This table is used by the texture composition code + for(int i = 0;i < 256; i++) + { + intensity = inv? 255-i : i; + cm->GrayscaleToColor[i] = PalEntry( MIN(255, int(intensity*r)), + MIN(255, int(intensity*g)), + MIN(255, int(intensity*b))); + } + } + return SpecialColormaps.Size() - 1; +} + void InitPalette () { BYTE pal[768]; - BYTE *shade; int c; bool usingBuild = false; int lump; @@ -398,37 +451,18 @@ void InitPalette () NormalLight.Fade = 0; // NormalLight.Maps is set by R_InitColormaps() - // build special maps (e.g. invulnerability) - double intensity; + // build default special maps (e.g. invulnerability) + SpecialColormaps.Clear(); for (int i = 0; i < countof(SpecialColormapParms); ++i) { - double r, g, b; - bool inv; - - shade = SpecialColormaps[i]; - r = SpecialColormapParms[i].Colorize[0]; - g = SpecialColormapParms[i].Colorize[1]; - b = SpecialColormapParms[i].Colorize[2]; - inv = SpecialColormapParms[i].Inverted; - for (c = 0; c < 256; c++) - { - intensity = (GPalette.BaseColors[c].r * 77 + - GPalette.BaseColors[c].g * 143 + - GPalette.BaseColors[c].b * 37) / 256.0; - if (inv) - { - intensity = 255 - intensity; - } - shade[c] = ColorMatcher.Pick( - MIN(255, int(intensity*r)), MIN(255, int(intensity*g)), MIN(255, int(intensity*b))); - } + AddSpecialColormap(SpecialColormapParms[i].Colorize[0], SpecialColormapParms[i].Colorize[1], + SpecialColormapParms[i].Colorize[2], SpecialColormapParms[i].Inverted); } - // desaturated colormaps for(int m = 0; m < 31; m++) { - shade = DesaturateColormap[m]; + BYTE *shade = DesaturateColormap[m]; for (c = 0; c < 256; c++) { int intensity = (GPalette.BaseColors[c].r * 77 + diff --git a/src/v_palette.h b/src/v_palette.h index 160ef6cea..a856de97d 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -88,25 +88,43 @@ struct FColormapStyle float FadeLevel; }; -// Special colormaps, like invulnerability. enum { NOFIXEDCOLORMAP = -1, - INVERSECOLORMAP, - GOLDCOLORMAP, - REDCOLORMAP, // [BC] New Skulltag colormaps. - GREENCOLORMAP, - BLUECOLORMAP, - - NUM_SPECIALCOLORMAPS + INVERSECOLORMAP, // the inverse map is used explicitly in a few places. }; -struct FSpecialColormapParameters + + +struct FSpecialColormap { float Colorize[3]; bool Inverted; + BYTE Colormap[256]; + PalEntry GrayscaleToColor[256]; }; -extern FSpecialColormapParameters SpecialColormapParms[NUM_SPECIALCOLORMAPS]; -extern BYTE SpecialColormaps[NUM_SPECIALCOLORMAPS][256]; + +extern TArray SpecialColormaps; + +// some utility functions to store special colormaps in powerup blends +#define SPECIALCOLORMAP_MASK 0x00ff0000 + +inline int MakeSpecialColormap(int index) +{ + return index | SPECIALCOLORMAP_MASK; +} + +inline bool IsSpecialColormap(int map) +{ + return (map & SPECIALCOLORMAP_MASK) == SPECIALCOLORMAP_MASK; +} + +inline int GetSpecialColormap(int blend) +{ + return IsSpecialColormap(blend)? blend & ~SPECIALCOLORMAP_MASK : NOFIXEDCOLORMAP; +} + +int AddSpecialColormap(double r, double g, double b, bool inv); + extern BYTE DesaturateColormap[31][256]; diff --git a/src/v_video.h b/src/v_video.h index 3ce0e2849..a6f30a43a 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -227,7 +227,7 @@ public: INTBOOL masked; INTBOOL bilinear; FRenderStyle style; - struct FSpecialColormapParameters *specialcolormap; + struct FSpecialColormap *specialcolormap; struct FColormapStyle *colormapstyle; }; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index a81c2ca7c..519d69010 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -3089,6 +3089,7 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR & stencilling = false; quad.Palette = NULL; + quad.Flags = 0; switch (style.BlendOp) { @@ -3124,7 +3125,7 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR & quad.ShaderNum = BQS_SpecialColormap; color0 = D3DCOLOR_COLORVALUE(parms.specialcolormap->Colorize[0]/2, parms.specialcolormap->Colorize[1]/2, parms.specialcolormap->Colorize[2]/2, 1); - color1 = 0; + color1 = D3DCOLOR_ARGB(255,0,0,0); } else if (parms.colormapstyle != NULL) { // Emulate the fading from an in-game colormap (colorized, faded, and desaturated) From 85a058436b5e4158f46bc3e19fd9f75095fad465 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Sep 2009 19:58:04 +0000 Subject: [PATCH 18/27] - added missing death sound to Strife's barrel. SVN r1861 (trunk) --- wadsrc/static/actors/strife/strifestuff.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/actors/strife/strifestuff.txt b/wadsrc/static/actors/strife/strifestuff.txt index 5d280be2b..d8ecd9bbb 100644 --- a/wadsrc/static/actors/strife/strifestuff.txt +++ b/wadsrc/static/actors/strife/strifestuff.txt @@ -177,6 +177,7 @@ ACTOR ExplosiveBarrel2 94 Height 32 ConversationID 204, -1, -1 +SOLID +SHOOTABLE +NOBLOOD +OLDRADIUSDMG + DeathSound "world/barrelx" +INCOMBAT States { From 83779274120a20e25a17e87d489ed958cacfc557 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 01:16:54 +0000 Subject: [PATCH 19/27] - Apply BHS's ThingActivation patch. SVN r1862 (trunk) --- src/thingdef/thingdef_parse.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 039d578b4..a4bde9259 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -617,6 +617,10 @@ static bool ParsePropertyParams(FScanner &sc, FPropertyInfo *prop, AActor *defau case 'M': // special case. An expression-aware parser will not need this. conv.i = ParseMorphStyle(sc); break; + + case 'N': // special case. An expression-aware parser will not need this. + conv.i = ParseThingActivation(sc); + break; case 'L': // Either a number or a list of strings if (sc.CheckNumber()) From e9d61a3f46f611df2cd9e284bbac61035228d49d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 01:28:13 +0000 Subject: [PATCH 20/27] - Fixed: In letterbox modes, the clipping window needs to be adjusted down. SVN r1863 (trunk) --- docs/rh-log.txt | 3 +++ src/win32/fb_d3d9.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 8b26fa2e6..42a25f927 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,6 @@ +September 21, 2009 +- Fixed: In letterbox modes, the clipping window needs to be adjusted down. + September 21, 2009 (Changes by Graf Zahl) - Fixed: When drawing with a special colormap the quad's flags weren't cleared which could cause crashes. diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 519d69010..08e97a3bb 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -2569,7 +2569,10 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi EndQuadBatch(); BeginQuadBatch(); } - RECT scissor = { parms.lclip, parms.uclip, parms.rclip, parms.dclip }; + RECT scissor = { + parms.lclip, parms.uclip + LBOffsetI, + parms.rclip, parms.dclip + LBOffsetI + }; D3DDevice->SetScissorRect(&scissor); D3DDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); } From 79298285f7118f49d96e2c7c740ee0d442c16120 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 01:31:36 +0000 Subject: [PATCH 21/27] - Making any blends with full red a special colormap seems like it would be far too easy to accidentally trigger. SVN r1864 (trunk) --- src/v_palette.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/v_palette.h b/src/v_palette.h index a856de97d..186c25d5e 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -106,21 +106,22 @@ struct FSpecialColormap extern TArray SpecialColormaps; // some utility functions to store special colormaps in powerup blends -#define SPECIALCOLORMAP_MASK 0x00ff0000 +#define SPECIALCOLORMAP_MASK 0xBEEF0000 inline int MakeSpecialColormap(int index) { + assert(index >= 0 && index < 65536); return index | SPECIALCOLORMAP_MASK; } inline bool IsSpecialColormap(int map) { - return (map & SPECIALCOLORMAP_MASK) == SPECIALCOLORMAP_MASK; + return (map & 0xFFFF0000) == SPECIALCOLORMAP_MASK; } inline int GetSpecialColormap(int blend) { - return IsSpecialColormap(blend)? blend & ~SPECIALCOLORMAP_MASK : NOFIXEDCOLORMAP; + return IsSpecialColormap(blend) ? blend & 0xFFFF : NOFIXEDCOLORMAP; } int AddSpecialColormap(double r, double g, double b, bool inv); From 84a018f05a3f05ec12acbb9aa9f4cfc50f9ae62a Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 02:54:19 +0000 Subject: [PATCH 22/27] - Added support for defining the full color range of a special colormap. SVN r1865 (trunk) --- docs/rh-log.txt | 4 + src/r_things.cpp | 4 - src/thingdef/thingdef_properties.cpp | 31 +++++-- src/v_palette.cpp | 73 +++++++++------- src/v_palette.h | 8 +- src/win32/fb_d3d9.cpp | 81 ++++++++---------- src/win32/win32iface.h | 2 - wadsrc/static/shaders/d3d/shaders.ps | 12 +-- .../shaders/d3d/sm14/SpecialColormap.pso | Bin 248 -> 276 bytes .../shaders/d3d/sm14/SpecialColormapInv.pso | Bin 264 -> 0 bytes .../shaders/d3d/sm14/SpecialColormapPal.pso | Bin 372 -> 388 bytes .../d3d/sm14/SpecialColormapPalInv.pso | Bin 388 -> 0 bytes wadsrc/static/shaders/d3d/sm14/build.bat | 2 - .../shaders/d3d/sm20/SpecialColormap.pso | Bin 300 -> 364 bytes .../shaders/d3d/sm20/SpecialColormapInv.pso | Bin 316 -> 0 bytes .../shaders/d3d/sm20/SpecialColormapPal.pso | Bin 424 -> 488 bytes .../d3d/sm20/SpecialColormapPalInv.pso | Bin 440 -> 0 bytes wadsrc/static/shaders/d3d/sm20/build.bat | 2 - .../shaders/d3d/sm30/SpecialColormap.pso | Bin 300 -> 352 bytes .../shaders/d3d/sm30/SpecialColormapInv.pso | Bin 316 -> 0 bytes .../shaders/d3d/sm30/SpecialColormapPal.pso | Bin 424 -> 476 bytes .../d3d/sm30/SpecialColormapPalInv.pso | Bin 440 -> 0 bytes wadsrc/static/shaders/d3d/sm30/build.bat | 2 - 23 files changed, 113 insertions(+), 108 deletions(-) delete mode 100644 wadsrc/static/shaders/d3d/sm14/SpecialColormapInv.pso delete mode 100644 wadsrc/static/shaders/d3d/sm14/SpecialColormapPalInv.pso delete mode 100644 wadsrc/static/shaders/d3d/sm20/SpecialColormapInv.pso delete mode 100644 wadsrc/static/shaders/d3d/sm20/SpecialColormapPalInv.pso delete mode 100644 wadsrc/static/shaders/d3d/sm30/SpecialColormapInv.pso delete mode 100644 wadsrc/static/shaders/d3d/sm30/SpecialColormapPalInv.pso diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 42a25f927..4b809f315 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ September 21, 2009 +- Added support for defining the full color range of a special colormap. +- Moved the code for specialcolormap and colormapstyle in D3DFB::SetStyle() + at the end of the normally-colored block so that they get all the proper + texture format setup. - Fixed: In letterbox modes, the clipping window needs to be adjusted down. September 21, 2009 (Changes by Graf Zahl) diff --git a/src/r_things.cpp b/src/r_things.cpp index e0e6a63cc..8a938ef9b 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1823,10 +1823,6 @@ void R_DrawRemainingPlayerSprites() { // Yuck! There needs to be a better way to store colormaps in the vissprite... :( ptrdiff_t specialmap = (vis->colormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap); - if (SpecialColormaps[specialmap].Inverted) - { - vis->RenderStyle.Flags ^= STYLEF_InvertSource; - } special = &SpecialColormaps[specialmap]; } else if (colormap->Color == PalEntry(255,255,255) && diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 0c579efa2..2a32d3160 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1608,7 +1608,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory) //========================================================================== // //========================================================================== -DEFINE_CLASS_PROPERTY_PREFIX(powerup, colormap, FFFI, Inventory) +DEFINE_CLASS_PROPERTY_PREFIX(powerup, colormap, FFFfff, Inventory) { PalEntry * pBlendColor; @@ -1626,14 +1626,27 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, colormap, FFFI, Inventory) return; } - PROP_FLOAT_PARM(r, 0); - PROP_FLOAT_PARM(g, 1); - PROP_FLOAT_PARM(b, 2); - PROP_INT_PARM(inv, 3); - - - - *pBlendColor = MakeSpecialColormap(AddSpecialColormap(r, g, b, !!inv)); + if (PROP_PARM_COUNT == 3) + { + PROP_FLOAT_PARM(r, 0); + PROP_FLOAT_PARM(g, 1); + PROP_FLOAT_PARM(b, 2); + *pBlendColor = MakeSpecialColormap(AddSpecialColormap(0, 0, 0, r, g, b)); + } + else if (PROP_PARM_COUNT == 6) + { + PROP_FLOAT_PARM(r1, 0); + PROP_FLOAT_PARM(g1, 1); + PROP_FLOAT_PARM(b1, 2); + PROP_FLOAT_PARM(r2, 0); + PROP_FLOAT_PARM(g2, 1); + PROP_FLOAT_PARM(b2, 2); + *pBlendColor = MakeSpecialColormap(AddSpecialColormap(r1, g1, b1, r2, g2, b2)); + } + else + { + I_Error("\"power.colormap\" must have either 3 or 6 parameters\n"); + } } //========================================================================== diff --git a/src/v_palette.cpp b/src/v_palette.cpp index 85570caa0..043e006fa 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -66,27 +66,26 @@ BYTE DesaturateColormap[31][256]; struct FSpecialColormapParameters { - float Colorize[3]; - bool Inverted; + float Start[3], End[3]; }; static FSpecialColormapParameters SpecialColormapParms[] = { // Doom invulnerability is an inverted grayscale. // Strife uses it when firing the Sigil - { { 1, 1, 1 }, true }, + { { 1, 1, 1 }, { 0, 0, 0 } }, // Heretic invulnerability is a golden shade. - { { 1.5, 0.75, 0 }, false }, + { { 0, 0, 0 }, { 1.5, 0.75, 0 }, }, // [BC] Build the Doomsphere colormap. It is red! - { { 1.5, 0, 0 }, false }, + { { 0, 0, 0 }, { 1.5, 0, 0 } }, // [BC] Build the Guardsphere colormap. It's a greenish-white kind of thing. - { { 1.25, 1.5, 1 }, false }, + { { 0, 0, 0 }, { 1.25, 1.5, 1 } }, // Build a blue colormap. - { { 0, 0, 1.5 }, false }, + {{ 0, 0, 0 }, { 0, 0, 1.5 } }, }; static void FreeSpecialLights(); @@ -361,14 +360,24 @@ static bool FixBuildPalette (BYTE *opal, int lump, bool blood) return true; } -int AddSpecialColormap(double r, double g, double b, bool inv) +int AddSpecialColormap(double r1, double g1, double b1, double r2, double g2, double b2) { + // Clamp these in range for the hardware shader. + r1 = clamp(r1, 0.0, 2.0); + g1 = clamp(g1, 0.0, 2.0); + b1 = clamp(b1, 0.0, 2.0); + r2 = clamp(r2, 0.0, 2.0); + g2 = clamp(g2, 0.0, 2.0); + b2 = clamp(b2, 0.0, 2.0); + for(unsigned i=0; iColorize[0] = float(r); - cm->Colorize[1] = float(g); - cm->Colorize[2] = float(b); - cm->Inverted = inv; + cm->ColorizeStart[0] = float(r1); + cm->ColorizeStart[1] = float(g1); + cm->ColorizeStart[2] = float(b1); + cm->ColorizeEnd[0] = float(r2); + cm->ColorizeEnd[1] = float(g2); + cm->ColorizeEnd[2] = float(b2); + + r2 -= r1; + g2 -= g1; + b2 -= b1; + r1 *= 255; + g1 *= 255; + b1 *= 255; for (int c = 0; c < 256; c++) { double intensity = (GPalette.BaseColors[c].r * 77 + GPalette.BaseColors[c].g * 143 + GPalette.BaseColors[c].b * 37) / 256.0; - if (inv) - { - intensity = 255 - intensity; - } - PalEntry pe = PalEntry( MIN(255, int(intensity*r)), - MIN(255, int(intensity*g)), - MIN(255, int(intensity*b))); + PalEntry pe = PalEntry( MIN(255, int(r1 + intensity*r2)), + MIN(255, int(g1 + intensity*g2)), + MIN(255, int(b1 + intensity*b2))); cm->Colormap[c] = ColorMatcher.Pick(pe); // This table is used by the texture composition code - for(int i = 0;i < 256; i++) - { - intensity = inv? 255-i : i; - cm->GrayscaleToColor[i] = PalEntry( MIN(255, int(intensity*r)), - MIN(255, int(intensity*g)), - MIN(255, int(intensity*b))); - } + cm->GrayscaleToColor[c] = pe; } return SpecialColormaps.Size() - 1; } @@ -456,8 +464,9 @@ void InitPalette () for (int i = 0; i < countof(SpecialColormapParms); ++i) { - AddSpecialColormap(SpecialColormapParms[i].Colorize[0], SpecialColormapParms[i].Colorize[1], - SpecialColormapParms[i].Colorize[2], SpecialColormapParms[i].Inverted); + AddSpecialColormap(SpecialColormapParms[i].Start[0], SpecialColormapParms[i].Start[1], + SpecialColormapParms[i].Start[2], SpecialColormapParms[i].End[0], + SpecialColormapParms[i].End[1], SpecialColormapParms[i].End[2]); } // desaturated colormaps for(int m = 0; m < 31; m++) diff --git a/src/v_palette.h b/src/v_palette.h index 186c25d5e..30bc9e8cf 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -97,8 +97,8 @@ enum struct FSpecialColormap { - float Colorize[3]; - bool Inverted; + float ColorizeStart[3]; + float ColorizeEnd[3]; BYTE Colormap[256]; PalEntry GrayscaleToColor[256]; }; @@ -124,7 +124,7 @@ inline int GetSpecialColormap(int blend) return IsSpecialColormap(blend) ? blend & 0xFFFF : NOFIXEDCOLORMAP; } -int AddSpecialColormap(double r, double g, double b, bool inv); +int AddSpecialColormap(double r1, double g1, double b1, double r2, double g2, double b2); @@ -152,7 +152,7 @@ void V_SetBlend (int blendr, int blendg, int blendb, int blenda); // V_ForceBlend() // // Normally, V_SetBlend() does nothing if the new blend is the -// same as the old. This function will performing the blending +// same as the old. This function will perform the blending // even if the blend hasn't changed. void V_ForceBlend (int blendr, int blendg, int blendb, int blenda); diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 08e97a3bb..82fc19f45 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -224,9 +224,7 @@ const char *const D3DFB::ShaderNames[D3DFB::NUM_SHADERS] = "VertexColor.pso", "SpecialColormap.pso", - "SpecialColormapInv.pso", "SpecialColorMapPal.pso", - "SpecialColorMapPalInv.pso", "InGameColormap.pso", "InGameColormapDesat.pso", @@ -2984,8 +2982,7 @@ void D3DFB::EndQuadBatch() { int select; - select = !!(quad->Flags & BQF_InvertSource); - select |= !!(quad->Flags & BQF_Paletted) << 1; + select = !!(quad->Flags & BQF_Paletted); SetPixelShader(Shaders[SHADER_SpecialColormap + select]); } else if (quad->ShaderNum == BQS_InGameColormap) @@ -3115,47 +3112,7 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR & SetColorOverlay(parms.colorOverlay, alpha, color0, color1); - if (parms.specialcolormap != NULL) - { // Emulate an invulnerability or similar colormap. - if (style.Flags & STYLEF_InvertSource) - { - quad.Flags |= BQF_InvertSource; - } - if (fmt == D3DFMT_L8) - { - quad.Flags |= BQF_GamePalette; - } - quad.ShaderNum = BQS_SpecialColormap; - color0 = D3DCOLOR_COLORVALUE(parms.specialcolormap->Colorize[0]/2, - parms.specialcolormap->Colorize[1]/2, parms.specialcolormap->Colorize[2]/2, 1); - color1 = D3DCOLOR_ARGB(255,0,0,0); - } - else if (parms.colormapstyle != NULL) - { // Emulate the fading from an in-game colormap (colorized, faded, and desaturated) - if (style.Flags & STYLEF_InvertSource) - { - quad.Flags |= BQF_InvertSource; - } - if (fmt == D3DFMT_L8) - { - quad.Flags |= BQF_GamePalette; - } - if (parms.colormapstyle->Desaturate != 0) - { - quad.Flags |= BQF_Desaturated; - } - quad.ShaderNum = BQS_InGameColormap; - color0 = D3DCOLOR_ARGB(parms.colormapstyle->Desaturate, - parms.colormapstyle->Color.r, - parms.colormapstyle->Color.g, - parms.colormapstyle->Color.b); - double fadelevel = parms.colormapstyle->FadeLevel; - color1 = D3DCOLOR_ARGB(DWORD((1 - fadelevel) * 255), - DWORD(parms.colormapstyle->Fade.r * fadelevel), - DWORD(parms.colormapstyle->Fade.g * fadelevel), - DWORD(parms.colormapstyle->Fade.b * fadelevel)); - } - else if (style.Flags & STYLEF_ColorIsFixed) + if (style.Flags & STYLEF_ColorIsFixed) { if (style.Flags & STYLEF_InvertSource) { // Since the source color is a constant, we can invert it now @@ -3219,10 +3176,42 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR & { quad.Flags |= BQF_InvertSource; } + + if (parms.specialcolormap != NULL) + { // Emulate an invulnerability or similar colormap. + float *start, *end; + start = parms.specialcolormap->ColorizeStart; + end = parms.specialcolormap->ColorizeEnd; + if (quad.Flags & BQF_InvertSource) + { + quad.Flags &= ~BQF_InvertSource; + swap(start, end); + } + quad.ShaderNum = BQS_SpecialColormap; + color0 = D3DCOLOR_RGBA(DWORD(start[0]/2*255), DWORD(start[1]/2*255), DWORD(start[2]/2*255), color0 >> 24); + color1 = D3DCOLOR_RGBA(DWORD(end[0]/2*255), DWORD(end[1]/2*255), DWORD(end[2]/2*255), color1 >> 24); + } + else if (parms.colormapstyle != NULL) + { // Emulate the fading from an in-game colormap (colorized, faded, and desaturated) + if (parms.colormapstyle->Desaturate != 0) + { + quad.Flags |= BQF_Desaturated; + } + quad.ShaderNum = BQS_InGameColormap; + color0 = D3DCOLOR_ARGB(parms.colormapstyle->Desaturate, + parms.colormapstyle->Color.r, + parms.colormapstyle->Color.g, + parms.colormapstyle->Color.b); + double fadelevel = parms.colormapstyle->FadeLevel; + color1 = D3DCOLOR_ARGB(DWORD((1 - fadelevel) * 255), + DWORD(parms.colormapstyle->Fade.r * fadelevel), + DWORD(parms.colormapstyle->Fade.g * fadelevel), + DWORD(parms.colormapstyle->Fade.b * fadelevel)); + } } // For unmasked images, force the alpha from the image data to be ignored. - if (!parms.masked) + if (!parms.masked && quad.ShaderNum != BQS_InGameColormap) { color0 = (color0 & D3DCOLOR_RGBA(255, 255, 255, 0)) | D3DCOLOR_COLORVALUE(0, 0, 0, alpha); color1 &= D3DCOLOR_RGBA(255, 255, 255, 0); diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 59741597a..26d8bf91d 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -310,9 +310,7 @@ private: SHADER_VertexColor, SHADER_SpecialColormap, - SHADER_SpecialColormapInv, SHADER_SpecialColorMapPal, - SHADER_SpecialColorMapPalInv, SHADER_InGameColormap, SHADER_InGameColormapDesat, diff --git a/wadsrc/static/shaders/d3d/shaders.ps b/wadsrc/static/shaders/d3d/shaders.ps index cf2899dcc..3039c7e2a 100644 --- a/wadsrc/static/shaders/d3d/shaders.ps +++ b/wadsrc/static/shaders/d3d/shaders.ps @@ -59,13 +59,15 @@ float4 VertexColor(float4 color : COLOR0) : COLOR // Emulate one of the special colormaps. (Invulnerability, gold, etc.) -float4 SpecialColormap(float2 tex_coord : TEXCOORD0, float4 icolor : COLOR0) : COLOR +float4 SpecialColormap(float2 tex_coord : TEXCOORD0, float4 start : COLOR0, float4 end : COLOR1) : COLOR { - // We can't store values greater than 1.0 in a color register, so we multiply - // intensity by 2 and expect the caller to divide icolor by 2. float4 color = SampleTexture(tex_coord); - float intensity = 2 * Grayscale(color); - color.rgb = icolor.rgb * intensity; + float4 range = end - start; + // We can't store values greater than 1.0 in a color register, so we multiply + // the final result by 2 and expect the caller to divide the start and end by 2. + color.rgb = 2 * (start + Grayscale(color) * range); + // Duplicate alpha semantics of NormalColor. + color.a = start.a + color.a * end.a; return color; } diff --git a/wadsrc/static/shaders/d3d/sm14/SpecialColormap.pso b/wadsrc/static/shaders/d3d/sm14/SpecialColormap.pso index 4d934e7c9379a5a5ccf85046b37f75f87762864f..8dc3111b2a45ffe3f1c37803a8e1c1503aeb8212 100644 GIT binary patch delta 83 zcmW-X!3}^g48)wMq8*C?7%FTKBnDs{2FVco(v-(NY~Lrh`g2PZlr&`3zwG{{~hD1_uTP_6A0V|Ls8e3IG2y GFaQ8|&<7KB{e?`$hVn!GZsi=1L-^8!{oh;i$EXj3dkq>FDZc^ZOSvb diff --git a/wadsrc/static/shaders/d3d/sm14/SpecialColormapPal.pso b/wadsrc/static/shaders/d3d/sm14/SpecialColormapPal.pso index 3cd83924c732fd1e169e9bdd96a8ddc8db544d59..4b5cf3f9f7ca083b009c4751519e4abb3062c980 100644 GIT binary patch delta 84 zcmW-X%ME}q3`1W7q8*7N129yO7@%yx2n>}GxCa+YmcOr^)3cV{7^n_$6{0sKqq)2< X#66FhdT4heUE0-c{GZe>J7Ok$J3|%q delta 68 zcmZo+{=&4ug3*S90R%W27#W^4urWMYzzF0qg8Ba&SQ!``7#Y|b7#RMyGcY`v0Fq;1 M;0LSy|DS;Y0ROlT<^TWy diff --git a/wadsrc/static/shaders/d3d/sm14/SpecialColormapPalInv.pso b/wadsrc/static/shaders/d3d/sm14/SpecialColormapPalInv.pso deleted file mode 100644 index 8cd7bc2608db187186e5fdb0bd77e1ea2d637ce8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 388 zcmZusu}T9$6r8=Rmji|TfW?*C90rweT};wg1Vjzmg~Oc5!G#OC{eTq&8w)?c;!5Ef zOG`U{c*pGJd0932r{qaL|Y zJq5>)^I diff --git a/wadsrc/static/shaders/d3d/sm20/SpecialColormapInv.pso b/wadsrc/static/shaders/d3d/sm20/SpecialColormapInv.pso deleted file mode 100644 index 27f8f26f2759ad4fe514d9ddbe795623326cf85a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 316 zcmYLD!D_-l6r5~ql0(6}6q=(#2@QL zJG)x@mf_9J+u3~(QeNZ>CZD766M!EA^aPvII08A_8(|U#1Oj$dOG3b+*TP0Sz(>5^ zhB%!Xc%-k+wH9Ht-Q^jzNi^<$nyvg*7t`qLkYves?zU$g_dS>g?tHi2ga>z$#A&oA z8G3%-8@~FUKj`)FtiA>cZgu|Wc6s9^oMtuFD>r$kKEtUi222CC(nkxja}^n9(3N;oSBlo;JYecND2G`2GKYA diff --git a/wadsrc/static/shaders/d3d/sm20/SpecialColormapPal.pso b/wadsrc/static/shaders/d3d/sm20/SpecialColormapPal.pso index 5985d0ba5cc60ec1053c8aaea0a447af136182bb..d8c347c63f12f0fbc2ade8878cb1e3f55d46ed62 100644 GIT binary patch delta 138 zcmW-au?@p83C!{7@D|F;#R2^15j^sh&$qow`#=KR zC|kAf3g!_0Aa>JE{m5;CDKTsAa(ff5!widZ{fXOwryN8T(T0=mE=HECe{<1oc<=BB DX(SvJ delta 74 zcmaFCyn=ay6eA=1WOc?s8%73>1_p*F4Qvcg7BDd|Ff%eRHZU^$2V+(spMilL$Yubk SnE<4j7&!RB>i_>|U;qGoCJ`_I diff --git a/wadsrc/static/shaders/d3d/sm20/SpecialColormapPalInv.pso b/wadsrc/static/shaders/d3d/sm20/SpecialColormapPalInv.pso deleted file mode 100644 index eb523d2ef6d720ca38532cd04e7119265aff3dad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 440 zcmZvYF-yZh7>3_VViHv7E`k|#2@t;_kDMlgQ3)?I!EvJqPq{^g94ewQ0G_z?+giLQUV5Y#(F$a zCW(NJXH9??MuSse8?Oy})66E@`(anJa1x;`E$r$YL{obmCQ+V8u(0zVAEaZHLZ51J z{d?R;@no83m}jG4bc{j#ut>A?G4~E{j=anMuvE@6Pk`6ocf)Uzz@#a zZ5-5B1|#H@~s^DAkGnqqjqr$-5-x?`cLv9K&P^!^WVS{^xez^E8Htoc^?JXADysbBS+hHd{JmejT=IZ2-cm7@8=M={huW}6d E1Ckpd{{R30 delta 101 zcmW;DK@os33`EhNGSJ*A0WSzaOC?l71)v2D9O5G+J!B?tcK0h!8Sh=k2?ZEvn-^@* fI#}4IE=#%}*p%$5hP}rqx|y+VPitMj#NHi#L9P_M diff --git a/wadsrc/static/shaders/d3d/sm30/SpecialColormapInv.pso b/wadsrc/static/shaders/d3d/sm30/SpecialColormapInv.pso deleted file mode 100644 index bbf2438754fea2150e8e8bf9d37be5905d11e202..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 316 zcmX|6!D_-#5S%17K1#uR5zNtogpyj(W7UH~ylBBoL8PWhpb{~;^%DOepOCx1mG9_t zHlq6&c4u}UvkOb>f8E36^JClw@JE1}$s`;nAY+;m7Gc1I&n)ppn6RlmV^=G{e7_9? zoX-tBQI~g(br6S9mXcdUhJSLTlgx0Bkqo diff --git a/wadsrc/static/shaders/d3d/sm30/SpecialColormapPal.pso b/wadsrc/static/shaders/d3d/sm30/SpecialColormapPal.pso index fbd9c32306859fc0216e75e32535820675bf3b2c..4ee1be80c6ec841aebb41a7edb85fb4dbe5d50ec 100644 GIT binary patch delta 110 zcmXAgu?>JQ5CiX%NJL1G9txIX0X7L6yu=ce3`ChFsKOHp%aZSW`rBWV3`rMoJ(3;i pm}Ogql!c-J0x@Q&#;QtdJdDP5cj)iXnS>|iz{!;=aB|1&TE E08*(7#Q*>R diff --git a/wadsrc/static/shaders/d3d/sm30/SpecialColormapPalInv.pso b/wadsrc/static/shaders/d3d/sm30/SpecialColormapPalInv.pso deleted file mode 100644 index 9c57af2dc3a7b5219f280fcf14138274f6260295..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 440 zcmZut!AiqG5Ph4(G*qE?5zJ99L1Gnq65ES~7Q`wZOR%vGq@*$OrV0qmUo) z*qc9+?{Iy)t>VGm4D;sAo7u_0l=4enqxW#rJp%Aa138OM#aICwx|n9t1Po;K>b%lS zG6FWIlBSJVJve;=Tv>2+xXFL`>CFs&4i diff --git a/wadsrc/static/shaders/d3d/sm30/build.bat b/wadsrc/static/shaders/d3d/sm30/build.bat index d0edc16b7..fe6602b86 100644 --- a/wadsrc/static/shaders/d3d/sm30/build.bat +++ b/wadsrc/static/shaders/d3d/sm30/build.bat @@ -9,9 +9,7 @@ fxc ..\shaders.ps /Tps_3_0 /O3 /ERedToAlpha -DINVERT=1 /FoRedToAlphaInv.pso fxc ..\shaders.ps /Tps_3_0 /O3 /EVertexColor /FoVertexColor.pso fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=0 -DINVERT=0 /FoSpecialColormap.pso -fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=0 -DINVERT=1 /FoSpecialColormapInv.pso fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=1 -DINVERT=0 /FoSpecialColormapPal.pso -fxc ..\shaders.ps /Tps_3_0 /O3 /ESpecialColormap -DPALTEX=1 -DINVERT=1 /FoSpecialColormapPalInv.pso fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=0 -DDESAT=0 /FoInGameColormap.pso fxc ..\shaders.ps /Tps_3_0 /O3 /EInGameColormap -DPALTEX=0 -DINVERT=0 -DDESAT=1 /FoInGameColormapDesat.pso From d5026558668de14b4f58fa798132e00b0d4c4bce Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 04:21:27 +0000 Subject: [PATCH 23/27] - For hardware 2D, apply fixed colormaps when copying to video memory instead of doing it directly during the rendering, in order to improve visual fidelity for colormaps that aren't grayscale. SVN r1866 (trunk) --- docs/rh-log.txt | 3 +++ src/r_main.cpp | 15 ++++++++++++++- src/r_main.h | 1 + src/r_things.cpp | 4 ++-- src/win32/fb_d3d9.cpp | 20 ++++++++++++++++---- src/win32/win32iface.h | 2 +- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4b809f315..d53617049 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ September 21, 2009 +- For hardware 2D, apply fixed colormaps when copying to video memory instead + of doing it directly during the rendering, in order to improve visual + fidelity for colormaps that aren't grayscale. - Added support for defining the full color range of a special colormap. - Moved the code for specialcolormap and colormapstyle in D3DFB::SetStyle() at the end of the normally-colored block so that they get all the proper diff --git a/src/r_main.cpp b/src/r_main.cpp index ea3936768..e5caada3d 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -140,6 +140,7 @@ int validcount = 1; // increment every time a check is made FDynamicColormap*basecolormap; // [RH] colormap currently drawing with int fixedlightlev; lighttable_t *fixedcolormap; +FSpecialColormap *realfixedcolormap; float WallTMapScale; float WallTMapScale2; @@ -1158,6 +1159,7 @@ void R_SetupFrame (AActor *actor) } } + realfixedcolormap = NULL; fixedcolormap = NULL; fixedlightlev = -1; @@ -1165,7 +1167,18 @@ void R_SetupFrame (AActor *actor) { if (player->fixedcolormap >= 0 && player->fixedcolormap < (int)SpecialColormaps.Size()) { - fixedcolormap = SpecialColormaps[player->fixedcolormap].Colormap; + realfixedcolormap = &SpecialColormaps[player->fixedcolormap]; + if (RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) + { + // Render everything fullbright. The copy to video memory will + // apply the special colormap, so it won't be restricted to the + // palette. + fixedcolormap = realcolormaps; + } + else + { + fixedcolormap = SpecialColormaps[player->fixedcolormap].Colormap; + } } else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS) { diff --git a/src/r_main.h b/src/r_main.h index f6948a545..e633404e1 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -121,6 +121,7 @@ extern int extralight, r_actualextralight; extern bool foggy; extern int fixedlightlev; extern lighttable_t* fixedcolormap; +extern FSpecialColormap*realfixedcolormap; // diff --git a/src/r_things.cpp b/src/r_things.cpp index 8a938ef9b..3e9b8b0b3 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1648,9 +1648,9 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ } } - if (fixedcolormap != NULL) + if (realfixedcolormap != NULL) { // fixed color - vis->colormap = fixedcolormap; + vis->colormap = realfixedcolormap->Colormap; } else { diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 82fc19f45..0cf47e9a6 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -61,7 +61,7 @@ #include "v_pfx.h" #include "stats.h" #include "doomerrors.h" -#include "r_draw.h" +#include "r_main.h" #include "r_translate.h" #include "f_wipe.h" #include "st_stuff.h" @@ -1074,19 +1074,30 @@ void D3DFB::Draw3DPart(bool copy3d) SetTexture (0, FBTexture); SetPaletteTexture(PaletteTexture, 256, BorderColor); - SetPixelShader(Shaders[SHADER_NormalColorPal]); D3DDevice->SetFVF (D3DFVF_FBVERTEX); memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(D3DBLENDOP(0)); EnableAlphaTest(FALSE); + SetPixelShader(Shaders[SHADER_NormalColorPal]); if (copy3d) { FBVERTEX verts[4]; D3DCOLOR color0, color1; if (Accel2D) { - color0 = 0; - color1 = 0xFFFFFFF; + if (realfixedcolormap == NULL) + { + color0 = 0; + color1 = 0xFFFFFFF; + } + else + { + color0 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeStart[0]/2, + realfixedcolormap->ColorizeStart[1]/2, realfixedcolormap->ColorizeStart[2]/2, 0); + color1 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeEnd[0]/2, + realfixedcolormap->ColorizeEnd[1]/2, realfixedcolormap->ColorizeEnd[2]/2, 1); + SetPixelShader(Shaders[SHADER_SpecialColormapPal]); + } } else { @@ -1096,6 +1107,7 @@ void D3DFB::Draw3DPart(bool copy3d) CalcFullscreenCoords(verts, Accel2D, false, color0, color1); D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); } + SetPixelShader(Shaders[SHADER_NormalColorPal]); } //========================================================================== diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 26d8bf91d..785664abd 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -310,7 +310,7 @@ private: SHADER_VertexColor, SHADER_SpecialColormap, - SHADER_SpecialColorMapPal, + SHADER_SpecialColormapPal, SHADER_InGameColormap, SHADER_InGameColormapDesat, From 9cc67f565ce48dc904bcfb21ec15f98a23c119dc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 22 Sep 2009 08:06:52 +0000 Subject: [PATCH 24/27] - Added a check to Dehacked code which tries to set the blend color. It must set it to 0 if the alpha is 0 to avoid problems with special colormap detection. - Changed SPECIALCOLORMAP_MASK again so that it does not interfere with any valid setting. It must use a value with a 0-alpha because these are guaranteed not to be produced by the DECORATE code elsewhere. - Fixed precision issues with AddFixedColormap's search for identical colormaps. - Added custom colormap support to texture composition code. - Fixed initialization of FSpecialColormap::GrayscaleToColor. This is not a mapping from the palette but from a [0,255] grayscale ramp and used to apply colormaps to true color images for texture composition. SVN r1867 (trunk) --- docs/rh-log.txt | 13 +++++++ src/d_dehacked.cpp | 6 +++- src/textures/multipatchtexture.cpp | 52 +++++++++++++++++++++++----- src/thingdef/thingdef_properties.cpp | 2 +- src/v_palette.cpp | 35 +++++++++++-------- src/v_palette.h | 4 +-- 6 files changed, 85 insertions(+), 27 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index d53617049..6b287c387 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,16 @@ +September 22, 2009 (Changes by Graf Zahl) +- Added a check to Dehacked code which tries to set the blend color. + It must set it to 0 if the alpha is 0 to avoid problems with special + colormap detection. +- Changed SPECIALCOLORMAP_MASK again so that it does not interfere with + any valid setting. It must use a value with a 0-alpha because these + are guaranteed not to be produced by the DECORATE code elsewhere. +- Fixed precision issues with AddFixedColormap's search for identical colormaps. +- Added custom colormap support to texture composition code. +- Fixed initialization of FSpecialColormap::GrayscaleToColor. This is not + a mapping from the palette but from a [0,255] grayscale ramp and used to + apply colormaps to true color images for texture composition. + September 21, 2009 - For hardware 2D, apply fixed colormaps when copying to video memory instead of doing it directly during the rendering, in order to improve visual diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 1ac3ff287..b4901bc8a 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1793,7 +1793,7 @@ static int PatchMisc (int dummy) { Printf ("Bad powerup color description \"%s\" for %s\n", Line2, Line1); } - else + else if (a > 0) { static_cast(GetDefaultByType (types[i]))->BlendColor = PalEntry( BYTE(clamp(a,0.f,1.f)*255.f), @@ -1801,6 +1801,10 @@ static int PatchMisc (int dummy) clamp(g,0,255), clamp(b,0,255)); } + else + { + static_cast(GetDefaultByType (types[i]))->BlendColor = 0; + } } } else diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index a52bd2e37..4b9bd5e1b 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -423,19 +423,19 @@ const BYTE *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spa BYTE *GetBlendMap(PalEntry blend, BYTE *blendwork) { - switch (blend.a==0 ? blend.r : -1) + switch (blend.a==0 ? int(blend) : -1) { case BLEND_ICEMAP: return TranslationToTable(TRANSLATION(TRANSLATION_Standard, 7))->Remap; default: - if (blend.r >= BLEND_SPECIALCOLORMAP1) + if (blend >= BLEND_SPECIALCOLORMAP1) { - return SpecialColormaps[blend.r - BLEND_SPECIALCOLORMAP1].Colormap; + return SpecialColormaps[blend - BLEND_SPECIALCOLORMAP1].Colormap; } - else if (blend.r >= BLEND_DESATURATE1 && blend.r <= BLEND_DESATURATE31) + else if (blend >= BLEND_DESATURATE1 && blend <= BLEND_DESATURATE31) { - return DesaturateColormap[blend.r - BLEND_DESATURATE1]; + return DesaturateColormap[blend - BLEND_DESATURATE1]; } else { @@ -1048,17 +1048,17 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part) match = sc.MatchString(maps); if (match >= 0) { - part.Blend.r = BLEND_SPECIALCOLORMAP1 + match; + part.Blend = BLEND_SPECIALCOLORMAP1 + match; } else if (sc.Compare("ICE")) { - part.Blend.r = BLEND_ICEMAP; + part.Blend = BLEND_ICEMAP; } else if (sc.Compare("DESATURATE")) { sc.MustGetStringName(","); sc.MustGetNumber(); - part.Blend.r = BLEND_DESATURATE1 + clamp(sc.Number-1, 0, 30); + part.Blend = BLEND_DESATURATE1 + clamp(sc.Number-1, 0, 30); } else { @@ -1074,6 +1074,36 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part) } } + else if (sc.Compare("Colormap")) + { + float r1,g1,b1; + float r2,g2,b2; + + sc.MustGetFloat(); + r1 = (float)sc.Float; + sc.MustGetStringName(","); + sc.MustGetFloat(); + g1 = (float)sc.Float; + sc.MustGetStringName(","); + sc.MustGetFloat(); + b1 = (float)sc.Float; + if (!sc.CheckString(",")) + { + part.Blend = AddSpecialColormap(0,0,0, r1, g1, b1); + } + else + { + sc.MustGetFloat(); + r2 = (float)sc.Float; + sc.MustGetStringName(","); + sc.MustGetFloat(); + g2 = (float)sc.Float; + sc.MustGetStringName(","); + sc.MustGetFloat(); + b2 = (float)sc.Float; + part.Blend = AddSpecialColormap(r1, g1, b1, r2, g2, b2); + } + } else if (sc.Compare("Blend")) { bComplex = true; @@ -1100,10 +1130,14 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part) sc.MustGetStringName(","); part.Blend = MAKERGB(r, g, b); } + // Blend.a may never be 0 here. if (sc.CheckString(",")) { sc.MustGetFloat(); - part.Blend.a = clamp(int(sc.Float*255), 1, 254); + if (sc.Float > 0.f) + part.Blend.a = clamp(int(sc.Float*255), 1, 254); + else + part.Blend = 0; } else part.Blend.a = 255; } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 2a32d3160..155a8942c 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1601,7 +1601,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory) else alpha = 255/3; alpha=clamp(alpha, 0, 255); - if (alpha!=0) *pBlendColor = MAKEARGB(alpha, 0, 0, 0) | color; + if (alpha != 0) *pBlendColor = MAKEARGB(alpha, 0, 0, 0) | color; else *pBlendColor = 0; } diff --git a/src/v_palette.cpp b/src/v_palette.cpp index 043e006fa..fa7a09bc5 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef _WIN32 #include #else @@ -360,24 +361,25 @@ static bool FixBuildPalette (BYTE *opal, int lump, bool blood) return true; } -int AddSpecialColormap(double r1, double g1, double b1, double r2, double g2, double b2) +int AddSpecialColormap(float r1, float g1, float b1, float r2, float g2, float b2) { // Clamp these in range for the hardware shader. - r1 = clamp(r1, 0.0, 2.0); - g1 = clamp(g1, 0.0, 2.0); - b1 = clamp(b1, 0.0, 2.0); - r2 = clamp(r2, 0.0, 2.0); - g2 = clamp(g2, 0.0, 2.0); - b2 = clamp(b2, 0.0, 2.0); + r1 = clamp(r1, 0.0f, 2.0f); + g1 = clamp(g1, 0.0f, 2.0f); + b1 = clamp(b1, 0.0f, 2.0f); + r2 = clamp(r2, 0.0f, 2.0f); + g2 = clamp(g2, 0.0f, 2.0f); + b2 = clamp(b2, 0.0f, 2.0f); for(unsigned i=0; iColormap[c] = ColorMatcher.Pick(pe); // This table is used by the texture composition code - cm->GrayscaleToColor[c] = pe; + for(int i = 0;i < 256; i++) + { + cm->GrayscaleToColor[i] = PalEntry( MIN(255, int(r1 + i*r2)), + MIN(255, int(g1 + i*g2)), + MIN(255, int(b1 + i*b2))); + } } return SpecialColormaps.Size() - 1; } diff --git a/src/v_palette.h b/src/v_palette.h index 30bc9e8cf..453365d53 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -106,7 +106,7 @@ struct FSpecialColormap extern TArray SpecialColormaps; // some utility functions to store special colormaps in powerup blends -#define SPECIALCOLORMAP_MASK 0xBEEF0000 +#define SPECIALCOLORMAP_MASK 0x00b60000 inline int MakeSpecialColormap(int index) { @@ -124,7 +124,7 @@ inline int GetSpecialColormap(int blend) return IsSpecialColormap(blend) ? blend & 0xFFFF : NOFIXEDCOLORMAP; } -int AddSpecialColormap(double r1, double g1, double b1, double r2, double g2, double b2); +int AddSpecialColormap(float r1, float g1, float b1, float r2, float g2, float b2); From a3c80447d47602b72a4ed36da432fc05e3c153bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 22 Sep 2009 10:05:27 +0000 Subject: [PATCH 25/27] - fixed Powerup.Colormap 6 parameter version. SVN r1868 (trunk) --- src/thingdef/thingdef_properties.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 155a8942c..92e259f0c 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1638,9 +1638,9 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, colormap, FFFfff, Inventory) PROP_FLOAT_PARM(r1, 0); PROP_FLOAT_PARM(g1, 1); PROP_FLOAT_PARM(b1, 2); - PROP_FLOAT_PARM(r2, 0); - PROP_FLOAT_PARM(g2, 1); - PROP_FLOAT_PARM(b2, 2); + PROP_FLOAT_PARM(r2, 3); + PROP_FLOAT_PARM(g2, 4); + PROP_FLOAT_PARM(b2, 5); *pBlendColor = MakeSpecialColormap(AddSpecialColormap(r1, g1, b1, r2, g2, b2)); } else From 1263d015cb86285050a8fbe505e8e30643efd522 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 18:59:36 +0000 Subject: [PATCH 26/27] - Don't initialize GrayscaleToColor 256 times for each special colormap. SVN r1869 (trunk) --- src/v_palette.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/v_palette.cpp b/src/v_palette.cpp index fa7a09bc5..b9279779d 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -412,14 +412,14 @@ int AddSpecialColormap(float r1, float g1, float b1, float r2, float g2, float b MIN(255, int(b1 + intensity*b2))); cm->Colormap[c] = ColorMatcher.Pick(pe); + } - // This table is used by the texture composition code - for(int i = 0;i < 256; i++) - { - cm->GrayscaleToColor[i] = PalEntry( MIN(255, int(r1 + i*r2)), - MIN(255, int(g1 + i*g2)), - MIN(255, int(b1 + i*b2))); - } + // This table is used by the texture composition code + for(int i = 0;i < 256; i++) + { + cm->GrayscaleToColor[i] = PalEntry( MIN(255, int(r1 + i*r2)), + MIN(255, int(g1 + i*g2)), + MIN(255, int(b1 + i*b2))); } return SpecialColormaps.Size() - 1; } From 11fbc5717890daffad08f16a50239fc4ae4fddad Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 20:17:54 +0000 Subject: [PATCH 27/27] - Added a technique to try and minimize input lag with vsync enabled: Two surfaces are alternately locked for read-only access each frame, forcing the driver to stop buffering more than one frame at a time. The input lag on my system doesn't seem to be as bad as it once was (I can no longer see it obviously with my naked eye), but turning antilag on "feels" slightly more responsive. The cvar d3d_antilag turns this technique on and off. See for more details. SVN r1870 (trunk) --- docs/rh-log.txt | 9 ++++++ src/win32/fb_d3d9.cpp | 65 ++++++++++++++++++++++++++++++++++++------ src/win32/win32iface.h | 4 +++ 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 6b287c387..ac304a52d 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,12 @@ +September 22, 2009 +- Added a technique to try and minimize input lag with vsync enabled: Two + surfaces are alternately locked for read-only access each frame, forcing + the driver to stop buffering more than one frame at a time. The input lag + on my system doesn't seem to be as bad as it once was (I can no longer + see it obviously with my naked eye), but turning antilag on "feels" + slightly more responsive. The cvar d3d_antilag turns this technique on and + off. See for more details. + September 22, 2009 (Changes by Graf Zahl) - Added a check to Dehacked code which tries to set the blend color. It must set it to 0 if the alpha is 0 to avoid problems with special diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 0cf47e9a6..562abf13d 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -246,6 +246,7 @@ CUSTOM_CVAR(Bool, vid_hw2d, true, CVAR_NOINITCALL) BorderNeedRefresh = SB_state = screen->GetPageCount(); } +CVAR(Bool, d3d_antilag, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Int, d3d_showpacks, 0, 0) CVAR(Bool, vid_hwaalines, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) @@ -276,6 +277,8 @@ D3DFB::D3DFB (int width, int height, bool fullscreen) { Shaders[i] = NULL; } + BlockSurface[0] = NULL; + BlockSurface[1] = NULL; FBFormat = D3DFMT_UNKNOWN; PalFormat = D3DFMT_UNKNOWN; VSync = vid_vsync; @@ -531,6 +534,7 @@ bool D3DFB::CreateResources() { return false; } + CreateBlockSurfaces(); return true; } @@ -640,6 +644,8 @@ void D3DFB::ReleaseDefaultPoolItems() SAFE_RELEASE( InitialWipeScreen ); SAFE_RELEASE( VertexBuffer ); SAFE_RELEASE( IndexBuffer ); + SAFE_RELEASE( BlockSurface[0] ); + SAFE_RELEASE( BlockSurface[1] ); } //========================================================================== @@ -674,10 +680,35 @@ bool D3DFB::Reset () { return false; } + CreateBlockSurfaces(); SetInitialState(); return true; } +//========================================================================== +// +// D3DFB :: CreateBlockSurfaces +// +// Create blocking surfaces for antilag. It's okay if these can't be +// created; antilag just won't work. +// +//========================================================================== + +void D3DFB::CreateBlockSurfaces() +{ + BlockNum = 0; + if (SUCCEEDED(D3DDevice->CreateOffscreenPlainSurface(16, 16, D3DFMT_A8R8G8B8, + D3DPOOL_DEFAULT, &BlockSurface[0], 0))) + { + if (FAILED(D3DDevice->CreateOffscreenPlainSurface(16, 16, D3DFMT_A8R8G8B8, + D3DPOOL_DEFAULT, &BlockSurface[1], 0))) + { + BlockSurface[0]->Release(); + BlockSurface[0] = NULL; + } + } +} + //========================================================================== // // D3DFB :: KillNativePals @@ -921,10 +952,7 @@ void D3DFB::Update () DrawRateStuff(); DrawPackedTextures(d3d_showpacks); EndBatch(); // Make sure all batched primitives are drawn. - DoWindowedGamma(); - D3DDevice->EndScene(); - D3DDevice->Present(NULL, NULL, NULL, NULL); - InScene = false; + Flip(); } In2D = 0; return; @@ -987,10 +1015,7 @@ void D3DFB::Update () Draw3DPart(In2D <= 1); if (In2D == 0) { - DoWindowedGamma(); - D3DDevice->EndScene(); - D3DDevice->Present(NULL, NULL, NULL, NULL); - InScene = false; + Flip(); } BlitCycles.Unclock(); @@ -1000,6 +1025,30 @@ void D3DFB::Update () UpdatePending = false; } +void D3DFB::Flip() +{ + assert(InScene); + + DoWindowedGamma(); + D3DDevice->EndScene(); + + // Attempt to counter input lag. + if (d3d_antilag && BlockSurface[0] != NULL) + { + D3DLOCKED_RECT lr; + volatile int dummy; + D3DDevice->ColorFill(BlockSurface[BlockNum], NULL, D3DCOLOR_ARGB(0xFF,0,0x20,0x50)); + BlockNum ^= 1; + if (!FAILED((BlockSurface[BlockNum]->LockRect(&lr, NULL, D3DLOCK_READONLY)))) + { + dummy = *(int *)lr.pBits; + BlockSurface[BlockNum]->UnlockRect(); + } + } + D3DDevice->Present(NULL, NULL, NULL, NULL); + InScene = false; +} + bool D3DFB::PaintToWindow () { HRESULT hr; diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 785664abd..e4c21a015 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -226,6 +226,7 @@ public: bool Lock (bool buffered); void Unlock (); void Update (); + void Flip (); PalEntry *GetPalette (); void GetFlashedPalette (PalEntry palette[256]); void UpdatePalette (); @@ -332,6 +333,7 @@ private: bool CreateResources(); void ReleaseResources(); bool LoadShaders(); + void CreateBlockSurfaces(); bool CreateFBTexture(); bool CreatePaletteTexture(); bool CreateGrayPaletteTexture(); @@ -404,6 +406,7 @@ private: bool SM14; bool GatheringWipeScreen; bool AALines; + BYTE BlockNum; D3DPal *Palettes; D3DTex *Textures; PackingTexture *Packs; @@ -427,6 +430,7 @@ private: IDirect3DPixelShader9 *Shaders[NUM_SHADERS]; + IDirect3DSurface9 *BlockSurface[2]; IDirect3DSurface9 *OldRenderTarget; IDirect3DTexture9 *InitialWipeScreen, *FinalWipeScreen;