Moved TranslatePoint into a separate file.
Implemented most of the main loop in main.c. Game now seems to run OK. Need to write texture code and then add OpenGL.
This commit is contained in:
parent
12c6a39177
commit
0770c95c17
7 changed files with 218 additions and 14 deletions
2
Makefile
2
Makefile
|
@ -10,7 +10,7 @@ LDLIBS += -L/usr/X11R6/lib -lX11 -lXext `sdl-config --libs`
|
||||||
|
|
||||||
AFLAGS = -g -Iinclude/ -w+macro-params -w+orphan-labels -w+number-overflow
|
AFLAGS = -g -Iinclude/ -w+macro-params -w+orphan-labels -w+number-overflow
|
||||||
|
|
||||||
ROOT = main.c stubs.c stubs2.cpp winapi.c afont.c frustum.c kshape.c map.c maths.c md5.c mem3dc.c mem3dcpp.cpp module.c morph.c mslhand.c object.c shpanim.c sphere.c tables.c vdb.c version.c
|
ROOT = main.c math.asm stubs.c stubs2.cpp winapi.c afont.c frustum.c kshape.c map.c maths.c md5.c mem3dc.c mem3dcpp.cpp module.c morph.c mslhand.c object.c shpanim.c sphere.c tables.c vdb.c version.c
|
||||||
AVP = ai_sight.c avpview.c bh_agun.c bh_ais.c bh_alien.c bh_binsw.c bh_cable.c bh_corpse.c bh_deathvol.c bh_debri.c bh_dummy.c bh_fan.c bh_far.c bh_fhug.c bh_gener.c bh_ldoor.c bh_lift.c bh_light.c bh_lnksw.c bh_ltfx.c bh_marin.c bh_mission.c bh_near.c bh_pargen.c bh_plachier.c bh_plift.c bh_pred.c bh_queen.c bh_rubberduck.c bh_selfdest.c bh_snds.c bh_spcl.c bh_swdor.c bh_track.c bh_types.c bh_videoscreen.c bh_waypt.c bh_weap.c bh_xeno.c bonusabilities.c cconvars.cpp cdtrackselection.cpp cheatmodes.c comp_map.c comp_shp.c consolelog.cpp davehook.cpp deaths.c decal.c detaillevels.c dynamics.c dynblock.c equipmnt.c equiputl.cpp extents.c game.c game_statistics.c gamecmds.cpp gameflow.c gamevars.cpp hmodel.c hud.c inventry.c language.c lighting.c load_shp.c los.c maps.c mempool.c messagehistory.c missions.cpp movement.c paintball.c particle.c pfarlocs.c pheromon.c player.c pmove.c psnd.c psndproj.c pvisible.c savegame.c scream.cpp secstats.c sfx.c stratdef.c targeting.c track.c triggers.c weapons.c
|
AVP = ai_sight.c avpview.c bh_agun.c bh_ais.c bh_alien.c bh_binsw.c bh_cable.c bh_corpse.c bh_deathvol.c bh_debri.c bh_dummy.c bh_fan.c bh_far.c bh_fhug.c bh_gener.c bh_ldoor.c bh_lift.c bh_light.c bh_lnksw.c bh_ltfx.c bh_marin.c bh_mission.c bh_near.c bh_pargen.c bh_plachier.c bh_plift.c bh_pred.c bh_queen.c bh_rubberduck.c bh_selfdest.c bh_snds.c bh_spcl.c bh_swdor.c bh_track.c bh_types.c bh_videoscreen.c bh_waypt.c bh_weap.c bh_xeno.c bonusabilities.c cconvars.cpp cdtrackselection.cpp cheatmodes.c comp_map.c comp_shp.c consolelog.cpp davehook.cpp deaths.c decal.c detaillevels.c dynamics.c dynblock.c equipmnt.c equiputl.cpp extents.c game.c game_statistics.c gamecmds.cpp gameflow.c gamevars.cpp hmodel.c hud.c inventry.c language.c lighting.c load_shp.c los.c maps.c mempool.c messagehistory.c missions.cpp movement.c paintball.c particle.c pfarlocs.c pheromon.c player.c pmove.c psnd.c psndproj.c pvisible.c savegame.c scream.cpp secstats.c sfx.c stratdef.c targeting.c track.c triggers.c weapons.c
|
||||||
SHAPES = cube.c
|
SHAPES = cube.c
|
||||||
SUPPORT = consbind.cpp consbtch.cpp coordstr.cpp daemon.cpp r2base.cpp r2pos666.cpp reflist.cpp refobj.cpp scstring.cpp strtab.cpp strutil.c trig666.cpp wrapstr.cpp
|
SUPPORT = consbind.cpp consbtch.cpp coordstr.cpp daemon.cpp r2base.cpp r2pos666.cpp reflist.cpp refobj.cpp scstring.cpp strtab.cpp strutil.c trig666.cpp wrapstr.cpp
|
||||||
|
|
|
@ -7,3 +7,5 @@ Changed filenames:
|
||||||
avp/win95/system.c (avp_load_rif calls)
|
avp/win95/system.c (avp_load_rif calls)
|
||||||
========
|
========
|
||||||
is AvP.CurrentEnv and StartingEnv used?
|
is AvP.CurrentEnv and StartingEnv used?
|
||||||
|
========
|
||||||
|
SCREENDESCRIPTORBLOCK.SDB_DiagonalWidth is unused
|
||||||
|
|
13
src/kshape.c
13
src/kshape.c
|
@ -32,9 +32,6 @@
|
||||||
#include "detaillevels.h"
|
#include "detaillevels.h"
|
||||||
#include "avp_userprofile.h"
|
#include "avp_userprofile.h"
|
||||||
|
|
||||||
#if SOFTWARE_RENDERER
|
|
||||||
#define D3D_ZBufferedGouraudTexturedPolygon_Output Software_ZBufferedGouraudTexturedPolygon_Output
|
|
||||||
#endif
|
|
||||||
#define ALIENS_LIFEFORCE_GLOW_COLOUR 0x20ff8080
|
#define ALIENS_LIFEFORCE_GLOW_COLOUR 0x20ff8080
|
||||||
#define MARINES_LIFEFORCE_GLOW_COLOUR 0x208080ff
|
#define MARINES_LIFEFORCE_GLOW_COLOUR 0x208080ff
|
||||||
#define PREDATORS_LIFEFORCE_GLOW_COLOUR 0x2080ff80
|
#define PREDATORS_LIFEFORCE_GLOW_COLOUR 0x2080ff80
|
||||||
|
@ -4503,10 +4500,16 @@ void TranslatePoint(int *source, int *dest, int *matrix)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
static void TranslatePoint(float *source, float *dest, float *matrix)
|
static void TranslatePoint(float *source, float *dest, float *matrix)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "TranslatePoint(%f, %f, %f)\n");
|
// fprintf(stderr, "TranslatePoint(%f, %f, %f)\n");
|
||||||
|
|
||||||
|
/* TODO - implement the inline assembly here? */
|
||||||
|
/* Moved to a separate file because I can't figure out the damn syntax! */
|
||||||
|
__asm__("call TranslatePoint_Asm \n\t"
|
||||||
|
:
|
||||||
|
: "S" (source), "b" (dest), "d" (matrix)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,6 @@
|
||||||
|
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
|
||||||
#define SOFTWARE_RENDERER 0
|
|
||||||
|
|
||||||
#if SOFTWARE_RENDERER
|
|
||||||
#include "SoftwareRender.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
124
src/main.c
124
src/main.c
|
@ -12,6 +12,10 @@
|
||||||
#include "vision.h"
|
#include "vision.h"
|
||||||
#include "comp_shp.h"
|
#include "comp_shp.h"
|
||||||
#include "avp_envinfo.h"
|
#include "avp_envinfo.h"
|
||||||
|
#include "stratdef.h"
|
||||||
|
#include "bh_types.h"
|
||||||
|
#include "avp_userprofile.h"
|
||||||
|
#include "pldnet.h"
|
||||||
#include "cdtrackselection.h"
|
#include "cdtrackselection.h"
|
||||||
|
|
||||||
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
|
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
|
||||||
|
@ -38,6 +42,9 @@ int ExitWindowsSystem()
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int menusActive = 0;
|
||||||
|
int thisLevelHasBeenCompleted = 0;
|
||||||
|
|
||||||
LoadCDTrackList();
|
LoadCDTrackList();
|
||||||
|
|
||||||
SetFastRandom();
|
SetFastRandom();
|
||||||
|
@ -56,7 +63,7 @@ int main(int argc, char *argv[])
|
||||||
InitialVideoMode();
|
InitialVideoMode();
|
||||||
|
|
||||||
/* Env_List can probably be removed */
|
/* Env_List can probably be removed */
|
||||||
// Env_List[0]->main = &(ELOLevelToLoad); /* overwrite the first entry of crappy env_list with LevelName */
|
// Env_List[0] = &(ELOLevelToLoad); /* overwrite the first entry of crappy env_list with LevelName */
|
||||||
Env_List[0]->main = LevelName;
|
Env_List[0]->main = LevelName;
|
||||||
|
|
||||||
InitialiseSystem();
|
InitialiseSystem();
|
||||||
|
@ -128,21 +135,134 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
switch(AvP.GameMode) {
|
switch(AvP.GameMode) {
|
||||||
case I_GM_Playing:
|
case I_GM_Playing:
|
||||||
|
if ((!menusActive || (AvP.Network!=I_No_Network && !netGameData.skirmishMode)) && !AvP.LevelCompleted) {
|
||||||
|
/* TODO: print some debugging stuff */
|
||||||
|
|
||||||
|
DoAllShapeAnimations();
|
||||||
|
|
||||||
|
UpdateGame();
|
||||||
|
|
||||||
|
AvpShowViews();
|
||||||
|
|
||||||
|
MaintainHUD();
|
||||||
|
|
||||||
|
CheckCDAndChooseTrackIfNeeded();
|
||||||
|
|
||||||
|
if(InGameMenusAreRunning() && ( (AvP.Network!=I_No_Network && netGameData.skirmishMode) || (AvP.Network==I_No_Network)) ) {
|
||||||
|
SoundSys_StopAll();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ReadUserInput();
|
||||||
|
|
||||||
|
/* UpdateAllFMVTextures(); NOT YET */
|
||||||
|
|
||||||
|
SoundSys_Management();
|
||||||
|
|
||||||
|
FlushD3DZBuffer();
|
||||||
|
|
||||||
|
ThisFramesRenderingHasBegun();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NOT YET
|
||||||
|
menusActive = AvP_InGameMenus();
|
||||||
|
if (AvP.RestartLevel) menusActive=0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (AvP.LevelCompleted) {
|
||||||
|
SoundSys_FadeOutFast();
|
||||||
|
DoCompletedLevelStatisticsScreen();
|
||||||
|
thisLevelHasBeenCompleted = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThisFramesRenderingHasFinished();
|
||||||
|
|
||||||
|
/* NOT YET
|
||||||
|
InGameFlipBuffers();
|
||||||
|
*/
|
||||||
|
|
||||||
|
FrameCounterHandler();
|
||||||
|
{
|
||||||
|
PLAYER_STATUS *playerStatusPtr = (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
|
||||||
|
|
||||||
|
if (!menusActive && playerStatusPtr->IsAlive && !AvP.LevelCompleted) {
|
||||||
|
DealWithElapsedTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case I_GM_Menus:
|
case I_GM_Menus:
|
||||||
AvP.GameMode = I_GM_Playing;
|
AvP.GameMode = I_GM_Playing;
|
||||||
break;
|
break;
|
||||||
case I_GM_Paused:
|
case I_GM_Paused:
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "AvP.MainLoopRunning: gamemode = %d\n", AvP.GameMode);
|
fprintf(stderr, "AvP.MainLoopRunning: gamemode = %d\n", AvP.GameMode);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AvP.RestartLevel) {
|
||||||
|
AvP.RestartLevel = 0;
|
||||||
|
AvP.LevelCompleted = 0;
|
||||||
|
/* NOT YET
|
||||||
|
FixCheatModesInUserProfile(UserProfilePtr);
|
||||||
|
*/
|
||||||
|
RestartLevel();
|
||||||
|
}
|
||||||
|
|
||||||
break; /* TODO -- remove when loop works */
|
break; /* TODO -- remove when loop works */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AvP.LevelCompleted = thisLevelHasBeenCompleted;
|
||||||
|
|
||||||
|
/* NOT YET
|
||||||
|
FixCheatModesInUserProfile(UserProfilePtr);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* NOT YET
|
||||||
|
CloseFMV();
|
||||||
|
ReleaseAllFMVTextures();
|
||||||
|
*/
|
||||||
|
|
||||||
|
CONSBIND_WriteKeyBindingsToConfigFile();
|
||||||
|
|
||||||
|
DeInitialisePlayer();
|
||||||
|
|
||||||
|
DeallocatePlayersMirrorImage();
|
||||||
|
|
||||||
|
KillHUD();
|
||||||
|
|
||||||
|
Destroy_CurrentEnvironment();
|
||||||
|
|
||||||
|
DeallocateAllImages();
|
||||||
|
|
||||||
|
EndNPCs();
|
||||||
|
|
||||||
|
ExitGame();
|
||||||
|
|
||||||
|
SoundSys_StopAll();
|
||||||
|
|
||||||
|
SoundSys_ResetFadeLevel();
|
||||||
|
|
||||||
|
CDDA_Stop();
|
||||||
|
|
||||||
|
if (AvP.Network != I_No_Network) {
|
||||||
|
/* NOT YET
|
||||||
|
EndAVPNetGame();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearMemoryPool();
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
SoundSys_StopAll();
|
||||||
|
SoundSys_RemoveAll();
|
||||||
|
|
||||||
|
ExitSystem();
|
||||||
|
|
||||||
|
CDDA_End();
|
||||||
|
ClearMemoryPool();
|
||||||
|
|
||||||
fprintf(stderr, "Now exiting Aliens vs Predator! At least it didn't crash!\n");
|
fprintf(stderr, "Now exiting Aliens vs Predator! At least it didn't crash!\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
52
src/math.asm
Normal file
52
src/math.asm
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
BITS 32
|
||||||
|
SECTION .text
|
||||||
|
|
||||||
|
GLOBAL TranslatePoint_Asm
|
||||||
|
|
||||||
|
; float *source, float *dest, float *matrix
|
||||||
|
; "S" (source), "b" (dest), "d" (matrix)
|
||||||
|
TranslatePoint_Asm:
|
||||||
|
fld dword [esi]
|
||||||
|
fmul dword [edi]
|
||||||
|
fld dword [esi+4]
|
||||||
|
fmul dword [edi+4]
|
||||||
|
fld dword [esi+8]
|
||||||
|
fmul dword [edi+8]
|
||||||
|
fxch st1
|
||||||
|
faddp st2, st0
|
||||||
|
fld dword [esi]
|
||||||
|
fmul dword [edi+16]
|
||||||
|
fxch st1
|
||||||
|
faddp st2, st0
|
||||||
|
fld dword [esi+4]
|
||||||
|
fmul dword [edi+20]
|
||||||
|
fld dword [esi+8]
|
||||||
|
fmul dword [edi+24]
|
||||||
|
fxch st1
|
||||||
|
faddp st2, st0
|
||||||
|
fld dword [esi]
|
||||||
|
fmul dword [edi+32]
|
||||||
|
fxch st1
|
||||||
|
faddp st2, st0
|
||||||
|
fld dword [esi+4]
|
||||||
|
fmul dword [edi+36]
|
||||||
|
fld dword [esi+8]
|
||||||
|
fmul dword [edi+40]
|
||||||
|
fxch st1
|
||||||
|
faddp st2, st0
|
||||||
|
fxch st3
|
||||||
|
fadd dword [edi+12]
|
||||||
|
fxch st1
|
||||||
|
faddp st3, st0
|
||||||
|
fxch st1
|
||||||
|
fadd dword [edi+28]
|
||||||
|
fxch st2
|
||||||
|
fadd dword [edi+44]
|
||||||
|
fxch st1
|
||||||
|
fstp dword [ebx]
|
||||||
|
fxch st1
|
||||||
|
fstp dword [ebx+4]
|
||||||
|
fstp dword [ebx+8]
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
33
src/stubs.c
33
src/stubs.c
|
@ -17,6 +17,9 @@
|
||||||
#include "kshape.h"
|
#include "kshape.h"
|
||||||
#include "d3d_hud.h"
|
#include "d3d_hud.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern IMAGEHEADER ImageHeaderArray[];
|
||||||
|
|
||||||
/* winmain.c */
|
/* winmain.c */
|
||||||
BOOL KeepMainRifFile = FALSE;
|
BOOL KeepMainRifFile = FALSE;
|
||||||
int HWAccel = 1;
|
int HWAccel = 1;
|
||||||
|
@ -478,6 +481,11 @@ void ThisFramesRenderingHasBegun()
|
||||||
fprintf(stderr, "ThisFramesRenderingHasBegun()\n");
|
fprintf(stderr, "ThisFramesRenderingHasBegun()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThisFramesRenderingHasFinished()
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ThisFramesRenderingHasFinished()\n");
|
||||||
|
}
|
||||||
|
|
||||||
void SecondFlushD3DZBuffer()
|
void SecondFlushD3DZBuffer()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SecondFlushD3DZBuffer()\n");
|
fprintf(stderr, "SecondFlushD3DZBuffer()\n");
|
||||||
|
@ -527,9 +535,24 @@ BOOL EndD3DScene()
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *CurrTextureHandle;
|
||||||
void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
|
void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
|
||||||
{
|
{
|
||||||
|
int texoffset;
|
||||||
|
void *TextureHandle;
|
||||||
|
|
||||||
|
texoffset = inputPolyPtr->PolyColour & ClrTxDefn;
|
||||||
|
if (texoffset) {
|
||||||
|
TextureHandle = (void *)ImageHeaderArray[texoffset].D3DHandle;
|
||||||
|
} else {
|
||||||
|
TextureHandle = CurrTextureHandle;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "D3D_ZBufferedGouraudTexturedPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr);
|
fprintf(stderr, "D3D_ZBufferedGouraudTexturedPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr);
|
||||||
|
fprintf(stderr, "\tRenderPolygon.NumberOfVertices = %d\n", RenderPolygon.NumberOfVertices);
|
||||||
|
fprintf(stderr, "\ttexoffset = %d (ptr = %p)\n", texoffset, texoffset ? (void *)ImageHeaderArray[texoffset].D3DHandle : CurrTextureHandle);
|
||||||
|
|
||||||
|
CurrTextureHandle = TextureHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D_ZBufferedGouraudPolygon_Output(POLYHEADER *inputPolyPtr,RENDERVERTEX *renderVerticesPtr)
|
void D3D_ZBufferedGouraudPolygon_Output(POLYHEADER *inputPolyPtr,RENDERVERTEX *renderVerticesPtr)
|
||||||
|
@ -727,6 +750,11 @@ void CDDA_Start()
|
||||||
fprintf(stderr, "CDDA_Start()\n");
|
fprintf(stderr, "CDDA_Start()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDDA_End()
|
||||||
|
{
|
||||||
|
fprintf(stderr, "CDDA_End()\n");
|
||||||
|
}
|
||||||
|
|
||||||
void CDDA_ChangeVolume(int volume)
|
void CDDA_ChangeVolume(int volume)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "CDDA_ChangeVolume(%d)\n", volume);
|
fprintf(stderr, "CDDA_ChangeVolume(%d)\n", volume);
|
||||||
|
@ -897,6 +925,11 @@ void RenderPlayersImageInMirror()
|
||||||
fprintf(stderr, "RenderPlayersImageInMirror()\n");
|
fprintf(stderr, "RenderPlayersImageInMirror()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeallocatePlayersMirrorImage()
|
||||||
|
{
|
||||||
|
fprintf(stderr, "DeallocatePlayersMirrorImage()\n");
|
||||||
|
}
|
||||||
|
|
||||||
void AddNetMsg_AlienAIKilled(STRATEGYBLOCK *sbPtr,int death_code,int death_time, int GibbFactor,DAMAGE_PROFILE* damage)
|
void AddNetMsg_AlienAIKilled(STRATEGYBLOCK *sbPtr,int death_code,int death_time, int GibbFactor,DAMAGE_PROFILE* damage)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "AddNetMsg_AlienAIKilled(%p, %d, %d, %d, %p)\n", sbPtr, death_code, death_time, GibbFactor, damage);
|
fprintf(stderr, "AddNetMsg_AlienAIKilled(%p, %d, %d, %d, %p)\n", sbPtr, death_code, death_time, GibbFactor, damage);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue