Fixes to DOOM demo to remove some operating system dependancies.

Also now has working input (although not perfect) - Needs mouse or touch.
Also now supports screen size doubling when the screen is significantly larger than doom's screen.
This commit is contained in:
inmarket 2013-12-24 19:58:18 +10:00
parent c24512f6ed
commit 0345dadebf
32 changed files with 612 additions and 397 deletions

View File

@ -5,9 +5,10 @@ See DOOMLIC.TXT for the real license.
This port display a fix sized window of 320 x 200 on your display (it tries to put the display in landscape mode first).
There is no sound currently until the GAUDOUT module is written.
There is no user input currently until the hooks are added into i_video.c (very soon).
There is no network support currently.
User input is not the best for actually playing yet. Requires Touch or Mouse.
The supplied DOOM1.WAD is the shareware version.
Currently this has been converted into doom1_wad.h for inclusion into the source code (rather than using file IO).
Note that this file is 4M in size so it will take 4Mbytes of Flash to store just the WAD file.

View File

@ -506,7 +506,7 @@ void AM_loadPics(void)
for (i=0;i<10;i++)
{
sprintf(namebuf, "AMMNUM%d", i);
I_sprintf(namebuf, "AMMNUM%d", i);
marknums[i] = W_CacheLumpName(namebuf, PU_STATIC);
}
@ -686,7 +686,7 @@ AM_Responder
plr->message = grid ? AMSTR_GRIDON : AMSTR_GRIDOFF;
break;
case AM_MARKKEY:
sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum);
I_sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum);
plr->message = buffer;
AM_addMark();
break;
@ -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++);
I_printf("fuck %d \r", fuck++);
return;
}

View File

@ -31,16 +31,6 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
#define FGCOLOR 8
#ifdef NORMALUNIX
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
#include "doomdef.h"
#include "doomstat.h"
@ -114,8 +104,6 @@ int startepisode;
int startmap;
boolean autostart;
FILE* debugfile;
boolean advancedemo;
@ -356,14 +344,6 @@ void D_DoomLoop (void)
if (demorecording)
G_BeginRecording ();
if (M_CheckParm ("-debugfile"))
{
char filename[20];
sprintf (filename,"debug%i.txt",consoleplayer);
printf ("debug output to: %s\n",filename);
debugfile = fopen (filename,"w");
}
I_InitGraphics ();
while (1)
@ -562,7 +542,7 @@ void D_AddFile (char *file)
//
void IdentifyVersion (void)
{
sprintf(basedefault, ".doomrc");
I_sprintf(basedefault, ".doomrc");
if (M_CheckParm ("-shdev"))
{
@ -647,7 +627,7 @@ void IdentifyVersion (void)
return;
}
printf("Game mode indeterminate.\n");
I_printf("Game mode indeterminate.\n");
gamemode = indetermined;
// We don't abort. Let's see what the PWAD contains.
@ -655,80 +635,6 @@ void IdentifyVersion (void)
//I_Error ("Game mode indeterminate\n");
}
//
// Find a Response File
//
void FindResponseFile (void)
{
int i;
#define MAXARGVS 100
for (i = 1;i < myargc;i++)
if (myargv[i][0] == '@')
{
FILE * handle;
int size;
int k;
int index;
int indexinfile;
char *infile;
char *file;
char *moreargs[20];
char *firstargv;
// READ THE RESPONSE FILE INTO MEMORY
handle = fopen (&myargv[i][1],"rb");
if (!handle)
{
printf ("\nNo such response file!");
exit(1);
}
printf("Found response file %s!\n",&myargv[i][1]);
fseek (handle,0,SEEK_END);
size = ftell(handle);
fseek (handle,0,SEEK_SET);
file = malloc (size);
fread (file,size,1,handle);
fclose (handle);
// KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
for (index = 0,k = i+1; k < myargc; k++)
moreargs[index++] = myargv[k];
firstargv = myargv[0];
myargv = malloc(sizeof(char *)*MAXARGVS);
memset(myargv,0,sizeof(char *)*MAXARGVS);
myargv[0] = firstargv;
infile = file;
indexinfile = k = 0;
indexinfile++; // SKIP PAST ARGV[0] (KEEP IT)
do
{
myargv[indexinfile++] = infile+k;
while(k < size &&
((*(infile+k)>= ' '+1) && (*(infile+k)<='z')))
k++;
*(infile+k) = 0;
while(k < size &&
((*(infile+k)<= ' ') || (*(infile+k)>'z')))
k++;
} while(k < size);
for (k = 0;k < index;k++)
myargv[indexinfile++] = moreargs[k];
myargc = indexinfile;
// DISPLAY ARGS
printf("%d command-line args:\n",myargc);
for (k=1;k<myargc;k++)
printf("%s\n",myargv[k]);
break;
}
}
//
// D_DoomMain
//
@ -737,11 +643,8 @@ void D_DoomMain (void)
int p;
char file[256];
FindResponseFile ();
IdentifyVersion ();
setbuf (stdout, NULL);
modifiedgame = false;
nomonsters = M_CheckParm ("-nomonsters");
@ -756,28 +659,28 @@ void D_DoomMain (void)
switch ( gamemode )
{
case retail:
sprintf (title,
I_sprintf (title,
" "
"The Ultimate DOOM Startup v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
case shareware:
sprintf (title,
I_sprintf (title,
" "
"DOOM Shareware Startup v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
case registered:
sprintf (title,
I_sprintf (title,
" "
"DOOM Registered Startup v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
case commercial:
sprintf (title,
I_sprintf (title,
" "
"DOOM 2: Hell on Earth v%i.%i"
" ",
@ -785,14 +688,14 @@ void D_DoomMain (void)
break;
/*FIXME
case pack_plut:
sprintf (title,
I_sprintf (title,
" "
"DOOM 2: Plutonia Experiment v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
case pack_tnt:
sprintf (title,
I_sprintf (title,
" "
"DOOM 2: TNT - Evilution v%i.%i"
" ",
@ -800,7 +703,7 @@ void D_DoomMain (void)
break;
*/
default:
sprintf (title,
I_sprintf (title,
" "
"Public DOOM - v%i.%i"
" ",
@ -808,17 +711,10 @@ void D_DoomMain (void)
break;
}
printf ("%s\n",title);
I_printf ("%s\n",title);
if (devparm)
printf(D_DEVSTR);
if (M_CheckParm("-cdrom"))
{
printf(D_CDROM);
mkdir("c:\\doomdata",0);
strcpy (basedefault,"c:/doomdata/default.cfg");
}
I_printf(D_DEVSTR);
// turbo option
if ( (p=M_CheckParm ("-turbo")) )
@ -833,7 +729,7 @@ void D_DoomMain (void)
scale = 10;
if (scale > 400)
scale = 400;
printf ("turbo scale: %i%%\n",scale);
I_printf ("turbo scale: %i%%\n",scale);
forwardmove[0] = forwardmove[0]*scale/100;
forwardmove[1] = forwardmove[1]*scale/100;
sidemove[0] = sidemove[0]*scale/100;
@ -856,9 +752,9 @@ void D_DoomMain (void)
case shareware:
case retail:
case registered:
sprintf (file,"~"DEVMAPS"E%cM%c.wad",
I_sprintf (file,"~"DEVMAPS"E%cM%c.wad",
myargv[p+1][0], myargv[p+2][0]);
printf("Warping to Episode %s, Map %s.\n",
I_printf("Warping to Episode %s, Map %s.\n",
myargv[p+1],myargv[p+2]);
break;
@ -866,9 +762,9 @@ void D_DoomMain (void)
default:
p = atoi (myargv[p+1]);
if (p<10)
sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
I_sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
else
sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
I_sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
break;
}
D_AddFile (file);
@ -891,9 +787,9 @@ void D_DoomMain (void)
if (p && p < myargc-1)
{
sprintf (file,"%s.lmp", myargv[p+1]);
I_sprintf (file,"%s.lmp", myargv[p+1]);
D_AddFile (file);
printf("Playing demo %s.lmp.\n",myargv[p+1]);
I_printf("Playing demo %s.lmp.\n",myargv[p+1]);
}
// get skill / episode / map from parms
@ -923,15 +819,15 @@ void D_DoomMain (void)
{
int time;
time = atoi(myargv[p+1]);
printf("Levels will end after %d minute",time);
I_printf("Levels will end after %d minute",time);
if (time>1)
printf("s");
printf(".\n");
I_printf("s");
I_printf(".\n");
}
p = M_CheckParm ("-avg");
if (p && p < myargc-1 && deathmatch)
printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");
I_printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");
p = M_CheckParm ("-warp");
if (p && p < myargc-1)
@ -947,16 +843,16 @@ void D_DoomMain (void)
}
// init subsystems
printf ("V_Init: allocate screens.\n");
I_printf ("V_Init: allocate screens.\n");
V_Init ();
printf ("M_LoadDefaults: Load system defaults.\n");
I_printf ("M_LoadDefaults: Load system defaults.\n");
M_LoadDefaults (); // load before initing other systems
printf ("Z_Init: Init zone memory allocation daemon. \n");
I_printf ("Z_Init: Init zone memory allocation daemon. \n");
Z_Init ();
printf ("W_Init: Init WADfiles.\n");
I_printf ("W_Init: Init WADfiles.\n");
W_InitMultipleFiles (wadfiles);
@ -988,7 +884,7 @@ void D_DoomMain (void)
// Iff additonal PWAD files are used, print modified banner
if (modifiedgame)
{
/*m*/printf (
/*m*/I_printf (
"===========================================================================\n"
"ATTENTION: This version of DOOM has been modified. If you would like to\n"
"get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
@ -996,7 +892,6 @@ void D_DoomMain (void)
" press enter to continue\n"
"===========================================================================\n"
);
getchar ();
}
@ -1005,7 +900,7 @@ void D_DoomMain (void)
{
case shareware:
case indetermined:
printf (
I_printf (
"===========================================================================\n"
" Shareware!\n"
"===========================================================================\n"
@ -1014,7 +909,7 @@ void D_DoomMain (void)
case registered:
case retail:
case commercial:
printf (
I_printf (
"===========================================================================\n"
" Commercial product - do not distribute!\n"
" Please report software piracy to the SPA: 1-800-388-PIR8\n"
@ -1027,28 +922,28 @@ void D_DoomMain (void)
break;
}
printf ("M_Init: Init miscellaneous info.\n");
I_printf ("M_Init: Init miscellaneous info.\n");
M_Init ();
printf ("R_Init: Init DOOM refresh daemon - ");
I_printf ("R_Init: Init DOOM refresh daemon - ");
R_Init ();
printf ("\nP_Init: Init Playloop state.\n");
I_printf ("\nP_Init: Init Playloop state.\n");
P_Init ();
printf ("I_Init: Setting up machine state.\n");
I_printf ("I_Init: Setting up machine state.\n");
I_Init ();
printf ("D_CheckNetGame: Checking network game status.\n");
I_printf ("D_CheckNetGame: Checking network game status.\n");
D_CheckNetGame ();
printf ("S_Init: Setting up sound.\n");
I_printf ("S_Init: Setting up sound.\n");
S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );
printf ("HU_Init: Setting up heads up display.\n");
I_printf ("HU_Init: Setting up heads up display.\n");
HU_Init ();
printf ("ST_Init: Init status bar.\n");
I_printf ("ST_Init: Init status bar.\n");
ST_Init ();
// check for a driver that wants intermission stats
@ -1059,7 +954,7 @@ void D_DoomMain (void)
extern void* statcopy;
statcopy = (void*)atoi(myargv[p+1]);
printf ("External statistics registered.\n");
I_printf ("External statistics registered.\n");
}
// start the apropriate game based on parms
@ -1090,9 +985,9 @@ void D_DoomMain (void)
if (p && p < myargc-1)
{
if (M_CheckParm("-cdrom"))
sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
I_sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
else
sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
I_sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
G_LoadGame (file);
}

View File

@ -162,7 +162,8 @@ HSendPacket
doomcom->command = CMD_SEND;
doomcom->remotenode = node;
doomcom->datalength = NetbufferSize ();
#if 0 // AJH HACK
if (debugfile)
{
int i;
@ -172,15 +173,16 @@ HSendPacket
else
realretrans = -1;
fprintf (debugfile,"send (%i + %i, R %i) [%i] ",
I_DBGprintf("send (%i + %i, R %i) [%i] ",
ExpandTics(netbuffer->starttic),
netbuffer->numtics, realretrans, doomcom->datalength);
for (i=0 ; i<doomcom->datalength ; i++)
fprintf (debugfile,"%i ",((byte *)netbuffer)[i]);
I_DBGprintf("%i ",((byte *)netbuffer)[i]);
fprintf (debugfile,"\n");
I_DBGprintf("\n");
}
#endif
I_NetCmd ();
}
@ -213,25 +215,24 @@ boolean HGetPacket (void)
if (doomcom->datalength != NetbufferSize ())
{
if (debugfile)
fprintf (debugfile,"bad packet length %i\n",doomcom->datalength);
I_DBGprintf("bad packet length %i\n",doomcom->datalength);
return false;
}
if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM) )
{
if (debugfile)
fprintf (debugfile,"bad packet checksum\n");
I_DBGprintf("bad packet checksum\n");
return false;
}
#if 0 // AJH uGFX Hack
if (debugfile)
{
int realretrans;
int i;
if (netbuffer->checksum & NCMD_SETUP)
fprintf (debugfile,"setup packet\n");
I_DBGprintf("setup packet\n");
else
{
if (netbuffer->checksum & NCMD_RETRANSMIT)
@ -239,16 +240,17 @@ boolean HGetPacket (void)
else
realretrans = -1;
fprintf (debugfile,"get %i = (%i + %i, R %i)[%i] ",
I_DBGprintf("get %i = (%i + %i, R %i)[%i] ",
doomcom->remotenode,
ExpandTics(netbuffer->starttic),
netbuffer->numtics, realretrans, doomcom->datalength);
for (i=0 ; i<doomcom->datalength ; i++)
fprintf (debugfile,"%i ",((byte *)netbuffer)[i]);
fprintf (debugfile,"\n");
I_DBGprintf("%i ",((byte *)netbuffer)[i]);
I_DBGprintf("\n");
}
}
#endif
return true;
}
@ -305,8 +307,7 @@ void GetPackets (void)
&& (netbuffer->checksum & NCMD_RETRANSMIT) )
{
resendto[netnode] = ExpandTics(netbuffer->retransmitfrom);
if (debugfile)
fprintf (debugfile,"retransmit from %i\n", resendto[netnode]);
I_DBGprintf ("retransmit from %i\n", resendto[netnode]);
resendcount[netnode] = RESENDCOUNT;
}
else
@ -318,9 +319,7 @@ void GetPackets (void)
if (realend < nettics[netnode])
{
if (debugfile)
fprintf (debugfile,
"out of order packet (%i + %i)\n" ,
I_DBGprintf ("out of order packet (%i + %i)\n" ,
realstart,netbuffer->numtics);
continue;
}
@ -329,9 +328,7 @@ void GetPackets (void)
if (realstart > nettics[netnode])
{
// stop processing until the other system resends the missed tics
if (debugfile)
fprintf (debugfile,
"missed tics from %i (%i - %i)\n",
I_DBGprintf("missed tics from %i (%i - %i)\n",
netnode, realstart, nettics[netnode]);
remoteresend[netnode] = true;
continue;
@ -404,7 +401,7 @@ void NetUpdate (void)
if (maketic - gameticdiv >= BACKUPTICS/2-1)
break; // can't hold any more
//printf ("mk:%i ",maketic);
//I_printf("mk:%i ",maketic);
G_BuildTiccmd (&localcmds[maketic%BACKUPTICS]);
maketic++;
}
@ -484,7 +481,7 @@ void D_ArbitrateNetStart (void)
if (doomcom->consoleplayer)
{
// listen for setup info from key player
printf ("listening for network start info...\n");
I_printf ("listening for network start info...\n");
while (1)
{
CheckAbort ();
@ -507,7 +504,7 @@ void D_ArbitrateNetStart (void)
else
{
// key player, send the setup info
printf ("sending network start info...\n");
I_printf ("sending network start info...\n");
do
{
CheckAbort ();
@ -574,7 +571,7 @@ void D_CheckNetGame (void)
if (netgame)
D_ArbitrateNetStart ();
printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n",
I_printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n",
startskill, deathmatch, startmap, startepisode);
// read values out of doomcom
@ -588,7 +585,7 @@ void D_CheckNetGame (void)
for (i=0 ; i<doomcom->numnodes ; i++)
nodeingame[i] = true;
printf ("player %i of %i (%i nodes)\n",
I_printf ("player %i of %i (%i nodes)\n",
consoleplayer+1, doomcom->numplayers, doomcom->numnodes);
}
@ -603,9 +600,6 @@ void D_QuitNetGame (void)
{
int i, j;
if (debugfile)
fclose (debugfile);
if (!netgame || !usergame || consoleplayer == -1 || demoplayback)
return;
@ -678,9 +672,7 @@ void TryRunTics (void)
frameon++;
if (debugfile)
fprintf (debugfile,
"=======real: %i avail: %i game: %i\n",
I_DBGprintf("=======real: %i avail: %i game: %i\n",
realtics, availabletics,counts);
if (!demoplayback)
@ -699,14 +691,14 @@ void TryRunTics (void)
if (nettics[0] <= nettics[nodeforplayer[i]])
{
gametime--;
// printf ("-");
// I_printf ("-");
}
frameskip[frameon&3] = (oldnettics > nettics[nodeforplayer[i]]);
oldnettics = nettics[0];
if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3])
{
skiptics = 1;
// printf ("+");
// I_printf ("+");
}
}
}// demoplayback

View File

@ -1,16 +1,17 @@
MYFILES = $(GFXLIB)/demos/3rdparty/doom
MYCSRC = $(MYFILES)/doomdef.c \
$(MYFILES)/doomstat.c \
$(MYFILES)/dstrings.c \
MYCSRC = \
$(MYFILES)/d_main.c \
$(MYFILES)/i_main.c \
$(MYFILES)/i_system.c \
$(MYFILES)/i_sound.c \
$(MYFILES)/i_video.c \
$(MYFILES)/i_net.c \
$(MYFILES)/doomdef.c \
$(MYFILES)/doomstat.c \
$(MYFILES)/dstrings.c \
$(MYFILES)/tables.c \
$(MYFILES)/f_finale.c \
$(MYFILES)/f_wipe.c \
$(MYFILES)/d_main.c \
$(MYFILES)/d_net.c \
$(MYFILES)/d_items.c \
$(MYFILES)/g_game.c \

View File

@ -242,7 +242,6 @@ extern int maxammo[NUMAMMO];
// File handling stuff.
extern char basedefault[1024];
extern FILE* debugfile;
// if true, load all graphics at level load
extern boolean precache;

View File

@ -31,7 +31,13 @@
#ifdef __cplusplus
typedef bool boolean;
#else
typedef enum {false, true} boolean;
#ifdef false
#undef false
#endif
#ifdef true
#undef true
#endif
typedef enum {false, true} boolean;
#endif
typedef unsigned char byte;
#endif

View File

@ -689,7 +689,7 @@ void F_BunnyScroll (void)
laststage = stage;
}
sprintf (name,"END%i",stage);
I_sprintf (name,"END%i",stage);
V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2,0, W_CacheLumpName (name,PU_CACHE));
}

View File

@ -279,12 +279,12 @@ void G_BuildTiccmd (ticcmd_t* cmd)
{
if (gamekeydown[key_right])
{
// fprintf(stderr, "strafe right\n");
// I_DBGprintf("strafe right\n");
side += sidemove[speed];
}
if (gamekeydown[key_left])
{
// fprintf(stderr, "strafe left\n");
// I_DBGprintf("strafe left\n");
side -= sidemove[speed];
}
if (joyxmove > 0)
@ -307,12 +307,12 @@ void G_BuildTiccmd (ticcmd_t* cmd)
if (gamekeydown[key_up])
{
// fprintf(stderr, "up\n");
// I_DBGprintf("up\n");
forward += forwardmove[speed];
}
if (gamekeydown[key_down])
{
// fprintf(stderr, "down\n");
// I_DBGprintf("down\n");
forward -= forwardmove[speed];
}
if (joyymove < 0)
@ -674,7 +674,7 @@ void G_Ticker (void)
{
static char turbomessage[80];
extern char *player_names[4];
sprintf (turbomessage, "%s is turbo!",player_names[i]);
I_sprintf (turbomessage, "%s is turbo!",player_names[i]);
players[consoleplayer].message = turbomessage;
}
@ -1212,7 +1212,7 @@ void G_DoLoadGame (void)
// skip the description field
memset (vcheck,0,sizeof(vcheck));
sprintf (vcheck,"version %i",VERSION);
I_sprintf (vcheck,"version %i",VERSION);
if (strcmp (save_p, vcheck))
return; // bad version
save_p += VERSIONSIZE;
@ -1276,9 +1276,9 @@ void G_DoSaveGame (void)
int i;
if (M_CheckParm("-cdrom"))
sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot);
I_sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot);
else
sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot);
I_sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot);
description = savedescription;
save_p = savebuffer = screens[1]+0x4000;
@ -1286,7 +1286,7 @@ void G_DoSaveGame (void)
memcpy (save_p, description, SAVESTRINGSIZE);
save_p += SAVESTRINGSIZE;
memset (name2,0,sizeof(name2));
sprintf (name2,"version %i",VERSION);
I_sprintf (name2,"version %i",VERSION);
memcpy (save_p, name2, VERSIONSIZE);
save_p += VERSIONSIZE;
@ -1588,7 +1588,7 @@ void G_DoPlayDemo (void)
demobuffer = demo_p = W_CacheLumpName (defdemoname, PU_STATIC);
if ( *demo_p++ != VERSION)
{
fprintf( stderr, "Demo is from a different game version!\n");
I_DBGprintf("Demo is from a different game version!\n");
gameaction = ga_nothing;
return;
}

View File

@ -29,6 +29,9 @@
#define GDISP_NEED_VALIDATION TRUE
#define GDISP_NEED_CONTROL TRUE
#define GDISP_NEED_STREAMING TRUE
#define GDISP_NEED_TEXT TRUE
#define GDISP_INCLUDE_FONT_UI2 TRUE
/* Features for the GINPUT subsystem. */
#define GINPUT_NEED_MOUSE TRUE

View File

@ -405,7 +405,7 @@ void HU_Init(void)
j = HU_FONTSTART;
for (i=0;i<HU_FONTSIZE;i++)
{
sprintf(buffer, "STCFN%.3d", j++);
I_sprintf(buffer, "STCFN%.3d", j++);
hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
}
@ -708,7 +708,7 @@ boolean HU_Responder(event_t *ev)
c = c - '0';
if (c > 9)
return false;
// fprintf(stderr, "got here\n");
// I_DBGprintf("got here\n");
macromessage = chat_macros[c];
// kill last message with a '\n'
@ -737,7 +737,7 @@ boolean HU_Responder(event_t *ev)
// static unsigned char buf[20]; // DEBUG
HU_queueChatChar(c);
// sprintf(buf, "KEY: %d => %d", ev->data1, c);
// I_sprintf(buf, "KEY: %d => %d", ev->data1, c);
// plr->message = buf;
}
if (c == KEY_ENTER)

View File

@ -6,13 +6,12 @@
#include "d_main.h"
// Emulate a command line
static int argc = 1;
static const char * const *argv = { "doom", };
static const char const *argv[] = { "doom" };
int main(void) {
gfxInit();
myargc = argc;
myargc = sizeof(argv)/sizeof(argv[0]);
myargv = argv;
D_DoomMain();
}

View File

@ -163,7 +163,7 @@ void PacketSend (void)
sw.cmds[c].buttons = netbuffer->cmds[c].buttons;
}
//printf ("sending %i\n",gametic);
//I_DBGprintf("sending %i\n",gametic);
c = sendto (sendsocket , &sw, doomcom->datalength
,0,(void *)&sendaddress[doomcom->remotenode]
,sizeof(sendaddress[doomcom->remotenode]));
@ -200,7 +200,7 @@ void PacketGet (void)
{
static int first=1;
if (first)
printf("len=%d:p=[0x%x 0x%x] \n", c, *(int*)&sw, *((int*)&sw+1));
I_printf("len=%d:p=[0x%x 0x%x] \n", c, *(int*)&sw, *((int*)&sw+1));
first = 0;
}
@ -276,7 +276,7 @@ void I_InitNetwork (void)
int p;
struct hostent* hostentry; // host information entry
doomcom = malloc (sizeof (*doomcom) );
doomcom = I_malloc (sizeof (*doomcom) );
memset (doomcom, 0, sizeof(*doomcom) );
// set up for network
@ -301,7 +301,7 @@ void I_InitNetwork (void)
if (p && p<myargc-1)
{
DOOMPORT = atoi (myargv[p+1]);
printf ("using alternate port %i\n",DOOMPORT);
I_printf ("using alternate port %i\n",DOOMPORT);
}
// parse network game options,
@ -358,7 +358,7 @@ void I_InitNetwork (void)
sendsocket = UDPsocket ();
#else
doomcom = malloc (sizeof (*doomcom) );
doomcom = gfxAlloc (sizeof (*doomcom) );
memset (doomcom, 0, sizeof(*doomcom) );
// single player game

View File

@ -126,7 +126,7 @@ getsfx
// Get the sound data from the WAD, allocate lump
// in zone memory.
sprintf(name, "ds%s", sfxname);
I_sprintf(name, "ds%s", sfxname);
// Now, there is a severe problem with the
// sound handling, in it is not (yet/anymore)
@ -146,10 +146,9 @@ getsfx
size = W_LumpLength( sfxlump );
// Debug.
// fprintf( stderr, "." );
//fprintf( stderr, " -loading %s (lump %d, %d bytes)\n",
// I_DBGprintf( "." );
//I_DBGprintf( " -loading %s (lump %d, %d bytes)\n",
// sfxname, sfxlump, size );
//fflush( stderr );
sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC );
@ -159,7 +158,7 @@ getsfx
// Allocate from zone memory.
paddedsfx = (unsigned char*)Z_Malloc( paddedsize+8, PU_STATIC, 0 );
// ddt: (unsigned char *) realloc(sfx, paddedsize+8);
// ddt: (unsigned char *) I_Realloc(sfx, paddedsize+8);
// This should interfere with zone memory handling,
// which does not kick in in the soundserver.
@ -381,7 +380,7 @@ void I_SetMusicVolume(int volume)
int I_GetSfxLumpNum(sfxinfo_t* sfx)
{
char namebuf[9];
sprintf(namebuf, "ds%s", sfx->name);
I_sprintf(namebuf, "ds%s", sfx->name);
return W_GetNumForName(namebuf);
}
@ -419,12 +418,12 @@ I_StartSound
return id;
#else
// Debug.
//fprintf( stderr, "starting sound %d", id );
//I_DBGprintf("starting sound %d", id );
// Returns a handle (not used).
id = addsfx( id, vol, steptable[pitch], sep );
// fprintf( stderr, "/handle is %d\n", id );
// I_DBGprintf("/handle is %d\n", id );
return id;
#endif
@ -581,7 +580,7 @@ void I_UpdateSound( void )
if ( misses > 10 )
{
fprintf( stderr, "I_SoundUpdate: missed 10 buffer writes\n");
I_DBGprintf("I_SoundUpdate: missed 10 buffer writes\n");
misses = 0;
}
@ -645,11 +644,11 @@ void I_InitSound()
char buffer[256];
if (getenv("DOOMWADDIR"))
sprintf(buffer, "%s/%s",
I_sprintf(buffer, "%s/%s",
getenv("DOOMWADDIR"),
sndserver_filename);
else
sprintf(buffer, "%s", sndserver_filename);
I_sprintf(buffer, "%s", sndserver_filename);
// start sound process
if ( !access(buffer, X_OK) )
@ -658,22 +657,22 @@ void I_InitSound()
sndserver = popen(buffer, "w");
}
else
fprintf(stderr, "Could not start sound server [%s]\n", buffer);
I_DBGprintf("Could not start sound server [%s]\n", buffer);
#else
int i;
#ifdef SNDINTR
fprintf( stderr, "I_SoundSetTimer: %d microsecs\n", SOUND_INTERVAL );
I_DBGprintf("I_SoundSetTimer: %d microsecs\n", SOUND_INTERVAL );
I_SoundSetTimer( SOUND_INTERVAL );
#endif
// Secure and configure sound device first.
fprintf( stderr, "I_InitSound: ");
I_DBGprintf( "I_InitSound: ");
audio_fd = open("/dev/dsp", O_WRONLY);
if (audio_fd<0)
fprintf(stderr, "Could not open /dev/dsp\n");
I_DBGprintf( "Could not open /dev/dsp\n");
i = 11 | (2<<16);
@ -692,13 +691,13 @@ void I_InitSound()
if (i&=AFMT_S16_LE)
myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i);
else
fprintf(stderr, "Could not play signed 16 data\n");
I_DBGprintf("Could not play signed 16 data\n");
fprintf(stderr, " configured audio device\n" );
I_DBGprintf(" configured audio device\n" );
// Initialize external data (all sounds) at start, keep static.
fprintf( stderr, "I_InitSound: ");
I_DBGprintf("I_InitSound: ");
for (i=1 ; i<NUMSFX ; i++)
{
@ -716,14 +715,14 @@ void I_InitSound()
}
}
fprintf( stderr, " pre-cached all sound data\n");
I_DBGprintf(" pre-cached all sound data\n");
// Now initialize mixbuffer with zero.
for ( i = 0; i< MIXBUFFERSIZE; i++ )
mixbuffer[i] = 0;
// Finished initialization.
fprintf(stderr, "I_InitSound: sound module ready\n");
I_DBGprintf("I_InitSound: sound module ready\n");
#endif
@ -799,7 +798,7 @@ void I_HandleSoundTimer( int ignore )
{
#if 0
// Debug.
//fprintf( stderr, "%c", '+' ); fflush( stderr );
//I_DBGprintf("%c", '+' ); fflush( stderr );
// Feed sound device if necesary.
if ( flag )

View File

@ -120,7 +120,7 @@ void I_EndRead(void)
{
}
byte* I_AllocLow(int length)
byte* I_Malloc(int length)
{
byte* mem;
@ -191,8 +191,217 @@ void I_FilePos(int handle, int pos) {
int I_FileOpenRead(char *fname) {
return strcmp(fname, F1NAME) ? -1 : F1HANDLE;
}
int I_FileCreate(char *fname) {
return -1;
}
int I_FileWrite(int handle, char *source, int length) {
return 0;
}
void I_FileClose(int handle) {
}
void *I_Realloc(void *p, int nsize) {
return gfxRealloc(p, 0 /* Oops - we don't know this */, nsize);
}
void I_Exit(int code) {
gfxExit();
}
void I_printf(const char *fmt, ...) {
}
void I_DBGprintf(const char *fmt, ...) {
}
#include <stdarg.h>
#define MAX_FILLER 11
#define FLOAT_PRECISION 100000
static char *ltoa_wd(char *p, long num, unsigned radix, long divisor) {
int i;
char *q;
if (!divisor) divisor = num;
q = p + MAX_FILLER;
do {
i = (int)(num % radix);
i += '0';
if (i > '9')
i += 'A' - '0' - 10;
*--q = i;
num /= radix;
} while ((divisor /= radix) != 0);
i = (int)(p + MAX_FILLER - q);
do {
*p++ = *q++;
} while (--i);
return p;
}
#if USE_FLOAT
static char *ftoa(char *p, double num) {
long l;
unsigned long precision = FLOAT_PRECISION;
l = num;
p = ltoa_wd(p, l, 10, 0);
*p++ = '.';
l = (num - l) * precision;
return ltoa_wd(p, l, 10, precision / 10);
}
#endif
void I_sprintf(char *buf, const char *fmt, ...) {
va_list ap;
char *p, *s, c, filler;
int i, precision, width;
bool_t is_long, left_align;
long l;
#if USE_FLOAT
float f;
char tmpbuf[2*MAX_FILLER + 1];
#else
char tmpbuf[MAX_FILLER + 1];
#endif
va_start(ap, fmt);
while (TRUE) {
c = *fmt++;
if (c == 0) {
va_end(ap);
return;
}
if (c != '%') {
*buf++ = c;
continue;
}
p = tmpbuf;
s = tmpbuf;
left_align = FALSE;
if (*fmt == '-') {
fmt++;
left_align = TRUE;
}
filler = ' ';
if (*fmt == '.') {
fmt++;
filler = '0';
}
width = 0;
while (TRUE) {
c = *fmt++;
if (c >= '0' && c <= '9')
c -= '0';
else if (c == '*')
c = va_arg(ap, int);
else
break;
width = width * 10 + c;
}
precision = 0;
if (c == '.') {
while (TRUE) {
c = *fmt++;
if (c >= '0' && c <= '9')
c -= '0';
else if (c == '*')
c = va_arg(ap, int);
else
break;
precision = precision * 10 + c;
}
}
/* Long modifier.*/
if (c == 'l' || c == 'L') {
is_long = TRUE;
if (*fmt)
c = *fmt++;
}
else
is_long = (c >= 'A') && (c <= 'Z');
/* Command decoding.*/
switch (c) {
case 'c':
filler = ' ';
*p++ = va_arg(ap, int);
break;
case 's':
filler = ' ';
if ((s = va_arg(ap, char *)) == 0)
s = "(null)";
if (precision == 0)
precision = 32767;
for (p = s; *p && (--precision >= 0); p++);
break;
case 'D':
case 'd':
if (is_long)
l = va_arg(ap, long);
else
l = va_arg(ap, int);
if (l < 0) {
*p++ = '-';
l = -l;
}
p = ltoa_wd(p, l, 10, 0);
break;
#if USE_FLOAT
case 'f':
f = (float) va_arg(ap, double);
if (f < 0) {
*p++ = '-';
f = -f;
}
p = ftoa(p, f);
break;
#endif
case 'X':
case 'x':
c = 16;
goto unsigned_common;
case 'U':
case 'u':
c = 10;
goto unsigned_common;
case 'O':
case 'o':
c = 8;
unsigned_common:
if (is_long)
l = va_arg(ap, long);
else
l = va_arg(ap, int);
p = ltoa_wd(p, l, c, 0);
break;
default:
*p++ = c;
break;
}
i = (int)(p - s);
if ((width -= i) < 0)
width = 0;
if (left_align == FALSE)
width = -width;
if (width < 0) {
if (*s == '-' && filler == '0') {
*buf++ = *s++;
i--;
}
do {
*buf++ = filler;
} while (++width != 0);
}
while (--i >= 0)
*buf++ = *s++;
while (width) {
*buf++ = filler;
width--;
}
}
}

View File

@ -80,8 +80,8 @@ void I_Quit (void);
// Allocates from low memory under dos,
// just mallocs under unix
byte* I_AllocLow (int length);
byte* I_Malloc(int length);
#define I_AllocLow(l) I_Malloc(l)
void I_Tactile (int on, int off, int total);
@ -91,11 +91,16 @@ void I_Error (char *error, ...);
int I_HaveFile(char *fname);
int I_FileSize(int handle);
int I_FileRead (int handle, char *buf, int len);
int I_FileWrite(int handle, char *source, int length);
void I_FilePos(int handle, int pos);
int I_FileOpenRead(char *fname);
int I_FileCreate(char *fname);
void I_FileClose(int handle);
void *I_Realloc(void *p, int nsize);
void I_Exit(int code);
void I_printf(const char *fmt, ...);
void I_DBGprintf(const char *fmt, ...);
void I_sprintf(char *buf, const char *fmt, ...);
#endif
//-----------------------------------------------------------------------------
//

View File

@ -31,12 +31,14 @@
#include "doomdef.h"
//
// Palette stuff.
//
static color_t colors[256];
//static int lastmousex = 0;
//static int lastmousey = 0;
static int multiply;
static coord_t w, h;
static size_t ldiff;
static coord_t lastmousex = 0;
static coord_t lastmousey = 0;
static boolean mousemoved = false;
void I_ShutdownGraphics(void)
@ -50,8 +52,104 @@ void I_StartFrame (void)
{
}
#if 0
int xlatekey(void)
{
int rc;
switch(rc = XKeycodeToKeysym(X_display, X_event.xkey.keycode, 0))
{
case XK_Left: rc = KEY_LEFTARROW; break;
case XK_Right: rc = KEY_RIGHTARROW; break;
case XK_Down: rc = KEY_DOWNARROW; break;
case XK_Up: rc = KEY_UPARROW; break;
case XK_Escape: rc = KEY_ESCAPE; break;
case XK_Return: rc = KEY_ENTER; break;
case XK_Tab: rc = KEY_TAB; break;
case XK_F1: rc = KEY_F1; break;
case XK_F2: rc = KEY_F2; break;
case XK_F3: rc = KEY_F3; break;
case XK_F4: rc = KEY_F4; break;
case XK_F5: rc = KEY_F5; break;
case XK_F6: rc = KEY_F6; break;
case XK_F7: rc = KEY_F7; break;
case XK_F8: rc = KEY_F8; break;
case XK_F9: rc = KEY_F9; break;
case XK_F10: rc = KEY_F10; break;
case XK_F11: rc = KEY_F11; break;
case XK_F12: rc = KEY_F12; break;
case XK_BackSpace:
case XK_Delete: rc = KEY_BACKSPACE; break;
case XK_Pause: rc = KEY_PAUSE; break;
case XK_KP_Equal:
case XK_equal: rc = KEY_EQUALS; break;
case XK_KP_Subtract:
case XK_minus: rc = KEY_MINUS; break;
case XK_Shift_L:
case XK_Shift_R:
rc = KEY_RSHIFT;
break;
case XK_Control_L:
case XK_Control_R:
rc = KEY_RCTRL;
break;
case XK_Alt_L:
case XK_Meta_L:
case XK_Alt_R:
case XK_Meta_R:
rc = KEY_RALT;
break;
default:
if (rc >= XK_space && rc <= XK_asciitilde)
rc = rc - XK_space + ' ';
if (rc >= 'A' && rc <= 'Z')
rc = rc - 'A' + 'a';
break;
}
return rc;
}
#endif
void I_GetEvent(void)
{
event_t event;
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
GEventMouse mev;
#endif
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
ginputGetMouseStatus(0, &mev);
event.type = ev_mouse;
event.data1 = mev.current_buttons & (GINPUT_MOUSE_BTN_LEFT|GINPUT_MOUSE_BTN_RIGHT|GINPUT_MOUSE_BTN_MIDDLE);
if ((mev.current_buttons ^ mev.last_buttons) & (GINPUT_MOUSE_BTN_LEFT|GINPUT_MOUSE_BTN_RIGHT|GINPUT_MOUSE_BTN_MIDDLE)) {
event.data2 = event.data3 = 0;
} else {
event.data2 = (mev.x - lastmousex) << 2;
event.data3 = (lastmousey - mev.y) << 2;
if (event.data2 || event.data3) {
lastmousex = mev.x;
lastmousey = mev.y;
if (mev.x/multiply != w/2 && mev.y/multiply != h/2) {
D_PostEvent(&event);
mousemoved = false;
} else
mousemoved = true;
}
}
#endif
#if 0
event_t event;
@ -142,6 +240,29 @@ void I_GetEvent(void)
//
void I_StartTic (void)
{
I_GetEvent();
#if 0
// Warp the pointer back to the middle of the window
// or it will wander off - that is, the game will
// loose input focus within X11.
if (grabMouse)
{
if (!--doPointerWarp)
{
XWarpPointer( X_display,
None,
X_mainWindow,
0, 0,
0, 0,
X_width/2, X_height/2);
doPointerWarp = POINTER_WARP_COUNTDOWN;
}
}
#endif
mousemoved = false;
}
@ -159,21 +280,25 @@ void I_FinishUpdate (void)
{
register byte *p;
register coord_t x, y;
coord_t w, h;
size_t ldiff;
w = gdispGetWidth();
if (w > SCREENWIDTH) w = SCREENWIDTH;
ldiff = SCREENWIDTH - w;
gdispStreamStart(0, 0, w*multiply, h*multiply);
h = gdispGetHeight();
if (h > SCREENHEIGHT) h = SCREENHEIGHT;
gdispStreamStart(0, 0, w, h);
for(p = screens[0], y=0; y < h; y++, p+=ldiff) {
for(x = 0; x < w; x++, p++)
gdispStreamColor(colors[*p]);
if (multiply == 1) {
for(p = screens[0], y=0; y < h; y++, p+=ldiff) {
for(x = 0; x < w; x++, p++)
gdispStreamColor(colors[*p]);
}
} else {
for(p = screens[0], y=0; y < h; y++, p+=ldiff) {
for(x = 0; x < w; x++, p++) {
gdispStreamColor(colors[*p]);
gdispStreamColor(colors[*p]);
}
for(p -= w, x = 0; x < w; x++, p++) {
gdispStreamColor(colors[*p]);
gdispStreamColor(colors[*p]);
}
}
}
gdispStreamStop();
@ -199,7 +324,7 @@ void I_SetPalette (byte* palette)
int i;
for (i=0 ; i<256 ; i++, palette+=3) {
colors[i] = RGB(gammatable[usegamma][palette[0]], gammatable[usegamma][palette[1]], gammatable[usegamma][palette[2]]);
colors[i] = RGB2COLOR(gammatable[usegamma][palette[0]], gammatable[usegamma][palette[1]], gammatable[usegamma][palette[2]]);
}
}
@ -207,4 +332,19 @@ void I_SetPalette (byte* palette)
void I_InitGraphics(void)
{
screens[0] = gfxAlloc(SCREENWIDTH*SCREENHEIGHT);
multiply = 1;
if (M_CheckParm("-2") || (gdispGetWidth() >= SCREENWIDTH*2 && gdispGetHeight() >= SCREENHEIGHT*2))
multiply = 2;
w = gdispGetWidth()/multiply;
if (w > SCREENWIDTH) w = SCREENWIDTH;
ldiff = SCREENWIDTH - w;
h = gdispGetHeight()/multiply;
if (h > SCREENHEIGHT) h = SCREENHEIGHT;
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
ginputGetMouse(0);
#endif
}

View File

@ -23,7 +23,7 @@
#ifndef __M_BBOX__
#define __M_BBOX__
#include <values.h>
//#include <values.h>
#include "m_fixed.h"

View File

@ -25,14 +25,8 @@
static const char
rcsid[] = "$Id: m_menu.c,v 1.7 1997/02/03 22:45:10 b1 Exp $";
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <ctype.h>
#include "doomdef.h"
#include "dstrings.h"
@ -517,20 +511,17 @@ void M_ReadSaveStrings(void)
for (i = 0;i < load_end;i++)
{
if (M_CheckParm("-cdrom"))
sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",i);
else
sprintf(name,SAVEGAMENAME"%d.dsg",i);
I_sprintf(name,SAVEGAMENAME"%d.dsg",i);
handle = open (name, O_RDONLY | 0, 0666);
handle = I_FileOpenRead (name);
if (handle == -1)
{
strcpy(&savegamestrings[i][0],EMPTYSTRING);
LoadMenu[i].status = 0;
continue;
}
count = read (handle, &savegamestrings[i], SAVESTRINGSIZE);
close (handle);
count = I_FileRead(handle, &savegamestrings[i], SAVESTRINGSIZE);
I_FileClose(handle);
LoadMenu[i].status = 1;
}
}
@ -581,9 +572,9 @@ void M_LoadSelect(int choice)
char name[256];
if (M_CheckParm("-cdrom"))
sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice);
I_sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice);
else
sprintf(name,SAVEGAMENAME"%d.dsg",choice);
I_sprintf(name,SAVEGAMENAME"%d.dsg",choice);
G_LoadGame (name);
M_ClearMenus ();
}
@ -706,7 +697,7 @@ void M_QuickSave(void)
quickSaveSlot = -2; // means to pick a slot now
return;
}
sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]);
I_sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]);
M_StartMessage(tempstring,M_QuickSaveResponse,true);
}
@ -738,7 +729,7 @@ void M_QuickLoad(void)
M_StartMessage(QSAVESPOT,NULL,false);
return;
}
sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]);
I_sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]);
M_StartMessage(tempstring,M_QuickLoadResponse,true);
}
@ -930,8 +921,7 @@ void M_Episode(int choice)
if ( (gamemode == registered)
&& (choice > 2))
{
fprintf( stderr,
"M_Episode: 4th episode requires UltimateDOOM\n");
I_DBGprintf("M_Episode: 4th episode requires UltimateDOOM\n");
choice = 0;
}
@ -1100,9 +1090,9 @@ void M_QuitDOOM(int choice)
// We pick index 0 which is language sensitive,
// or one at random, between 1 and maximum number.
if (language != english )
sprintf(endstring,"%s\n\n"DOSY, endmsg[0] );
I_sprintf(endstring,"%s\n\n"DOSY, endmsg[0] );
else
sprintf(endstring,"%s\n\n"DOSY, endmsg[ (gametic%(NUM_QUITMESSAGES-2))+1 ]);
I_sprintf(endstring,"%s\n\n"DOSY, endmsg[ (gametic%(NUM_QUITMESSAGES-2))+1 ]);
M_StartMessage(endstring,M_QuitResponse,true);
}
@ -1134,7 +1124,7 @@ void M_ChangeDetail(int choice)
detailLevel = 1 - detailLevel;
// FIXME - does not work. Remove anyway?
fprintf( stderr, "M_ChangeDetail: low detail mode n.a.\n");
I_DBGprintf("M_ChangeDetail: low detail mode n.a.\n");
return;

View File

@ -27,12 +27,6 @@
static const char
rcsid[] = "$Id: m_misc.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
@ -118,13 +112,13 @@ M_WriteFile
int handle;
int count;
handle = open ( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
handle = I_FileCreate(name);
if (handle == -1)
return false;
count = write (handle, source, length);
close (handle);
count = I_FileWrite (handle, source, length);
I_FileClose(handle);
if (count < length)
return false;
@ -142,18 +136,15 @@ M_ReadFile
byte** buffer )
{
int handle, count, length;
struct stat fileinfo;
byte *buf;
handle = open (name, O_RDONLY | O_BINARY, 0666);
handle = I_FileOpenRead (name);
if (handle == -1)
I_Error ("Couldn't read file %s", name);
if (fstat (handle,&fileinfo) == -1)
I_Error ("Couldn't read file %s", name);
length = fileinfo.st_size;
length = I_FileSize(handle);
buf = Z_Malloc (length, PU_STATIC, NULL);
count = read (handle, buf, length);
close (handle);
count = I_FileRead (handle, buf, length);
I_FileClose (handle);
if (count < length)
I_Error ("Couldn't read file %s", name);
@ -307,6 +298,7 @@ char* defaultfile;
//
void M_SaveDefaults (void)
{
#if 0 // AJH uGFX HACK
int i;
int v;
FILE* f;
@ -329,6 +321,7 @@ void M_SaveDefaults (void)
}
fclose (f);
#endif
}
@ -358,11 +351,12 @@ void M_LoadDefaults (void)
if (i && i<myargc-1)
{
defaultfile = myargv[i+1];
printf (" default file: %s\n",defaultfile);
I_printf (" default file: %s\n",defaultfile);
}
else
defaultfile = basedefault;
#if 0 // AJH uGFX HACK
// read the file in, overriding any set defaults
f = fopen (defaultfile, "r");
if (f)
@ -377,7 +371,7 @@ void M_LoadDefaults (void)
// get a string default
isstring = true;
len = strlen(strparm);
newstring = (char *) malloc(len);
newstring = (char *) I_malloc(len);
strparm[len-1] = 0;
strcpy(newstring, strparm+1);
}
@ -400,6 +394,7 @@ void M_LoadDefaults (void)
fclose (f);
}
#endif
}
@ -517,7 +512,7 @@ void M_ScreenShot (void)
{
lbmname[4] = i/10 + '0';
lbmname[5] = i%10 + '0';
if (access(lbmname,0) == -1)
if (!I_HaveFile(lbmname))
break; // file doesn't exist
}
if (i==100)

View File

@ -628,9 +628,9 @@ P_SetupLevel
if ( gamemode == commercial)
{
if (map<10)
sprintf (lumpname,"map0%i", map);
I_sprintf (lumpname,"map0%i", map);
else
sprintf (lumpname,"map%i", map);
I_sprintf (lumpname,"map%i", map);
}
else
{
@ -688,7 +688,7 @@ P_SetupLevel
if (precache)
R_PrecacheLevel ();
//printf ("free memory: 0x%x\n", Z_FreeMemory());
//I_printf ("free memory: 0x%x\n", Z_FreeMemory());
}

View File

@ -354,8 +354,7 @@ P_FindNextHighestFloor
// Check for overflow. Exit.
if ( h >= MAX_ADJOINING_SECTORS )
{
fprintf( stderr,
"Sector with more than 20 adjoining sectors\n" );
I_DBGprintf("Sector with more than 20 adjoining sectors\n" );
break;
}
}

View File

@ -350,7 +350,7 @@ void R_GenerateLookup (int texnum)
{
if (!patchcount[x])
{
printf ("R_GenerateLookup: column without a patch (%s)\n",
I_printf ("R_GenerateLookup: column without a patch (%s)\n",
texture->name);
return;
}
@ -493,18 +493,18 @@ void R_InitTextures (void)
temp1 = W_GetNumForName ("S_START"); // P_???????
temp2 = W_GetNumForName ("S_END") - 1;
temp3 = ((temp2-temp1+63)/64) + ((numtextures+63)/64);
printf("[");
I_printf("[");
for (i = 0; i < temp3; i++)
printf(" ");
printf(" ]");
I_printf(" ");
I_printf(" ]");
for (i = 0; i < temp3; i++)
printf("\x8");
printf("\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8");
I_printf("\x8");
I_printf("\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8");
for (i=0 ; i<numtextures ; i++, directory++)
{
if (!(i&63))
printf (".");
I_printf (".");
if (i == numtextures1)
{
@ -616,7 +616,7 @@ void R_InitSpriteLumps (void)
for (i=0 ; i< numspritelumps ; i++)
{
if (!(i&63))
printf (".");
I_printf (".");
patch = W_CacheLumpNum (firstspritelump+i, PU_CACHE);
spritewidth[i] = SHORT(patch->width)<<FRACBITS;
@ -654,13 +654,13 @@ void R_InitColormaps (void)
void R_InitData (void)
{
R_InitTextures ();
printf ("\nInitTextures");
I_printf ("\nInitTextures");
R_InitFlats ();
printf ("\nInitFlats");
I_printf ("\nInitFlats");
R_InitSpriteLumps ();
printf ("\nInitSprites");
I_printf ("\nInitSprites");
R_InitColormaps ();
printf ("\nInitColormaps");
I_printf ("\nInitColormaps");
}

View File

@ -40,6 +40,8 @@ static const char rcsid[] = "$Id: r_main.c,v 1.5 1997/02/03 22:45:12 b1 Exp $";
#include "r_local.h"
#include "r_sky.h"
#include "i_system.h"
@ -110,7 +112,7 @@ angle_t xtoviewangle[SCREENWIDTH+1];
// fixed_t finetangent[FINEANGLES/2];
// fixed_t finesine[5*FINEANGLES/4];
fixed_t* finecosine = &finesine[FINEANGLES/4];
const fixed_t* finecosine = &finesine[FINEANGLES/4];
lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
@ -773,22 +775,22 @@ extern int screenblocks;
void R_Init (void)
{
R_InitData ();
printf ("\nR_InitData");
I_printf ("\nR_InitData");
R_InitPointToAngle ();
printf ("\nR_InitPointToAngle");
I_printf ("\nR_InitPointToAngle");
R_InitTables ();
// viewwidth / viewheight / detailLevel are set by the defaults
printf ("\nR_InitTables");
I_printf ("\nR_InitTables");
R_SetViewSize (screenblocks, detailLevel);
R_InitPlanes ();
printf ("\nR_InitPlanes");
I_printf ("\nR_InitPlanes");
R_InitLightTables ();
printf ("\nR_InitLightTables");
I_printf ("\nR_InitLightTables");
R_InitSkyMap ();
printf ("\nR_InitSkyMap");
I_printf ("\nR_InitSkyMap");
R_InitTranslationTables ();
printf ("\nR_InitTranslationsTables");
I_printf ("\nR_InitTranslationsTables");
framecount = 0;
}

View File

@ -164,7 +164,7 @@ void S_Init
{
int i;
fprintf( stderr, "S_Init: default sfx volume %d\n", sfxVolume);
I_DBGprintf("S_Init: default sfx volume %d\n", sfxVolume);
// Whatever these did with DMX, these are rather dummies now.
I_SetChannels();
@ -269,8 +269,7 @@ S_StartSoundAtVolume
// Debug.
/*fprintf( stderr,
"S_StartSoundAtVolume: playing sound %d (%s)\n",
/*I_DBGprintf("S_StartSoundAtVolume: playing sound %d (%s)\n",
sfx_id, S_sfx[sfx_id].name );*/
// check for bogus sound #
@ -368,13 +367,11 @@ S_StartSoundAtVolume
// cache data if necessary
if (!sfx->data)
{
fprintf( stderr,
"S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n");
I_DBGprintf("S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n");
// DOS remains, 8bit handling
//sfx->data = (void *) W_CacheLumpNum(sfx->lumpnum, PU_MUSIC);
// fprintf( stderr,
// "S_StartSoundAtVolume: loading %d (lump %d) : 0x%x\n",
// I_DBGprintf("S_StartSoundAtVolume: loading %d (lump %d) : 0x%x\n",
// sfx_id, sfx->lumpnum, (int)sfx->data );
}
@ -423,7 +420,7 @@ S_StartSound
{
for (i=first_saw;i!=next_saw;i=(i+1)%10)
if (last_saw_origins[i] != origin)
fprintf(stderr, "old origin 0x%lx != "
I_DBGprintf("old origin 0x%lx != "
"origin 0x%lx for sfx %d\n",
last_saw_origins[i],
origin,
@ -449,15 +446,14 @@ S_StartSound
|| channels[i].sfxinfo == &S_sfx[sfx_sawful]
|| channels[i].sfxinfo == &S_sfx[sfx_sawhit])
{
fprintf(stderr,
"chn: sfxinfo=0x%lx, origin=0x%lx, "
I_DBGprintf("chn: sfxinfo=0x%lx, origin=0x%lx, "
"handle=%d\n",
channels[i].sfxinfo,
channels[i].origin,
channels[i].handle);
}
}
fprintf(stderr, "\n");
I_DBGprintf("\n");
}
}
}
@ -671,7 +667,7 @@ S_ChangeMusic
// get lumpnum if neccessary
if (!music->lumpnum)
{
sprintf(namebuf, "d_%s", music->name);
I_sprintf(namebuf, "d_%s", music->name);
music->lumpnum = W_GetNumForName(namebuf);
}
@ -718,7 +714,7 @@ void S_StopChannel(int cnum)
{
#ifdef SAWDEBUG
if (c->sfxinfo == &S_sfx[sfx_sawful])
fprintf(stderr, "stopped\n");
I_DBGprintf("stopped\n");
#endif
I_StopSound(c->handle);
}

View File

@ -531,7 +531,7 @@ ST_Responder (event_t* ev)
break;
case AM_MSGEXITED:
// fprintf(stderr, "AM exited\n");
// I_DBGprintf("AM exited\n");
st_gamestate = FirstPersonState;
break;
}
@ -664,7 +664,7 @@ ST_Responder (event_t* ev)
else if (cht_CheckCheat(&cheat_mypos, ev->data1))
{
static char buf[ST_MSGWIDTH];
sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
I_sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
players[consoleplayer].mo->angle,
players[consoleplayer].mo->x,
players[consoleplayer].mo->y);
@ -1133,10 +1133,10 @@ void ST_loadGraphics(void)
// Load the numbers, tall and short
for (i=0;i<10;i++)
{
sprintf(namebuf, "STTNUM%d", i);
I_sprintf(namebuf, "STTNUM%d", i);
tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STYSNUM%d", i);
I_sprintf(namebuf, "STYSNUM%d", i);
shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
}
@ -1147,7 +1147,7 @@ void ST_loadGraphics(void)
// key cards
for (i=0;i<NUMCARDS;i++)
{
sprintf(namebuf, "STKEYS%d", i);
I_sprintf(namebuf, "STKEYS%d", i);
keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
}
@ -1157,7 +1157,7 @@ void ST_loadGraphics(void)
// arms ownership widgets
for (i=0;i<6;i++)
{
sprintf(namebuf, "STGNUM%d", i+2);
I_sprintf(namebuf, "STGNUM%d", i+2);
// gray #
arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
@ -1167,7 +1167,7 @@ void ST_loadGraphics(void)
}
// face backgrounds for different color players
sprintf(namebuf, "STFB%d", consoleplayer);
I_sprintf(namebuf, "STFB%d", consoleplayer);
faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
// status bar background bits
@ -1179,18 +1179,18 @@ void ST_loadGraphics(void)
{
for (j=0;j<ST_NUMSTRAIGHTFACES;j++)
{
sprintf(namebuf, "STFST%d%d", i, j);
I_sprintf(namebuf, "STFST%d%d", i, j);
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
}
sprintf(namebuf, "STFTR%d0", i); // turn right
I_sprintf(namebuf, "STFTR%d0", i); // turn right
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFTL%d0", i); // turn left
I_sprintf(namebuf, "STFTL%d0", i); // turn left
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFOUCH%d", i); // ouch!
I_sprintf(namebuf, "STFOUCH%d", i); // ouch!
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFEVL%d", i); // evil grin ;)
I_sprintf(namebuf, "STFEVL%d", i); // evil grin ;)
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFKILL%d", i); // pissed off
I_sprintf(namebuf, "STFKILL%d", i); // pissed off
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
}
faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC);

View File

@ -64,7 +64,7 @@ SlopeDiv
int finetangent[4096] =
const int finetangent[4096] =
{
-170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683,
-10052327,-8994149,-8137527,-7429880,-6835455,-6329090,-5892567,-5512368,
@ -581,7 +581,7 @@ int finetangent[4096] =
};
int finesine[10240] =
const int finesine[10240] =
{
25,75,125,175,226,276,326,376,
427,477,527,578,628,678,728,779,
@ -1867,7 +1867,7 @@ int finesine[10240] =
angle_t tantoangle[2049] =
const angle_t tantoangle[2049] =
{
0,333772,667544,1001315,1335086,1668857,2002626,2336395,
2670163,3003929,3337694,3671457,4005219,4338979,4672736,5006492,

View File

@ -55,14 +55,14 @@
#define ANGLETOFINESHIFT 19
// Effective size is 10240.
extern fixed_t finesine[5*FINEANGLES/4];
extern const fixed_t finesine[5*FINEANGLES/4];
// Re-use data, is just PI/2 pahse shift.
extern fixed_t* finecosine;
extern const fixed_t* finecosine;
// Effective size is 4096.
extern fixed_t finetangent[FINEANGLES/2];
extern const fixed_t finetangent[FINEANGLES/2];
// Binary Angle Measument, BAM.
#define ANG45 0x20000000
@ -81,7 +81,7 @@ typedef unsigned angle_t;
// Effective size is 2049;
// The +1 size is to handle the case when x==y
// without additional checking.
extern angle_t tantoangle[SLOPERANGE+1];
extern const angle_t tantoangle[SLOPERANGE+1];
// Utility function,

View File

@ -225,9 +225,9 @@ V_DrawPatch
|| y+SHORT(patch->height)>SCREENHEIGHT
|| (unsigned)scrn>4)
{
fprintf( stderr, "Patch at %d,%d exceeds LFB\n", x,y );
I_DBGprintf("Patch at %d,%d exceeds LFB\n", x,y );
// No I_Error abort - what is up with TNT.WAD?
fprintf( stderr, "V_DrawPatch: bad patch (ignored)\n");
I_DBGprintf("V_DrawPatch: bad patch (ignored)\n");
return;
}
#endif
@ -292,7 +292,7 @@ V_DrawPatchFlipped
|| y+SHORT(patch->height)>SCREENHEIGHT
|| (unsigned)scrn>4)
{
fprintf( stderr, "Patch origin %d,%d exceeds LFB\n", x,y );
I_DBGprintf("Patch origin %d,%d exceeds LFB\n", x,y );
I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
}
#endif

View File

@ -26,18 +26,6 @@ static const char
rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";
#ifdef NORMALUNIX
#include <ctype.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <alloca.h>
#define O_BINARY 0
#endif
#include "doomtype.h"
#include "m_swap.h"
#include "i_system.h"
@ -73,11 +61,6 @@ void strupr (char* s)
int filelength (int handle)
{
// struct stat fileinfo;
//
// if (fstat (handle,&fileinfo) == -1)
// I_Error ("Error fstating");
return I_FileSize(handle);
}
@ -162,11 +145,11 @@ void W_AddFile (char *filename)
if ( (handle = I_FileOpenRead(filename)) == -1)
{
printf (" couldn't open %s\n",filename);
I_printf (" couldn't open %s\n",filename);
return;
}
printf (" adding %s\n",filename);
I_printf (" adding %s\n",filename);
startlump = numlumps;
if (strcmp (filename+strlen(filename)-3 , "wad" ) && strcmp (filename+strlen(filename)-3 , "WAD" ) )
@ -297,7 +280,7 @@ void W_InitMultipleFiles (char** filenames)
numlumps = 0;
// will be realloced as lumps are added
lumpinfo = malloc(1);
lumpinfo = I_Malloc(1);
for ( ; *filenames ; filenames++)
W_AddFile (*filenames);
@ -307,7 +290,7 @@ void W_InitMultipleFiles (char** filenames)
// set up caching
size = numlumps * sizeof(*lumpcache);
lumpcache = malloc (size);
lumpcache = I_Malloc (size);
if (!lumpcache)
I_Error ("Couldn't allocate lumpcache");
@ -486,13 +469,13 @@ W_CacheLumpNum
{
// read the lump in
//printf ("cache miss on lump %i\n",lump);
//I_printf ("cache miss on lump %i\n",lump);
ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]);
W_ReadLump (lump, lumpcache[lump]);
}
else
{
//printf ("cache hit on lump %i\n",lump);
//I_printf ("cache hit on lump %i\n",lump);
Z_ChangeTag (lumpcache[lump],tag);
}
@ -550,7 +533,7 @@ void W_Profile (void)
}
profilecount++;
#if 0
#if 0 // AJH uGFX HACK
f = fopen ("waddump.txt","w");
name[8] = 0;

View File

@ -494,7 +494,7 @@ WI_drawOnLnode
else
{
// DEBUG
printf("Could not place patch on level %d", n+1);
I_printf("Could not place patch on level %d", n+1);
}
}
@ -1545,7 +1545,7 @@ void WI_loadData(void)
if (gamemode == commercial)
strcpy(name, "INTERPIC");
else
sprintf(name, "WIMAP%d", wbs->epsd);
I_sprintf(name, "WIMAP%d", wbs->epsd);
if ( gamemode == retail )
{
@ -1576,7 +1576,7 @@ void WI_loadData(void)
PU_STATIC, 0);
for (i=0 ; i<NUMCMAPS ; i++)
{
sprintf(name, "CWILV%2.2d", i);
I_sprintf(name, "CWILV%2.2d", i);
lnames[i] = W_CacheLumpName(name, PU_STATIC);
}
}
@ -1586,7 +1586,7 @@ void WI_loadData(void)
PU_STATIC, 0);
for (i=0 ; i<NUMMAPS ; i++)
{
sprintf(name, "WILV%d%d", wbs->epsd, i);
I_sprintf(name, "WILV%d%d", wbs->epsd, i);
lnames[i] = W_CacheLumpName(name, PU_STATIC);
}
@ -1610,7 +1610,7 @@ void WI_loadData(void)
if (wbs->epsd != 1 || j != 8)
{
// animations
sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i);
I_sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i);
a->p[i] = W_CacheLumpName(name, PU_STATIC);
}
else
@ -1629,7 +1629,7 @@ void WI_loadData(void)
for (i=0;i<10;i++)
{
// numbers 0-9
sprintf(name, "WINUM%d", i);
I_sprintf(name, "WINUM%d", i);
num[i] = W_CacheLumpName(name, PU_STATIC);
}
@ -1695,11 +1695,11 @@ void WI_loadData(void)
for (i=0 ; i<MAXPLAYERS ; i++)
{
// "1,2,3,4"
sprintf(name, "STPB%d", i);
I_sprintf(name, "STPB%d", i);
p[i] = W_CacheLumpName(name, PU_STATIC);
// "1,2,3,4"
sprintf(name, "WIBP%d", i+1);
I_sprintf(name, "WIBP%d", i+1);
bp[i] = W_CacheLumpName(name, PU_STATIC);
}

View File

@ -330,16 +330,16 @@ Z_DumpHeap
{
memblock_t* block;
printf ("zone size: %i location: %p\n",
I_printf ("zone size: %i location: %p\n",
mainzone->size,mainzone);
printf ("tag range: %i to %i\n",
I_printf ("tag range: %i to %i\n",
lowtag, hightag);
for (block = mainzone->blocklist.next ; ; block = block->next)
{
if (block->tag >= lowtag && block->tag <= hightag)
printf ("block:%p size:%7i user:%p tag:%3i\n",
I_printf ("block:%p size:%7i user:%p tag:%3i\n",
block, block->size, block->user, block->tag);
if (block->next == &mainzone->blocklist)
@ -349,17 +349,18 @@ Z_DumpHeap
}
if ( (byte *)block + block->size != (byte *)block->next)
printf ("ERROR: block size does not touch the next block\n");
I_printf ("ERROR: block size does not touch the next block\n");
if ( block->next->prev != block)
printf ("ERROR: next block doesn't have proper back link\n");
I_printf ("ERROR: next block doesn't have proper back link\n");
if (!block->user && !block->next->user)
printf ("ERROR: two consecutive free blocks\n");
I_printf ("ERROR: two consecutive free blocks\n");
}
}
#if 0
//
// Z_FileDumpHeap
//
@ -390,7 +391,7 @@ void Z_FileDumpHeap (FILE* f)
fprintf (f,"ERROR: two consecutive free blocks\n");
}
}
#endif
//