#
# $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 \
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):
$(O)/%.o: %.c $(O)
@echo [Compiling $<]
- $V$(CC) $(CFLAGS) -c $< -o $@
+ $(VB)$(CC) $(CFLAGS) -c $< -o $@
#############################################################
#
{
int rc;
- static int cheatstate=0;
+ //static int cheatstate=0;
static int bigstate=0;
static char buffer[20];
plr->message = AMSTR_MARKSCLEARED;
break;
default:
- cheatstate=0;
+ //cheatstate=0;
rc = false;
}
if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1))
//
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;
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;
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
|| 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;
}
void D_PostEvent (event_t* ev)
{
events[eventhead] = *ev;
- eventhead = (++eventhead)&(MAXEVENTS-1);
+ eventhead = (eventhead + 1) % MAXEVENTS;
}
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);
//
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);
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;
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
}
}
- lastautomapactive = automapactive;
+ //lastautomapactive = automapactive;
if (l->needsupdate) l->needsupdate--;
}
#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);
int i;
int c;
struct sockaddr_in fromaddress;
- int fromlen;
+ unsigned int fromlen;
doomdata_t sw;
fromlen = sizeof(fromaddress);
//
void I_InitNetwork (void)
{
- boolean trueval = true;
+ //boolean trueval = true;
int i;
int p;
struct hostent* hostentry; // host information entry
// 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 )
// 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;
}
#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",
"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"
};
} state_t;
extern state_t states[NUMSTATES];
-extern char *sprnames[NUMSPRITES];
+extern char *sprnames[];
mobj_t* thing )
{
player_t* player;
- int secnum;
+ //int secnum;
sector_t* sec;
vldoor_t* door;
int side;
// 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)
{
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;
//
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;
{true, "WFALL4", "WFALL1", 8},
{true, "DBRAIN4", "DBRAIN1", 8},
- {false, "\0", "\0", 0}
+ {-1, "", "", 0}
};
anim_t anims[MAXANIMS];
{
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)
{
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;
{
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.
#ifdef LINUX
#include <alloca.h>
#endif
+#include <stdlib.h>
#include "r_data.h"
int count;
int position;
byte* source;
- byte* dest;
-
- dest = (byte *)cache + 3;
+ //byte* dest;
+ //
+ //dest = (byte *)cache + 3;
while (patch->topdelta != 0xff)
{
{
texture_t* texture;
byte* patchcount; // patchcount[texture->width]
+ byte* patchcount_alloc;
texpatch_t* patch;
patch_t* realpatch;
int x;
// 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);
}
}
- free(patchcount);
+ free(patchcount_alloc);
}
char* name_p;
int* patchlookup;
+ int* patchlookup_alloc;
int totalwidth;
int nummappatches;
name_p = names+4;
//XXX patchlookup = alloca (nummappatches*sizeof(*patchlookup));
patchlookup = malloc (nummappatches*sizeof(*patchlookup));
+ patchlookup_alloc = patchlookup;
if (!patchlookup)
return;
for (i=0 ; i<numtextures ; i++)
texturetranslation[i] = i;
- free(patchlookup);
+ free(patchlookup_alloc);
}
void R_PrecacheLevel (void)
{
char* flatpresent;
+ char* flatpresent_alloc;
char* texturepresent;
+ char* texturepresent_alloc;
char* spritepresent;
+ char* spritepresent_alloc;
int i;
int j;
// Precache flats.
//XXX flatpresent = alloca(numflats);
flatpresent = malloc(numflats);
+ flatpresent_alloc = flatpresent;
if (!flatpresent)
return;
memset (flatpresent,0,numflats);
}
}
- free(flatpresent);
+ free(flatpresent_alloc);
// Precache textures.
//XXX texturepresent = alloca(numtextures);
texturepresent = malloc(numtextures);
+ texturepresent_alloc = texturepresent;
if (!texturepresent)
return;
memset (texturepresent,0, numtextures);
}
}
- free(texturepresent);
+ free(texturepresent_alloc);
// Precache sprites.
//XXX spritepresent = alloca(numsprites);
spritepresent = malloc(numsprites);
- if (!numsprites)
+ spritepresent_alloc = spritepresent;
+ if (!spritepresent)
return;
memset (spritepresent,0, numsprites);
}
}
- free(numsprites);
+ free(spritepresent_alloc);
}
// count the number of sprite names
check = namelist;
while (*check != NULL)
- check++;
+ check++;
numsprites = check-namelist;
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <string.h>
//XXX FIXME
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;
-//}
int length;
int startlump;
filelump_t* fileinfo;
+ filelump_t* fileinfo_alloc;
filelump_t singleinfo;
int storehandle;
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;
}
//XXX: Alloca replacement
- free(fileinfo);
+ free(fileinfo_alloc);
if (reloadname)
close (handle);
int handle;
int length;
filelump_t* fileinfo;
+ filelump_t* fileinfo_alloc;
if (!reloadname)
return;
length = lumpcount*sizeof(filelump_t);
//XXX fileinfo = alloca (length);
fileinfo = malloc (length);
+ fileinfo_alloc = fileinfo;
if (!fileinfo)
return;
lseek (handle, header.infotableofs, SEEK_SET);
lump_p->size = LONG(fileinfo->size);
}
- free(fileinfo);
+ free(fileinfo_alloc);
close (handle);
}
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];
int y;
int w;
- int lh; // line height
+ //int lh; // line height
- lh = WI_SPACINGY;
+ //lh = WI_SPACINGY;
WI_slamBackground();