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

View File

@ -674,8 +674,7 @@ void TryRunTics (void)
frameon++;
if (debugfile)
fprintf (debugfile,
"=======real: %i avail: %i game: %i\n",
printf ( "=======real: %i avail: %i game: %i\n",
realtics, availabletics,counts);
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>
// Functions.
#include "m_swap.h"
#include "i_system.h"
#include "m_swap.h"
#include "z_zone.h"
#include "v_video.h"
#include "w_wad.h"

View File

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

View File

@ -24,24 +24,32 @@
static const char
rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $";
//#include "SDL.h"
#include "doomdef.h"
#include "m_argv.h"
#include "d_main.h"
#include "kolibri.h"
int
main( int argc, char** argv)
int main(int argc, char **argv)
{
static char * tmp[]=
{"/hd/1/menuetos/doom/mdoom",
NULL};
// static char * tmp[]=
// {"/hd/1/menuetos/doom/mdoom",
// NULL};
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 ();

View File

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

View File

@ -332,8 +332,8 @@ void I_SetChannels()
channels[i] = 0;
}
for (i=-128 ; i<128 ; i++)
steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
// for (i=-128 ; i<128 ; i++)
// steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
// Generates volume lookup tables
// which also turn the unsigned samples
@ -515,7 +515,7 @@ void I_UpdateSound( void )
leftout += 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 <stdarg.h>
#include <ctype.h>
//#include "SDL.h"
//#include "SDL_timer.h"
#include "doomdef.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 "kolibri.h"
int mb_used = 6;
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);
}
int mb_used = 8;
void
I_Tactile
@ -91,21 +76,17 @@ byte* I_ZoneBase (int* size)
// returns time in 1/35 second tics
//
__declspec(dllimport) unsigned int __stdcall GetTickCount(void);
int I_GetTime (void)
{
unsigned int tm;
// _asm
// {
// mov eax, 26
// mov ebx, 9
// int 0x40
// mov [tm], eax
// };
tm=GetTickCount()/10;
_asm
{ push ebx
mov eax, 26
mov ebx, 9
int 0x40
mov dword ptr [tm], eax
pop ebx
};
return (tm*TICRATE)/100;
}
@ -118,7 +99,7 @@ int I_GetTime (void)
void I_Init (void)
{
I_InitGraphics();
I_InitSound();
// I_InitSound();
}
//
@ -148,6 +129,7 @@ void I_EndRead(void)
{
}
/***********
byte* I_AllocLow(int length)
{
byte* mem;
@ -156,7 +138,7 @@ byte* I_AllocLow(int length)
memset (mem,0,length);
return mem;
}
************/
//
// I_Error
@ -170,8 +152,8 @@ void I_Error (char *error, ...)
// Message first.
va_start (argptr,error);
printf ("Error: ");
printf (argptr);
printf ("\n");
printf (error,argptr);
printf ("\n\r");
va_end (argptr);
// 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 "SDL.h"
//#include "m_swap.h"
#include "m_swap.h"
#include "doomstat.h"
#include "i_system.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 "doomdef.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "kolibri.h"
void BlitDIB();
typedef struct SURFACE
{
unsigned char *pixels;
int w, h;
int pitch;
unsigned char *pixels;
int offset;
} SURFACE;
@ -58,109 +58,26 @@ boolean grabMouse;
// to use ....
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 closed=0;
static int windowActive = 0;
HWND win;
static HINSTANCE inst;
static HDC dibDC;
static LOGPALETTE *palette;
static HPALETTE dibPal;
BITMAPINFO *bminfo;
static unsigned char *dibData;
static int bits8;
int palette_color[256];
static int scr_w =0;
static int scr_h =0;
static int win_x, win_y;
static int win_w, win_h;
//int palette_color[256];
static int lastmousex = 0;
static int lastmousey = 0;
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)
{
// SDL_Quit();
}
@ -172,97 +89,81 @@ void I_StartFrame (void)
{
// er?
//printf("start new frame\n\r" );
}
/* This processes SDL events */
/*****
void I_GetEvent(SDL_Event *Event)
{
Uint8 buttonstate;
event_t event;
switch (Event->type)
{
case SDL_KEYDOWN:
event.type = ev_keydown;
event.data1 = xlatekey(&Event->key.keysym);
D_PostEvent(&event);
break;
case SDL_KEYUP:
event.type = ev_keyup;
event.data1 = xlatekey(&Event->key.keysym);
D_PostEvent(&event);
break;
case SDL_QUIT:
I_Quit();
break;
}
}
*******/
int test_for_event(void)
{ int retval;
_asm
{ push ebx
push ecx
push edx
push esi
push edi
mov eax,11
int 0x40
mov [retval], eax
pop edi
pop esi
pop edx
pop ecx
pop ebx
};
return retval;
};
void I_GetEvent(void)
{
MSG msg;
POINT point;
static LONG prevX, prevY;
static int hadMouse = 0;
event_t event;
RECT rect;
int lb, rb;
static int prevlb = 0, prevrb = 0;
event_t evnt;
int val;
int key;
//printf("begin get_event()\n\r");
do
{ val= test_for_event();
switch(val)
{ case EV_REDRAW:
BeginDraw();
DrawWindow(win_x,win_y,win_w,win_h,0x404040,3,0,0,0);
EndDraw();
BlitDIB();
break;
/* Dispatch all messages: */
while ( PeekMessage(&msg, NULL, 0, 0xFFFFFFFF, PM_REMOVE) )
case EV_KEY:
if(!get_key(&key))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
/* Check mouse and generate events if necessary: */
if ( !GetCursorPos(&point) )
WinError("GetCursorPos() failed");
if ( hadMouse && windowActive)
{
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;
}
switch(key)
{ case 0xE0:
case 0xE1:
continue;
default:
if(key&0x80)
{ //printf("key released\n\r");
evnt.type = ev_keyup;
}
else
{
prevX = point.x;
prevY = point.y;
hadMouse = 1;
}
{ //printf("key pressed %x\n\r",key);
evnt.type = ev_keydown;
};
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)
{
// SDL_Event Event;
// while ( SDL_PollEvent(&Event) )
// I_GetEvent(&Event);
I_GetEvent();
}
@ -302,136 +199,49 @@ void I_ReadScreen (byte* scr)
// I_SetPalette
//
typedef struct SDL_Color
{
byte r;
byte g;
byte b;
byte unused;
} SDL_Color;
SDL_Color colors[256];
unsigned int colors[256];
void I_SetPalette (byte* palette)
{
int i;
RGBQUAD *rgb;
unsigned int r;
unsigned int g;
unsigned int b;
//
// 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++ )
for ( i=0; i<256; ++i )
{
rgb->rgbRed = gammatable[usegamma][*palette++];
rgb->rgbGreen = gammatable[usegamma][*palette++];
rgb->rgbBlue = gammatable[usegamma][*palette++];
rgb->rgbReserved = 0;
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);
r = gammatable[usegamma][*palette++];
g = gammatable[usegamma][*palette++];
b = gammatable[usegamma][*palette++];
colors[i]= b|(g<<8)|(r<<16);
}
return 0;
}
void WinError(char *msg)
{
printf("Windows Error: %s, GetLastError(): %u\n", msg, GetLastError());
exit(EXIT_FAILURE);
}
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
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 BeginDraw()
{ _asm
{ push ebx
mov eax,12
mov ebx, 1
int 0x40
pop ebx
};
};
void EndDraw()
{ _asm
{ push ebx
mov eax,12
mov ebx, 2
int 0x40
pop ebx
};
};
void I_InitGraphics(void)
{
static int firsttime=1;
WNDCLASS wc;
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;
int frameX, frameY;
if (!firsttime)
return;
@ -446,8 +256,8 @@ void I_InitGraphics(void)
if (M_CheckParm("-4"))
multiply = 4;
X_width = SCREENWIDTH * multiply;
X_height = SCREENHEIGHT * multiply;
win_w = SCREENWIDTH * multiply;
win_h = SCREENHEIGHT * multiply;
// check if the user wants to grab the mouse (quite unnice)
grabMouse = !!M_CheckParm("-grabmouse");
@ -458,409 +268,111 @@ void I_InitGraphics(void)
/* Build and initialize the window: */
inst = (HINSTANCE) GetModuleHandle(NULL);
frameX = 0;
frameY = 18;
frameX = GetSystemMetrics(SM_CXFRAME);
frameY = GetSystemMetrics(SM_CYFRAME);
capY = GetSystemMetrics(SM_CYCAPTION);
GetScreenSize(&scr_w, &scr_h);
win_x = (scr_w-win_w)/2;
win_y = (scr_h-win_h)/2;
wc.style = CS_HREDRAW | CS_VREDRAW;
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";
// hCursor = LoadCursor( 0, IDC_ARROW );
retval= RegisterClass(&wc);
printf("I_InitGraphics: Client area: %ux%u\n\r", win_w, win_h);
width = X_width + 2*frameX;
height = X_height + 2*frameY + capY;
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.pixels= (byte*) UserAlloc(640*400*4);
screen.h = win_w;
screen.w = win_h;
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;
RECT rect;
switch ( message )
{
case WM_DESTROY:
if ( grabMouse )
{
ClipCursor(NULL);
ShowCursor(TRUE);
_asm
{ push ebx
push ecx
push edx
mov eax, 7
mov ebx, dword ptr [screen]
mov ecx, 0x02800190
xor edx, edx
int 0x40
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
//
void I_FinishUpdate (void)
{
char *dst0;
char *dst1;
char *src;
static int lasttic;
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];
}
int x, y;
dst0 = &((char *)screen.pixels)[0];
dst1 = dst0+640*3;
src= (char*)screens[0];
y = SCREENHEIGHT;
while (y--)
{
x = SCREENWIDTH;
do
{
fouripixels = *ilineptr++;
twoopixels = (fouripixels & 0xff000000)
| ((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;
}
conv(dst0,src);
src+=320;
dst0+=640*3*2;
dst1+=640*3*2;
}
BlitDIB();
}
/**
void I_InitGraphics(void)
void conv(char *dst, char *src)
{
_asm
{
push ebx
push ecx
push esi
push edi
static int firsttime=1;
int video_w, video_h, w, h;
byte video_bpp;
unsigned int video_flags;
mov ecx, 320
mov esi, [src]
mov edi, [dst]
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 "i_system.h"
int myargc;
char** myargv;
@ -46,7 +44,7 @@ int M_CheckParm (char *check)
for (i = 1;i<myargc;i++)
{
if ( !I_strncasecmp(check, myargv[i], strlen(check)) )
if ( !strnicmp(check, myargv[i], strlen(check)) )
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 <ctype.h>
//#include "//kolibc.h"
extern int access(char *file, int mode);
//extern int access(char *file, int mode);
#include "doomdef.h"
@ -119,7 +120,7 @@ M_WriteFile
if (handle == NULL)
return false;
count = fwrite (source, 1, length, handle);
// count = fwrite (source, 1, length, handle);
fclose (handle);
if (count < length)
@ -141,6 +142,9 @@ M_ReadFile
int count, length;
byte *buf;
handle=0;
buf=0;
handle = fopen (name, "rb");
if (handle == NULL)
I_Error ("Couldn't read file %s", name);
@ -228,6 +232,12 @@ default_t defaults[] =
{"key_left",&key_left, KEY_LEFTARROW},
{"key_up",&key_up, KEY_UPARROW},
{"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_straferight",&key_straferight, '.'},
@ -310,6 +320,8 @@ void M_SaveDefaults (void)
//
extern byte scantokey[128];
size_t FileSize(FILE *handle);
void M_LoadDefaults (void)
{
int i;
@ -320,7 +332,10 @@ void M_LoadDefaults (void)
char* newstring;
int parm;
boolean isstring;
char *buf;
char *p;
size_t val;
// set everything to base values
numdefaults = sizeof(defaults)/sizeof(defaults[0]);
for (i=0 ; i<numdefaults ; i++)
@ -335,15 +350,24 @@ void M_LoadDefaults (void)
}
else
defaultfile = basedefault;
/**********
// read the file in, overriding any set defaults
f = fopen (defaultfile, "r");
f = fopen (defaultfile, "rb");
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;
if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2)
if (sscanf (p, "%79s %[^\n]\n", def, strparm) == 2)
{
if (strparm[0] == '"')
{
@ -354,7 +378,8 @@ void M_LoadDefaults (void)
strparm[len-1] = 0;
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);
else
sscanf(strparm, "%i", &parm);
@ -364,17 +389,17 @@ void M_LoadDefaults (void)
if (!isstring)
*defaults[i].location = parm;
else
*defaults[i].location =
(int) newstring;
*defaults[i].location = (int) newstring;
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"
// Not needed with big endian.
#ifndef __BIG_ENDIAN__
// Swap 16bit, that is, MSB and LSB byte.
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
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 "z_zone.h"
#include "m_swap.h"
#include "w_wad.h"
#include "doomdef.h"
@ -49,8 +41,11 @@ extern void *alloca(int);
#include "doomstat.h"
#include "r_sky.h"
#include "r_data.h"
#include <malloc.h>
#include "r_data.h"
//
// Graphics.
// DOOM graphics for walls and sprites
@ -122,7 +117,7 @@ typedef struct
// All the patches[patchcount]
// are drawn back to front into the cached texture.
short patchcount;
short int patchcount;
texpatch_t patches[1];
} texture_t;
@ -291,6 +286,8 @@ void R_GenerateComposite (int texnum)
Z_ChangeTag (block, PU_CACHE);
}
//
// R_GenerateLookup
//
@ -351,11 +348,11 @@ void R_GenerateLookup (int texnum)
{
if (!patchcount[x])
{
printf("R_GenerateLookup: column without a patch (%s)\n",
printf ("R_GenerateLookup: column without a patch (%s)\n",
texture->name);
return;
}
// I_Error ("R_GenerateLookup: column without a patch");
// I_Error ("R_GenerateLookup: column without a patch");
if (patchcount[x] > 1)
{
@ -531,17 +528,7 @@ void R_InitTextures (void)
texture->height = SHORT(mtexture->height);
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));
#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];
patch = &texture->patches[0];
@ -665,13 +652,13 @@ void R_InitColormaps (void)
void R_InitData (void)
{
R_InitTextures ();
printf ("\nInitTextures");
printf ("InitTextures\n\r");
R_InitFlats ();
printf ("\nInitFlats");
printf ("InitFlats\n\r");
R_InitSpriteLumps ();
printf ("\nInitSprites");
printf ("InitSprites\n\r");
R_InitColormaps ();
printf ("\nInitColormaps");
printf ("InitColormaps\n\r");
}
@ -713,14 +700,12 @@ int R_CheckTextureNumForName (char *name)
return 0;
for (i=0 ; i<numtextures ; i++)
if (!I_strncasecmp (textures[i]->name, name, 8) )
if (!strnicmp (textures[i]->name, name, 8) )
return i;
return -1;
}
//
// R_TextureNumForName
// 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)
{
R_InitData ();
printf ("\nR_InitData");
printf ("R_InitData\n\r");
R_InitPointToAngle ();
printf ("\nR_InitPointToAngle");
printf ("R_InitPointToAngle\n\r");
R_InitTables ();
// viewwidth / viewheight / detailLevel are set by the defaults
printf ("\nR_InitTables");
printf ("R_InitTables\n\r");
R_SetViewSize (screenblocks, detailLevel);
R_InitPlanes ();
printf ("\nR_InitPlanes");
printf ("R_InitPlanes\n\r");
R_InitLightTables ();
printf ("\nR_InitLightTables");
printf ("R_InitLightTables\n\r");
R_InitSkyMap ();
printf ("\nR_InitSkyMap");
printf ("R_InitSkyMap\n\r");
R_InitTranslationTables ();
printf ("\nR_InitTranslationsTables");
printf ("R_InitTranslationsTables\n\r");
framecount = 0;
}

View File

@ -169,7 +169,7 @@ void S_Init
printf("S_Init: default sfx volume %d\n", sfxVolume);
I_CreateSound();
//I_CreateSound();
numChannels = NUM_CHANNELS;
// 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
// mix/output buffer.
//WriteDebug("I_StartSound...\n");
channels[cnum].handle = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin);
//cnum = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin);
channels[cnum].handle = I_StartSound(sfx_id,volume,sep,pitch,priority);
channels[cnum].handle = cnum;
channels[cnum].sfxinfo = sfx;
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 "v_video.h"
#include "m_swap.h"
#include "i_system.h"
#include "w_wad.h"
@ -94,8 +96,8 @@ STlib_drawNum
int numdigits = n->width;
int num = *n->num;
int w = (n->p[0]->width);
int h = (n->p[0]->height);
int w = SHORT(n->p[0]->width);
int h = SHORT(n->p[0]->height);
int x = n->x;
int neg;
@ -222,10 +224,10 @@ STlib_updateMultIcon
{
if (mi->oldinum != -1)
{
x = mi->x - (mi->p[mi->oldinum]->leftoffset);
y = mi->y - (mi->p[mi->oldinum]->topoffset);
w = (mi->p[mi->oldinum]->width);
h = (mi->p[mi->oldinum]->height);
x = mi->x - SHORT(mi->p[mi->oldinum]->leftoffset);
y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset);
w = SHORT(mi->p[mi->oldinum]->width);
h = SHORT(mi->p[mi->oldinum]->height);
if (y - ST_Y < 0)
I_Error("updateMultIcon: y - ST_Y < 0");
@ -271,10 +273,10 @@ STlib_updateBinIcon
if (*bi->on
&& (bi->oldval != *bi->val || refresh))
{
x = bi->x - (bi->p->leftoffset);
y = bi->y - (bi->p->topoffset);
w = (bi->p->width);
h = (bi->p->height);
x = bi->x - SHORT(bi->p->leftoffset);
y = bi->y - SHORT(bi->p->topoffset);
w = SHORT(bi->p->width);
h = SHORT(bi->p->height);
if (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);
for (i=0;i<5;i++)
for (i=0;i<6;i++)
STlib_updateMultIcon(&w_arms[i], refresh);
STlib_updateMultIcon(&w_faces, refresh);
@ -1273,7 +1273,7 @@ void ST_initData(void)
for (i=0;i<3;i++)
keyboxes[i] = -1;
// STlib_init();
STlib_init();
}

View File

@ -225,9 +225,9 @@ V_DrawPatch
|| y+SHORT(patch->height)>SCREENHEIGHT
|| (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?
printf("V_DrawPatch: bad patch (ignored)\n");
//printf("V_DrawPatch: bad patch (ignored)\n");
return;
}
#endif
@ -292,7 +292,7 @@ V_DrawPatchFlipped
|| y+SHORT(patch->height)>SCREENHEIGHT
|| (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");
}
#endif

View File

@ -24,8 +24,6 @@
static const char
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"
char MsgText[256];
@ -67,13 +65,13 @@ void I_CreateSound(void)
hret = DirectSoundCreate8(NULL, &lpDS, NULL);
if (hret != DS_OK)
{
printf("failed DirectSoundCreate");
//printf("failed DirectSoundCreate");
return;
}
hret = lpDS->lpVtbl->SetCooperativeLevel(lpDS, win, DSSCL_PRIORITY);
if (hret != DS_OK)
printf("failled DirectSound.SetCooperativeLevel");
//printf("failled DirectSound.SetCooperativeLevel");
memset( &wfx,0, sizeof(WAVEFORMATEX) );
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,
&dwSize1,&pPtr2,&dwSize2,0);
if (hret!=DS_OK)
{ printf("Error locking on play start");
{ //printf("Error locking on play start");
return ;
}
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>
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
//
@ -50,19 +71,6 @@ int numlumps;
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
ExtractFileBase
( char* path,
@ -115,13 +123,6 @@ ExtractFileBase
// specially to allow map reloads.
// 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;
char* reloadname;
@ -138,6 +139,8 @@ void W_AddFile (char *filename)
filelump_t* fileinfo;
filelump_t singleinfo;
int storehandle;
int err;
size_t bytes;
// open the file and add to directory
@ -155,24 +158,23 @@ void W_AddFile (char *filename)
return;
}
printf (" adding %s\n",filename);
printf (" adding %s\n\r",filename);
startlump = numlumps;
if (I_strncasecmp (filename+strlen(filename)-3 , "wad", 3 ) )
if (strnicmp (filename+strlen(filename)-3 , "wad", 3 ) )
{
// single lump file
fileinfo = &singleinfo;
singleinfo.filepos = 0;
singleinfo.size = LONG(filelength(handle));
singleinfo.size = FileSize(handle);
ExtractFileBase (filename, singleinfo.name);
numlumps++;
}
else
{
//WAD file
printf("f1 at %x,%u\n",&header,handle);
fread (&header, 1, sizeof(header), handle);
printf("f2\n");
if (strncmp(header.identification,"IWAD",4))
{
printf("No IWAD id\n");
@ -182,23 +184,19 @@ void W_AddFile (char *filename)
I_Error ("Wad file %s doesn't have IWAD "
"or PWAD id\n", filename);
}
// printf("WAD magic OK\n");
printf("WAD magic OK\n");
// ???modifiedgame = true;
}
printf("after checking hdr\n");
header.numlumps = LONG(header.numlumps);
printf("%u lumps in WAD\n",header.numlumps);
header.infotableofs = LONG(header.infotableofs);
printf("infor table at %x\n",header.infotableofs);
length = header.numlumps*sizeof(filelump_t);
printf("length %u\n",length);
fileinfo = alloca(length);
printf("seeking to info table\n");
fseek (handle, header.infotableofs, SEEK_SET);
printf("f3\n");
fread (fileinfo, 1, length, handle);
printf("f4\n");
numlumps += header.numlumps;
}
@ -249,17 +247,14 @@ void W_Reload (void)
if ( (handle = fopen (reloadname,"rb")) == NULL)
I_Error ("W_Reload: couldn't open %s",reloadname);
printf("f5\n");
fread (&header, 1, sizeof(header), handle);
printf("f6\n");
lumpcount = LONG(header.numlumps);
header.infotableofs = LONG(header.infotableofs);
length = lumpcount*sizeof(filelump_t);
fileinfo = malloc (length);
fseek (handle, header.infotableofs, SEEK_SET);
printf("f7\n");
fread (fileinfo, 1, length, handle);
printf("f8\n");
// Fill in lumpinfo
lump_p = &lumpinfo[reloadlump];
@ -278,8 +273,6 @@ void W_Reload (void)
fclose (handle);
}
//
// W_InitMultipleFiles
// Pass a null terminated list of files to use.
@ -301,7 +294,7 @@ void W_InitMultipleFiles (char** filenames)
numlumps = 0;
// will be realloced as lumps are added
lumpinfo = malloc(1);
lumpinfo = malloc(16384);
for ( ; *filenames ; filenames++)
W_AddFile (*filenames);
@ -440,6 +433,7 @@ W_ReadLump
int c;
lumpinfo_t* l;
FILE *handle;
size_t bytes;
if (lump >= numlumps)
I_Error ("W_ReadLump: %i >= numlumps",lump);
@ -482,7 +476,7 @@ W_CacheLumpNum
{
byte* ptr;
if ((unsigned)lump >= numlumps)
if ((unsigned)lump >= (unsigned)numlumps)
I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
if (!lumpcache[lump])
@ -568,14 +562,21 @@ void W_Profile (void)
for ( ; j<8 ; j++)
name[j] = ' ';
printf ("%s ",name);
//printf ("%s ",name);
for (j=0 ; j<profilecount ; j++)
fprintf (f," %c",info[i][j]);
printf ("\n");
//printf ("\n");
}
fclose (f);
}
#endif

View File

@ -339,11 +339,11 @@ Z_DumpHeap
{
memblock_t* block;
printf ("zone size: %i location: %p\n",
mainzone->size,mainzone);
//printf ("zone size: %i location: %p\n",
// mainzone->size,mainzone);
printf ("tag range: %i to %i\n",
lowtag, hightag);
//printf ("tag range: %i to %i\n",
// lowtag, hightag);
for (block = mainzone->blocklist.next ; ; block = block->next)
{
@ -376,11 +376,11 @@ void Z_FileDumpHeap (FILE* f)
{
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)
{
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);
if (block->next == &mainzone->blocklist)
@ -390,13 +390,13 @@ void Z_FileDumpHeap (FILE* f)
}
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)
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)
fprintf (f,"ERROR: two consecutive free blocks\n");
printf ("ERROR: two consecutive free blocks\n");
}
}