From 0345dadebf55980d765826e32854049e498d5759 Mon Sep 17 00:00:00 2001 From: inmarket Date: Tue, 24 Dec 2013 19:58:18 +1000 Subject: [PATCH] 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. --- demos/3rdparty/doom/README.txt | 3 +- demos/3rdparty/doom/am_map.c | 6 +- demos/3rdparty/doom/d_main.c | 185 +++++++---------------------- demos/3rdparty/doom/d_net.c | 58 ++++----- demos/3rdparty/doom/doom.mk | 9 +- demos/3rdparty/doom/doomstat.h | 1 - demos/3rdparty/doom/doomtype.h | 8 +- demos/3rdparty/doom/f_finale.c | 2 +- demos/3rdparty/doom/g_game.c | 20 ++-- demos/3rdparty/doom/gfxconf.h | 3 + demos/3rdparty/doom/hu_stuff.c | 6 +- demos/3rdparty/doom/i_main.c | 5 +- demos/3rdparty/doom/i_net.c | 10 +- demos/3rdparty/doom/i_sound.c | 41 ++++--- demos/3rdparty/doom/i_system.c | 211 ++++++++++++++++++++++++++++++++- demos/3rdparty/doom/i_system.h | 11 +- demos/3rdparty/doom/i_video.c | 178 ++++++++++++++++++++++++--- demos/3rdparty/doom/m_bbox.h | 2 +- demos/3rdparty/doom/m_menu.c | 34 ++---- demos/3rdparty/doom/m_misc.c | 35 +++--- demos/3rdparty/doom/p_setup.c | 6 +- demos/3rdparty/doom/p_spec.c | 3 +- demos/3rdparty/doom/r_data.c | 24 ++-- demos/3rdparty/doom/r_main.c | 18 +-- demos/3rdparty/doom/s_sound.c | 22 ++-- demos/3rdparty/doom/st_stuff.c | 26 ++-- demos/3rdparty/doom/tables.c | 6 +- demos/3rdparty/doom/tables.h | 8 +- demos/3rdparty/doom/v_video.c | 6 +- demos/3rdparty/doom/w_wad.c | 31 ++--- demos/3rdparty/doom/wi_stuff.c | 16 +-- demos/3rdparty/doom/z_zone.c | 15 +-- 32 files changed, 612 insertions(+), 397 deletions(-) diff --git a/demos/3rdparty/doom/README.txt b/demos/3rdparty/doom/README.txt index 7a76473e..521c0f9d 100644 --- a/demos/3rdparty/doom/README.txt +++ b/demos/3rdparty/doom/README.txt @@ -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. diff --git a/demos/3rdparty/doom/am_map.c b/demos/3rdparty/doom/am_map.c index 999e4558..932062a4 100644 --- a/demos/3rdparty/doom/am_map.c +++ b/demos/3rdparty/doom/am_map.c @@ -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; } diff --git a/demos/3rdparty/doom/d_main.c b/demos/3rdparty/doom/d_main.c index 52eaa322..f16dc89b 100644 --- a/demos/3rdparty/doom/d_main.c +++ b/demos/3rdparty/doom/d_main.c @@ -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 -#include -#include -#include -#include -#include -#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 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); } diff --git a/demos/3rdparty/doom/d_net.c b/demos/3rdparty/doom/d_net.c index 75b5436e..dc577839 100644 --- a/demos/3rdparty/doom/d_net.c +++ b/demos/3rdparty/doom/d_net.c @@ -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 ; idatalength ; 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 ; idatalength ; 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 ; inumnodes ; 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 diff --git a/demos/3rdparty/doom/doom.mk b/demos/3rdparty/doom/doom.mk index 2c26053f..6581f8c1 100644 --- a/demos/3rdparty/doom/doom.mk +++ b/demos/3rdparty/doom/doom.mk @@ -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 \ diff --git a/demos/3rdparty/doom/doomstat.h b/demos/3rdparty/doom/doomstat.h index 65f52256..0ff7de76 100644 --- a/demos/3rdparty/doom/doomstat.h +++ b/demos/3rdparty/doom/doomstat.h @@ -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; diff --git a/demos/3rdparty/doom/doomtype.h b/demos/3rdparty/doom/doomtype.h index e89a7a6d..f1f67236 100644 --- a/demos/3rdparty/doom/doomtype.h +++ b/demos/3rdparty/doom/doomtype.h @@ -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 diff --git a/demos/3rdparty/doom/f_finale.c b/demos/3rdparty/doom/f_finale.c index a6e74dd4..4977f1de 100644 --- a/demos/3rdparty/doom/f_finale.c +++ b/demos/3rdparty/doom/f_finale.c @@ -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)); } diff --git a/demos/3rdparty/doom/g_game.c b/demos/3rdparty/doom/g_game.c index 30ac33c2..8f038c3a 100644 --- a/demos/3rdparty/doom/g_game.c +++ b/demos/3rdparty/doom/g_game.c @@ -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; } diff --git a/demos/3rdparty/doom/gfxconf.h b/demos/3rdparty/doom/gfxconf.h index a061bdba..205f75ba 100644 --- a/demos/3rdparty/doom/gfxconf.h +++ b/demos/3rdparty/doom/gfxconf.h @@ -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 diff --git a/demos/3rdparty/doom/hu_stuff.c b/demos/3rdparty/doom/hu_stuff.c index efb13967..eed227dc 100644 --- a/demos/3rdparty/doom/hu_stuff.c +++ b/demos/3rdparty/doom/hu_stuff.c @@ -405,7 +405,7 @@ void HU_Init(void) j = HU_FONTSTART; for (i=0;i 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) diff --git a/demos/3rdparty/doom/i_main.c b/demos/3rdparty/doom/i_main.c index 0c618a5b..5c40432a 100644 --- a/demos/3rdparty/doom/i_main.c +++ b/demos/3rdparty/doom/i_main.c @@ -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(); } diff --git a/demos/3rdparty/doom/i_net.c b/demos/3rdparty/doom/i_net.c index 550ef68b..d167e538 100644 --- a/demos/3rdparty/doom/i_net.c +++ b/demos/3rdparty/doom/i_net.c @@ -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 && pname); + 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 + +#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--; + } + } +} + diff --git a/demos/3rdparty/doom/i_system.h b/demos/3rdparty/doom/i_system.h index d9a1fb04..3f7bd4bb 100644 --- a/demos/3rdparty/doom/i_system.h +++ b/demos/3rdparty/doom/i_system.h @@ -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 //----------------------------------------------------------------------------- // diff --git a/demos/3rdparty/doom/i_video.c b/demos/3rdparty/doom/i_video.c index 98167534..6f045ebf 100644 --- a/demos/3rdparty/doom/i_video.c +++ b/demos/3rdparty/doom/i_video.c @@ -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 } diff --git a/demos/3rdparty/doom/m_bbox.h b/demos/3rdparty/doom/m_bbox.h index 66be2fbd..e709bb21 100644 --- a/demos/3rdparty/doom/m_bbox.h +++ b/demos/3rdparty/doom/m_bbox.h @@ -23,7 +23,7 @@ #ifndef __M_BBOX__ #define __M_BBOX__ -#include +//#include #include "m_fixed.h" diff --git a/demos/3rdparty/doom/m_menu.c b/demos/3rdparty/doom/m_menu.c index 4d415aed..efd95621 100644 --- a/demos/3rdparty/doom/m_menu.c +++ b/demos/3rdparty/doom/m_menu.c @@ -25,14 +25,8 @@ static const char rcsid[] = "$Id: m_menu.c,v 1.7 1997/02/03 22:45:10 b1 Exp $"; -#include -#include -#include -#include -#include #include - #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; diff --git a/demos/3rdparty/doom/m_misc.c b/demos/3rdparty/doom/m_misc.c index 0df4fe57..c42c6a10 100644 --- a/demos/3rdparty/doom/m_misc.c +++ b/demos/3rdparty/doom/m_misc.c @@ -27,12 +27,6 @@ static const char rcsid[] = "$Id: m_misc.c,v 1.6 1997/02/03 22:45:10 b1 Exp $"; -#include -#include -#include -#include -#include - #include @@ -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= MAX_ADJOINING_SECTORS ) { - fprintf( stderr, - "Sector with more than 20 adjoining sectors\n" ); + I_DBGprintf("Sector with more than 20 adjoining sectors\n" ); break; } } diff --git a/demos/3rdparty/doom/r_data.c b/demos/3rdparty/doom/r_data.c index acabd53f..7d2b9483 100644 --- a/demos/3rdparty/doom/r_data.c +++ b/demos/3rdparty/doom/r_data.c @@ -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 ; iwidth)<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); } diff --git a/demos/3rdparty/doom/st_stuff.c b/demos/3rdparty/doom/st_stuff.c index 16f2e3f1..dadf1495 100644 --- a/demos/3rdparty/doom/st_stuff.c +++ b/demos/3rdparty/doom/st_stuff.c @@ -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;iheight)>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 diff --git a/demos/3rdparty/doom/w_wad.c b/demos/3rdparty/doom/w_wad.c index eceba36d..bc19a509 100644 --- a/demos/3rdparty/doom/w_wad.c +++ b/demos/3rdparty/doom/w_wad.c @@ -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 -#include -#include -#include -#include -#include -#include -#include -#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; diff --git a/demos/3rdparty/doom/wi_stuff.c b/demos/3rdparty/doom/wi_stuff.c index 01502c89..afa48935 100644 --- a/demos/3rdparty/doom/wi_stuff.c +++ b/demos/3rdparty/doom/wi_stuff.c @@ -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 ; iepsd, 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 ; isize,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 //