doom beta

git-svn-id: svn://kolibrios.org@550 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-06-22 10:29:55 +00:00
parent d7d49c0feb
commit 9b1d2c1c51
21 changed files with 1186 additions and 1159 deletions

View File

@ -0,0 +1,34 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: declaration for set commit mode function
*
****************************************************************************/
/* see note in commode.c */
_WCRTLINK extern void _WCI86FAR __set_commode( void );
#pragma aux __set_commode "*_";

View File

@ -0,0 +1,33 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
/* define _fmode to be _fmode */

View File

@ -0,0 +1,75 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef _OPENMODE_H_INCLUDED
#define _OPENMODE_H_INCLUDED
enum {
FILEATTR_MASK = 0x003f,
FILEATTR_NORMAL = 0x0000,
FILEATTR_READONLY = 0x0001,
FILEATTR_HIDDEN = 0x0002,
FILEATTR_SYSTEM = 0x0004,
FILEATTR_DIRECTORY = 0x0010,
FILEATTR_ARCHIVED = 0x0020
};
enum {
OPENFLAG_FAIL_IF_EXISTS = 0x0000,
OPENFLAG_OPEN_IF_EXISTS = 0x0001,
OPENFLAG_REPLACE_IF_EXISTS = 0x0002,
OPENFLAG_FAIL_IF_NOT_EXISTS = 0x0000,
OPENFLAG_CREATE_IF_NOT_EXISTS = 0x0010
};
enum {
OPENMODE_DASD = 0x8000,
OPENMODE_WRITE_THROUGH = 0x4000,
OPENMODE_FAIL_ERRORS = 0x2000,
OPENMODE_NO_CACHE = 0x1000,
OPENMODE_LOCALITY_MASK = 0x0700,
OPENMODE_LOCALITY_RANDSEQ = 0x0300,
OPENMODE_LOCALITY_RANDOM = 0x0200,
OPENMODE_LOCALITY_SEQUENTIAL = 0x0100,
OPENMODE_LOCALITY_NONE = 0x0000,
OPENMODE_INHERITANCE = 0x0080,
OPENMODE_SHARE_MASK = 0x0070,
OPENMODE_DENY_COMPAT = 0x0000,
OPENMODE_DENY_ALL = 0x0010,
OPENMODE_DENY_WRITE = 0x0020,
OPENMODE_DENY_READ = 0x0030,
OPENMODE_DENY_NONE = 0x0040,
OPENMODE_ACCESS_MASK = 0x0007,
OPENMODE_ACCESS_RDONLY = 0x0000,
OPENMODE_ACCESS_WRONLY = 0x0001,
OPENMODE_ACCESS_RDWR = 0x0002
};
#endif

View File

@ -0,0 +1,36 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototype for __qread() internal helper.
*
****************************************************************************/
#ifdef __NETWARE__
#define __qread( h, b, l ) read( h, b, l )
#else
extern int __qread( int handle, void *buffer, unsigned len );
#endif

View File

@ -44,18 +44,6 @@
#include "close.h"
#include "flush.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
#define lib_free dlfree
#endif
#ifndef __UNIX__
void (*__RmTmpFileFn)( FILE *fp );

View File

@ -0,0 +1,161 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent fwrite() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "qwrite.h"
#include "flush.h"
#include "streamio.h"
_WCRTLINK size_t fwrite( const void *buf, size_t size, size_t n, FILE *fp )
{
size_t count;
unsigned oflag;
_ValidFile( fp, 0 );
_AccessFile( fp );
if( (fp->_flag & _WRITE) == 0 ) {
__set_errno( EBADF );
fp->_flag |= _SFERR;
_ReleaseFile( fp );
return( 0 ); /* POSIX says return 0 */
}
n *= size;
if( n == 0 ) {
_ReleaseFile( fp );
return( n );
}
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp ); /* allocate buffer */
}
oflag = fp->_flag & (_SFERR | _EOF); /* JBS 27-jan-92 */
fp->_flag &= ~(_SFERR | _EOF); /* JBS 27-jan-92 */
count = 0;
#if !defined( __UNIX__ )
if( fp->_flag & _BINARY ) { /* binary I/O */
#else
{
#endif
size_t bytes_left = n, bytes;
do {
/* if our buffer is empty, and user's buffer is larger,
then write directly from user's buffer. 28-apr-90 */
if( fp->_cnt == 0 && bytes_left >= fp->_bufsize ) {
bytes = bytes_left & -512; /* multiple of 512 */
if( bytes == 0 ) {
bytes = bytes_left; /* bufsize < 512 */
}
n = __qwrite( fileno( fp ), buf, bytes );
if( n == -1 ) {
fp->_flag |= _SFERR;
}
#if !defined( __UNIX__ )
else if( n == 0 ) {
_RWD_errno = ENOSPC;
fp->_flag |= _SFERR;
}
#endif
bytes = n;
} else {
bytes = fp->_bufsize - fp->_cnt;
if( bytes > bytes_left ) {
bytes = bytes_left;
}
memcpy( fp->_ptr, buf, bytes );
fp->_ptr += bytes;
fp->_cnt += bytes;
fp->_flag |= _DIRTY;
if( (fp->_cnt == fp->_bufsize) || (fp->_flag & _IONBF) ) {
__flush(fp);
}
}
buf = ((const char *)buf) + bytes;
count += bytes;
bytes_left -= bytes;
} while( bytes_left && !ferror( fp ) );
#if !defined( __UNIX__ )
} else { /* text I/O */
const char *bufptr;
int not_buffered;
#ifndef __NETWARE__
int old_orientation;
#endif
/* temporarily enable buffering saving the previous setting */
not_buffered = 0;
if( fp->_flag & _IONBF ) {
not_buffered = 1;
fp->_flag &= ~_IONBF;
fp->_flag |= _IOFBF;
}
/*** Use fputc, and make it think the stream is byte-oriented ***/
#ifndef __NETWARE__
old_orientation = _FP_ORIENTATION(fp);
_FP_ORIENTATION(fp) = _BYTE_ORIENTED;
#endif
bufptr = (const char *)buf;
do {
fputc( *(bufptr++), fp );
if( fp->_flag & (_EOF | _SFERR) ) break;
++count;
} while( count != n );
#ifndef __NETWARE__
_FP_ORIENTATION(fp) = old_orientation;
#endif
if( not_buffered ) { /* if wasn't buffered, then reset */
fp->_flag &= ~_IOFBF;
fp->_flag |= _IONBF;
__flush( fp );
}
#endif
}
if( fp->_flag & _SFERR ) {
/*
* Quantum 11-17-92 Temporary buffering confuses the return
* value if the call is interrupted.
* kludge: return 0 on error
*/
count = 0;
}
fp->_flag |= oflag; /* JBS 27-jan-92 */
_ReleaseFile( fp );
return( count / size );
}

View File

@ -67,6 +67,7 @@ typedef struct
} FILEINFO;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall create_file(const char *name);
typedef struct
@ -76,7 +77,7 @@ typedef struct
}__file_handle;
static char* getfullpath(const char* path)
char* getfullpath(const char* path)
{
int prev_is_slash=0;
int len=0, depth=0, i;
@ -177,20 +178,27 @@ int access(const char *path, int mode)
}
static HANDLE __createFileHandle(const CHAR_TYPE *name)
static HANDLE __openFileHandle(const CHAR_TYPE *name, int mode)
{
FILEINFO info;
__file_handle *handle;
char *path;
int err;
path = getfullpath(name);
if(get_fileinfo(path,&info))
if(err=get_fileinfo(path,&info))
{
// printf("failed getfileinfo %s\n\r", path);
lib_free(path);
return (HANDLE)-1;
if(mode & O_CREAT)
err=create_file(path);
if(err)
{
lib_free(path);
return (HANDLE)-1;
};
};
if ( !(handle=(__file_handle*)lib_malloc(sizeof( __file_handle) )))
@ -205,7 +213,6 @@ static HANDLE __createFileHandle(const CHAR_TYPE *name)
};
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
{
HANDLE handle;
@ -225,24 +232,12 @@ static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share
/*** Open the file ***/
handle = __createFileHandle( name);
handle = __openFileHandle( name, mode);
if( handle==(HANDLE)-1 )
{
printf("handle = -1 \n\r");
if( mode&O_CREAT )
{
// handle = CreateFileA( name, desired_access,
// share_mode, NULL, create_disp,
// fileattr, NULL );
}
if( handle == (HANDLE)-1 )
{
__freePOSIXHandle( hid );
return( -1 ); //error
}
__freePOSIXHandle( hid );
return( -1 ); //error
}
// Now use the slot we got.

View File

@ -34,19 +34,14 @@
#include <stdio.h>
#include <errno.h>
//#if defined(__NT__)
//#elif defined(__OS2__)
//#else
// #include "tinyio.h"
//#endif
#include "iomode.h"
#include "fileacc.h"
#include "rtcheck.h"
#include "rtdata.h"
#include "seterrno.h"
//#include "defwin.h"
#include "qwrite.h"
#include "liballoc.h"
/*
Use caution when setting the file pointer in a multithreaded
@ -56,83 +51,79 @@
using a critical section object or a mutex object.
*/
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
typedef struct
{
char *name;
unsigned int offset;
}__file_handle;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall write_file(const char *name,const void *buff,unsigned offset,unsigned count,unsigned *writes);
char* getfullpath(const char* path);
int __qwrite( int handle, const void *buffer, unsigned len )
{
int atomic;
#if defined(__NT__)
DWORD len_written;
HANDLE h;
int error;
__file_handle *fh;
unsigned len_written;
#elif defined(__WARP__)
#elif defined(__OS2_286__)
#else
#endif
#if !defined(__NT__)
tiny_ret_t rc;
#endif
__handle_check( handle, -1 );
#if defined(__NT__)
h = __getOSHandle( handle );
#endif
fh = (__file_handle*) __getOSHandle( handle );
atomic = 0;
if( __GetIOMode( handle ) & _APPEND )
{
_AccessFileH( handle );
atomic = 1;
#if defined(__NT__)
// if( SetFilePointer( h, 0, NULL, FILE_END ) == -1 )
// {
// error = GetLastError();
// _ReleaseFileH( handle );
// return( __set_errno_dos( error ) );
// }
#elif defined(__OS2__)
#else
rc = TinySeek( handle, 0L, SEEK_END );
#endif
#if !defined(__NT__)
if( TINY_ERROR( rc ) ) {
_ReleaseFileH( handle );
return( __set_errno_dos( TINY_INFO( rc ) ) );
}
#endif
}
#if defined(__NT__)
FILEINFO info;
// if( !WriteFile( h, buffer, len, &len_written, NULL ) )
// {
// error = GetLastError();
// if( atomic == 1 ) {
// _ReleaseFileH( handle );
// }
// return( __set_errno_dos( error ) );
// }
_AccessFileH( handle );
atomic = 1;
get_fileinfo(fh->name,&info);
fh->offset = info.size;
};
if(write_file(fh->name,buffer,fh->offset,len,&len_written))
{
if ( len_written == 0)
{
if( atomic == 1 )
_ReleaseFileH( handle );
return (-1);
};
};
fh->offset+=len_written;
#elif defined(__OS2__)
#elif defined(__WINDOWS_386__)
#else
rc = TinyWrite( handle, buffer, len );
len_written = TINY_LINFO( rc );
#endif
#if !defined(__NT__)
if( TINY_ERROR( rc ) ) {
if( atomic == 1 ) {
_ReleaseFileH( handle );
}
return( __set_errno_dos( TINY_INFO( rc ) ) );
}
#endif
if( len_written != len ) {
__set_errno( ENOSPC );
}
if( atomic == 1 )
{
_ReleaseFileH( handle );
}
return( len_written );
}
int write_once(const char *name, void *buffer, unsigned len)
{ char *path;
unsigned count;
path= getfullpath(name);
write_file(path,buffer,0,len,&count);
lib_free(path);
return count;
}

View File

@ -7,8 +7,7 @@ extern "C"
{
#endif
#define SOUND_VERSION 5
#define SOUND_VERSION 0x0100
#define PCM_ALL 0
#define PCM_OUT 0x08000000

View File

@ -1168,9 +1168,9 @@ void D_DoomMain (void)
if (p && p < myargc-1)
{
if (M_CheckParm("-cdrom"))
sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
sprintf(file, "c:\\doomdata\\doomsav%c.dsg",myargv[p+1][0]);
else
sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
sprintf(file, "doomsav%c.dsg",myargv[p+1][0]);
G_LoadGame (file);
}

View File

@ -1269,13 +1269,13 @@ G_SaveGame
void G_DoSaveGame (void)
{
char name[100];
char name[128];
char name2[VERSIONSIZE];
char* description;
int length;
int i;
sprintf (name,"%d.dsg",savegameslot);
sprintf (name,"doomsav%d.dsg",savegameslot);
description = savedescription;
save_p = savebuffer = screens[1]+0x4000;
@ -1306,6 +1306,7 @@ void G_DoSaveGame (void)
length = save_p - savebuffer;
if (length > SAVEGAMESIZE)
I_Error ("Savegame buffer overrun");
M_WriteFile (name, savebuffer, length);
gameaction = ga_nothing;
savedescription[0] = 0;

View File

@ -18,7 +18,7 @@
// $Log:$
//
// DESCRIPTION:
// DOOM strings, by language.
// DOOM strings, by language.
//
//-----------------------------------------------------------------------------
@ -38,7 +38,7 @@
#endif
// Misc. other strings.
#define SAVEGAMENAME "doomsav"
//#define SAVEGAMENAME "doomsav"
//

View File

@ -1,177 +0,0 @@
#ifndef kolibc_h
#define kolibc_h
#ifdef __cplusplus
extern "C"
{
#endif
typedef unsigned char byte;
typedef unsigned short int word;
typedef unsigned int dword;
typedef unsigned int fpos_t;
typedef unsigned int size_t;
#//define NULL (void*)0
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define FILE_OPEN_READ 0x01
#define FILE_OPEN_WRITE 0x02
#define FILE_OPEN_APPEND 0x04
#define FILE_OPEN_TEXT 0x08
#define FILE_OPEN_PLUS 0x10
#define EOF -1
typedef struct
{
char *buffer;
char *stream;
size_t strpos;
size_t remain;
size_t filepos;
size_t buffersize;
size_t filesize;
char* filename;
int mode;
} FILE;
extern FILE* fopen(const char* filename, const char *mode);
extern int fclose(FILE* file);
extern int feof(FILE* file);
extern int fflush(FILE* file);
extern int fgetc(FILE* file);
extern int fgetpos(FILE* file,fpos_t* pos);
extern int fsetpos(FILE* file,const fpos_t* pos);
extern int fputc(int c,FILE* file);
extern int fread(void* buffer,size_t size,size_t count,FILE* file);
extern int fwrite(const void* buffer,size_t size,size_t count,FILE* file);
extern long ftell(FILE* file);
extern int fseek(FILE* file,long offset,int origin);
extern void rewind(FILE* file);
extern int fprintf(FILE* file, const char* format, ...);
extern int fscanf(FILE* file,const char* format, ...);
extern int ungetc(int c,FILE* file);
extern int sprintf(char *dest, const char *format,...);
extern int printf(const char *format,...);
typedef char *va_list;
#define _roundsize(n) ( (sizeof(n) + 3) & ~3 )
#define va_start(ap,v) (ap = (va_list)&v+_roundsize(v))
#define va_arg(ap,t) ( *(t *)((ap += _roundsize(t)) - _roundsize(t)) )
#define va_end(ap) (ap = (va_list)0)
/*
** All character classification functions except isascii().
** Integer argument (c) must be in ASCII range (0-127) for
** dependable answers.
*/
#define ALNUM 1
#define ALPHA 2
#define CNTRL 4
#define DIGIT 8
#define GRAPH 16
#define LOWER 32
#define PRINT 64
#define PUNCT 128
#define BLANK 256
#define UPPER 512
#define XDIGIT 1024
extern short int _is[128];
#define isalnum(c)(_is[c] & ALNUM ) /* 'a'-'z', 'A'-'Z', '0'-'9' */
#define isalpha(c)(_is[c] & ALPHA ) /* 'a'-'z', 'A'-'Z' */
#define iscntrl(c)(_is[c] & CNTRL ) /* 0-31, 127 */
#define isdigit(c)(_is[c] & DIGIT ) /* '0'-'9' */
#define isgraph(c)(_is[c] & GRAPH ) /* '!'-'~' */
#define islower(c)(_is[c] & LOWER ) /* 'a'-'z' */
#define isprint(c)(_is[c] & PRINT ) /* ' '-'~' */
#define ispunct(c)(_is[c] & PUNCT ) /* !alnum && !cntrl && !space */
#define isspace(c)(_is[c] & BLANK ) /* HT, LF, VT, FF, CR, ' ' */
#define isupper(c)(_is[c] & UPPER ) /* 'A'-'Z' */
#define isxdigit(c)(_is[c] & XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */
#define _LOWER 0x80
#define _UPPER 0x40
#define _DIGIT 0x20
#define _XDIGT 0x10
#define _PRINT 0x08
#define _PUNCT 0x04
#define _SPACE 0x02
#define _CNTRL 0x01
#define abs(i) (((i)<0)?(-(i)):(i))
#if 0
extern int atoib(char *s,int b);
extern int atoi(char *s);
extern char tolower(char c);
extern char toupper(char c);
extern void itoab(int n,char* s,int b);
extern void itoa(int n,char* s);
extern char* strcat(char*,const char*);
extern char* strchr(const char*,int);
extern int strcmp(const char*,const char*);
extern int strcoll(const char*,const char*);
extern char* strcpy(char*,const char*);
extern int strcspn(const char*,const char*);
extern size_t strlen(const char*);
extern char* strncat(char*,const char*,int);
extern int strncmp(const char*,const char*,int);
extern char* strncpy(char*,const char*,int);
extern char* strpbrk(const char*,const char*);
extern char* strrchr(const char*,int);
extern int strspn(const char*,const char*);
extern char* strstr(const char*,const char*);
extern char* strtok(char*,const char*);
extern int strxfrm(char*,const char*,int);
extern char* strdup(const char*);
extern char toupper(char c);
#define isascii(char) ( (unsigned)char < 0x80 )
extern void* memchr(const void*,int,int);
extern extern void* memchr(const void*,int,int);
extern int memcmp(const void*,const void*,int);
extern void* memcpy(void*,const void*,size_t);
void kmemset (void *dst, int val, size_t count);
extern void* memmove(void*,const void*,int);
extern void* memset(void*,int,int);
int memcmp(const void*,const void*,int);
extern void* memcpy(void*,const void*,size_t);
void kmemset (void *dst, int val, size_t count);
extern void* memmove(void*,const void*,int);
extern void* memset(void*,int,int);
#endif
void debug_out_str(char* str);
void* _cdecl dlmalloc(size_t size);
void* _cdecl dlrealloc(void* oldmem, size_t bytes);
void _cdecl dlfree(void *mem);
//double pow_test(x,y);
#ifdef __cplusplus
extern "C"
}
#endif
#endif //kolibc_h

View File

@ -1,100 +0,0 @@
//#include "kolibc.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef unsigned int dword;
typedef unsigned int size_t;
#define PINUSE_BIT 1
#define CINUSE_BIT 2
#define INUSE_BITS 3
struct m_seg
{
char* base; /* base address */
dword size; /* allocated size */
struct m_seg* next; /* ptr to next segment */
dword flags; /* mmap and extern flag */
};
struct m_chunk
{
dword prev_foot; /* Size of previous chunk (if free). */
dword head; /* Size and inuse bits. */
struct m_chunk* fd; /* double links -- used only if free. */
struct m_chunk* bk;
};
typedef struct m_chunk* mchunkptr;
struct t_chunk
{
/* The first four fields must be compatible with malloc_chunk */
dword prev_foot;
dword head;
struct t_chunk* fd;
struct t_chunk* bk;
struct t_chunk* child[2];
struct t_chunk* parent;
dword index;
};
typedef struct t_chunk* tchunkptr;
typedef struct t_chunk* tbinptr;
typedef struct m_state
{
dword smallmap;
dword treemap;
// DWORD dvsize;
dword topsize;
char* least_addr;
// mchunkptr dv;
mchunkptr top;
dword magic;
struct m_chunk smallbins[32];
tbinptr treebins[32];
};
void _cdecl mf_init();
void* _cdecl dlmalloc(size_t);
void* _cdecl dlrealloc(void *,size_t);
void _cdecl dlfree(void*);
dword compute_tree_index(size_t s);
static void insert_chunk(mchunkptr P, size_t S);
static void insert_large_chunk(tchunkptr X, size_t S);
static void unlink_large_chunk(tchunkptr X);
//void replace_dv(mchunkptr P, size_t S);
static void* malloc_small(size_t nb);
static void* malloc_large(size_t nb);
#define leftshift_for_tree_index(i) \
((i == 31)? 0 : (31 - (i >> 1) + 8 - 2))
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])
#define chunk2mem(p) (void*)((char*)p + 8)
#define mem2chunk(mem) (mchunkptr)((char*)mem - 8)
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
#ifdef __cplusplus
}
#endif /* __cplusplus */

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,6 @@ 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);
@ -106,22 +105,29 @@ M_DrawText
#define O_BINARY 0
#endif
int write_once(const char *name, void *buffer, unsigned len);
boolean
M_WriteFile
( char const* name,
void* source,
int length )
{
FILE *handle;
// FILE *handle;
int count;
handle = fopen ( name, "wb");
// handle = fopen ( name, "wb");
if (handle == NULL)
return false;
// if (handle == NULL)
// return false;
// count = fwrite (source, 1, length, handle);
fclose (handle);
// printf("writeFile %s, &s, %d \n\r", name, source, length);
count = write_once(name, source, length);
// printf("%d \n\r", count);
// count = fwrite (source, 1, length, handle);
// fclose (handle);
if (count < length)
return false;

View File

@ -257,10 +257,22 @@ void sound_proc(void)
}
if(ver< SOUND_VERSION)
if( SOUND_VERSION>(ver&0xFFFF))
{
printf("Sound service version mismatch\n\r");
printf("Installed version: %d, required version %d\n\r",
printf("Sound version mismatch\n\r");
printf("Current version: %d, required version %d\n\r",
ver&0xFFFF, SOUND_VERSION);
_asm
{
mov eax, -1
int 0x40
};
};
if(SOUND_VERSION<(ver >> 16))
{
printf("Sound version obsolete\n\r");
printf("Compatible version: %d, required version %d\n\r",
ver, SOUND_VERSION);
_asm
{

View File

@ -64,28 +64,21 @@ typedef struct
void _stdcall InitHeap(int heap_size);
void* _stdcall UserAlloc(int size);
void _stdcall GetNotify(DWORD *event);
int _stdcall UserFree(void* p);
void _stdcall GetNotify(void *event);
void _stdcall CreateThread(void *fn, char *p_stack);
//void _stdcall CreateThread(void *fn, char *p_stack);
DWORD _stdcall GetMousePos(DWORD rel_type);
int _stdcall GetService(char *srv_name);
void _stdcall GetDevInfo(DWORD hSrv,CTRL_INFO *pInfo);
int _stdcall GetMasterVol(DWORD hSrv,int* vol);
int _stdcall SetMasterVol(DWORD hSrv, int vol);
DWORD _stdcall CreateBuffer(DWORD hSrv, DWORD format);
int _stdcall DestroyBuffer(DWORD hSrv, DWORD hBuff);
int _stdcall SetBuffer(DWORD hSrv, DWORD hBuff,char* buff,
DWORD offs, int size);
int _stdcall PlayBuffer(DWORD hSrv, DWORD hBuff);
int _stdcall StopBuffer(DWORD hSrv, DWORD hBuff);
void _stdcall debug_out_hex(DWORD val);
void debug_out_str(char* str);
//void debug_out_str(char* str);
int _stdcall get_fileinfo(char *name,FILEINFO* pinfo);
int _stdcall read_file (char *name,char*buff,int offset, int count,int *reads);
int _stdcall write_file(char *name,char*buff,int offset,int count,int *writes);
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall create_file(const char *name);
int _stdcall read_file (const char *name,char*buff,DWORD offset,DWORD count,DWORD *reads);
int _stdcall write_file(const char *name,const void *buff,DWORD offset,DWORD count,DWORD *writes);
//void exit();
int _stdcall get_key(int *key);
@ -94,13 +87,12 @@ int _stdcall remap_key(int key);
int _cdecl get_button_id();
void delay(int val);
int wait_for_event(int time);
int wait_for_event_infinite();
void BeginDraw(void);
void EndDraw(void);
//void BeginDraw(void);
//void EndDraw(void);
void _stdcall GetScreenSize(int *x, int*y);
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style,
int captioncolor,int windowtype,int bordercolor);
void _stdcall debug_out(int ch);
@ -108,13 +100,6 @@ void _stdcall make_button(int x, int y, int xsize, int ysize, int id, int color)
void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color);
void _stdcall write_text(int x,int y,int color,char* text,int len);
void _cdecl mf_init();
void* _cdecl dlmalloc(size_t size);
void _cdecl dlfree(void *mem);
void* _cdecl dlrealloc(void* oldmem, size_t bytes);
#ifdef __cplusplus
extern "C"
}

View File

@ -7,8 +7,7 @@ extern "C"
{
#endif
#define SOUND_VERSION 5
#define SOUND_VERSION 0x0100
#define PCM_ALL 0
#define PCM_OUT 0x08000000

View File

@ -42,22 +42,10 @@ rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";
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);
//int _stdcall read_file (char *name, void *buff,
// size_t offset, size_t count, size_t *reads);
@ -196,7 +184,6 @@ void W_AddFile (char *filename)
length = header.numlumps*sizeof(filelump_t);
fileinfo = alloca(length);
fseek (handle, header.infotableofs, SEEK_SET);
fread (fileinfo, 1, length, handle);
numlumps += header.numlumps;