Doom alpha 2

git-svn-id: svn://kolibrios.org@333 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-02-08 22:53:29 +00:00
parent a89bf95159
commit c682e2d8c0
22 changed files with 4263 additions and 4763 deletions

View File

@ -31,34 +31,17 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
#define FGCOLOR 8 #define FGCOLOR 8
#define R_OK 4
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
extern int access(char *file, int mode);
#define R_OK 4
#if 0
static int access(char *file, int mode)
{
FILE *test_fp;
test_fp = fopen(file, "r");
if ( test_fp != NULL ) {
fclose(test_fp);
return(0);
}
return(-1);
}
#endif
#include "doomdef.h" #include "doomdef.h"
#include "doomstat.h" #include "doomstat.h"
#include "dstrings.h" #include "dstrings.h"
#include "sounds.h" #include "sounds.h"
#include "z_zone.h" #include "z_zone.h"
#include "w_wad.h" #include "w_wad.h"
#include "s_sound.h" #include "s_sound.h"
@ -86,7 +69,12 @@ static int access(char *file, int mode)
#include "r_local.h" #include "r_local.h"
#include "d_main.h" #include "d_main.h"
//#include "kolibri.h"
extern int access(char *file, int mode);
// //
// D-DoomLoop() // D-DoomLoop()
@ -243,9 +231,7 @@ void D_Display (void)
if (gamestate != wipegamestate) if (gamestate != wipegamestate)
{ {
wipe = true; wipe = true;
XXX(4);
wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
XXX(5);
} }
else else
wipe = false; wipe = false;
@ -253,9 +239,7 @@ void D_Display (void)
if (gamestate == GS_LEVEL && gametic) if (gamestate == GS_LEVEL && gametic)
{ {
XXX(7);
HU_Erase(); HU_Erase();
XXX(8);
} }
// do buffered drawing // do buffered drawing
XXX(9); XXX(9);
@ -414,9 +398,8 @@ void D_DoomLoop (void)
if (M_CheckParm ("-debugfile")) if (M_CheckParm ("-debugfile"))
{ {
char filename[20]; char filename[32];
sprintf (filename,"debug%i.txt",consoleplayer); sprintf (filename,"debug%i.txt",consoleplayer);
// __libclog_printf ("debug output to: %s\n",filename);
debugfile = fopen (filename,"w"); debugfile = fopen (filename,"w");
} }
@ -432,35 +415,28 @@ void D_DoomLoop (void)
// process one or more tics // process one or more tics
if (singletics) if (singletics)
{ {
XXX(201);
I_StartTic (); I_StartTic ();
XXX(202);
D_ProcessEvents (); D_ProcessEvents ();
XXX(203);
G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]);
XXX(204);
if (advancedemo) if (advancedemo)
{
D_DoAdvanceDemo (); D_DoAdvanceDemo ();
XXX(205); };
M_Ticker (); M_Ticker ();
XXX(206);
G_Ticker (); G_Ticker ();
gametic++; gametic++;
maketic++; maketic++;
} }
else else
{
XXX(102);
TryRunTics (); // will run at least one tic TryRunTics (); // will run at least one tic
XXX(103);
}
S_UpdateSounds (players[consoleplayer].mo);// move positional sounds S_UpdateSounds (players[consoleplayer].mo);// move positional sounds
// Update display, next frame, with current state.
XXX(104);
D_Display (); D_Display ();
I_UpdateSound(); // I_UpdateSound();
XXX(105); XXX(105);
} }
} }
@ -640,7 +616,6 @@ void IdentifyVersion (void)
// Commercial. // Commercial.
doom2wad = malloc(strlen(doomwaddir)+1+9+1); doom2wad = malloc(strlen(doomwaddir)+1+9+1);
sprintf(doom2wad, "%s/doom2.wad", doomwaddir); sprintf(doom2wad, "%s/doom2.wad", doomwaddir);
// Retail. // Retail.
doomuwad = malloc(strlen(doomwaddir)+1+8+1); doomuwad = malloc(strlen(doomwaddir)+1+8+1);
sprintf(doomuwad, "%s/doomu.wad", doomwaddir); sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
@ -656,12 +631,11 @@ void IdentifyVersion (void)
// Bug, dear Shawn. // Bug, dear Shawn.
// Insufficient malloc, caused spurious realloc errors. // Insufficient malloc, caused spurious realloc errors.
plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1); plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1);
sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir); sprintf(plutoniawad, "%splutonia.wad", doomwaddir);
tntwad = malloc(strlen(doomwaddir)+1+9+1); tntwad = malloc(strlen(doomwaddir)+1+9+1);
sprintf(tntwad, "%s/tnt.wad", doomwaddir); sprintf(tntwad, "%s/tnt.wad", doomwaddir);
// French stuff. // French stuff.
doom2fwad = malloc(strlen(doomwaddir)+1+10+1); doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);
@ -718,7 +692,6 @@ void IdentifyVersion (void)
// C'est ridicule! // C'est ridicule!
// Let's handle languages in config files, okay? // Let's handle languages in config files, okay?
language = french; language = french;
// __libclog_printf("French version\n");
D_AddFile (doom2fwad); D_AddFile (doom2fwad);
return; return;
} }
@ -765,7 +738,7 @@ void IdentifyVersion (void)
return; return;
} }
// __libclog_printf("Game mode indeterminate.\n"); printf("Game mode indeterminate.\n");
gamemode = indetermined; gamemode = indetermined;
// We don't abort. Let's see what the PWAD contains. // We don't abort. Let's see what the PWAD contains.
@ -802,12 +775,12 @@ void FindResponseFile (void)
exit(1); exit(1);
} }
// __libclog_printf("Found response file %s!\n",&myargv[i][1]); // __libclog_printf("Found response file %s!\n",&myargv[i][1]);
fseek (handle,0,SEEK_END); // fseek (handle,0,SEEK_END);
size = ftell(handle); // size = ftell(handle);
fseek (handle,0,SEEK_SET); // fseek (handle,0,SEEK_SET);
file = malloc (size); // file = malloc (size);
fread (file,size,1,handle); // fread (file,size,1,handle);
fclose (handle); // fclose (handle);
// KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
for (index = 0,k = i+1; k < myargc; k++) for (index = 0,k = i+1; k < myargc; k++)
@ -839,7 +812,7 @@ void FindResponseFile (void)
// DISPLAY ARGS // DISPLAY ARGS
// __libclog_printf("%d command-line args:\n",myargc); // __libclog_printf("%d command-line args:\n",myargc);
for (k=1;k<myargc;k++) // for (k=1;k<myargc;k++)
// __libclog_printf("%s\n",myargv[k]); // __libclog_printf("%s\n",myargv[k]);
break; break;
@ -859,9 +832,6 @@ void D_DoomMain (void)
IdentifyVersion (); IdentifyVersion ();
// I_BeginSplash();
// setbuf (stdout, NULL);
modifiedgame = false; modifiedgame = false;
nomonsters = M_CheckParm ("-nomonsters"); nomonsters = M_CheckParm ("-nomonsters");
@ -931,7 +901,7 @@ void D_DoomMain (void)
// __libclog_printf ("%s\n",title); // __libclog_printf ("%s\n",title);
if (devparm) if (devparm)
// __libclog_printf(D_DEVSTR); printf(D_DEVSTR);
// turbo option // turbo option
if ( (p=M_CheckParm ("-turbo")) ) if ( (p=M_CheckParm ("-turbo")) )
@ -946,7 +916,7 @@ void D_DoomMain (void)
scale = 10; scale = 10;
if (scale > 400) if (scale > 400)
scale = 400; scale = 400;
// __libclog_printf ("turbo scale: %i%%\n",scale); printf ("turbo scale: %i%%\n",scale);
forwardmove[0] = forwardmove[0]*scale/100; forwardmove[0] = forwardmove[0]*scale/100;
forwardmove[1] = forwardmove[1]*scale/100; forwardmove[1] = forwardmove[1]*scale/100;
sidemove[0] = sidemove[0]*scale/100; sidemove[0] = sidemove[0]*scale/100;
@ -971,8 +941,6 @@ void D_DoomMain (void)
case registered: case registered:
sprintf (file,"~"DEVMAPS"E%cM%c.wad", sprintf (file,"~"DEVMAPS"E%cM%c.wad",
myargv[p+1][0], myargv[p+2][0]); myargv[p+1][0], myargv[p+2][0]);
// __libclog_printf("Warping to Episode %s, Map %s.\n",
// myargv[p+1],myargv[p+2]);
break; break;
case commercial: case commercial:
@ -1006,7 +974,6 @@ void D_DoomMain (void)
{ {
sprintf (file,"%s.lmp", myargv[p+1]); sprintf (file,"%s.lmp", myargv[p+1]);
D_AddFile (file); D_AddFile (file);
printf("Playing demo %s.lmp.\n",myargv[p+1]);
} }
// get skill / episode / map from parms // get skill / episode / map from parms
@ -1015,7 +982,6 @@ void D_DoomMain (void)
startmap = 1; startmap = 1;
autostart = false; autostart = false;
p = M_CheckParm ("-skill"); p = M_CheckParm ("-skill");
if (p && p < myargc-1) if (p && p < myargc-1)
{ {
@ -1036,7 +1002,6 @@ void D_DoomMain (void)
{ {
int time; int time;
time = atoi(myargv[p+1]); time = atoi(myargv[p+1]);
printf("Levels will end after %d minute",time);
if (time>1) if (time>1)
printf("s"); printf("s");
printf(".\n"); printf(".\n");
@ -1059,20 +1024,19 @@ void D_DoomMain (void)
autostart = true; autostart = true;
} }
// init subsystems // init subsystems
printf ("V_Init: allocate screens.\n"); printf ("V_Init: allocate screens.\n\r");
V_Init (); V_Init ();
printf ("M_LoadDefaults: Load system defaults.\n"); printf ("M_LoadDefaults: Load system defaults.\n\r");
M_LoadDefaults (); // load before initing other systems M_LoadDefaults (); // load before initing other systems
printf ("Z_Init: Init zone memory allocation daemon. \n"); printf ("Z_Init: Init zone memory allocation daemon. \n\r");
Z_Init (); Z_Init ();
printf ("W_Init: Init WADfiles.\n"); printf ("W_Init: Init WADfiles.\n\r");
W_InitMultipleFiles (wadfiles); W_InitMultipleFiles (wadfiles);
printf("added\n");
// Check for -file in shareware // Check for -file in shareware
if (modifiedgame) if (modifiedgame)
@ -1088,7 +1052,7 @@ void D_DoomMain (void)
int i; int i;
if ( gamemode == shareware) if ( gamemode == shareware)
I_Error("\nYou cannot -file with the shareware " I_Error("\n\rYou cannot -file with the shareware "
"version. Register!"); "version. Register!");
// Check for fake IWAD with right name, // Check for fake IWAD with right name,
@ -1096,20 +1060,20 @@ void D_DoomMain (void)
if (gamemode == registered) if (gamemode == registered)
for (i = 0;i < 23; i++) for (i = 0;i < 23; i++)
if (W_CheckNumForName(name[i])<0) if (W_CheckNumForName(name[i])<0)
I_Error("\nThis is not the registered version."); I_Error("\n\rThis is not the registered version.");
} }
// Iff additonal PWAD files are used, print modified banner // Iff additonal PWAD files are used, print modified banner
if (modifiedgame) if (modifiedgame)
{ {
printf ( // //printf (
"===========================================================================\n" // "===========================================================================\n\r"
"ATTENTION: This version of DOOM has been modified. If you would like to\n" // "ATTENTION: This version of DOOM has been modified. If you would like to\n\r"
"get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n" // "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n\r"
" You will not receive technical support for modified games.\n" // " You will not receive technical support for modified games.\n\r"
" press enter to continue\n" // " press enter to continue\n\r"
"===========================================================================\n" // "===========================================================================\n\r"
); // );
// getchar (); // getchar ();
} }
@ -1119,21 +1083,21 @@ void D_DoomMain (void)
{ {
case shareware: case shareware:
case indetermined: case indetermined:
printf ( // //printf (
"===========================================================================\n" // "===========================================================================\n\r"
" Shareware!\n" // " Shareware!\n\r"
"===========================================================================\n" // "===========================================================================\n\r"
); // );
break; break;
case registered: case registered:
case retail: case retail:
case commercial: case commercial:
printf ( // //printf (
"===========================================================================\n" // "===========================================================================\n\r"
" Commercial product - do not distribute!\n" // " Commercial product - do not distribute!\n\r"
" Please report software piracy to the SPA: 1-800-388-PIR8\n" // " Please report software piracy to the SPA: 1-800-388-PIR8\n\r"
"===========================================================================\n" // "===========================================================================\n\r"
); // );
break; break;
default: default:
@ -1141,30 +1105,28 @@ void D_DoomMain (void)
break; break;
} }
printf ("M_Init: Init miscellaneous info.\n"); printf ("M_Init: Init miscellaneous info.\n\r");
M_Init (); M_Init ();
printf ("R_Init: Init DOOM refresh daemon - "); printf ("R_Init: Init DOOM refresh daemon - \n\r");
R_Init (); R_Init ();
printf ("\nP_Init: Init Playloop state.\n"); printf ("\nP_Init: Init Playloop state.\n\r");
P_Init (); P_Init ();
printf ("I_Init: Setting up machine state.\n"); printf ("I_Init: Setting up machine state.\n\r");
I_Init (); I_Init ();
printf ("D_CheckNetGame: Checking network game status.\n"); printf ("D_CheckNetGame: Checking network game status.\n\r");
D_CheckNetGame (); D_CheckNetGame ();
printf ("S_Init: Setting up sound.\n"); // printf ("S_Init: Setting up sound.\n\r");
S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ ); // S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );
printf ("HU_Init: Setting up heads up display.\n"); printf ("HU_Init: Setting up heads up display.\n\r");
HU_Init (); HU_Init ();
// I_EndSplash(); printf ("ST_Init: Init status bar.\n\r");
printf ("ST_Init: Init status bar.\n");
ST_Init (); ST_Init ();
// check for a driver that wants intermission stats // check for a driver that wants intermission stats
@ -1175,7 +1137,7 @@ void D_DoomMain (void)
extern void* statcopy; extern void* statcopy;
statcopy = (void*)atoi(myargv[p+1]); statcopy = (void*)atoi(myargv[p+1]);
printf ("External statistics registered.\n"); //printf ("External statistics registered.\n\r");
} }
// start the apropriate game based on parms // start the apropriate game based on parms

View File

@ -674,8 +674,7 @@ void TryRunTics (void)
frameon++; frameon++;
if (debugfile) if (debugfile)
fprintf (debugfile, printf ( "=======real: %i avail: %i game: %i\n",
"=======real: %i avail: %i game: %i\n",
realtics, availabletics,counts); realtics, availabletics,counts);
if (!demoplayback) if (!demoplayback)

View File

@ -28,8 +28,8 @@ rcsid[] = "$Id: f_finale.c,v 1.5 1997/02/03 21:26:34 b1 Exp $";
#include <ctype.h> #include <ctype.h>
// Functions. // Functions.
#include "m_swap.h"
#include "i_system.h" #include "i_system.h"
#include "m_swap.h"
#include "z_zone.h" #include "z_zone.h"
#include "v_video.h" #include "v_video.h"
#include "w_wad.h" #include "w_wad.h"

View File

@ -253,9 +253,9 @@ void G_BuildTiccmd (ticcmd_t* cmd)
consistancy[consoleplayer][maketic%BACKUPTICS]; consistancy[consoleplayer][maketic%BACKUPTICS];
strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] strafe = gamekeydown[key_strafe]; // || mousebuttons[mousebstrafe]
|| joybuttons[joybstrafe]; // || joybuttons[joybstrafe];
speed = gamekeydown[key_speed] || joybuttons[joybspeed]; speed = gamekeydown[key_speed]; // || joybuttons[joybspeed];
forward = side = 0; forward = side = 0;
@ -312,13 +312,13 @@ void G_BuildTiccmd (ticcmd_t* cmd)
} }
if (gamekeydown[key_down]) if (gamekeydown[key_down])
{ {
// fprintf(stderr, "down\n");
forward -= forwardmove[speed]; forward -= forwardmove[speed];
// printf("forward= %d\n\r", forward);
} }
if (joyymove < 0) // if (joyymove < 0)
forward += forwardmove[speed]; // forward += forwardmove[speed];
if (joyymove > 0) // if (joyymove > 0)
forward -= forwardmove[speed]; // forward -= forwardmove[speed];
if (gamekeydown[key_straferight]) if (gamekeydown[key_straferight])
side += sidemove[speed]; side += sidemove[speed];
if (gamekeydown[key_strafeleft]) if (gamekeydown[key_strafeleft])
@ -402,7 +402,7 @@ void G_BuildTiccmd (ticcmd_t* cmd)
} }
} }
forward += mousey; // forward += mousey;
if (strafe) if (strafe)
side += mousex*2; side += mousex*2;
else else
@ -705,10 +705,10 @@ void G_Ticker (void)
{ {
case BTS_PAUSE: case BTS_PAUSE:
paused ^= 1; paused ^= 1;
if (paused) // if (paused)
S_PauseSound (); // S_PauseSound ();
else // else
S_ResumeSound (); // S_ResumeSound ();
break; break;
case BTS_SAVEGAME: case BTS_SAVEGAME:
@ -882,8 +882,8 @@ G_CheckSpot
, ss->sector->floorheight , ss->sector->floorheight
, MT_TFOG); , MT_TFOG);
if (players[consoleplayer].viewz != 1) // if (players[consoleplayer].viewz != 1)
S_StartSound (mo, sfx_telept); // don't start sound on first frame // S_StartSound (mo, sfx_telept); // don't start sound on first frame
return true; return true;
} }
@ -1369,7 +1369,7 @@ G_InitNew
if (paused) if (paused)
{ {
paused = false; paused = false;
S_ResumeSound (); // S_ResumeSound ();
} }

View File

@ -25,11 +25,10 @@ rcsid[] = "$Id: hu_lib.c,v 1.3 1997/01/26 07:44:58 b1 Exp $";
#include <ctype.h> #include <ctype.h>
#include "m_swap.h"
#include "doomdef.h" #include "doomdef.h"
#include "v_video.h" #include "v_video.h"
#include "m_swap.h"
#include "hu_lib.h" #include "hu_lib.h"
#include "r_local.h" #include "r_local.h"

View File

@ -24,24 +24,32 @@
static const char static const char
rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $"; rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $";
//#include "SDL.h"
#include "doomdef.h" #include "doomdef.h"
#include "m_argv.h" #include "m_argv.h"
#include "d_main.h" #include "d_main.h"
#include "kolibri.h"
int int main(int argc, char **argv)
main( int argc, char** argv)
{ {
static char * tmp[]= // static char * tmp[]=
{"/hd/1/menuetos/doom/mdoom", // {"/hd/1/menuetos/doom/mdoom",
NULL}; // NULL};
myargc = 1; myargc = 1;
myargv = tmp; myargv = argv;
// chdir("/hd/1/menuetos/doom"); // InitHeap(32*1024*1024);
_asm
{
push ebx
push ecx
mov eax, 66
mov ebx, 1
mov ecx, 1
int 0x40
pop ecx
pop ebx
};
D_DoomMain (); D_DoomMain ();

View File

@ -1,3 +1,4 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -9,6 +10,18 @@
#include "doomstat.h" #include "doomstat.h"
#include "i_net.h" #include "i_net.h"
#ifdef DLHEAP
void* _cdecl dlmalloc(size_t);
void _cdecl dlfree(void*);
void _cdecl mf_init();
#define malloc dlmalloc
#define free dlfree
#define realloc dlrealloc
#endif
#ifndef B_HOST_IS_LENDIAN #ifndef B_HOST_IS_LENDIAN
#define B_HOST_IS_LENDIAN 1 #define B_HOST_IS_LENDIAN 1
#endif #endif
@ -56,6 +69,7 @@ void (*netsend) (void);
static int first_user_port=IPPORT_USERRESERVED+0x1D+0x10; static int first_user_port=IPPORT_USERRESERVED+0x1D+0x10;
/**********
int GetAvailPort(void) int GetAvailPort(void)
{ {
int i,d0; int i,d0;
@ -70,11 +84,11 @@ int GetAvailPort(void)
I_Error("Unable to get new port\n"); I_Error("Unable to get new port\n");
return -1; return -1;
} }
**********/
int CreateInputUDPsocket(void) int CreateInputUDPsocket(void)
{ {
int d0; int d0=0;
//__asm__ __volatile__( //__asm__ __volatile__(
// "int $0x40" // "int $0x40"
// :"=a"(d0) // :"=a"(d0)
@ -109,6 +123,11 @@ void PacketSend (void)
{ {
int c; int c;
doomdata_t sw; doomdata_t sw;
//printf("ERROR Packet Send\n\r");
// byte swap // byte swap
sw.checksum = htonl(netbuffer->checksum); sw.checksum = htonl(netbuffer->checksum);
sw.player = netbuffer->player; sw.player = netbuffer->player;
@ -158,6 +177,7 @@ int GetLocalAddress (void)
// //
// I_InitNetwork // I_InitNetwork
// //
void I_InitNetwork (void) void I_InitNetwork (void)
{ {
boolean trueval = true; boolean trueval = true;
@ -226,16 +246,20 @@ void I_InitNetwork (void)
// __libclog_printf("DOOM: Input UDP socket is %d\n",insocket); // __libclog_printf("DOOM: Input UDP socket is %d\n",insocket);
} }
void I_NetCmd (void) void I_NetCmd (void)
{ {
//printf("ERROR NetCmd");
if (doomcom->command == CMD_SEND) if (doomcom->command == CMD_SEND)
{ {
netsend (); // netsend ();
} }
else if (doomcom->command == CMD_GET) else if (doomcom->command == CMD_GET)
{ {
netget (); // netget ();
} }
else else
I_Error ("Bad net cmd: %i\n",doomcom->command); I_Error ("Bad net cmd: %i\n",doomcom->command);

View File

@ -332,8 +332,8 @@ void I_SetChannels()
channels[i] = 0; channels[i] = 0;
} }
for (i=-128 ; i<128 ; i++) // for (i=-128 ; i<128 ; i++)
steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0); // steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
// Generates volume lookup tables // Generates volume lookup tables
// which also turn the unsigned samples // which also turn the unsigned samples
@ -515,7 +515,7 @@ void I_UpdateSound( void )
leftout += step; leftout += step;
rightout += step; rightout += step;
} }
I_SubmitSound(mixbuffer); // I_SubmitSound(mixbuffer);
} }

View File

@ -26,8 +26,6 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <ctype.h> #include <ctype.h>
//#include "SDL.h"
//#include "SDL_timer.h"
#include "doomdef.h" #include "doomdef.h"
#include "m_misc.h" #include "m_misc.h"
@ -39,23 +37,10 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include "i_system.h" #include "i_system.h"
#include "kolibri.h" #include "kolibri.h"
int mb_used = 6; int mb_used = 8;
int I_strncasecmp(char *str1, char *str2, int len)
{
char c1, c2;
while ( *str1 && *str2 && len-- ) {
c1 = *str1++;
c2 = *str2++;
if ( toupper(c1) != toupper(c2) )
return(1);
}
return(0);
}
void void
I_Tactile I_Tactile
@ -91,21 +76,17 @@ byte* I_ZoneBase (int* size)
// returns time in 1/35 second tics // returns time in 1/35 second tics
// //
__declspec(dllimport) unsigned int __stdcall GetTickCount(void);
int I_GetTime (void) int I_GetTime (void)
{ {
unsigned int tm; unsigned int tm;
// _asm _asm
// { { push ebx
// mov eax, 26 mov eax, 26
// mov ebx, 9 mov ebx, 9
// int 0x40 int 0x40
// mov [tm], eax mov dword ptr [tm], eax
// }; pop ebx
};
tm=GetTickCount()/10;
return (tm*TICRATE)/100; return (tm*TICRATE)/100;
} }
@ -118,7 +99,7 @@ int I_GetTime (void)
void I_Init (void) void I_Init (void)
{ {
I_InitGraphics(); I_InitGraphics();
I_InitSound(); // I_InitSound();
} }
// //
@ -148,6 +129,7 @@ void I_EndRead(void)
{ {
} }
/***********
byte* I_AllocLow(int length) byte* I_AllocLow(int length)
{ {
byte* mem; byte* mem;
@ -156,7 +138,7 @@ byte* I_AllocLow(int length)
memset (mem,0,length); memset (mem,0,length);
return mem; return mem;
} }
************/
// //
// I_Error // I_Error
@ -170,8 +152,8 @@ void I_Error (char *error, ...)
// Message first. // Message first.
va_start (argptr,error); va_start (argptr,error);
printf ("Error: "); printf ("Error: ");
printf (argptr); printf (error,argptr);
printf ("\n"); printf ("\n\r");
va_end (argptr); va_end (argptr);
// Shutdown. Here might be other errors. // Shutdown. Here might be other errors.

View File

@ -26,9 +26,7 @@ rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
#include <stdlib.h> #include <stdlib.h>
//#include "SDL.h" #include "m_swap.h"
//#include "m_swap.h"
#include "doomstat.h" #include "doomstat.h"
#include "i_system.h" #include "i_system.h"
#include "v_video.h" #include "v_video.h"
@ -36,14 +34,16 @@ rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
#include "d_main.h" #include "d_main.h"
#include "doomdef.h" #include "doomdef.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include "kolibri.h"
void BlitDIB();
typedef struct SURFACE typedef struct SURFACE
{ {
unsigned char *pixels;
int w, h; int w, h;
int pitch; int pitch;
unsigned char *pixels;
int offset; int offset;
} SURFACE; } SURFACE;
@ -58,109 +58,26 @@ boolean grabMouse;
// to use .... // to use ....
static int multiply=2; static int multiply=2;
void WinError(char *msg);
int BPP;
byte *hicolortable;
short hicolortransmask1,hicolortransmask2;
int X_width;
int X_height;
static int disableVerticalMouse = 0; static int disableVerticalMouse = 0;
static int closed=0;
static int windowActive = 0;
HWND win; static int scr_w =0;
static HINSTANCE inst; static int scr_h =0;
static HDC dibDC; static int win_x, win_y;
static LOGPALETTE *palette; static int win_w, win_h;
static HPALETTE dibPal;
BITMAPINFO *bminfo;
static unsigned char *dibData;
static int bits8; //int palette_color[256];
int palette_color[256];
static int lastmousex = 0; static int lastmousex = 0;
static int lastmousey = 0; static int lastmousey = 0;
boolean mousemoved = false; boolean mousemoved = false;
boolean shmFinished;
//
// Translates the key
//
/*******
int xlatekey(SDL_keysym *key)
{
int rc;
switch(key->sym)
{
case SDLK_LEFT: rc = KEY_LEFTARROW; break;
case SDLK_RIGHT: rc = KEY_RIGHTARROW; break;
case SDLK_DOWN: rc = KEY_DOWNARROW; break;
case SDLK_UP: rc = KEY_UPARROW; break;
case SDLK_ESCAPE: rc = KEY_ESCAPE; break;
case SDLK_RETURN: rc = KEY_ENTER; break;
case SDLK_TAB: rc = KEY_TAB; break;
case SDLK_F1: rc = KEY_F1; break;
case SDLK_F2: rc = KEY_F2; break;
case SDLK_F3: rc = KEY_F3; break;
case SDLK_F4: rc = KEY_F4; break;
case SDLK_F5: rc = KEY_F5; break;
case SDLK_F6: rc = KEY_F6; break;
case SDLK_F7: rc = KEY_F7; break;
case SDLK_F8: rc = KEY_F8; break;
case SDLK_F9: rc = KEY_F9; break;
case SDLK_F10: rc = KEY_F10; break;
case SDLK_F11: rc = KEY_F11; break;
case SDLK_F12: rc = KEY_F12; break;
case SDLK_BACKSPACE:
case SDLK_DELETE: rc = KEY_BACKSPACE; break;
case SDLK_PAUSE: rc = KEY_PAUSE; break;
case SDLK_EQUALS: rc = KEY_EQUALS; break;
case SDLK_KP_MINUS:
case SDLK_MINUS: rc = KEY_MINUS; break;
case SDLK_LSHIFT:
case SDLK_RSHIFT:
rc = KEY_RSHIFT;
break;
case 'z':
case SDLK_LCTRL:
case SDLK_RCTRL:
rc = KEY_RCTRL;
break;
case SDLK_LALT:
case SDLK_LMETA:
case SDLK_RALT:
case SDLK_RMETA:
rc = KEY_RALT;
break;
default:
rc = key->sym;
break;
}
return rc;
}
**********/
void I_ShutdownGraphics(void) void I_ShutdownGraphics(void)
{ {
// SDL_Quit();
} }
@ -172,97 +89,81 @@ void I_StartFrame (void)
{ {
// er? // er?
//printf("start new frame\n\r" );
} }
/* This processes SDL events */ int test_for_event(void)
/***** { int retval;
void I_GetEvent(SDL_Event *Event) _asm
{ { push ebx
Uint8 buttonstate; push ecx
event_t event; push edx
push esi
switch (Event->type) push edi
{ mov eax,11
case SDL_KEYDOWN: int 0x40
event.type = ev_keydown; mov [retval], eax
event.data1 = xlatekey(&Event->key.keysym); pop edi
D_PostEvent(&event); pop esi
break; pop edx
case SDL_KEYUP: pop ecx
event.type = ev_keyup; pop ebx
event.data1 = xlatekey(&Event->key.keysym); };
D_PostEvent(&event); return retval;
break; };
case SDL_QUIT:
I_Quit();
break;
}
}
*******/
void I_GetEvent(void) void I_GetEvent(void)
{ {
MSG msg; event_t evnt;
POINT point; int val;
static LONG prevX, prevY; int key;
static int hadMouse = 0; //printf("begin get_event()\n\r");
event_t event; do
RECT rect; { val= test_for_event();
int lb, rb; switch(val)
static int prevlb = 0, prevrb = 0; { case EV_REDRAW:
BeginDraw();
DrawWindow(win_x,win_y,win_w,win_h,0x404040,3,0,0,0);
EndDraw();
BlitDIB();
break;
/* Dispatch all messages: */ case EV_KEY:
while ( PeekMessage(&msg, NULL, 0, 0xFFFFFFFF, PM_REMOVE) ) if(!get_key(&key))
{ {
TranslateMessage (&msg) ; switch(key)
DispatchMessage (&msg) ; { case 0xE0:
} case 0xE1:
continue;
/* Check mouse and generate events if necessary: */ default:
if ( !GetCursorPos(&point) ) if(key&0x80)
WinError("GetCursorPos() failed"); { //printf("key released\n\r");
if ( hadMouse && windowActive) evnt.type = ev_keyup;
{
lb = (GetAsyncKeyState(VK_LBUTTON) < 0);
rb = (GetAsyncKeyState(VK_RBUTTON) < 0);
if ( (prevX != point.x) || (prevY != point.y) ||
(prevlb != lb) || (prevrb != rb) )
{
event.type = ev_mouse;
event.data1 = lb | (rb << 1);
event.data2 = (point.x - prevX)*9;
if ( disableVerticalMouse )
event.data3 = 0;
else
event.data3 = (prevY - point.y)*9;
prevX = point.x;
prevY = point.y;
prevlb = lb;
prevrb = rb;
D_PostEvent(&event);
}
if ( grabMouse )
{
GetWindowRect(win, &rect);
if ( !SetCursorPos((rect.left + rect.right) / 2,
(rect.top + rect.bottom) / 2) )
WinError("SetCursorPos() failed");
prevX = (rect.left + rect.right) / 2;
prevY = (rect.top + rect.bottom) / 2;
}
} }
else else
{ { //printf("key pressed %x\n\r",key);
prevX = point.x; evnt.type = ev_keydown;
prevY = point.y; };
hadMouse = 1; key&=0x7F;
} evnt.data1=remap_key(key);
if ( evnt.data1 != 0 )
D_PostEvent(&evnt);
continue;
};
};
continue;
case EV_BUTTON:
switch(get_button_id())
{ case 1:
return;
default:;
};
};
}while(val);
} }
@ -272,10 +173,6 @@ void I_GetEvent(void)
// //
void I_StartTic (void) void I_StartTic (void)
{ {
// SDL_Event Event;
// while ( SDL_PollEvent(&Event) )
// I_GetEvent(&Event);
I_GetEvent(); I_GetEvent();
} }
@ -302,136 +199,49 @@ void I_ReadScreen (byte* scr)
// I_SetPalette // I_SetPalette
// //
typedef struct SDL_Color unsigned int colors[256];
{
byte r;
byte g;
byte b;
byte unused;
} SDL_Color;
SDL_Color colors[256];
void I_SetPalette (byte* palette) void I_SetPalette (byte* palette)
{ {
int i; int i;
RGBQUAD *rgb; unsigned int r;
unsigned int g;
unsigned int b;
// for ( i=0; i<256; ++i )
// for ( i=0; i<256; ++i ) {
// colors[i].r = gammatable[usegamma][*palette++];
// colors[i].g = gammatable[usegamma][*palette++];
// colors[i].b = gammatable[usegamma][*palette++];
// colors[i].unused = 0;
// }
// SDL_SetColors(screen, colors, 0, 256);
rgb = bminfo->bmiColors;
for ( i = 0; i < 256; i++ )
{ {
rgb->rgbRed = gammatable[usegamma][*palette++]; r = gammatable[usegamma][*palette++];
rgb->rgbGreen = gammatable[usegamma][*palette++]; g = gammatable[usegamma][*palette++];
rgb->rgbBlue = gammatable[usegamma][*palette++]; b = gammatable[usegamma][*palette++];
rgb->rgbReserved = 0; colors[i]= b|(g<<8)|(r<<16);
rgb++;
};
}
int makecol(int r, int g, int b)
{
// assert(BPP==2);
return (b >> 3) | ((g >> 3) << 5) | ((r >> 3) << 10);
}
int TranslateKey(unsigned k)
{
/*wtf? if ( (k >= VK_0) && (k <= VK_9) )*/
if ( (k >= 0x30) && (k <= 0x39) )
return (k - 0x30 + '0');
if ( (k >= 0x41) && (k <= 0x5a) )
return (k - 0x41 + 'a');
#define K(a,b) case a: return b;
switch ( k )
{
K(VK_LEFT, KEY_LEFTARROW);
K(VK_RIGHT, KEY_RIGHTARROW);
K(VK_UP, KEY_UPARROW);
K(VK_DOWN, KEY_DOWNARROW);
K(VK_BACK, KEY_BACKSPACE);
K(VK_TAB, KEY_TAB);
K(VK_RETURN, KEY_ENTER);
K(VK_SHIFT, KEY_RSHIFT);
K(VK_CONTROL, KEY_RCTRL);
K(VK_MENU, KEY_RALT);
K(VK_PAUSE, KEY_PAUSE);
K(VK_ESCAPE, KEY_ESCAPE);
K(VK_SPACE, ' ');
K(VK_DELETE, KEY_BACKSPACE);
K(VK_ADD, '+');
K(VK_SUBTRACT, KEY_MINUS);
K(0xBC, ',');
K(0xBE, '.');
K(VK_F1, KEY_F1);
K(VK_F2, KEY_F2);
K(VK_F3, KEY_F3);
K(VK_F4, KEY_F4);
K(VK_F5, KEY_F5);
K(VK_F6, KEY_F6);
K(VK_F7, KEY_F7);
K(VK_F8, KEY_F8);
K(VK_F9, KEY_F9);
K(VK_F10, KEY_F10);
K(VK_F11, KEY_F11);
K(VK_F12, KEY_F12);
} }
return 0;
} }
void WinError(char *msg) void BeginDraw()
{ { _asm
printf("Windows Error: %s, GetLastError(): %u\n", msg, GetLastError()); { push ebx
exit(EXIT_FAILURE); mov eax,12
} mov ebx, 1
int 0x40
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, pop ebx
WPARAM wparam, LPARAM lparam); };
};
void BlitDIB(void)
{
RECT rect;
GetClientRect(win, &rect);
if ( StretchDIBits(dibDC, rect.left, rect.top, rect.right-rect.left,
rect.bottom-rect.top, 0, 0, SCREENWIDTH*2,
SCREENHEIGHT*2, dibData, bminfo, DIB_RGB_COLORS,
SRCCOPY)
== GDI_ERROR )
WinError("StrecthDIBits failed");
GdiFlush();
}
void EndDraw()
{ _asm
{ push ebx
mov eax,12
mov ebx, 2
int 0x40
pop ebx
};
};
void I_InitGraphics(void) void I_InitGraphics(void)
{ {
static int firsttime=1; static int firsttime=1;
WNDCLASS wc; int frameX, frameY;
unsigned i, x, y, j;
WORD *d;
unsigned char *b;
int bits;
int frameX, frameY, capY;
RECT rect;
int width, height;
RGBQUAD *rgb;
int retval;
if (!firsttime) if (!firsttime)
return; return;
@ -446,8 +256,8 @@ void I_InitGraphics(void)
if (M_CheckParm("-4")) if (M_CheckParm("-4"))
multiply = 4; multiply = 4;
X_width = SCREENWIDTH * multiply; win_w = SCREENWIDTH * multiply;
X_height = SCREENHEIGHT * multiply; win_h = SCREENHEIGHT * multiply;
// check if the user wants to grab the mouse (quite unnice) // check if the user wants to grab the mouse (quite unnice)
grabMouse = !!M_CheckParm("-grabmouse"); grabMouse = !!M_CheckParm("-grabmouse");
@ -458,409 +268,111 @@ void I_InitGraphics(void)
/* Build and initialize the window: */ /* Build and initialize the window: */
inst = (HINSTANCE) GetModuleHandle(NULL); frameX = 0;
frameY = 18;
frameX = GetSystemMetrics(SM_CXFRAME); GetScreenSize(&scr_w, &scr_h);
frameY = GetSystemMetrics(SM_CYFRAME); win_x = (scr_w-win_w)/2;
capY = GetSystemMetrics(SM_CYCAPTION); win_y = (scr_h-win_h)/2;
wc.style = CS_HREDRAW | CS_VREDRAW; // hCursor = LoadCursor( 0, IDC_ARROW );
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = inst;
wc.hIcon = NULL;
if ( grabMouse )
wc.hCursor = LoadCursor( 0, IDC_ARROW );
else
wc.hCursor = LoadCursor( 0, IDC_ARROW );
/*wc.hbrBackground = GetStockObject( WHITE_BRUSH );*/
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "DoomWindowClass";
retval= RegisterClass(&wc); printf("I_InitGraphics: Client area: %ux%u\n\r", win_w, win_h);
width = X_width + 2*frameX; screen.pixels= (byte*) UserAlloc(640*400*4);
height = X_height + 2*frameY + capY; screen.h = win_w;
screen.w = win_h;
win = CreateWindow("DoomWindowClass", "NTDOOM",
WS_OVERLAPPEDWINDOW | WS_VISIBLE, 200, 200, width, height,
NULL, NULL, inst, NULL);
/* Display the window: */
ShowWindow(win, SW_SHOW);
UpdateWindow(win);
GetClientRect(win, &rect);
printf("I_InitGraphics: Client area: %ux%u\n",
rect.right-rect.left, rect.bottom-rect.top);
if ( (rect.right-rect.left) != X_width )
{
printf("I_InitGraphics: Fixing width\n");
width += X_width - (rect.right-rect.left);
MoveWindow(win, 0, 0, width, height, TRUE);
}
if ( (rect.bottom-rect.top) != X_height )
{
printf("I_InitGraphics: Fixing height\n");
height += X_height - (rect.bottom-rect.top);
MoveWindow(win, 0, 0, width, height, TRUE);
}
GetClientRect(win, &rect);
printf("I_InitGraphics: Client area: %ux%u\n",
rect.right-rect.left, rect.bottom-rect.top);
dibDC = GetDC(win);
BPP=1;
bits = 8; //GetDeviceCaps(dibDC, BITSPIXEL);
printf("I_InitGraphics: %i bpp screen\n", bits);
if ( BPP == 1 )
bminfo = malloc(sizeof(BITMAPINFOHEADER) + 4*256);
else
bminfo = malloc(sizeof(BITMAPINFOHEADER));
if ( BPP == 1 )
{
rgb = bminfo->bmiColors;
for ( i = 0; i < 256; i++ )
{
rgb->rgbRed = i;
rgb->rgbGreen = i;
rgb->rgbBlue = i;
rgb->rgbReserved = 0;
rgb++;
}
}
bminfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bminfo->bmiHeader.biWidth = 640; X_width;
bminfo->bmiHeader.biHeight = -400 ;X_height;
bminfo->bmiHeader.biPlanes = 1;
if ( BPP == 1 )
bminfo->bmiHeader.biBitCount = 8;
else
bminfo->bmiHeader.biBitCount = 16;
bminfo->bmiHeader.biCompression = BI_RGB;
bminfo->bmiHeader.biSizeImage = 0;
bminfo->bmiHeader.biXPelsPerMeter = 0;
bminfo->bmiHeader.biYPelsPerMeter = 0;
bminfo->bmiHeader.biClrUsed = 0;
bminfo->bmiHeader.biClrImportant = 0;
dibData = malloc(640*400*BPP);
// BlitDIB();
screen.pixels=(unsigned char *) (dibData);
screen.h=400;
screen.w=640;
screen.pitch=640; screen.pitch=640;
// screens[0] = malloc(320*200); BeginDraw();
DrawWindow(win_x,win_y,win_w,win_h,0x404040,3,0,0,0);
EndDraw();
/* Build magic highcolor table: */
if (BPP==2)
{
byte *tempptr, *tempptr2;
tempptr=hicolortable=(byte *)malloc(256*32*9);
for (i=0;i<32;i++)
{
for (j=0;j<256;j++)
{
*tempptr=j*gammatable[3][i*(256/32)]/256;
tempptr++;
}
}
for (i=1;i<=8;i++)
{
tempptr2=hicolortable;
for (j=0;j<(256*32);j++)
{
*tempptr=(byte)(((int)(*tempptr2))*(8-i)/8);
tempptr++; tempptr2++;
}
}
hicolortransmask1=makecol(127,127,127);
hicolortransmask2=makecol(63,63,63);
}
} }
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam) void conv(char *dst, char *src);
void BlitDIB()
{ {
event_t event; _asm
RECT rect; { push ebx
push ecx
switch ( message ) push edx
{ mov eax, 7
case WM_DESTROY: mov ebx, dword ptr [screen]
if ( grabMouse ) mov ecx, 0x02800190
{ xor edx, edx
ClipCursor(NULL); int 0x40
ShowCursor(TRUE); pop edx
pop ecx
pop ebx
} }
printf("WM_DESTROY\n"); };
PostQuitMessage(0);
closed = 1;
break;
case WM_MOVE:
GetWindowRect(win, &rect);
printf("%u,%u - %u, %u\n",
rect.left,rect.top,rect.right,rect.bottom);
ClipCursor(&rect);
break;
case WM_ACTIVATE:
printf("WM_ACTIVATE %u\n", (unsigned) LOWORD(wparam));
if ( LOWORD(wparam) )
{
if ( !windowActive )
{
if ( grabMouse )
{
ClipCursor(NULL); /* helps with Win95? */
GetWindowRect(win, &rect);
printf("%u,%u - %u, %u\n",
rect.left,rect.top,rect.right,rect.bottom);
ClipCursor(&rect);
ShowCursor(FALSE);
}
}
windowActive = 1;
if ( bits8 )
{
if ( SetPaletteEntries(dibPal, 0, 256, palette->palPalEntry) != 256 )
WinError("SetPaletteEntries failed");
if ( !UnrealizeObject(dibPal) )
WinError("UnrealizeObject failed");
if ( SelectPalette(dibDC, dibPal, FALSE) == NULL )
WinError("SelectPalette failed");
}
}
else
{
if ( grabMouse )
{
ClipCursor(NULL);
ShowCursor(TRUE);
}
windowActive = 0;
}
return DefWindowProc(hwnd, message, wparam, lparam);
case WM_KEYDOWN:
event.type = ev_keydown;
event.data1 = TranslateKey(wparam);
if ( event.data1 != 0 )
D_PostEvent(&event);
break;
case WM_KEYUP:
event.type = ev_keyup;
event.data1 = TranslateKey(wparam);
if ( event.data1 != 0 )
D_PostEvent(&event);
break;
default:
return(DefWindowProc(hwnd, message, wparam, lparam));
}
return 0;
}
// //
// I_FinishUpdate // I_FinishUpdate
// //
void I_FinishUpdate (void) void I_FinishUpdate (void)
{ {
char *dst0;
char *dst1;
char *src;
static int lasttic; int x, y;
int tics;
int i;
// draws little dots on the bottom of the screen
if (devparm)
{ i = I_GetTime();
tics = i - lasttic;
lasttic = i;
if (tics > 20)
tics = 20;
for (i=0 ; i<tics*2 ; i+=2)
screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff;
for ( ; i<20*2 ; i+=2)
screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
}
// scales the screen size before blitting it
if (multiply == 1)
{
unsigned char *olineptr;
unsigned char *ilineptr;
int y;
ilineptr = (unsigned char *) screens[0];
olineptr = (unsigned char *) screen.pixels;
y = SCREENHEIGHT;
while (y--)
{
memcpy(olineptr, ilineptr, screen.w);
ilineptr += SCREENWIDTH;
olineptr += screen.pitch;
}
}
else if (multiply == 2)
{
unsigned int *olineptrs[2];
unsigned int *ilineptr;
int x, y, i;
unsigned int twoopixels;
unsigned int twomoreopixels;
unsigned int fouripixels;
ilineptr = (unsigned int *) (screens[0]);
for (i=0 ; i<2 ; i++) {
olineptrs[i] =
(unsigned int *)&((byte *)screen.pixels)[i*screen.pitch];
}
dst0 = &((char *)screen.pixels)[0];
dst1 = dst0+640*3;
src= (char*)screens[0];
y = SCREENHEIGHT; y = SCREENHEIGHT;
while (y--) while (y--)
{ {
x = SCREENWIDTH; x = SCREENWIDTH;
do conv(dst0,src);
{ src+=320;
fouripixels = *ilineptr++; dst0+=640*3*2;
twoopixels = (fouripixels & 0xff000000) dst1+=640*3*2;
| ((fouripixels>>8) & 0xffff00)
| ((fouripixels>>16) & 0xff);
twomoreopixels = ((fouripixels<<16) & 0xff000000)
| ((fouripixels<<8) & 0xffff00)
| (fouripixels & 0xff);
*olineptrs[0]++ = twomoreopixels;
*olineptrs[1]++ = twomoreopixels;
*olineptrs[0]++ = twoopixels;
*olineptrs[1]++ = twoopixels;
} while (x-=4);
olineptrs[0] += screen.pitch/4;
olineptrs[1] += screen.pitch/4;
}
}
else if (multiply == 3)
{
unsigned int *olineptrs[3];
unsigned int *ilineptr;
int x, y, i;
unsigned int fouropixels[3];
unsigned int fouripixels;
ilineptr = (unsigned int *) (screens[0]);
for (i=0 ; i<3 ; i++) {
olineptrs[i] =
(unsigned int *)&((byte *)screen.pixels)[i*screen.pitch];
}
y = SCREENHEIGHT;
while (y--)
{
x = SCREENWIDTH;
do
{
fouripixels = *ilineptr++;
fouropixels[0] = (fouripixels & 0xff000000)
| ((fouripixels>>8) & 0xff0000)
| ((fouripixels>>16) & 0xffff);
fouropixels[1] = ((fouripixels<<8) & 0xff000000)
| (fouripixels & 0xffff00)
| ((fouripixels>>8) & 0xff);
fouropixels[2] = ((fouripixels<<16) & 0xffff0000)
| ((fouripixels<<8) & 0xff00)
| (fouripixels & 0xff);
*olineptrs[0]++ = fouropixels[2];
*olineptrs[1]++ = fouropixels[2];
*olineptrs[2]++ = fouropixels[2];
*olineptrs[0]++ = fouropixels[1];
*olineptrs[1]++ = fouropixels[1];
*olineptrs[2]++ = fouropixels[1];
*olineptrs[0]++ = fouropixels[0];
*olineptrs[1]++ = fouropixels[0];
*olineptrs[2]++ = fouropixels[0];
} while (x-=4);
olineptrs[0] += 2*screen.pitch/4;
olineptrs[1] += 2*screen.pitch/4;
olineptrs[2] += 2*screen.pitch/4;
}
} }
BlitDIB(); BlitDIB();
} }
void conv(char *dst, char *src)
/**
void I_InitGraphics(void)
{ {
_asm
{
push ebx
push ecx
push esi
push edi
static int firsttime=1; mov ecx, 320
int video_w, video_h, w, h; mov esi, [src]
byte video_bpp; mov edi, [dst]
unsigned int video_flags; cld
l1:
lodsb
movzx eax, al
mov eax, [colors+eax*4]
mov ebx, eax
bswap ebx
and ebx, 0xFF000000
or eax, ebx
mov [edi],eax
mov [edi+640*3], eax
shr eax, 8
mov [edi+4], ax
mov [edi+640*3+4], ax
add edi, 6
dec ecx
jnz l1
pop edi
pop esi
pop ecx
pop ebx
};
};
if (!firsttime)
return;
firsttime = 0;
video_flags = (SDL_SWSURFACE|SDL_HWPALETTE);
if (!!M_CheckParm("-fullscreen"))
video_flags |= SDL_FULLSCREEN;
if (M_CheckParm("-2"))
multiply = 2;
if (M_CheckParm("-3"))
multiply = 3;
// check if the user wants to grab the mouse (quite unnice)
grabMouse = !!M_CheckParm("-grabmouse");
video_w = w = SCREENWIDTH * multiply;
video_h = h = SCREENHEIGHT * multiply;
video_bpp = 8;
if ( multiply > 3 ) {
I_Error("Smallest available mode (%dx%d) is too large!",
video_w, video_h);
}
screen = SDL_SetVideoMode(video_w, video_h, 8, video_flags);
if ( screen == NULL ) {
I_Error("Could not set %dx%d video mode: %s", video_w, video_h,
SDL_GetError());
}
SDL_ShowCursor(0);
SDL_WM_SetCaption("MenuetOS-DOOM", "doom");
w = SCREENWIDTH * multiply;
h = SCREENHEIGHT * multiply;
if (multiply == 1 && !SDL_MUSTLOCK(screen) ) {
screens[0] = (unsigned char *) screen->pixels;
} else {
screens[0] = (unsigned char *) malloc (SCREENWIDTH * SCREENHEIGHT);
if ( screens[0] == NULL )
I_Error("Couldn't allocate screen memory");
}
}
*****/

View File

@ -26,8 +26,6 @@ rcsid[] = "$Id: m_argv.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include <string.h> #include <string.h>
#include "i_system.h"
int myargc; int myargc;
char** myargv; char** myargv;
@ -46,7 +44,7 @@ int M_CheckParm (char *check)
for (i = 1;i<myargc;i++) for (i = 1;i<myargc;i++)
{ {
if ( !I_strncasecmp(check, myargv[i], strlen(check)) ) if ( !strnicmp(check, myargv[i], strlen(check)) )
return i; return i;
} }

View File

@ -29,8 +29,9 @@ rcsid[] = "$Id: m_misc.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
//#include "//kolibc.h"
extern int access(char *file, int mode); //extern int access(char *file, int mode);
#include "doomdef.h" #include "doomdef.h"
@ -119,7 +120,7 @@ M_WriteFile
if (handle == NULL) if (handle == NULL)
return false; return false;
count = fwrite (source, 1, length, handle); // count = fwrite (source, 1, length, handle);
fclose (handle); fclose (handle);
if (count < length) if (count < length)
@ -141,6 +142,9 @@ M_ReadFile
int count, length; int count, length;
byte *buf; byte *buf;
handle=0;
buf=0;
handle = fopen (name, "rb"); handle = fopen (name, "rb");
if (handle == NULL) if (handle == NULL)
I_Error ("Couldn't read file %s", name); I_Error ("Couldn't read file %s", name);
@ -228,6 +232,12 @@ default_t defaults[] =
{"key_left",&key_left, KEY_LEFTARROW}, {"key_left",&key_left, KEY_LEFTARROW},
{"key_up",&key_up, KEY_UPARROW}, {"key_up",&key_up, KEY_UPARROW},
{"key_down",&key_down, KEY_DOWNARROW}, {"key_down",&key_down, KEY_DOWNARROW},
// {"key_right",&key_right, KEY_D},
// {"key_left",&key_left, KEY_A},
// {"key_up",&key_up, KEY_W},
// {"key_down",&key_down, KEY_S},
{"key_strafeleft",&key_strafeleft, ','}, {"key_strafeleft",&key_strafeleft, ','},
{"key_straferight",&key_straferight, '.'}, {"key_straferight",&key_straferight, '.'},
@ -310,6 +320,8 @@ void M_SaveDefaults (void)
// //
extern byte scantokey[128]; extern byte scantokey[128];
size_t FileSize(FILE *handle);
void M_LoadDefaults (void) void M_LoadDefaults (void)
{ {
int i; int i;
@ -320,7 +332,10 @@ void M_LoadDefaults (void)
char* newstring; char* newstring;
int parm; int parm;
boolean isstring; boolean isstring;
char *buf;
char *p;
size_t val;
// set everything to base values // set everything to base values
numdefaults = sizeof(defaults)/sizeof(defaults[0]); numdefaults = sizeof(defaults)/sizeof(defaults[0]);
for (i=0 ; i<numdefaults ; i++) for (i=0 ; i<numdefaults ; i++)
@ -335,15 +350,24 @@ void M_LoadDefaults (void)
} }
else else
defaultfile = basedefault; defaultfile = basedefault;
/**********
// read the file in, overriding any set defaults // read the file in, overriding any set defaults
f = fopen (defaultfile, "r"); f = fopen (defaultfile, "rb");
if (f) if (f)
{ {
while (!feof(f)) len=FileSize(f)+1;
buf = malloc(len);
memset(buf,0,len);
val = fread(buf,1,len,f);
fclose (f);
p = buf;
while(*p)
{ {
isstring = false; isstring = false;
if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2)
if (sscanf (p, "%79s %[^\n]\n", def, strparm) == 2)
{ {
if (strparm[0] == '"') if (strparm[0] == '"')
{ {
@ -354,7 +378,8 @@ void M_LoadDefaults (void)
strparm[len-1] = 0; strparm[len-1] = 0;
strcpy(newstring, strparm+1); strcpy(newstring, strparm+1);
} }
else if (strparm[0] == '0' && strparm[1] == 'x') else
if (strparm[0] == '0' && strparm[1] == 'x')
sscanf(strparm+2, "%x", &parm); sscanf(strparm+2, "%x", &parm);
else else
sscanf(strparm, "%i", &parm); sscanf(strparm, "%i", &parm);
@ -364,17 +389,17 @@ void M_LoadDefaults (void)
if (!isstring) if (!isstring)
*defaults[i].location = parm; *defaults[i].location = parm;
else else
*defaults[i].location = *defaults[i].location = (int) newstring;
(int) newstring;
break; break;
} }
} };
} p=strchr(p, '\n')+1;
};
free(buf);
};
};
fclose (f);
}
**********/
}
// //

View File

@ -31,6 +31,9 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include "m_swap.h" #include "m_swap.h"
// Not needed with big endian.
#ifndef __BIG_ENDIAN__
// Swap 16bit, that is, MSB and LSB byte. // Swap 16bit, that is, MSB and LSB byte.
unsigned short SwapSHORT(unsigned short x) unsigned short SwapSHORT(unsigned short x)
{ {
@ -49,3 +52,6 @@ unsigned long SwapLONG( unsigned long x)
} }
#endif

View File

@ -27,19 +27,11 @@
static const char static const char
rcsid[] = "$Id: r_data.c,v 1.4 1997/02/03 16:47:55 b1 Exp $"; rcsid[] = "$Id: r_data.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";
#ifdef __BEOS__
#ifdef __GNUC__
extern void *alloca(int);
#else
#include <alloca.h>
#endif
#endif /* __BEOS__ */
#include "m_swap.h"
#include "i_system.h" #include "i_system.h"
#include "z_zone.h" #include "z_zone.h"
#include "m_swap.h"
#include "w_wad.h" #include "w_wad.h"
#include "doomdef.h" #include "doomdef.h"
@ -49,8 +41,11 @@ extern void *alloca(int);
#include "doomstat.h" #include "doomstat.h"
#include "r_sky.h" #include "r_sky.h"
#include "r_data.h"
#include <malloc.h> #include <malloc.h>
#include "r_data.h"
// //
// Graphics. // Graphics.
// DOOM graphics for walls and sprites // DOOM graphics for walls and sprites
@ -122,7 +117,7 @@ typedef struct
// All the patches[patchcount] // All the patches[patchcount]
// are drawn back to front into the cached texture. // are drawn back to front into the cached texture.
short patchcount; short int patchcount;
texpatch_t patches[1]; texpatch_t patches[1];
} texture_t; } texture_t;
@ -291,6 +286,8 @@ void R_GenerateComposite (int texnum)
Z_ChangeTag (block, PU_CACHE); Z_ChangeTag (block, PU_CACHE);
} }
// //
// R_GenerateLookup // R_GenerateLookup
// //
@ -351,11 +348,11 @@ void R_GenerateLookup (int texnum)
{ {
if (!patchcount[x]) if (!patchcount[x])
{ {
printf("R_GenerateLookup: column without a patch (%s)\n", printf ("R_GenerateLookup: column without a patch (%s)\n",
texture->name); texture->name);
return; return;
} }
// I_Error ("R_GenerateLookup: column without a patch"); // I_Error ("R_GenerateLookup: column without a patch");
if (patchcount[x] > 1) if (patchcount[x] > 1)
{ {
@ -531,17 +528,7 @@ void R_InitTextures (void)
texture->height = SHORT(mtexture->height); texture->height = SHORT(mtexture->height);
texture->patchcount = SHORT(mtexture->patchcount); texture->patchcount = SHORT(mtexture->patchcount);
// memcpy() generates a BUS error on Solaris with optimization on */
#if 1
memcpy (texture->name, mtexture->name, sizeof(texture->name)); memcpy (texture->name, mtexture->name, sizeof(texture->name));
#else
{ char *src; char *dst;
src = (char *)mtexture->name;
dst = (char *)texture->name;
for (j=0; j<sizeof(texture->name); ++j )
*dst++ = *src++;
}
#endif
mpatch = &mtexture->patches[0]; mpatch = &mtexture->patches[0];
patch = &texture->patches[0]; patch = &texture->patches[0];
@ -665,13 +652,13 @@ void R_InitColormaps (void)
void R_InitData (void) void R_InitData (void)
{ {
R_InitTextures (); R_InitTextures ();
printf ("\nInitTextures"); printf ("InitTextures\n\r");
R_InitFlats (); R_InitFlats ();
printf ("\nInitFlats"); printf ("InitFlats\n\r");
R_InitSpriteLumps (); R_InitSpriteLumps ();
printf ("\nInitSprites"); printf ("InitSprites\n\r");
R_InitColormaps (); R_InitColormaps ();
printf ("\nInitColormaps"); printf ("InitColormaps\n\r");
} }
@ -713,14 +700,12 @@ int R_CheckTextureNumForName (char *name)
return 0; return 0;
for (i=0 ; i<numtextures ; i++) for (i=0 ; i<numtextures ; i++)
if (!I_strncasecmp (textures[i]->name, name, 8) ) if (!strnicmp (textures[i]->name, name, 8) )
return i; return i;
return -1; return -1;
} }
// //
// R_TextureNumForName // R_TextureNumForName
// Calls R_CheckTextureNumForName, // Calls R_CheckTextureNumForName,

View File

@ -24,7 +24,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static const char rcsid[] = "$Id: r_main.c,v 1.5 1997/02/03 22:45:12 b1 Exp $"; //static const char rcsid[] = "$Id: r_main.c,v 1.5 1997/02/03 22:45:12 b1 Exp $";
@ -773,22 +773,22 @@ extern int screenblocks;
void R_Init (void) void R_Init (void)
{ {
R_InitData (); R_InitData ();
printf ("\nR_InitData"); printf ("R_InitData\n\r");
R_InitPointToAngle (); R_InitPointToAngle ();
printf ("\nR_InitPointToAngle"); printf ("R_InitPointToAngle\n\r");
R_InitTables (); R_InitTables ();
// viewwidth / viewheight / detailLevel are set by the defaults // viewwidth / viewheight / detailLevel are set by the defaults
printf ("\nR_InitTables"); printf ("R_InitTables\n\r");
R_SetViewSize (screenblocks, detailLevel); R_SetViewSize (screenblocks, detailLevel);
R_InitPlanes (); R_InitPlanes ();
printf ("\nR_InitPlanes"); printf ("R_InitPlanes\n\r");
R_InitLightTables (); R_InitLightTables ();
printf ("\nR_InitLightTables"); printf ("R_InitLightTables\n\r");
R_InitSkyMap (); R_InitSkyMap ();
printf ("\nR_InitSkyMap"); printf ("R_InitSkyMap\n\r");
R_InitTranslationTables (); R_InitTranslationTables ();
printf ("\nR_InitTranslationsTables"); printf ("R_InitTranslationsTables\n\r");
framecount = 0; framecount = 0;
} }

View File

@ -169,7 +169,7 @@ void S_Init
printf("S_Init: default sfx volume %d\n", sfxVolume); printf("S_Init: default sfx volume %d\n", sfxVolume);
I_CreateSound(); //I_CreateSound();
numChannels = NUM_CHANNELS; numChannels = NUM_CHANNELS;
// Whatever these did with DMX, these are rather dummies now. // Whatever these did with DMX, these are rather dummies now.
@ -372,8 +372,7 @@ void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
// Assigns the handle to one of the channels in the // Assigns the handle to one of the channels in the
// mix/output buffer. // mix/output buffer.
//WriteDebug("I_StartSound...\n"); //WriteDebug("I_StartSound...\n");
channels[cnum].handle = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin); channels[cnum].handle = I_StartSound(sfx_id,volume,sep,pitch,priority);
//cnum = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin);
channels[cnum].handle = cnum; channels[cnum].handle = cnum;
channels[cnum].sfxinfo = sfx; channels[cnum].sfxinfo = sfx;
channels[cnum].origin = origin; channels[cnum].origin = origin;

View File

@ -32,6 +32,8 @@ rcsid[] = "$Id: st_lib.c,v 1.4 1997/02/03 16:47:56 b1 Exp $";
#include "z_zone.h" #include "z_zone.h"
#include "v_video.h" #include "v_video.h"
#include "m_swap.h"
#include "i_system.h" #include "i_system.h"
#include "w_wad.h" #include "w_wad.h"
@ -94,8 +96,8 @@ STlib_drawNum
int numdigits = n->width; int numdigits = n->width;
int num = *n->num; int num = *n->num;
int w = (n->p[0]->width); int w = SHORT(n->p[0]->width);
int h = (n->p[0]->height); int h = SHORT(n->p[0]->height);
int x = n->x; int x = n->x;
int neg; int neg;
@ -222,10 +224,10 @@ STlib_updateMultIcon
{ {
if (mi->oldinum != -1) if (mi->oldinum != -1)
{ {
x = mi->x - (mi->p[mi->oldinum]->leftoffset); x = mi->x - SHORT(mi->p[mi->oldinum]->leftoffset);
y = mi->y - (mi->p[mi->oldinum]->topoffset); y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset);
w = (mi->p[mi->oldinum]->width); w = SHORT(mi->p[mi->oldinum]->width);
h = (mi->p[mi->oldinum]->height); h = SHORT(mi->p[mi->oldinum]->height);
if (y - ST_Y < 0) if (y - ST_Y < 0)
I_Error("updateMultIcon: y - ST_Y < 0"); I_Error("updateMultIcon: y - ST_Y < 0");
@ -271,10 +273,10 @@ STlib_updateBinIcon
if (*bi->on if (*bi->on
&& (bi->oldval != *bi->val || refresh)) && (bi->oldval != *bi->val || refresh))
{ {
x = bi->x - (bi->p->leftoffset); x = bi->x - SHORT(bi->p->leftoffset);
y = bi->y - (bi->p->topoffset); y = bi->y - SHORT(bi->p->topoffset);
w = (bi->p->width); w = SHORT(bi->p->width);
h = (bi->p->height); h = SHORT(bi->p->height);
if (y - ST_Y < 0) if (y - ST_Y < 0)
I_Error("updateBinIcon: y - ST_Y < 0"); I_Error("updateBinIcon: y - ST_Y < 0");

View File

@ -1074,7 +1074,7 @@ void ST_drawWidgets(boolean refresh)
STlib_updateBinIcon(&w_armsbg, refresh); STlib_updateBinIcon(&w_armsbg, refresh);
for (i=0;i<5;i++) for (i=0;i<6;i++)
STlib_updateMultIcon(&w_arms[i], refresh); STlib_updateMultIcon(&w_arms[i], refresh);
STlib_updateMultIcon(&w_faces, refresh); STlib_updateMultIcon(&w_faces, refresh);
@ -1273,7 +1273,7 @@ void ST_initData(void)
for (i=0;i<3;i++) for (i=0;i<3;i++)
keyboxes[i] = -1; keyboxes[i] = -1;
// STlib_init(); STlib_init();
} }

View File

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

View File

@ -24,8 +24,6 @@
static const char static const char
rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $"; rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
#include <windows.h>
#include <dsound.h>
#include "sounds.h" #include "sounds.h"
char MsgText[256]; char MsgText[256];
@ -67,13 +65,13 @@ void I_CreateSound(void)
hret = DirectSoundCreate8(NULL, &lpDS, NULL); hret = DirectSoundCreate8(NULL, &lpDS, NULL);
if (hret != DS_OK) if (hret != DS_OK)
{ {
printf("failed DirectSoundCreate"); //printf("failed DirectSoundCreate");
return; return;
} }
hret = lpDS->lpVtbl->SetCooperativeLevel(lpDS, win, DSSCL_PRIORITY); hret = lpDS->lpVtbl->SetCooperativeLevel(lpDS, win, DSSCL_PRIORITY);
if (hret != DS_OK) if (hret != DS_OK)
printf("failled DirectSound.SetCooperativeLevel"); //printf("failled DirectSound.SetCooperativeLevel");
memset( &wfx,0, sizeof(WAVEFORMATEX) ); memset( &wfx,0, sizeof(WAVEFORMATEX) );
wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.wFormatTag = WAVE_FORMAT_PCM;
@ -119,7 +117,7 @@ void I_SubmitSound(signed short *mixbuffer)
hret=lpMix[mixbuff]->lpVtbl->Lock(lpMix[mixbuff],0,MIXBUFFERSIZE,&pPtr1, hret=lpMix[mixbuff]->lpVtbl->Lock(lpMix[mixbuff],0,MIXBUFFERSIZE,&pPtr1,
&dwSize1,&pPtr2,&dwSize2,0); &dwSize1,&pPtr2,&dwSize2,0);
if (hret!=DS_OK) if (hret!=DS_OK)
{ printf("Error locking on play start"); { //printf("Error locking on play start");
return ; return ;
} }
memcpy(pPtr1, (void*)mixbuffer, MIXBUFFERSIZE); memcpy(pPtr1, (void*)mixbuffer, MIXBUFFERSIZE);

View File

@ -40,6 +40,27 @@ rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";
#include <malloc.h> #include <malloc.h>
extern char *main_file;
#ifdef DLHEAP
void* _cdecl dlmalloc(size_t);
void _cdecl dlfree(void*);
void _cdecl mf_init();
#define malloc dlmalloc
#define free dlfree
#define realloc dlrealloc
#endif
size_t FileSize(FILE *handle);
int _stdcall read_file (char *name, void *buff,
size_t offset, size_t count, size_t *reads);
// //
// GLOBALS // GLOBALS
// //
@ -50,19 +71,6 @@ int numlumps;
void** lumpcache; void** lumpcache;
int filelength (FILE *handle)
{
unsigned long pos, size;
pos = ftell(handle);
fseek(handle, 0, SEEK_END);
size = ftell(handle);
fseek(handle, pos, SEEK_SET);
return (int)size;
}
void void
ExtractFileBase ExtractFileBase
( char* path, ( char* path,
@ -115,13 +123,6 @@ ExtractFileBase
// specially to allow map reloads. // specially to allow map reloads.
// But: the reload feature is a fragile hack... // But: the reload feature is a fragile hack...
#ifdef __BEOS__
#ifdef __GNUC__
extern void *alloca(int);
#else
#include <alloca.h>
#endif
#endif /* __BEOS__ */
int reloadlump; int reloadlump;
char* reloadname; char* reloadname;
@ -138,6 +139,8 @@ void W_AddFile (char *filename)
filelump_t* fileinfo; filelump_t* fileinfo;
filelump_t singleinfo; filelump_t singleinfo;
int storehandle; int storehandle;
int err;
size_t bytes;
// open the file and add to directory // open the file and add to directory
@ -155,24 +158,23 @@ void W_AddFile (char *filename)
return; return;
} }
printf (" adding %s\n",filename); printf (" adding %s\n\r",filename);
startlump = numlumps; startlump = numlumps;
if (I_strncasecmp (filename+strlen(filename)-3 , "wad", 3 ) ) if (strnicmp (filename+strlen(filename)-3 , "wad", 3 ) )
{ {
// single lump file // single lump file
fileinfo = &singleinfo; fileinfo = &singleinfo;
singleinfo.filepos = 0; singleinfo.filepos = 0;
singleinfo.size = LONG(filelength(handle)); singleinfo.size = FileSize(handle);
ExtractFileBase (filename, singleinfo.name); ExtractFileBase (filename, singleinfo.name);
numlumps++; numlumps++;
} }
else else
{ {
//WAD file //WAD file
printf("f1 at %x,%u\n",&header,handle);
fread (&header, 1, sizeof(header), handle); fread (&header, 1, sizeof(header), handle);
printf("f2\n");
if (strncmp(header.identification,"IWAD",4)) if (strncmp(header.identification,"IWAD",4))
{ {
printf("No IWAD id\n"); printf("No IWAD id\n");
@ -182,23 +184,19 @@ void W_AddFile (char *filename)
I_Error ("Wad file %s doesn't have IWAD " I_Error ("Wad file %s doesn't have IWAD "
"or PWAD id\n", filename); "or PWAD id\n", filename);
} }
// printf("WAD magic OK\n"); printf("WAD magic OK\n");
// ???modifiedgame = true; // ???modifiedgame = true;
} }
printf("after checking hdr\n");
header.numlumps = LONG(header.numlumps); header.numlumps = LONG(header.numlumps);
printf("%u lumps in WAD\n",header.numlumps);
header.infotableofs = LONG(header.infotableofs); header.infotableofs = LONG(header.infotableofs);
printf("infor table at %x\n",header.infotableofs);
length = header.numlumps*sizeof(filelump_t); length = header.numlumps*sizeof(filelump_t);
printf("length %u\n",length);
fileinfo = alloca(length); fileinfo = alloca(length);
printf("seeking to info table\n");
fseek (handle, header.infotableofs, SEEK_SET); fseek (handle, header.infotableofs, SEEK_SET);
printf("f3\n");
fread (fileinfo, 1, length, handle); fread (fileinfo, 1, length, handle);
printf("f4\n");
numlumps += header.numlumps; numlumps += header.numlumps;
} }
@ -249,17 +247,14 @@ void W_Reload (void)
if ( (handle = fopen (reloadname,"rb")) == NULL) if ( (handle = fopen (reloadname,"rb")) == NULL)
I_Error ("W_Reload: couldn't open %s",reloadname); I_Error ("W_Reload: couldn't open %s",reloadname);
printf("f5\n");
fread (&header, 1, sizeof(header), handle); fread (&header, 1, sizeof(header), handle);
printf("f6\n");
lumpcount = LONG(header.numlumps); lumpcount = LONG(header.numlumps);
header.infotableofs = LONG(header.infotableofs); header.infotableofs = LONG(header.infotableofs);
length = lumpcount*sizeof(filelump_t); length = lumpcount*sizeof(filelump_t);
fileinfo = malloc (length); fileinfo = malloc (length);
fseek (handle, header.infotableofs, SEEK_SET); fseek (handle, header.infotableofs, SEEK_SET);
printf("f7\n");
fread (fileinfo, 1, length, handle); fread (fileinfo, 1, length, handle);
printf("f8\n");
// Fill in lumpinfo // Fill in lumpinfo
lump_p = &lumpinfo[reloadlump]; lump_p = &lumpinfo[reloadlump];
@ -278,8 +273,6 @@ void W_Reload (void)
fclose (handle); fclose (handle);
} }
// //
// W_InitMultipleFiles // W_InitMultipleFiles
// Pass a null terminated list of files to use. // Pass a null terminated list of files to use.
@ -301,7 +294,7 @@ void W_InitMultipleFiles (char** filenames)
numlumps = 0; numlumps = 0;
// will be realloced as lumps are added // will be realloced as lumps are added
lumpinfo = malloc(1); lumpinfo = malloc(16384);
for ( ; *filenames ; filenames++) for ( ; *filenames ; filenames++)
W_AddFile (*filenames); W_AddFile (*filenames);
@ -440,6 +433,7 @@ W_ReadLump
int c; int c;
lumpinfo_t* l; lumpinfo_t* l;
FILE *handle; FILE *handle;
size_t bytes;
if (lump >= numlumps) if (lump >= numlumps)
I_Error ("W_ReadLump: %i >= numlumps",lump); I_Error ("W_ReadLump: %i >= numlumps",lump);
@ -482,7 +476,7 @@ W_CacheLumpNum
{ {
byte* ptr; byte* ptr;
if ((unsigned)lump >= numlumps) if ((unsigned)lump >= (unsigned)numlumps)
I_Error ("W_CacheLumpNum: %i >= numlumps",lump); I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
if (!lumpcache[lump]) if (!lumpcache[lump])
@ -568,14 +562,21 @@ void W_Profile (void)
for ( ; j<8 ; j++) for ( ; j<8 ; j++)
name[j] = ' '; name[j] = ' ';
printf ("%s ",name); //printf ("%s ",name);
for (j=0 ; j<profilecount ; j++) for (j=0 ; j<profilecount ; j++)
fprintf (f," %c",info[i][j]); fprintf (f," %c",info[i][j]);
printf ("\n"); //printf ("\n");
} }
fclose (f); fclose (f);
} }
#endif #endif

View File

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