Commits

Braden Obrzut committed daf2892

- Accidentally implemented mouse look (so it's now available as Tab+M).

  • Participants
  • Parent commits 7f92913

Comments (0)

Files changed (6)

File src/r_sprites.cpp

 int CalcRotate(AActor *ob);
 extern byte* vbuf;
 extern unsigned vbufPitch;
+extern int viewshift;
 
 void ScaleSprite(AActor *actor, int xcenter, const Frame *frame, unsigned height)
 {
 		return;
 
 	const unsigned int scale = height>>3; // Integer part of the height
-	if(scale == 0)
+	if(scale == 0 || -(viewheight/2 - viewshift) >= (signed)scale)
 		return;
 
 	const double dyScale = height/256.0;
-	const int upperedge = (viewheight/2)+scale - tex->GetScaledTopOffsetDouble()*dyScale;
-	if(upperedge > viewheight)
-		return;
+	const int upperedge = (viewheight/2 - viewshift)+scale - tex->GetScaledTopOffsetDouble()*dyScale;
 
 	const double dxScale = (height/256.0)/(yaspect/65536.);
 	const int actx = xcenter - tex->GetScaledLeftOffsetDouble()*dxScale;
 	const fixed yStep = (1/dyScale)*FRACUNIT;
 	const fixed xRun = MIN<fixed>(texWidth<<FRACBITS, xStep*(viewwidth-actx));
 	const fixed yRun = MIN<fixed>(tex->GetHeight()<<FRACBITS, yStep*(viewheight-upperedge));
+	if((fixed)startY < viewscreeny)
+		return;
 
 	const BYTE *colormap;
 	if(!r_depthfog || (actor->flags & FL_BRIGHT) || frame->fullbright)

File src/wl_debug.cpp

 
 		return 1;
 	}
+	else if (Keyboard[sc_M]) // M = Mouse look
+	{
+		mouselook ^= 1;
+		US_CenterWindow (17,3);
+		if (mouselook)
+			US_PrintCentered ("Mouse look ON");
+		else
+			US_PrintCentered ("Mouse look OFF");
+		VW_UpdateScreen();
+		IN_Ack ();
+		return 1;
+	}
 	else if (Keyboard[sc_N])        // N = no clip
 	{
 		noclip^=1;

File src/wl_draw.cpp

 fixed   viewx,viewy;                    // the focal point
 angle_t viewangle;
 fixed   viewsin,viewcos;
+int viewshift = 0;
 
 void    TransformActor (AActor *ob);
 void    BuildTables (void);
 
 	BYTE *curshades = &NormalLight.Maps[256*GetShade(wallheight[postx])];
 
-	ywcount = yd = wallheight[postx] >> 3;
+	ywcount = yd = (wallheight[postx] >> 3);
 	if(yd <= 0) yd = 100;
 
-	yoffs = (viewheight / 2 - ywcount) * vbufPitch;
+	yoffs = (viewheight / 2 - ywcount - viewshift) * vbufPitch;
 	if(yoffs < 0) yoffs = 0;
 	yoffs += postx;
 
-	yendoffs = viewheight / 2 + ywcount - 1;
+	yendoffs = viewheight / 2 + ywcount - 1 - viewshift;
 	yw=texyscale-1;
 
 	while(yendoffs >= viewheight)
 				yw--;
 			}
 			while(ywcount <= 0);
-			if(yw < 0) break;
+			//if(yw < 0) break;
 			if(r_depthfog)
 				col = curshades[postsource[yw]];
 			else

File src/wl_floorceiling.cpp

 #include "wl_shade.h"
 #include "r_data/colormaps.h"
 
+extern int viewshift;
+
 // Textured Floor and Ceiling by DarkOne
 // With multi-textured floors and ceilings stored in lower and upper bytes of
 // according tile in third mapplane, respectively.
 	lasttoptex.SetInvalid();
 
 	int halfheight = viewheight >> 1;
+	halfheight -= viewshift;
 	int y0 = min_wallheight >> 3;              // starting y value
+	y0 -= abs(viewshift);
 	if(y0 > halfheight)
 		return;                                // view obscured by walls
-	if(!y0) y0 = 1;                            // don't let division by zero
-	byte* bot_offset = vbuf + vbufPitch * (halfheight + y0);
-	byte* top_offset = vbuf + vbufPitch * (halfheight - y0 - 1);
+	if(y0 <= 0) y0 = 1;                            // don't let division by zero
+	byte* bot_offset = vbuf + (signed)vbufPitch * (halfheight + y0);
+	byte* top_offset = vbuf + (signed)vbufPitch * (halfheight - y0 - 1);
 
 	const unsigned int mapwidth = map->GetHeader().width;
 	const unsigned int mapheight = map->GetHeader().height;
 
 	const unsigned int texDivisor = viewwidth*AspectCorrection[r_ratio].multiplier*175/48;
 
+	bool floordone = false, ceilingdone = false;
 	// draw horizontal lines
-	for(int y = y0;
-		y <= halfheight; ++y, bot_offset += vbufPitch, top_offset -= vbufPitch)
+	for(int y = y0;!(floordone && ceilingdone); ++y, bot_offset += vbufPitch, top_offset -= vbufPitch)
 	{
 		dist = (heightnumerator / (y + 1)) << 5;
 		gu =  viewx + FixedMul(dist, viewcos);
 					u = (gu >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
 					v = (gv >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
 					unsigned texoffs = (u << TEXTURESHIFT) + (TEXTURESIZE - 1) - v;
-					if(toptex && y < halfheight)
-						top_offset[top_add] = curshades[toptex[texoffs]];
-					if(bottex && y+halfheight < viewheight)
-						bot_offset[bot_add] = curshades[bottex[texoffs]];
+					if(!ceilingdone && y >= halfheight - viewheight)
+					{
+						if(y >= halfheight)
+							ceilingdone = true;
+						else if(toptex)
+							top_offset[top_add] = curshades[toptex[texoffs]];
+					}
+					if(!floordone && y+halfheight >= 0)
+					{
+						if(y+halfheight >= viewheight)
+							floordone = true;
+						else if(bottex)
+							bot_offset[bot_add] = curshades[bottex[texoffs]];
+					}
 				}
 			}
 			gu += du;

File src/wl_play.cpp

 
 static int DebugOk;
 
-bool noclip, ammocheat;
+bool noclip, ammocheat, mouselook = false;
 int godmode, singlestep;
 bool notargetmode = false;
 unsigned int extravbls = 0; // to remove flicker (gray stuff at the bottom)
 =
 ===================
 */
-
+extern int viewshift;
 void PollKeyboardMove (void)
 {
 	int delta = (!alwaysrun && buttonstate[bt_run]) || (alwaysrun && !buttonstate[bt_run]) ? RUNMOVE : BASEMOVE;
 	controlx += mousexmove * 20 / (21 - mouseadjustment);
 	if(!mouseyaxisdisabled)
 		controly += mouseymove * 40 / (21 - mouseadjustment);
+	else if(mouselook)
+		viewshift += mouseymove * 5 / (21 - mouseadjustment);
 }
 
 

File src/wl_play.h

 
 extern  int32_t     funnyticount;           // FOR FUNNY BJ FACE
 
-extern  bool        noclip,ammocheat;
+extern  bool        noclip,ammocheat,mouselook;
 extern  int         singlestep;
 extern  unsigned int extravbls;