diff --git a/frosted-doom/Makefile b/frosted-doom/Makefile index 690f54e..ceafa88 100644 --- a/frosted-doom/Makefile +++ b/frosted-doom/Makefile @@ -4,44 +4,54 @@ # # $Log:$ # -CROSS_COMPILE = arm-frosted-eabi- -CC= $(CROSS_COMPILE)gcc # gcc or g++ -ifeq ($V,'1') - V='' +ifeq ($(V),1) + VB='' else - V=@ + VB=@ endif -CFLAGS+=-mthumb -mlittle-endian -mthumb-interwork -ffunction-sections -fdata-sections -mcpu=cortex-m3 -CFLAGS+=-DCORE_M3 -D__frosted__ -# COMPILER FLAGS -- No gcc libraries -CFLAGS+=-nostartfiles -# COMPILER FLAGS -- GOT/PIC -CFLAGS+=-fPIC -mlong-calls -fno-common -msingle-pic-base -mno-pic-data-is-text-relative -Wstack-usage=1024 +ifeq ($(ARM),1) + CROSS_COMPILE = arm-frosted-eabi- + OBJS+=$(O)/i_video_fbdev.o + CFLAGS+=-mthumb -mlittle-endian -mthumb-interwork -ffunction-sections -fdata-sections -mcpu=cortex-m3 + CFLAGS+=-DCORE_M3 -D__frosted__ + # COMPILER FLAGS -- No gcc libraries + CFLAGS+=-nostartfiles + # COMPILER FLAGS -- GOT/PIC + CFLAGS+=-fPIC -mlong-calls -fno-common -msingle-pic-base -mno-pic-data-is-text-relative -Wstack-usage=1024 + # LINKER FLAGS + LDFLAGS+=-fPIC -mlong-calls -fno-common -Wl,-elf2flt -lgloss +else + CFLAGS+=-m32 -fsanitize=address -Wunused-const-variable=0 + LIBS+=-lXext -lX11 -lnsl -lm -lSDL2 + OBJS+=$(O)/i_video_SDL.o +endif + +CC= $(CROSS_COMPILE)gcc # gcc or g++ + + # Debugging CFLAGS+=-ggdb3 - -# LINKER FLAGS -LDFLAGS+=-fPIC -mlong-calls -fno-common -Wl,-elf2flt -lgloss -Wl,--gc-sections +LDFLAGS+=-Wl,--gc-sections CFLAGS+=-ggdb3 -Wall -DNORMALUNIX -DLINUX -DSNDSERV # -DUSEASM CFLAGS+=-Icompat +LIBS+=-lm -lc + #LDFLAGS=-L/usr/X11R6/lib #LIBS=-lXext -lX11 -lnsl -lm -LIBS=-lm -lc # subdirectory for objects O=frosted # not too sophisticated dependency -OBJS= \ +OBJS+= \ $(O)/stubs.o \ $(O)/doomdef.o \ $(O)/doomstat.o \ $(O)/dstrings.o \ $(O)/i_system.o \ $(O)/i_sound_dummy.o \ - $(O)/i_video_fbdev.o \ $(O)/i_net.o \ $(O)/tables.o \ $(O)/f_finale.o \ @@ -102,11 +112,12 @@ all: $(O)/fdoom clean: rm -f *.o *~ *.flc - rm -f frosted/* + rm -f frosted/*.o + rm -f frosted/fdoom $(O)/fdoom: $(OBJS) $(O)/i_main.o @echo [Linking $@] - $V$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(O)/i_main.o \ + $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(O)/i_main.o \ -o $(O)/fdoom $(LIBS) -Wl,-Map,fdoom.map $(O): @@ -114,7 +125,7 @@ $(O): $(O)/%.o: %.c $(O) @echo [Compiling $<] - $V$(CC) $(CFLAGS) -c $< -o $@ + $(VB)$(CC) $(CFLAGS) -c $< -o $@ ############################################################# # diff --git a/frosted-doom/am_map.c b/frosted-doom/am_map.c index 999e455..84c9cf7 100644 --- a/frosted-doom/am_map.c +++ b/frosted-doom/am_map.c @@ -616,7 +616,7 @@ AM_Responder { int rc; - static int cheatstate=0; + //static int cheatstate=0; static int bigstate=0; static char buffer[20]; @@ -695,7 +695,7 @@ AM_Responder plr->message = AMSTR_MARKSCLEARED; break; default: - cheatstate=0; + //cheatstate=0; rc = false; } if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1)) @@ -783,7 +783,7 @@ void AM_doFollowPlayer(void) // void AM_updateLightLev(void) { - static nexttic = 0; + static int nexttic = 0; //static int litelevels[] = { 0, 3, 5, 6, 6, 7, 7, 7 }; static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 }; static int litelevelscnt = 0; @@ -856,9 +856,9 @@ AM_clipMline TOP =8 }; - register outcode1 = 0; - register outcode2 = 0; - register outside; + register int outcode1 = 0; + register int outcode2 = 0; + register int outside; fpoint_t tmp; int dx; @@ -989,7 +989,7 @@ AM_drawFline register int ay; register int d; - static fuck = 0; + //static fuck = 0; // For debugging only if ( fl->a.x < 0 || fl->a.x >= f_w @@ -997,7 +997,7 @@ AM_drawFline || fl->b.x < 0 || fl->b.x >= f_w || fl->b.y < 0 || fl->b.y >= f_h) { - fprintf(stderr, "fuck %d \r", fuck++); + //fprintf(stderr, "fuck %d \r", fuck++); return; } diff --git a/frosted-doom/d_main.c b/frosted-doom/d_main.c index c8c7a2b..4c69af5 100644 --- a/frosted-doom/d_main.c +++ b/frosted-doom/d_main.c @@ -150,7 +150,7 @@ int eventtail; void D_PostEvent (event_t* ev) { events[eventhead] = *ev; - eventhead = (++eventhead)&(MAXEVENTS-1); + eventhead = (eventhead + 1) % MAXEVENTS; } @@ -576,9 +576,11 @@ void IdentifyVersion (void) char *home; char *doomwaddir; doomwaddir = getenv("DOOMWADDIR"); +#ifdef __linux__ + doomwaddir = "."; +#endif if (!doomwaddir) - doomwaddir = "/mnt"; - //XXX doomwaddir = "."; + doomwaddir = "/mnt"; // Commercial. doom2wad = malloc(strlen(doomwaddir)+1+9+1); diff --git a/frosted-doom/g_game.c b/frosted-doom/g_game.c index 1da2353..0b84cb7 100644 --- a/frosted-doom/g_game.c +++ b/frosted-doom/g_game.c @@ -760,10 +760,10 @@ void G_Ticker (void) // void G_InitPlayer (int player) { - player_t* p; + //player_t* p; // set up the saved info - p = &players[player]; + //p = &players[player]; // clear everything else to defaults G_PlayerReborn (player); @@ -1200,20 +1200,21 @@ void G_LoadGame (char* name) void G_DoLoadGame (void) { - int length; + //int length; int i; int a,b,c; char vcheck[VERSIONSIZE]; gameaction = ga_nothing; - length = M_ReadFile (savename, &savebuffer); + //length = M_ReadFile (savename, &savebuffer); + M_ReadFile (savename, &savebuffer); save_p = savebuffer + SAVESTRINGSIZE; // skip the description field memset (vcheck,0,sizeof(vcheck)); sprintf (vcheck,"version %i",VERSION); - if (strcmp (save_p, vcheck)) + if (strcmp ((const char*)save_p, vcheck)) return; // bad version save_p += VERSIONSIZE; diff --git a/frosted-doom/hu_lib.c b/frosted-doom/hu_lib.c index 7ab5e3d..57fb52e 100644 --- a/frosted-doom/hu_lib.c +++ b/frosted-doom/hu_lib.c @@ -145,7 +145,7 @@ void HUlib_eraseTextLine(hu_textline_t* l) int lh; int y; int yoffset; - static boolean lastautomapactive = true; + //static boolean lastautomapactive = true; // Only erases when NOT in automap and the screen is reduced, // and the text must either need updating or refreshing @@ -168,7 +168,7 @@ void HUlib_eraseTextLine(hu_textline_t* l) } } - lastautomapactive = automapactive; + //lastautomapactive = automapactive; if (l->needsupdate) l->needsupdate--; } diff --git a/frosted-doom/i_net.c b/frosted-doom/i_net.c index 9678931..71f5498 100644 --- a/frosted-doom/i_net.c +++ b/frosted-doom/i_net.c @@ -49,23 +49,6 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $"; #include "i_net.h" - - - -// For some odd reason... -#define ntohl(x) \ - ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ - (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ - (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ - (((unsigned long int)(x) & 0xff000000U) >> 24))) - -#define ntohs(x) \ - ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ - (((unsigned short int)(x) & 0xff00) >> 8))) \ - -#define htonl(x) ntohl(x) -#define htons(x) ntohs(x) - void NetSend (void); boolean NetListen (void); @@ -164,7 +147,7 @@ void PacketGet (void) int i; int c; struct sockaddr_in fromaddress; - int fromlen; + unsigned int fromlen; doomdata_t sw; fromlen = sizeof(fromaddress); @@ -244,7 +227,7 @@ int GetLocalAddress (void) // void I_InitNetwork (void) { - boolean trueval = true; + //boolean trueval = true; int i; int p; struct hostent* hostentry; // host information entry diff --git a/frosted-doom/i_sound_dummy.c b/frosted-doom/i_sound_dummy.c index add55a8..97b6bf9 100644 --- a/frosted-doom/i_sound_dummy.c +++ b/frosted-doom/i_sound_dummy.c @@ -906,9 +906,6 @@ int I_QrySongPlaying(int handle) // time independend timer happens to get lost due to heavy load. // SIGALRM and ITIMER_REAL doesn't really work well. // There are issues with profiling as well. -static int /*__itimer_which*/ itimer = ITIMER_REAL; - -static int sig = SIGALRM; // Interrupt handler. void I_HandleSoundTimer( int ignore ) @@ -937,39 +934,7 @@ void I_HandleSoundTimer( int ignore ) // Get the interrupt. Set duration in millisecs. int I_SoundSetTimer( int duration_of_tick ) { - // Needed for gametick clockwork. - struct itimerval value; - struct itimerval ovalue; - struct sigaction act; - struct sigaction oact; - - int res; - - // This sets to SA_ONESHOT and SA_NOMASK, thus we can not use it. - // signal( _sig, handle_SIG_TICK ); - - // Now we have to change this attribute for repeated calls. - act.sa_handler = I_HandleSoundTimer; -#ifndef sun - //ac t.sa_mask = _sig; -#endif - act.sa_flags = SA_RESTART; - - sigaction( sig, &act, &oact ); - - value.it_interval.tv_sec = 0; - value.it_interval.tv_usec = duration_of_tick; - value.it_value.tv_sec = 0; - value.it_value.tv_usec = duration_of_tick; - - // Error is -1. - res = -1; //setitimer( itimer, &value, &ovalue ); - - // Debug. - if ( res == -1 ) - fprintf( stderr, "I_SoundSetTimer: interrupt n.a.\n"); - - return res; + return -1; } diff --git a/frosted-doom/info.c b/frosted-doom/info.c index 230c72b..72a7362 100644 --- a/frosted-doom/info.c +++ b/frosted-doom/info.c @@ -37,7 +37,7 @@ rcsid[] = "$Id: info.c,v 1.3 1997/01/26 07:45:00 b1 Exp $"; #include "p_mobj.h" -char *sprnames[NUMSPRITES] = { +char *sprnames[] = { "TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG", "MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2", "PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS", @@ -51,7 +51,7 @@ char *sprnames[NUMSPRITES] = { "POL3","POL1","POL6","GOR2","GOR3","GOR4","GOR5","SMIT","COL1","COL2", "COL3","COL4","CAND","CBRA","COL6","TRE1","TRE2","ELEC","CEYE","FSKU", "COL5","TBLU","TGRN","TRED","SMBT","SMGT","SMRT","HDB1","HDB2","HDB3", - "HDB4","HDB5","HDB6","POB1","POB2","BRS1","TLMP","TLP2" + "HDB4","HDB5","HDB6","POB1","POB2","BRS1","TLMP","TLP2",NULL,"DUMM" }; diff --git a/frosted-doom/info.h b/frosted-doom/info.h index 786a717..cc35e33 100644 --- a/frosted-doom/info.h +++ b/frosted-doom/info.h @@ -1156,7 +1156,7 @@ typedef struct } state_t; extern state_t states[NUMSTATES]; -extern char *sprnames[NUMSPRITES]; +extern char *sprnames[]; diff --git a/frosted-doom/p_doors.c b/frosted-doom/p_doors.c index b22dd15..2e0442e 100644 --- a/frosted-doom/p_doors.c +++ b/frosted-doom/p_doors.c @@ -356,7 +356,7 @@ EV_VerticalDoor mobj_t* thing ) { player_t* player; - int secnum; + //int secnum; sector_t* sec; vldoor_t* door; int side; @@ -411,7 +411,7 @@ EV_VerticalDoor // if the sector has an active thinker, use it sec = sides[ line->sidenum[side^1]] .sector; - secnum = sec-sectors; + //secnum = sec-sectors; if (sec->specialdata) { diff --git a/frosted-doom/p_enemy.c b/frosted-doom/p_enemy.c index 25b5b2d..6d0175a 100644 --- a/frosted-doom/p_enemy.c +++ b/frosted-doom/p_enemy.c @@ -503,11 +503,11 @@ P_LookForPlayers int c; int stop; player_t* player; - sector_t* sector; + //sector_t* sector; angle_t an; fixed_t dist; - sector = actor->subsector->sector; + //sector = actor->subsector->sector; c = 0; stop = (actor->lastlook-1)&3; diff --git a/frosted-doom/p_spec.c b/frosted-doom/p_spec.c index 78452c8..ba33460 100644 --- a/frosted-doom/p_spec.c +++ b/frosted-doom/p_spec.c @@ -72,7 +72,7 @@ typedef struct // typedef struct { - boolean istexture; // if false, it is a flat + int istexture; // if false, it is a flat char endname[9]; char startname[9]; int speed; @@ -128,7 +128,7 @@ animdef_t animdefs[] = {true, "WFALL4", "WFALL1", 8}, {true, "DBRAIN4", "DBRAIN1", 8}, - {false, "\0", "\0", 0} + {-1, "", "", 0} }; anim_t anims[MAXANIMS]; @@ -149,11 +149,9 @@ void P_InitPicAnims (void) { int i; - // Init animation lastanim = anims; - //for (i=0 ; animdefs[i].istexture != -1 ; i++) - for (i=0 ; animdefs[i].startname[0] != NULL ; i++) + for (i=0 ; animdefs[i].istexture != -1 ; i++) { if (animdefs[i].istexture) { @@ -1185,7 +1183,7 @@ int EV_DoDonut(line_t* line) s2 = getNextSector(s1->lines[0],s1); for (i = 0;i < s2->linecount;i++) { - if ((!s2->lines[i]->flags & ML_TWOSIDED) || + if ((!(s2->lines[i]->flags & ML_TWOSIDED)) || (s2->lines[i]->backsector == s1)) continue; s3 = s2->lines[i]->backsector; @@ -1241,11 +1239,11 @@ void P_SpawnSpecials (void) { sector_t* sector; int i; - int episode; + //int episode; - episode = 1; + //episode = 1; if (W_CheckNumForName("texture2") >= 0) - episode = 2; + //episode = 2; // See if -TIMER needs to be used. diff --git a/frosted-doom/r_data.c b/frosted-doom/r_data.c index 54e6ec5..cb29313 100644 --- a/frosted-doom/r_data.c +++ b/frosted-doom/r_data.c @@ -44,6 +44,7 @@ rcsid[] = "$Id: r_data.c,v 1.4 1997/02/03 16:47:55 b1 Exp $"; #ifdef LINUX #include #endif +#include #include "r_data.h" @@ -191,9 +192,9 @@ R_DrawColumnInCache int count; int position; byte* source; - byte* dest; - - dest = (byte *)cache + 3; + //byte* dest; + // + //dest = (byte *)cache + 3; while (patch->topdelta != 0xff) { @@ -297,6 +298,7 @@ void R_GenerateLookup (int texnum) { texture_t* texture; byte* patchcount; // patchcount[texture->width] + byte* patchcount_alloc; texpatch_t* patch; patch_t* realpatch; int x; @@ -321,6 +323,7 @@ void R_GenerateLookup (int texnum) // with only a single patch are all done. //XXX patchcount = (byte *)alloca (texture->width); patchcount = (byte *)malloc (texture->width); + patchcount_alloc = patchcount; if (!patchcount) return; memset (patchcount, 0, texture->width); @@ -375,7 +378,7 @@ void R_GenerateLookup (int texnum) } } - free(patchcount); + free(patchcount_alloc); } @@ -432,6 +435,7 @@ void R_InitTextures (void) char* name_p; int* patchlookup; + int* patchlookup_alloc; int totalwidth; int nummappatches; @@ -455,6 +459,7 @@ void R_InitTextures (void) name_p = names+4; //XXX patchlookup = alloca (nummappatches*sizeof(*patchlookup)); patchlookup = malloc (nummappatches*sizeof(*patchlookup)); + patchlookup_alloc = patchlookup; if (!patchlookup) return; @@ -580,7 +585,7 @@ void R_InitTextures (void) for (i=0 ; i #include #include +#include //XXX FIXME in_addr_t inet_addr(const char *cp) @@ -9,14 +10,3 @@ in_addr_t inet_addr(const char *cp) return (in_addr_t)NULL; } -// XXX FIXME -//int usleep(useconds_t us) -//{ -// return 0; -//} -// -// -//struct hostent *gethostbyname(const char *name) -//{ -// return NULL; -//} diff --git a/frosted-doom/w_wad.c b/frosted-doom/w_wad.c index 636e4fb..7bf69b7 100644 --- a/frosted-doom/w_wad.c +++ b/frosted-doom/w_wad.c @@ -147,6 +147,7 @@ void W_AddFile (char *filename) int length; int startlump; filelump_t* fileinfo; + filelump_t* fileinfo_alloc; filelump_t singleinfo; int storehandle; @@ -198,6 +199,7 @@ void W_AddFile (char *filename) length = header.numlumps*sizeof(filelump_t); //XXX fileinfo = alloca (length); fileinfo = malloc (length); + fileinfo_alloc = fileinfo; lseek (handle, header.infotableofs, SEEK_SET); read (handle, fileinfo, length); numlumps += header.numlumps; @@ -223,7 +225,7 @@ void W_AddFile (char *filename) } //XXX: Alloca replacement - free(fileinfo); + free(fileinfo_alloc); if (reloadname) close (handle); @@ -246,6 +248,7 @@ void W_Reload (void) int handle; int length; filelump_t* fileinfo; + filelump_t* fileinfo_alloc; if (!reloadname) return; @@ -259,6 +262,7 @@ void W_Reload (void) length = lumpcount*sizeof(filelump_t); //XXX fileinfo = alloca (length); fileinfo = malloc (length); + fileinfo_alloc = fileinfo; if (!fileinfo) return; lseek (handle, header.infotableofs, SEEK_SET); @@ -278,7 +282,7 @@ void W_Reload (void) lump_p->size = LONG(fileinfo->size); } - free(fileinfo); + free(fileinfo_alloc); close (handle); } @@ -492,16 +496,20 @@ W_CacheLumpNum if (!lumpcache[lump]) { - // read the lump in - - //printf ("cache miss on lump %i\n",lump); - ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]); - W_ReadLump (lump, lumpcache[lump]); + // read the lump in + //printf ("cache miss on lump %i\n",lump); + ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]); + if (!ptr) + return NULL; + W_ReadLump (lump, lumpcache[lump]); } else { - //printf ("cache hit on lump %i\n",lump); - Z_ChangeTag (lumpcache[lump],tag); + //printf ("cache hit on lump %i\n",lump); + //Z_ChangeTag (lumpcache[lump],tag); + if (( (memblock_t *)( (byte *)(lumpcache[lump]) - sizeof(memblock_t)))->id!=0x1d4a11) + I_Error("Z_CT at "__FILE__":%i",__LINE__); + Z_ChangeTag2(lumpcache[lump],tag); } return lumpcache[lump]; diff --git a/frosted-doom/wi_stuff.c b/frosted-doom/wi_stuff.c index 01502c8..98be302 100644 --- a/frosted-doom/wi_stuff.c +++ b/frosted-doom/wi_stuff.c @@ -987,9 +987,9 @@ void WI_drawDeathmatchStats(void) int y; int w; - int lh; // line height + //int lh; // line height - lh = WI_SPACINGY; + //lh = WI_SPACINGY; WI_slamBackground();