From 681b48343d4d109592f8208881f6547a5ddac472 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Wed, 15 Aug 2001 07:53:04 +0000 Subject: [PATCH] Added a README. Added the HUD font drawing code. now stubs2.cpp is no longer needed. --- Makefile | 9 +- README | 55 ++++ TODO | 2 - fontbr.pgm | Bin 7533 -> 0 bytes src/aafont.h | 258 ++++++++++++++++++ src/avp/psndproj.c | 89 +------ src/avp/support/indexfnt.cpp | 26 +- src/avp/support/indexfnt.hpp | 7 +- src/avp/win95/frontend/avp_menugfx.hpp | 5 + src/main.c | 17 +- src/opengl.c | 352 ++++++++++++++++++++++++- src/stubs.c | 24 +- src/stubs2.cpp | 107 -------- 13 files changed, 703 insertions(+), 248 deletions(-) create mode 100644 README delete mode 100644 fontbr.pgm create mode 100644 src/aafont.h delete mode 100644 src/stubs2.cpp diff --git a/Makefile b/Makefile index 364bcab..4ef1628 100644 --- a/Makefile +++ b/Makefile @@ -10,15 +10,14 @@ LDLIBS += -L/usr/X11R6/lib -lX11 -lXext -lGL `sdl-config --libs` -lopenal -lm AFLAGS = -g -Iinclude/ -w+macro-params -w+orphan-labels -w+number-overflow -ROOT = main.c mathline.c math.asm net.c render.c opengl.c openal.c winapi.c stubs.c stubs2.cpp afont.c frustum.c kshape.c map.c maths.c md5.c mem3dc.c mem3dcpp.cpp module.c morph.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 +ROOT = main.c mathline.c math.asm net.c render.c opengl.c openal.c winapi.c stubs.c frustum.c kshape.c map.c maths.c md5.c mem3dc.c mem3dcpp.cpp module.c morph.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 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 -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 -AVPWIN95 = avpchunk.cpp cheat.c chtcodes.cpp d3d_hud.cpp ddplat.cpp endianio.c ffread.cpp ffstdio.cpp gammacontrol.cpp gflwplat.c hierplace.cpp iofocus.cpp jsndsup.cpp kzsort.c langplat.c modcmds.cpp npcsetup.cpp objsetup.cpp pathchnk.cpp platsup.c pldghost.c progress_bar.cpp projload.cpp scrshot.cpp strachnk.cpp system.c usr_io.c vision.c +SUPPORT = consbind.cpp consbtch.cpp coordstr.cpp daemon.cpp indexfnt.cpp r2base.cpp r2pos666.cpp reflist.cpp refobj.cpp scstring.cpp strtab.cpp strutil.c trig666.cpp wrapstr.cpp +AVPWIN95 = avpchunk.cpp cheat.c chtcodes.cpp d3d_hud.cpp ddplat.cpp endianio.c ffread.cpp ffstdio.cpp gammacontrol.cpp hierplace.cpp iofocus.cpp jsndsup.cpp kzsort.c langplat.c modcmds.cpp npcsetup.cpp objsetup.cpp pathchnk.cpp platsup.c pldghost.c progress_bar.cpp projload.cpp scrshot.cpp strachnk.cpp system.c usr_io.c vision.c FRONTEND = avp_envinfo.c avp_intro.cpp avp_menudata.c GADGETS = ahudgadg.cpp conscmnd.cpp conssym.cpp consvar.cpp gadget.cpp hudgadg.cpp rootgadg.cpp t_ingadg.cpp teletype.cpp textexp.cpp textin.cpp trepgadg.cpp WIN95 = animchnk.cpp animobs.cpp awtexld.cpp awbmpld.cpp awiffld.cpp awpnmld.cpp bmpnames.cpp chnkload.cpp chnktexi.cpp chnktype.cpp chunk.cpp chunkpal.cpp db.c debuglog.cpp dummyobjectchunk.cpp enumchnk.cpp enumsch.cpp envchunk.cpp fail.c fragchnk.cpp gsprchnk.cpp hierchnk.cpp huffman.cpp iff.cpp iff_ilbm.cpp ilbm_ext.cpp io.c list_tem.cpp ltchunk.cpp media.cpp mishchnk.cpp obchunk.cpp oechunk.cpp our_mem.c plat_shp.c plspecfn.c shpchunk.cpp sndchunk.cpp sprchunk.cpp string.cpp texio.c toolchnk.cpp txioctrl.cpp wpchunk.cpp zsp.cpp -# awbmpld.cpp awiffld.cpp awpnmld.cpp awtexld.cpp # the following should really be autogenerated... diff --git a/README b/README new file mode 100644 index 0000000..33a3154 --- /dev/null +++ b/README @@ -0,0 +1,55 @@ +Aliens vs Predator Linux http://icculus.org/avp/ +------------------------ + +This is an unofficial Linux port of the Fox Interactive / Rebellion +Developments game, Aliens Verses Predator. + +The port is currently under development; it is not yet "suitable for +end users." Hopefully this status will change in the not-so-distant future. + + + + + + + +Obviously this README is totally incomplete, and will probably remain so for +quite a while, so I'll just try to list a few important notes. + + +The original copyright statement for the source code: +"The source code to Aliens Vs Predator is copyright (c) 1999-2000 Rebellion + and is provided as is with no warranty for its suitability for use. You may + not use this source code in full or in part for commercial purposes. Any use + must include a clearly visible credit to Rebellion as the creators and + owners, and reiteration of this license." +Take that as you will. +You can find the original source code and other related tools at: +http://www.avpnews.com/mods/tools/ + + +The source code that was released only works with Aliens vs Predator Gold. +In the future I'd like this port to support Gold, Regular and the three +demos. Plus, I am told that the Regular edition does seem to work by +renaming a file or two. + + +At least with the Gold edition, a number of files are encoded on the CD. So +you would need to install the game in Windows (VMware works also) in order +to get this to work. Currently wine does not work because it fails the CD +Check. + + +The full motion sequences cannot be played because they are encoded with +proprietary codecs (Bink and Smacker). But I do not think they will be +greatly missed. + + +More information about the game and the series can be found at +http://www.avpnews.com. + + +Last, but surely not least: +Thanks go out to Chuck Mason for testing and the OpenAL code, Dan Olson for +trying the code out with the Regular version, and Ryan C. Gordon for hosting +this project. diff --git a/TODO b/TODO index 432e173..cceb0f8 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,2 @@ * Debug, verify, and reimplant the inline functions in mathline.c to inline.h - - diff --git a/fontbr.pgm b/fontbr.pgm deleted file mode 100644 index b66111b0ba570fef3178c54a6245968212445275..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7533 zcmcJQTaMj03`FzYtH=@tgEWxY#q57G9Tr(dQ4-|`k{GzA_&O}fcK83EA3wkU_v4?B ze?LDzzS;GKn_YJ{sz#ms#eNaA+NJEVyKug6p?Mhk%iQAt?o<8RH+}4{@*nKi>(L&4 zVX|+8U8mJhz(F9h%eJ!%ag-!Sa}PMHOrn?2JC@%kdY-tlW1AUi(V5*A3ee7`WtAYR zy+h}34`}k0FFn^w&gZ^>i^v?mX1vM%-g6uJ-pqVc%YEw@#`E4F%L%D5>SphPB5XGJ z0=MpG!7Nl~Z&emH+tj|;+jHf4NE2p~tN|_~9DJQ@=*3NW_Q(j~d^jGs#$n3bukT~D zFE5_zdx6p~F@~dz9Q0D({8^p2h;xuiT7lAsBnwqPyGyi%IfVNo4{hGcbC)lR2Y6)l zygWcP(uTRgjalkagJ`O_%d1ZIu6~)bjuXbLND-R7%yx^yI4$e*M$PJ<`V>#u$HlBS z%LG{M@?Kba2FT668{)#VYCm{S43Uc+G!2pR(SeVMqTGPG~&9kSs&H=eH2`gB$Hpwj$uS~W*x`>mT_iQlYZvM z4mzkqyf3o1zHLV}Cm!}P0n3Ff(0hH+Wp`iT7Lf%cx6$V*#<3P7fcNJY^ECCTm7v+8`^~SO z-%JYc#IhkFbhQk3EW}PcU?N9rrq({?5yMGtTxVr@-~im}LeAj1N;Hci+XM0bse<;( z`1hpxmMENxZf%b5af}L++qzg}ZAX;8{eaXq+fm=qEXHy^2Y3P;8vaVyWcCM{(NvX- zKO&@zbue{cUH#K6i5WHo#jrjQQwz za9{P6^Yd=z&!iX&QP2`Mh#B$Vkl;mJKQY{o@Z6=w_#j|_jrp8Qw#E$`dE5~@{n*|Z zku*U5!Rj0uk_dAu^|wF^dR$iLAx77PnCc}b{m7|(x7Tt?Hz#YrPHH2D_eK~jcFPU7 z-FwjbgJ<{P^>*((M7W<53orVivkh?c7Sv;MdO^&lmM}^=9OwYQM9e?c#_kUwA0m86~3ZTU!ui cIfjuZtYi$|yGDJ1)TPy=SID_MAXIMUM)) continue; /* invalid sound number */ - if(GameSounds[soundNum].loaded) continue; /* Duplicate game sound loaded */ - ok = FindAndLoadWavFile(soundNum, wavFileName); - - /* Fill in the GameSound: the pointer to the ds buffer is filled in by - the wav file loader, if everthing went ok. If the load failed, do not - fill in the game sound data: it should remain initialised */ - if(ok) - { - GameSounds[soundNum].loaded = 1; - GameSounds[soundNum].activeInstances = 0;; - GameSounds[soundNum].volume = VOLUME_DEFAULT; - GameSounds[soundNum].pitch = pitchOffset; - InitialiseBaseFrequency(soundNum); - } - } - fclose(myFile); - - db_log1("loaded all the sounds."); -} -#endif \ No newline at end of file diff --git a/src/avp/support/indexfnt.cpp b/src/avp/support/indexfnt.cpp index d163f90..678e9a7 100644 --- a/src/avp/support/indexfnt.cpp +++ b/src/avp/support/indexfnt.cpp @@ -12,7 +12,7 @@ #include "3dc.h" #include "inline.h" #include "indexfnt.hpp" -#include "tallfont.hpp" +//#include "tallfont.hpp" extern "C" { @@ -29,8 +29,10 @@ extern "C" /* Macros **********************************************************/ /* Imported function prototypes ************************************/ +extern "C" { extern void D3D_RenderHUDString(char *stringPtr,int x,int y,int colour); extern void D3D_RenderHUDString_Clipped(char *stringPtr,int x,int y,int colour); +}; /* Imported data ***************************************************/ #ifdef __cplusplus @@ -39,22 +41,13 @@ extern void D3D_RenderHUDString_Clipped(char *stringPtr,int x,int y,int colour); #endif extern unsigned char *ScreenBuffer; extern long BackBufferPitch; +#if 0 /* LINUX */ extern LPDIRECTDRAWSURFACE lpDDSBack; extern DDPIXELFORMAT DisplayPixelFormat; +#endif extern int CloudTable[128][128]; extern int CloakingPhase; - #if 0 - extern OurBool DaveDebugOn; - extern FDIEXTENSIONTAG FDIET_Dummy; - extern IFEXTENSIONTAG IFET_Dummy; - extern FDIQUAD FDIQuad_WholeScreen; - extern FDIPOS FDIPos_Origin; - extern FDIPOS FDIPos_ScreenCentre; - extern IFOBJECTLOCATION IFObjLoc_Origin; - extern UncompressedGlobalPlotAtomID UGPAID_StandardNull; - extern IFCOLOUR IFColour_Dummy; - extern IFVECTOR IFVec_Zero; - #endif + #ifdef __cplusplus }; #endif @@ -422,6 +415,9 @@ IndexedFont_Kerned :: RenderString_Clipped const SCString& SCStr ) const { + fprintf(stderr, "IndexedFont_Kerned :: RenderString_Clipped\n"); + +#if 0 /* LINUX */ ProjChar* pProjChar_I = SCStr . pProjCh(); const LPDIRECTDRAWSURFACE image_ptr = GetImagePtr(); @@ -575,6 +571,7 @@ IndexedFont_Kerned :: RenderString_Clipped pProjChar_I++; } image_ptr->Unlock((LPVOID)ddsdimage.lpSurface); +#endif } void @@ -586,6 +583,8 @@ IndexedFont_Kerned :: RenderString_Unclipped ) const #if 1 { + fprintf(stderr, "IndexedFont_Kerned :: RenderString_Unclipped\n"); +#if 0 /* LINUX */ ProjChar* pProjChar_I = SCStr . pProjCh(); const LPDIRECTDRAWSURFACE image_ptr = GetImagePtr(); @@ -743,6 +742,7 @@ IndexedFont_Kerned :: RenderString_Unclipped pProjChar_I++; } image_ptr->Unlock((LPVOID)ddsdimage.lpSurface); +#endif } #else { diff --git a/src/avp/support/indexfnt.hpp b/src/avp/support/indexfnt.hpp index a8acb16..19d57c6 100644 --- a/src/avp/support/indexfnt.hpp +++ b/src/avp/support/indexfnt.hpp @@ -243,16 +243,13 @@ ) const; // protected: - IndexedFont_HUD(FontIndex I_Font_New); - - #if 0 + IndexedFont_HUD(FontIndex I_Font_New) : IndexedFont ( I_Font_New - ) ; + ) { } - #endif }; inline r2size IndexedFont_HUD::CalcSize ( diff --git a/src/avp/win95/frontend/avp_menugfx.hpp b/src/avp/win95/frontend/avp_menugfx.hpp index 8e78157..e8d9a23 100644 --- a/src/avp/win95/frontend/avp_menugfx.hpp +++ b/src/avp/win95/frontend/avp_menugfx.hpp @@ -1,3 +1,6 @@ +#ifndef __AVP_WIN95_FRONTEND_AVP_MENUGFX_HPP__ +#define __AVP_WIN95_FRONTEND_AVP_MENUGFX_HPP__ + /* KJL 12:27:18 26/06/98 - AvP_MenuGfx.hpp */ enum AVPMENUGFX_ID @@ -114,3 +117,5 @@ extern int HeightOfMenuGfx(enum AVPMENUGFX_ID menuGfxID); extern void ClearScreenToBlack(void); + +#endif diff --git a/src/main.c b/src/main.c index 9d3c012..f1acf0d 100644 --- a/src/main.c +++ b/src/main.c @@ -23,8 +23,8 @@ #include "cdtrackselection.h" #include "gammacontrol.h" -#define MyWidth 512 -#define MyHeight 384 +#define MyWidth 1024 +#define MyHeight 768 char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */ @@ -555,7 +555,6 @@ int main(int argc, char *argv[]) LoadKeyConfiguration(); - SoundSys_Start(); CDDA_Start(); @@ -567,18 +566,24 @@ int main(int argc, char *argv[]) AvP.LevelCompleted = 0; LoadSounds("PLAYER"); +{ + extern int DebuggingCommandsActive; +// AvP.Network = I_Host; /* for exploring */ + DebuggingCommandsActive = 1; +} + AvP.CurrentEnv = AvP.StartingEnv = 0; /* are these even used? */ // AvP.PlayerType = I_Alien; // SetLevelToLoad(AVP_ENVIRONMENT_TEMPLE); /* starting alien level */ - + AvP.PlayerType = I_Marine; -// SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */ + SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */ // AvP.PlayerType = I_Predator; // SetLevelToLoad(AVP_ENVIRONMENT_WATERFALL); /* starting predator level */ - SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP); /* multiplayer */ +// SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP); /* multiplayer */ // SetLevelToLoad(AVP_ENVIRONMENT_E3DEMOSP); /* demo level */ diff --git a/src/opengl.c b/src/opengl.c index 578acbf..3ea3293 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -35,6 +35,7 @@ extern int StaticImageNumber; extern int PredatorNumbersImageNumber; extern int BurningImageNumber; extern int HUDFontsImageNumber; +extern int AAFontImageNumber; extern int FMVParticleColour; extern int HUDScaleFactor; @@ -44,6 +45,8 @@ static D3DTexture *CurrTextureHandle; static enum TRANSLUCENCY_TYPE CurrentTranslucencyMode = TRANSLUCENCY_OFF; /* opengl state variable */ +static enum FILTERING_MODE_ID CurrentFilteringMode = FILTERING_BILINEAR_OFF; + static GLuint CurrentlyBoundTexture = 0; /* opengl state variable */ static void CheckBoundTextureIsCorrect(GLuint tex) @@ -52,6 +55,20 @@ static void CheckBoundTextureIsCorrect(GLuint tex) return; glBindTexture(GL_TEXTURE_2D, tex); + +/* + switch(CurrentFilteringMode) { + case FILTERING_BILINEAR_OFF: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + break; + case FILTERING_BILINEAR_ON: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + break; + default: + } +*/ CurrentlyBoundTexture = tex; } @@ -100,6 +117,27 @@ static void CheckTranslucencyModeIsCorrect(enum TRANSLUCENCY_TYPE mode) CurrentTranslucencyMode = mode; } +void CheckFilteringModeIsCorrect(enum FILTERING_MODE_ID filter) +{ + if (filter == CurrentFilteringMode) + return; + + switch(filter) { + case FILTERING_BILINEAR_OFF: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + break; + case FILTERING_BILINEAR_ON: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + break; + default: + fprintf(stderr, "CheckFilteringModeIsCorrect: filter = %d\n", filter); + } + + CurrentFilteringMode = filter; +} + #define TA_MAXVERTICES 8 typedef struct TriangleArray { @@ -989,8 +1027,8 @@ void D3D_PlayerOnFireOverlay() tex = ImageHeaderArray[BurningImageNumber].D3DTexture; CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING); - //CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); CheckBoundTextureIsCorrect(tex->id); + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); glColor4ub(r, g, b, a); @@ -1059,9 +1097,8 @@ void D3D_PlayerDamagedOverlay(int intensity) break; } - - // CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); CheckBoundTextureIsCorrect(tex->id); + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); colour = 0xffffff - baseColour + (intensity<<24); @@ -1143,8 +1180,8 @@ void DrawNoiseOverlay(int tr) tex = ImageHeaderArray[StaticImageNumber].D3DTexture; CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING); - // CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); CheckBoundTextureIsCorrect(tex->id); + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); glDepthFunc(GL_ALWAYS); u = FastRandom()&255; @@ -1201,8 +1238,8 @@ void D3D_ScreenInversionOverlay() tex = ImageHeaderArray[SpecialFXImageNumber].D3DTexture; CheckTranslucencyModeIsCorrect(TRANSLUCENCY_DARKENINGCOLOUR); -// CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); CheckBoundTextureIsCorrect(tex->id); + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); @@ -1284,8 +1321,8 @@ void DrawScanlinesOverlay(float level) tex = ImageHeaderArray[PredatorNumbersImageNumber].D3DTexture; CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL); - //CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); CheckBoundTextureIsCorrect(tex->id); + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON); glDepthFunc(GL_ALWAYS); c = 255; @@ -1458,7 +1495,7 @@ void D3D_RenderHUDNumber_Centred(unsigned int number,int x,int y,int colour) x += (3*w)/2; -// CheckFilteringModeIsCorrect(FILTERING_BILINEAR_OFF); + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_OFF); do { int topLeftU, topLeftV; @@ -1495,6 +1532,212 @@ void D3D_RenderHUDNumber_Centred(unsigned int number,int x,int y,int colour) } while (--noOfDigits); } +void D3D_RenderHUDString(char *stringPtr,int x,int y,int colour) +{ + struct VertexTag quadVertices[4]; + + quadVertices[0].Y = y-1; + quadVertices[1].Y = y-1; + quadVertices[2].Y = y + HUD_FONT_HEIGHT + 1; + quadVertices[3].Y = y + HUD_FONT_HEIGHT + 1; + + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_OFF); + + while( *stringPtr ) + { + char c = *stringPtr++; + + { + int topLeftU = 1+((c-32)&15)*16; + int topLeftV = 1+((c-32)>>4)*16; + + quadVertices[0].U = topLeftU - 1; + quadVertices[0].V = topLeftV - 1; + quadVertices[1].U = topLeftU + HUD_FONT_WIDTH + 1; + quadVertices[1].V = topLeftV - 1; + quadVertices[2].U = topLeftU + HUD_FONT_WIDTH + 1; + quadVertices[2].V = topLeftV + HUD_FONT_HEIGHT + 1; + quadVertices[3].U = topLeftU - 1; + quadVertices[3].V = topLeftV + HUD_FONT_HEIGHT + 1; + + quadVertices[0].X = x - 1; + quadVertices[3].X = x - 1; + quadVertices[1].X = x + HUD_FONT_WIDTH + 1; + quadVertices[2].X = x + HUD_FONT_WIDTH + 1; + + D3D_HUDQuad_Output + ( + AAFontImageNumber, + quadVertices, + colour + ); + } + x += AAFontWidths[(int)c]; + } +} + +void D3D_RenderHUDString_Clipped(char *stringPtr,int x,int y,int colour) +{ + struct VertexTag quadVertices[4]; + +// LOCALASSERT(y<=0); + + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_OFF); + + quadVertices[2].Y = y + HUD_FONT_HEIGHT + 1; + quadVertices[3].Y = y + HUD_FONT_HEIGHT + 1; + + quadVertices[0].Y = 0; + quadVertices[1].Y = 0; + + while ( *stringPtr ) + { + char c = *stringPtr++; + + { + int topLeftU = 1+((c-32)&15)*16; + int topLeftV = 1+((c-32)>>4)*16; + + quadVertices[0].U = topLeftU - 1; + quadVertices[0].V = topLeftV - y; + quadVertices[1].U = topLeftU + HUD_FONT_WIDTH+1; + quadVertices[1].V = topLeftV - y; + quadVertices[2].U = topLeftU + HUD_FONT_WIDTH+1; + quadVertices[2].V = topLeftV + HUD_FONT_HEIGHT+1; + quadVertices[3].U = topLeftU - 1; + quadVertices[3].V = topLeftV + HUD_FONT_HEIGHT+1; + + quadVertices[0].X = x - 1; + quadVertices[3].X = x - 1; + quadVertices[1].X = x + HUD_FONT_WIDTH + 1; + quadVertices[2].X = x + HUD_FONT_WIDTH + 1; + + D3D_HUDQuad_Output + ( + AAFontImageNumber, + quadVertices, + colour + ); + } + x += AAFontWidths[(int)c]; + } +} + +void D3D_RenderHUDString_Centred(char *stringPtr, int centreX, int y, int colour) +{ + int x, length = 0; + char *ptr = stringPtr; + struct VertexTag quadVertices[4]; + + while(*ptr) + { + length+=AAFontWidths[(int)*ptr++]; + } + length = MUL_FIXED(HUDScaleFactor,length); + + x = centreX-length/2; + + quadVertices[0].Y = y-MUL_FIXED(HUDScaleFactor,1); + quadVertices[1].Y = y-MUL_FIXED(HUDScaleFactor,1); + quadVertices[2].Y = y + MUL_FIXED(HUDScaleFactor,HUD_FONT_HEIGHT + 1); + quadVertices[3].Y = y + MUL_FIXED(HUDScaleFactor,HUD_FONT_HEIGHT + 1); + + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_OFF); + + while( *stringPtr ) + { + char c = *stringPtr++; + + { + int topLeftU = 1+((c-32)&15)*16; + int topLeftV = 1+((c-32)>>4)*16; + + quadVertices[0].U = topLeftU - 1; + quadVertices[0].V = topLeftV - 1; + quadVertices[1].U = topLeftU + HUD_FONT_WIDTH + 1; + quadVertices[1].V = topLeftV - 1; + quadVertices[2].U = topLeftU + HUD_FONT_WIDTH + 1; + quadVertices[2].V = topLeftV + HUD_FONT_HEIGHT + 1; + quadVertices[3].U = topLeftU - 1; + quadVertices[3].V = topLeftV + HUD_FONT_HEIGHT + 1; + + quadVertices[0].X = x - MUL_FIXED(HUDScaleFactor,1); + quadVertices[3].X = x - MUL_FIXED(HUDScaleFactor,1); + quadVertices[1].X = x + MUL_FIXED(HUDScaleFactor,HUD_FONT_WIDTH + 1); + quadVertices[2].X = x + MUL_FIXED(HUDScaleFactor,HUD_FONT_WIDTH + 1); + + D3D_HUDQuad_Output + ( + AAFontImageNumber, + quadVertices, + colour + ); + } + x += MUL_FIXED(HUDScaleFactor,AAFontWidths[(int)c]); + } +} + +void RenderString(char *stringPtr, int x, int y, int colour) +{ + D3D_RenderHUDString(stringPtr,x,y,colour); +} + +void RenderStringCentred(char *stringPtr, int centreX, int y, int colour) +{ + int length = 0; + char *ptr = stringPtr; + + while(*ptr) + { + length+=AAFontWidths[(int)*ptr++]; + } + D3D_RenderHUDString(stringPtr,centreX-length/2,y,colour); +} + +void RenderStringVertically(char *stringPtr, int centreX, int bottomY, int colour) +{ + struct VertexTag quadVertices[4]; + int y = bottomY; + + quadVertices[0].X = centreX - (HUD_FONT_HEIGHT/2) - 1; + quadVertices[1].X = quadVertices[0].X; + quadVertices[2].X = quadVertices[0].X+2+HUD_FONT_HEIGHT*1; + quadVertices[3].X = quadVertices[2].X; + + CheckFilteringModeIsCorrect(FILTERING_BILINEAR_OFF); + while( *stringPtr ) + { + char c = *stringPtr++; + + { + int topLeftU = 1+((c-32)&15)*16; + int topLeftV = 1+((c-32)>>4)*16; + + quadVertices[0].U = topLeftU - 1; + quadVertices[0].V = topLeftV - 1; + quadVertices[1].U = topLeftU + HUD_FONT_WIDTH; + quadVertices[1].V = topLeftV - 1; + quadVertices[2].U = topLeftU + HUD_FONT_WIDTH; + quadVertices[2].V = topLeftV + HUD_FONT_HEIGHT + 1; + quadVertices[3].U = topLeftU - 1; + quadVertices[3].V = topLeftV + HUD_FONT_HEIGHT + 1; + + quadVertices[0].Y = y ; + quadVertices[1].Y = y - HUD_FONT_WIDTH*1 -1; + quadVertices[2].Y = y - HUD_FONT_WIDTH*1 -1; + quadVertices[3].Y = y ; + + D3D_HUDQuad_Output + ( + AAFontImageNumber, + quadVertices, + colour + ); + } + y -= AAFontWidths[(int)c]; + } +} + void ColourFillBackBuffer(int FillColour) { float r, g, b, a; @@ -1565,3 +1808,98 @@ void D3D_DrawBackdrop() return; } } + +#if 0 +/* ** menu-type stuff that should be moved later ** */ +#include "avp_menugfx.hpp" + +int Hardware_RenderSmallMenuText(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format) +{ + switch(format) + { + default: +// GLOBALASSERT("UNKNOWN TEXT FORMAT"==0); + case AVPMENUFORMAT_LEFTJUSTIFIED: + { + // supplied x is correct + break; + } + case AVPMENUFORMAT_RIGHTJUSTIFIED: + { + int length = 0; + char *ptr = textPtr; + + while(*ptr) + { + length+=AAFontWidths[*ptr++]; + } + + x -= length; + break; + } + case AVPMENUFORMAT_CENTREJUSTIFIED: + { + int length = 0; + char *ptr = textPtr; + + while(*ptr) + { + length+=AAFontWidths[*ptr++]; + } + + x -= length/2; + break; + } + } + +// LOCALASSERT(x>0); + + { + unsigned int colour = alpha>>8; + if (colour>255) colour = 255; + colour = (colour<<24)+0xffffff; + D3D_RenderHUDString(textPtr,x,y,colour); + } + return x; +} + +void RenderBriefingText(int centreY, int brightness) +{ + int lengthOfLongestLine=-1; + int x,y,i; + + for(i=0; i<5; i++) + { + int length = 0; + { + char *ptr = BriefingTextString[i]; + + while(*ptr) + { + length+=AAFontWidths[*ptr++]; + } + } + + if (lengthOfLongestLine < length) + { + lengthOfLongestLine = length; + } + } + + x = (ScreenDescriptorBlock.SDB_Width-lengthOfLongestLine)/2; + y = centreY - 3*HUD_FONT_HEIGHT; + for(i=0; i<5; i++) + { +// if (AvPMenus.MenusState != MENUSSTATE_MAINMENUS) + { + Hardware_RenderSmallMenuText(BriefingTextString[i], x, y, brightness, AVPMENUFORMAT_LEFTJUSTIFIED/*,MENU_CENTREY-60-100,MENU_CENTREY-60+180*/); +// } +// else +// { +// RenderSmallMenuText(BriefingTextString[i], x, y, brightness, AVPMENUFORMAT_LEFTJUSTIFIED); +// } + if (i) y+=HUD_FONT_HEIGHT; + else y+=HUD_FONT_HEIGHT*2; + } +} +#endif diff --git a/src/stubs.c b/src/stubs.c index e266874..c1e70a2 100644 --- a/src/stubs.c +++ b/src/stubs.c @@ -41,12 +41,6 @@ void Draw_Item_2dTexturePolygon(int *itemptr) } -/* indexfnt.cpp */ -void INDEXFNT_PFLoadHook(FontIndex I_Font_New, PFFONT *pffont_New) -{ - fprintf(stderr, "INDEXFNT_PFLoadHook(%d, %p)\n", I_Font_New, pffont_New); -} - /* avp_mp_config.cpp */ char* GetCustomMultiplayerLevelName(int index, int gameType) @@ -136,7 +130,7 @@ void ATRemoveTexture(void * pTexture) /* avp_menugfx.cpp */ -char AAFontWidths[256]; +/* char AAFontWidths[256]; */ AVPMENUGFX AvPMenuGfxStorage[MAX_NO_OF_AVPMENUGFXS]; /* TODO: this is initialized in avp_menugfx.cpp */ void FadedScreen(int alpha) @@ -277,16 +271,6 @@ void InitForceField() fprintf(stderr, "InitForceField()\n"); } -void RenderString(char *stringPtr, int x, int y, int colour) -{ - fprintf(stderr, "RenderString(%s, %d, %d, %d)\n", stringPtr, x, y, colour); -} - -void RenderStringCentred(char *stringPtr, int centreX, int y, int colour) -{ - fprintf(stderr, "RenderStringCentred(%s, %d, %d, %d)\n", stringPtr, centreX, y, colour); -} - void PostLandscapeRendering() { fprintf(stderr, "PostLandscapeRendering()\n"); @@ -375,10 +359,6 @@ void D3D_BackdropPolygon_Output(POLYHEADER *inputPolyPtr,RENDERVERTEX *renderVer fprintf(stderr, "D3D_BackdropPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr); } -void D3D_RenderHUDString_Centred(char *stringPtr, int centreX, int y, int colour) -{ - fprintf(stderr, "D3D_RenderHUDString_Centred(%s, %d, %d, %d)\n", stringPtr, centreX, y, colour); -} /* dd_func.cpp */ long BackBufferPitch; @@ -737,3 +717,5 @@ void AddNetMsg_SpotOtherSound(enum soundindex SoundIndex,VECTORCH *position,int fprintf(stderr, "AddNetMsg_SpotOtherSound(%d, %p, %d)\n", SoundIndex, position, explosion); } + +#include "aafont.h" diff --git a/src/stubs2.cpp b/src/stubs2.cpp deleted file mode 100644 index a68ba99..0000000 --- a/src/stubs2.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include -#include - -#include "fixer.h" - -#include "3dc.h" -#include "platform.h" -#include "indexfnt.hpp" - -/* indexfnt.cpp */ -IndexedFont* IndexedFont :: pIndexedFont[ IndexedFonts_MAX_NUMBER_OF_FONTS ]; - -IndexedFont::IndexedFont(FontIndex I_Font_New) -{ - fprintf(stderr, "IndexedFont::IndexedFont(%d)\n", I_Font_New); - - I_Font_Val = I_Font_New; - - pIndexedFont[ I_Font_New ] = this; -} - -IndexedFont::~IndexedFont() -{ - fprintf(stderr, "IndexedFont::~IndexedFont()\n"); -} - -void IndexedFont::UnloadFont(FontIndex I_Font_ToGet) -{ - fprintf(stderr, "IndexedFont::UnloadFont(%d)\n", I_Font_ToGet); -} - -OurBool IndexedFont::bCanRenderFully(ProjChar* pProjCh) -{ - fprintf(stderr, "IndexedFont::bCanRenderFully(%p)\n", pProjCh); - - return 0; -} - -void IndexedFont_Proportional_PF::PFUnLoadHook(FontIndex I_Font_ToGet) -{ - fprintf(stderr, "IndexedFont_Proportional_PF::PFUnLoadHook(%d)\n", I_Font_ToGet); -} - -IndexedFont_HUD::IndexedFont_HUD(FontIndex I_Font_New) : IndexedFont(I_Font_New) -{ - fprintf(stderr, "IndexedFont_HUD::IndexedFont_HUD(%d)\n", I_Font_New); -} - -void IndexedFont_HUD :: RenderString_Clipped -( - struct r2pos& R2Pos_Cursor, - const struct r2rect& R2Rect_Clip, - int FixP_Alpha,// FixP_Alpha, - const SCString& SCStr -) const -{ - fprintf(stderr, "IndexedFont_HUD :: RenderString_Clipped(stuff, stuff, %d, stuff)\n", FixP_Alpha); -} - -void IndexedFont_HUD :: RenderString_Unclipped -( - struct r2pos& R2Pos_Cursor, - int FixP_Alpha, // FixP_Alpha, - const SCString& SCStr -) const -{ - fprintf(stderr, "IndexedFont_HUD :: RenderString_Unclipped: shouldn't be called!\n"); - exit(EXIT_FAILURE); -} - -r2size IndexedFont_HUD :: CalcSize -( - ProjChar* pProjCh -) const -{ - r2size R2Size_Return - ( - 0, - GetHeight() - ); - - fprintf(stderr, "IndexedFont_HUD :: CalcSize(%p)\n", pProjCh); - - return R2Size_Return; -} - -void IndexedFont_HUD :: RenderChar_Clipped -( - struct r2pos& R2Pos_Cursor, - const struct r2rect& R2Rect_Clip, - int, // FixP_Alpha, - ProjChar ProjCh -) const -{ - fprintf(stderr, "IndexedFont_HUD :: RenderChar_Clipped(stuff, stuff, stuff, stuff)\n"); -} - -void IndexedFont_HUD :: RenderChar_Unclipped -( - struct r2pos& R2Pos_Cursor, - int, // FixP_Alpha, - ProjChar ProjCh -) const -{ - fprintf(stderr, "IndexedFont_HUD :: RenderChar_Unclipped(stuff, stuff, stuff)\n"); -}