Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wolf3d
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
wolf3d
Commits
aa24f7d5
Commit
aa24f7d5
authored
Jun 08, 2000
by
Steven Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Added functions to do simple timing (to get a general feeling of frames
per second).
parent
61c56bb1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
11 deletions
+114
-11
Refresh.c
macsrc/Refresh.c
+2
-3
WolfMain.c
macsrc/WolfMain.c
+19
-1
stub.c
macsrc/stub.c
+56
-0
vi_glx.c
macsrc/vi_glx.c
+1
-0
wolfdef.h
macsrc/wolfdef.h
+36
-7
No files found.
macsrc/Refresh.c
View file @
aa24f7d5
...
@@ -442,9 +442,8 @@ void AdvancePushWall(void)
...
@@ -442,9 +442,8 @@ void AdvancePushWall(void)
void
RenderView
(
void
)
void
RenderView
(
void
)
{
{
Word
frame
;
Word
frame
;
centerangle
=
gamestate
.
viewangle
<<
GAMEANGLETOFINE
;
/* 512 to 2048 */
centerangle
=
gamestate
.
viewangle
<<
GAMEANGLETOFINE
;
/* 512 to 2048 */
centershort
=
centerangle
<<
ANGLETOFINESHIFT
;
/* 2048 to 64k */
centershort
=
centerangle
<<
ANGLETOFINESHIFT
;
/* 2048 to 64k */
viewsin
=
sintable
[
gamestate
.
viewangle
];
/* Get the basic sine */
viewsin
=
sintable
[
gamestate
.
viewangle
];
/* Get the basic sine */
...
@@ -472,5 +471,5 @@ void RenderView(void)
...
@@ -472,5 +471,5 @@ void RenderView(void)
}
}
IO_AttackShape
(
gamestate
.
weapon
*
4
+
frame
);
/* Draw the gun shape */
IO_AttackShape
(
gamestate
.
weapon
*
4
+
frame
);
/* Draw the gun shape */
}
}
IO_DisplayViewBuffer
();
/* blit to screen */
IO_DisplayViewBuffer
();
/* blit to screen */
}
}
macsrc/WolfMain.c
View file @
aa24f7d5
...
@@ -358,20 +358,29 @@ Again:
...
@@ -358,20 +358,29 @@ Again:
void
PlayLoop
(
void
)
void
PlayLoop
(
void
)
{
{
LongWord
Timer
;
LongWord
Timer
;
LastTicCount
=
ReadTick
();
InitGameCounter
();
InitRendCounter
();
LastTicCount
=
ReadTick
();
do
{
do
{
Timer
=
ReadTick
();
/* How much time has elapsed */
Timer
=
ReadTick
();
/* How much time has elapsed */
TicCount
=
(
Timer
-
LastTicCount
);
TicCount
=
(
Timer
-
LastTicCount
);
gamestate
.
playtime
+=
TicCount
;
/* Add the physical time to the elapsed time */
gamestate
.
playtime
+=
TicCount
;
/* Add the physical time to the elapsed time */
LastTicCount
=
Timer
;
LastTicCount
=
Timer
;
if
(
!
SlowDown
)
{
if
(
!
SlowDown
)
{
TicCount
=
4
;
/* Adjust from 4 */
TicCount
=
4
;
/* Adjust from 4 */
}
}
if
(
TicCount
>=
5
)
{
if
(
TicCount
>=
5
)
{
TicCount
=
4
;
TicCount
=
4
;
}
}
IO_CheckInput
();
/* Read the controls from the system */
IO_CheckInput
();
/* Read the controls from the system */
StartGameCounter
();
madenoise
=
FALSE
;
/* No noise made (Yet) */
madenoise
=
FALSE
;
/* No noise made (Yet) */
MoveDoors
();
/* Open and close all doors */
MoveDoors
();
/* Open and close all doors */
MovePWalls
();
/* Move all push walls */
MovePWalls
();
/* Move all push walls */
...
@@ -381,8 +390,17 @@ void PlayLoop(void)
...
@@ -381,8 +390,17 @@ void PlayLoop(void)
UpdateFace
();
/* Draw BJ's face and animate it */
UpdateFace
();
/* Draw BJ's face and animate it */
viewx
=
actors
[
0
].
x
;
/* Where is the camera? */
viewx
=
actors
[
0
].
x
;
/* Where is the camera? */
viewy
=
actors
[
0
].
y
;
viewy
=
actors
[
0
].
y
;
StartRendCounter
();
RenderView
();
/* Draw the 3D view */
RenderView
();
/* Draw the 3D view */
EndRendCounter
();
EndGameCounter
();
}
while
(
playstate
==
EX_STILLPLAYING
);
}
while
(
playstate
==
EX_STILLPLAYING
);
PrintGameCounter
();
PrintRendCounter
();
StopSong
();
StopSong
();
}
}
...
...
macsrc/stub.c
View file @
aa24f7d5
...
@@ -20,11 +20,67 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
...
@@ -20,11 +20,67 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/time.h>
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
#include <stdio.h>
#include "wolfdef.h"
#include "wolfdef.h"
LongWord
LastTick
;
LongWord
LastTick
;
TimeCounter
gametime
,
rendtime
;
void
InitTimeCounter
(
TimeCounter
*
t
)
{
t
->
frames
=
0
;
t
->
mintime
=
0xFFFFFFFF
;
t
->
maxtime
=
0
;
t
->
total
=
0
;
}
void
StartTimeCounter
(
TimeCounter
*
t
)
{
struct
timeval
t0
;
gettimeofday
(
&
t0
,
NULL
);
t
->
secs
=
t0
.
tv_sec
;
t
->
usecs
=
t0
.
tv_usec
;
}
void
EndTimeCounter
(
TimeCounter
*
t
)
{
struct
timeval
t0
;
unsigned
long
curtime
;
long
secs
,
usecs
;
gettimeofday
(
&
t0
,
NULL
);
secs
=
t0
.
tv_sec
-
t
->
secs
;
usecs
=
t0
.
tv_usec
-
t
->
usecs
;
curtime
=
secs
*
1000000
+
usecs
;
if
(
curtime
>
t
->
maxtime
)
t
->
maxtime
=
curtime
;
if
(
curtime
<
t
->
mintime
)
t
->
mintime
=
curtime
;
t
->
total
+=
curtime
;
t
->
frames
++
;
}
void
PrintTimeCounter
(
TimeCounter
*
t
,
char
*
header
)
{
double
avg
;
if
(
t
->
frames
==
0
)
return
;
avg
=
(
double
)
t
->
total
/
(
double
)
t
->
frames
;
printf
(
"%s:
\n
"
,
header
);
printf
(
"Frames: %lu, time %lu, avg %f
\n
"
,
t
->
frames
,
t
->
total
,
avg
);
printf
(
"Min: %lu, max:%lu
\n
"
,
t
->
mintime
,
t
->
maxtime
);
}
unsigned
short
int
sMSB
(
unsigned
short
int
x
)
unsigned
short
int
sMSB
(
unsigned
short
int
x
)
{
{
int
x1
=
(
x
&
0x00FF
)
<<
8
;
int
x1
=
(
x
&
0x00FF
)
<<
8
;
...
...
macsrc/vi_glx.c
View file @
aa24f7d5
...
@@ -175,6 +175,7 @@ int main(int argc, char *argv[])
...
@@ -175,6 +175,7 @@ int main(int argc, char *argv[])
InitData
();
InitData
();
SlowDown
=
1
;
GameViewSize
=
3
;
GameViewSize
=
3
;
NewGameWindow
(
GameViewSize
);
NewGameWindow
(
GameViewSize
);
...
...
macsrc/wolfdef.h
View file @
aa24f7d5
...
@@ -36,16 +36,45 @@ typedef struct {
...
@@ -36,16 +36,45 @@ typedef struct {
int
bottom
;
int
bottom
;
}
Rect
;
}
Rect
;
typedef
struct
{
unsigned
long
frames
;
unsigned
long
mintime
;
unsigned
long
maxtime
;
unsigned
long
total
;
long
secs
;
long
usecs
;
}
TimeCounter
;
extern
void
InitTimeCounter
(
TimeCounter
*
t
);
extern
void
StartTimeCounter
(
TimeCounter
*
t
);
extern
void
EndTimeCounter
(
TimeCounter
*
t
);
extern
void
PrintTimeCounter
(
TimeCounter
*
t
,
char
*
header
);
extern
TimeCounter
gametime
,
rendtime
;
#define InitGameCounter() InitTimeCounter(&gametime)
#define StartGameCounter() StartTimeCounter(&gametime)
#define EndGameCounter() EndTimeCounter(&gametime)
#define PrintGameCounter() PrintTimeCounter(&gametime, "Game Loop Time")
#define InitRendCounter() InitTimeCounter(&rendtime)
#define StartRendCounter() StartTimeCounter(&rendtime)
#define EndRendCounter() EndTimeCounter(&rendtime)
#define PrintRendCounter() PrintTimeCounter(&rendtime, "Render Loop Time")
#ifdef __BIGENDIAN__
#ifdef __BIGENDIAN__
unsigned
short
int
sLSB
(
unsigned
short
int
i
);
extern
unsigned
short
int
sLSB
(
unsigned
short
int
i
);
#define sMSB(i) i
#define sMSB(i) i
unsigned
long
lLSB
(
unsigned
long
i
);
extern
unsigned
long
lLSB
(
unsigned
long
i
);
#define lMSB(i) i
#define lMSB(i) i
#else
/* __BIGENDIAN__ */
#else
/* __BIGENDIAN__ */
unsigned
short
int
sLSB
(
unsigned
short
int
i
);
#define sLSB(i) i
unsigned
short
int
sMSB
(
unsigned
short
int
i
);
extern
unsigned
short
int
sMSB
(
unsigned
short
int
i
);
unsigned
long
lLSB
(
unsigned
long
i
);
#define lLSB(i) i
unsigned
long
lMSB
(
unsigned
long
i
);
extern
unsigned
long
lMSB
(
unsigned
long
i
);
#endif
/* __BIGENDIAN__ */
#endif
/* __BIGENDIAN__ */
/* an angle_t occupies an entire 16 bits so wraparound is automatically handled */
/* an angle_t occupies an entire 16 bits so wraparound is automatically handled */
...
@@ -104,10 +133,10 @@ typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */
...
@@ -104,10 +133,10 @@ typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */
#define VIEWHEIGHT 160 /* Height of the viewing area */
#define VIEWHEIGHT 160 /* Height of the viewing area */
#endif
#endif
extern
int
VidWidth
,
VidHeight
,
ViewHeight
;
#define SCREENWIDTH VidWidth
#define SCREENWIDTH VidWidth
#define SCREENHEIGHT VidHeight
#define SCREENHEIGHT VidHeight
#define VIEWHEIGHT ViewHeight
#define VIEWHEIGHT ViewHeight
extern
int
VidWidth
,
VidHeight
,
ViewHeight
;
Word
ScaleX
(
Word
x
);
/* Scale factor for 320 mode points projected to SCREEN */
Word
ScaleX
(
Word
x
);
/* Scale factor for 320 mode points projected to SCREEN */
Word
ScaleY
(
Word
y
);
Word
ScaleY
(
Word
y
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment