From 9b1d2c1c519b8d99875b20742aa26a69db79876b Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Fri, 22 Jun 2007 10:29:55 +0000 Subject: [PATCH] doom beta git-svn-id: svn://kolibrios.org@550 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../open watcom/trunk/clib/h/commode.h | 34 + .../develop/open watcom/trunk/clib/h/fmode.h | 33 + .../open watcom/trunk/clib/h}/kolibri.h | 0 .../open watcom/trunk/clib/h/openmode.h | 75 + .../develop/open watcom/trunk/clib/h/qread.h | 36 + .../open watcom/trunk/clib/src/fclose.c | 12 - .../open watcom/trunk/clib/src/fwrite.c | 161 +++ .../open watcom/trunk/clib/src/openklbr.c | 43 +- .../open watcom/trunk/clib/src/qwrit.c | 267 ++-- .../develop/sdk/trunk/sound/include/sound.h | 13 +- programs/games/doom/trunk/d_main.c | 4 +- programs/games/doom/trunk/g_game.c | 13 +- programs/games/doom/trunk/h/dstrings.h | 4 +- .../games/doom/trunk/kolibc/include/kolibc.h | 177 --- programs/games/doom/trunk/kolibc/include/mf.h | 100 -- programs/games/doom/trunk/m_menu.c | 1262 +++++++++-------- programs/games/doom/trunk/m_misc.c | 20 +- programs/games/doom/trunk/s_sound.c | 20 +- .../trunk/{h => system/include}/kolibri.h | 41 +- .../trunk/{kolibc => system}/include/sound.h | 13 +- programs/games/doom/trunk/w_wad.c | 17 +- 21 files changed, 1186 insertions(+), 1159 deletions(-) create mode 100644 programs/develop/open watcom/trunk/clib/h/commode.h create mode 100644 programs/develop/open watcom/trunk/clib/h/fmode.h rename programs/{games/doom/trunk/kolibc/include => develop/open watcom/trunk/clib/h}/kolibri.h (100%) create mode 100644 programs/develop/open watcom/trunk/clib/h/openmode.h create mode 100644 programs/develop/open watcom/trunk/clib/h/qread.h create mode 100644 programs/develop/open watcom/trunk/clib/src/fwrite.c delete mode 100644 programs/games/doom/trunk/kolibc/include/kolibc.h delete mode 100644 programs/games/doom/trunk/kolibc/include/mf.h rename programs/games/doom/trunk/{h => system/include}/kolibri.h (62%) rename programs/games/doom/trunk/{kolibc => system}/include/sound.h (88%) diff --git a/programs/develop/open watcom/trunk/clib/h/commode.h b/programs/develop/open watcom/trunk/clib/h/commode.h new file mode 100644 index 0000000000..76af4ba5d6 --- /dev/null +++ b/programs/develop/open watcom/trunk/clib/h/commode.h @@ -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 "*_"; diff --git a/programs/develop/open watcom/trunk/clib/h/fmode.h b/programs/develop/open watcom/trunk/clib/h/fmode.h new file mode 100644 index 0000000000..386ac1af38 --- /dev/null +++ b/programs/develop/open watcom/trunk/clib/h/fmode.h @@ -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 */ diff --git a/programs/games/doom/trunk/kolibc/include/kolibri.h b/programs/develop/open watcom/trunk/clib/h/kolibri.h similarity index 100% rename from programs/games/doom/trunk/kolibc/include/kolibri.h rename to programs/develop/open watcom/trunk/clib/h/kolibri.h diff --git a/programs/develop/open watcom/trunk/clib/h/openmode.h b/programs/develop/open watcom/trunk/clib/h/openmode.h new file mode 100644 index 0000000000..4e29d357c0 --- /dev/null +++ b/programs/develop/open watcom/trunk/clib/h/openmode.h @@ -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 diff --git a/programs/develop/open watcom/trunk/clib/h/qread.h b/programs/develop/open watcom/trunk/clib/h/qread.h new file mode 100644 index 0000000000..ff1b3e2392 --- /dev/null +++ b/programs/develop/open watcom/trunk/clib/h/qread.h @@ -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 diff --git a/programs/develop/open watcom/trunk/clib/src/fclose.c b/programs/develop/open watcom/trunk/clib/src/fclose.c index 7bb7c17b4a..473fabc94e 100644 --- a/programs/develop/open watcom/trunk/clib/src/fclose.c +++ b/programs/develop/open watcom/trunk/clib/src/fclose.c @@ -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 ); diff --git a/programs/develop/open watcom/trunk/clib/src/fwrite.c b/programs/develop/open watcom/trunk/clib/src/fwrite.c new file mode 100644 index 0000000000..eff6f9ec39 --- /dev/null +++ b/programs/develop/open watcom/trunk/clib/src/fwrite.c @@ -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 +#include +#include +#include +#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 ); +} diff --git a/programs/develop/open watcom/trunk/clib/src/openklbr.c b/programs/develop/open watcom/trunk/clib/src/openklbr.c index dc3e31c858..b8474d8032 100644 --- a/programs/develop/open watcom/trunk/clib/src/openklbr.c +++ b/programs/develop/open watcom/trunk/clib/src/openklbr.c @@ -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; +// printf("failed getfileinfo %s\n\r", path); + + 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. diff --git a/programs/develop/open watcom/trunk/clib/src/qwrit.c b/programs/develop/open watcom/trunk/clib/src/qwrit.c index 67a136ccb3..1d7f0ac8b4 100644 --- a/programs/develop/open watcom/trunk/clib/src/qwrit.c +++ b/programs/develop/open watcom/trunk/clib/src/qwrit.c @@ -1,138 +1,129 @@ -/**************************************************************************** -* -* 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! -* -****************************************************************************/ - - -#include "variety.h" -#include -#include - -//#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" - -/* - Use caution when setting the file pointer in a multithreaded - application. You must synchronize access to shared resources. For - example, an application whose threads share a file handle, update the - file pointer, and read from the file must protect this sequence by - using a critical section object or a mutex object. - */ - - -int __qwrite( int handle, const void *buffer, unsigned len ) -{ - int atomic; -#if defined(__NT__) - DWORD len_written; - HANDLE h; - int error; - -#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 - 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__) - -// if( !WriteFile( h, buffer, len, &len_written, NULL ) ) -// { -// error = GetLastError(); -// if( atomic == 1 ) { -// _ReleaseFileH( handle ); -// } -// return( __set_errno_dos( error ) ); -// } - -#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 ); -} +/**************************************************************************** +* +* 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! +* +****************************************************************************/ + + +#include "variety.h" +#include +#include + +#include "iomode.h" +#include "fileacc.h" +#include "rtcheck.h" +#include "rtdata.h" +#include "seterrno.h" +#include "qwrite.h" +#include "liballoc.h" + + +/* + Use caution when setting the file pointer in a multithreaded + application. You must synchronize access to shared resources. For + example, an application whose threads share a file handle, update the + file pointer, and read from the file must protect this sequence by + 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; + __file_handle *fh; + unsigned len_written; + + + __handle_check( handle, -1 ); + + fh = (__file_handle*) __getOSHandle( handle ); + + atomic = 0; + if( __GetIOMode( handle ) & _APPEND ) + { + FILEINFO info; + + _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; + + + 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; + +} diff --git a/programs/develop/sdk/trunk/sound/include/sound.h b/programs/develop/sdk/trunk/sound/include/sound.h index 0e9454d3ce..430c210e36 100644 --- a/programs/develop/sdk/trunk/sound/include/sound.h +++ b/programs/develop/sdk/trunk/sound/include/sound.h @@ -7,8 +7,7 @@ extern "C" { #endif -#define SOUND_VERSION 5 - +#define SOUND_VERSION 0x0100 #define PCM_ALL 0 #define PCM_OUT 0x08000000 @@ -58,7 +57,7 @@ extern "C" #define SND_CREATE_BUFF 1 #define SND_DESTROY_BUFF 2 #define SND_SETFORMAT 3 -#define SND_GETFORMAT 4 +#define SND_GETFORMAT 4 #define SND_RESET 5 #define SND_SETPOS 6 #define SND_GETPOS 7 @@ -81,8 +80,8 @@ int _stdcall InitSound(int *version); int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf); int _stdcall DestroyBuffer(SNDBUF hBuff); -int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); -int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format); +int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); +int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format); int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); int _stdcall SetBufferPos(SNDBUF hBuff, int offset); @@ -94,12 +93,12 @@ int _stdcall SetBuffer(SNDBUF hBuff,void* buff, int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags); int _stdcall StopBuffer(SNDBUF hBuff); - + int _stdcall SetVolume(SNDBUF hBuff, int left, int right); int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); int _stdcall SetPan(SNDBUF hBuff, int pan); int _stdcall GetPan(SNDBUF hBuff, int *pan); - + int _stdcall GetMasterVol(int* vol); int _stdcall SetMasterVol(int vol); diff --git a/programs/games/doom/trunk/d_main.c b/programs/games/doom/trunk/d_main.c index fa371d791d..2fa8e41a49 100644 --- a/programs/games/doom/trunk/d_main.c +++ b/programs/games/doom/trunk/d_main.c @@ -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); } diff --git a/programs/games/doom/trunk/g_game.c b/programs/games/doom/trunk/g_game.c index 2b7c52b4b8..eec772f8ca 100644 --- a/programs/games/doom/trunk/g_game.c +++ b/programs/games/doom/trunk/g_game.c @@ -1206,7 +1206,7 @@ void G_DoLoadGame (void) char vcheck[VERSIONSIZE]; gameaction = ga_nothing; - + length = M_ReadFile (savename, &savebuffer); save_p = savebuffer + SAVESTRINGSIZE; @@ -1266,20 +1266,20 @@ G_SaveGame strcpy (savedescription, description); sendsave = true; } - + 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; - + memcpy (save_p, description, SAVESTRINGSIZE); save_p += SAVESTRINGSIZE; memset (name2,0,sizeof(name2)); @@ -1305,7 +1305,8 @@ void G_DoSaveGame (void) length = save_p - savebuffer; if (length > SAVEGAMESIZE) - I_Error ("Savegame buffer overrun"); + I_Error ("Savegame buffer overrun"); + M_WriteFile (name, savebuffer, length); gameaction = ga_nothing; savedescription[0] = 0; diff --git a/programs/games/doom/trunk/h/dstrings.h b/programs/games/doom/trunk/h/dstrings.h index 291767bc30..685cd1a2e0 100644 --- a/programs/games/doom/trunk/h/dstrings.h +++ b/programs/games/doom/trunk/h/dstrings.h @@ -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" // diff --git a/programs/games/doom/trunk/kolibc/include/kolibc.h b/programs/games/doom/trunk/kolibc/include/kolibc.h deleted file mode 100644 index af4e8e82c7..0000000000 --- a/programs/games/doom/trunk/kolibc/include/kolibc.h +++ /dev/null @@ -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 - - diff --git a/programs/games/doom/trunk/kolibc/include/mf.h b/programs/games/doom/trunk/kolibc/include/mf.h deleted file mode 100644 index 33cf4b69e3..0000000000 --- a/programs/games/doom/trunk/kolibc/include/mf.h +++ /dev/null @@ -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 */ - - - diff --git a/programs/games/doom/trunk/m_menu.c b/programs/games/doom/trunk/m_menu.c index e9ec469f27..f834455735 100644 --- a/programs/games/doom/trunk/m_menu.c +++ b/programs/games/doom/trunk/m_menu.c @@ -17,8 +17,8 @@ // $Log:$ // // DESCRIPTION: -// DOOM selection menu, options, episode etc. -// Sliders and icons. Kinda widget stuff. +// DOOM selection menu, options, episode etc. +// Sliders and icons. Kinda widget stuff. // //----------------------------------------------------------------------------- @@ -60,46 +60,46 @@ rcsid[] = "$Id: m_menu.c,v 1.7 1997/02/03 22:45:10 b1 Exp $"; -extern patch_t* hu_font[HU_FONTSIZE]; -extern boolean message_dontfuckwithme; +extern patch_t* hu_font[HU_FONTSIZE]; +extern boolean message_dontfuckwithme; -extern boolean chat_on; // in heads-up code +extern boolean chat_on; // in heads-up code // // defaulted values // -int mouseSensitivity; // has default +int mouseSensitivity; // has default // Show messages has default, 0 = off, 1 = on -int showMessages; - +int showMessages; + // Blocky mode, has default, 0 = high, 1 = normal -int detailLevel; -int screenblocks; // has default +int detailLevel; +int screenblocks; // has default // temp for screenblocks (0-9) -int screenSize; +int screenSize; // -1 = no quicksave slot picked! -int quickSaveSlot; +int quickSaveSlot; // 1 = message to be printed -int messageToPrint; +int messageToPrint; // ...and here is the message string! -char* messageString; +char* messageString; // message x & y -int messx; -int messy; -int messageLastMenuActive; +int messx; +int messy; +int messageLastMenuActive; // timed message = no input from user -boolean messageNeedsInput; +boolean messageNeedsInput; void (*messageRoutine)(int response); -#define SAVESTRINGSIZE 24 +#define SAVESTRINGSIZE 24 char gammamsg[5][26] = { @@ -111,22 +111,22 @@ char gammamsg[5][26] = }; // we are going to be entering a savegame string -int saveStringEnter; -int saveSlot; // which slot to save in -int saveCharIndex; // which char we're editing +int saveStringEnter; +int saveSlot; // which slot to save in +int saveCharIndex; // which char we're editing // old save description before edit -char saveOldString[SAVESTRINGSIZE]; +char saveOldString[SAVESTRINGSIZE]; -boolean inhelpscreens; -boolean menuactive; +boolean inhelpscreens; +boolean menuactive; -#define SKULLXOFF -32 -#define LINEHEIGHT 16 +#define SKULLXOFF -32 +#define LINEHEIGHT 16 -extern boolean sendpause; -char savegamestrings[10][SAVESTRINGSIZE]; +extern boolean sendpause; +char savegamestrings[10][SAVESTRINGSIZE]; -char endstring[160]; +char endstring[160]; // @@ -135,42 +135,42 @@ char endstring[160]; typedef struct { // 0 = no cursor here, 1 = ok, 2 = arrows ok - short status; + short status; - char name[10]; + char name[10]; // choice = menu item #. // if status = 2, // choice=0:leftarrow,1:rightarrow - void (*routine)(int choice); + void (*routine)(int choice); // hotkey in menu - char alphaKey; + char alphaKey; } menuitem_t; typedef struct menu_s { - short numitems; // # of menu items - struct menu_s* prevMenu; // previous menu - menuitem_t* menuitems; // menu items - void (*routine)(); // draw routine - short x; - short y; // x,y of menu - short lastOn; // last item user was on in menu + short numitems; // # of menu items + struct menu_s* prevMenu; // previous menu + menuitem_t* menuitems; // menu items + void (*routine)(); // draw routine + short x; + short y; // x,y of menu + short lastOn; // last item user was on in menu } menu_t; -short itemOn; // menu item skull is on -short skullAnimCounter; // skull animation counter -short whichSkull; // which skull to draw +short itemOn; // menu item skull is on +short skullAnimCounter; // skull animation counter +short whichSkull; // which skull to draw // graphic name of skulls // warning: initializer-string for array of chars is too long char skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"}; // current menudef -menu_t* currentMenu; +menu_t* currentMenu; // // PROTOTYPES @@ -286,12 +286,12 @@ menuitem_t EpisodeMenu[]= menu_t EpiDef = { - ep_end, // # of menu items - &MainDef, // previous menu - EpisodeMenu, // menuitem_t -> - M_DrawEpisode, // drawing routine -> + ep_end, // # of menu items + &MainDef, // previous menu + EpisodeMenu, // menuitem_t -> + M_DrawEpisode, // drawing routine -> 48,63, // x,y - ep1 // lastOn + ep1 // lastOn }; // @@ -309,21 +309,21 @@ enum menuitem_t NewGameMenu[]= { - {1,"M_JKILL", M_ChooseSkill, 'i'}, - {1,"M_ROUGH", M_ChooseSkill, 'h'}, - {1,"M_HURT", M_ChooseSkill, 'h'}, - {1,"M_ULTRA", M_ChooseSkill, 'u'}, - {1,"M_NMARE", M_ChooseSkill, 'n'} + {1,"M_JKILL", M_ChooseSkill, 'i'}, + {1,"M_ROUGH", M_ChooseSkill, 'h'}, + {1,"M_HURT", M_ChooseSkill, 'h'}, + {1,"M_ULTRA", M_ChooseSkill, 'u'}, + {1,"M_NMARE", M_ChooseSkill, 'n'} }; menu_t NewDef = { - newg_end, // # of menu items - &EpiDef, // previous menu - NewGameMenu, // menuitem_t -> - M_DrawNewGame, // drawing routine -> + newg_end, // # of menu items + &EpiDef, // previous menu + NewGameMenu, // menuitem_t -> + M_DrawNewGame, // drawing routine -> 48,63, // x,y - hurtme // lastOn + hurtme // lastOn }; @@ -346,14 +346,14 @@ enum menuitem_t OptionsMenu[]= { - {1,"M_ENDGAM", M_EndGame,'e'}, - {1,"M_MESSG", M_ChangeMessages,'m'}, - {1,"M_DETAIL", M_ChangeDetail,'g'}, - {2,"M_SCRNSZ", M_SizeDisplay,'s'}, + {1,"M_ENDGAM", M_EndGame,'e'}, + {1,"M_MESSG", M_ChangeMessages,'m'}, + {1,"M_DETAIL", M_ChangeDetail,'g'}, + {2,"M_SCRNSZ", M_SizeDisplay,'s'}, {-1,"",0}, - {2,"M_MSENS", M_ChangeSensitivity,'m'}, + {2,"M_MSENS", M_ChangeSensitivity,'m'}, {-1,"",0}, - {1,"M_SVOL", M_Sound,'s'} + {1,"M_SVOL", M_Sound,'s'} }; menu_t OptionsDef = @@ -509,21 +509,21 @@ void M_ReadSaveStrings(void) int count; int i; char name[256]; - + for (i = 0;i < load_end;i++) { - sprintf(name,SAVEGAMENAME"%d.dsg",i); + sprintf(name,"doomsav%d.dsg",i); - handle = fopen (name, "r"); - if (handle == NULL) - { - strcpy(&savegamestrings[i][0],EMPTYSTRING); - LoadMenu[i].status = 0; - continue; - } - count = fread (&savegamestrings[i], 1, SAVESTRINGSIZE, handle); - fclose (handle); - LoadMenu[i].status = 1; + handle = fopen (name, "r"); + if (handle == NULL) + { + strcpy(&savegamestrings[i][0],EMPTYSTRING); + LoadMenu[i].status = 0; + continue; + } + count = fread (&savegamestrings[i], 1, SAVESTRINGSIZE, handle); + fclose (handle); + LoadMenu[i].status = 1; } } @@ -534,12 +534,12 @@ void M_ReadSaveStrings(void) void M_DrawLoad(void) { int i; - + V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_LOADG",PU_CACHE)); for (i = 0;i < load_end; i++) { - M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); - M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); + M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); + M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); } } @@ -551,13 +551,13 @@ void M_DrawLoad(void) void M_DrawSaveLoadBorder(int x,int y) { int i; - + V_DrawPatchDirect (x-8,y+7,0,W_CacheLumpName("M_LSLEFT",PU_CACHE)); - + for (i = 0;i < 24;i++) { - V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE)); - x += 8; + V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE)); + x += 8; } V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSRGHT",PU_CACHE)); @@ -571,11 +571,12 @@ void M_DrawSaveLoadBorder(int x,int y) void M_LoadSelect(int choice) { char name[256]; - - if (M_CheckParm("-cdrom")) - sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice); - else - sprintf(name,SAVEGAMENAME"%d.dsg",choice); + +// if (M_CheckParm("-cdrom")) +// sprintf(name,"c:\\doomdata\\doomsav%d.dsg",choice); +// else + sprintf(name,"doomsav%d.dsg",choice); + G_LoadGame (name); M_ClearMenus (); } @@ -587,10 +588,10 @@ void M_LoadGame (int choice) { if (netgame) { - M_StartMessage(LOADNET,NULL,false); - return; + M_StartMessage(LOADNET,NULL,false); + return; } - + M_SetupNextMenu(&LoadDef); M_ReadSaveStrings(); } @@ -602,18 +603,18 @@ void M_LoadGame (int choice) void M_DrawSave(void) { int i; - + V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_SAVEG",PU_CACHE)); for (i = 0;i < load_end; i++) { - M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); - M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); + M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); + M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); } - + if (saveStringEnter) { - i = M_StringWidth(savegamestrings[saveSlot]); - M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_"); + i = M_StringWidth(savegamestrings[saveSlot]); + M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_"); } } @@ -622,12 +623,13 @@ void M_DrawSave(void) // void M_DoSave(int slot) { + G_SaveGame (slot,savegamestrings[slot]); M_ClearMenus (); // PICK QUICKSAVE SLOT YET? if (quickSaveSlot == -2) - quickSaveSlot = slot; + quickSaveSlot = slot; } // @@ -641,7 +643,7 @@ void M_SaveSelect(int choice) saveSlot = choice; strcpy(saveOldString,savegamestrings[choice]); if (!strcmp(savegamestrings[choice],EMPTYSTRING)) - savegamestrings[choice][0] = 0; + savegamestrings[choice][0] = 0; saveCharIndex = strlen(savegamestrings[choice]); } @@ -652,13 +654,13 @@ void M_SaveGame (int choice) { if (!usergame) { - M_StartMessage(SAVEDEAD,NULL,false); - return; + M_StartMessage(SAVEDEAD,NULL,false); + return; } - + if (gamestate != GS_LEVEL) - return; - + return; + M_SetupNextMenu(&SaveDef); M_ReadSaveStrings(); } @@ -674,8 +676,8 @@ void M_QuickSaveResponse(int ch) { if (ch == 'y') { - M_DoSave(quickSaveSlot); - S_StartSound(NULL,sfx_swtchx); + M_DoSave(quickSaveSlot); + S_StartSound(NULL,sfx_swtchx); } } @@ -683,20 +685,20 @@ void M_QuickSave(void) { if (!usergame) { - S_StartSound(NULL,sfx_oof); - return; + S_StartSound(NULL,sfx_oof); + return; } if (gamestate != GS_LEVEL) - return; - + return; + if (quickSaveSlot < 0) { - M_StartControlPanel(); - M_ReadSaveStrings(); - M_SetupNextMenu(&SaveDef); - quickSaveSlot = -2; // means to pick a slot now - return; + M_StartControlPanel(); + M_ReadSaveStrings(); + M_SetupNextMenu(&SaveDef); + quickSaveSlot = -2; // means to pick a slot now + return; } sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickSaveResponse,true); @@ -711,8 +713,8 @@ void M_QuickLoadResponse(int ch) { if (ch == 'y') { - M_LoadSelect(quickSaveSlot); - S_StartSound(NULL,sfx_swtchx); + M_LoadSelect(quickSaveSlot); + S_StartSound(NULL,sfx_swtchx); } } @@ -721,14 +723,14 @@ void M_QuickLoad(void) { if (netgame) { - M_StartMessage(QLOADNET,NULL,false); - return; + M_StartMessage(QLOADNET,NULL,false); + return; } - + if (quickSaveSlot < 0) { - M_StartMessage(QSAVESPOT,NULL,false); - return; + M_StartMessage(QSAVESPOT,NULL,false); + return; } sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickLoadResponse,true); @@ -747,15 +749,15 @@ void M_DrawReadThis1(void) switch ( gamemode ) { case commercial: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP",PU_CACHE)); - break; + V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP",PU_CACHE)); + break; case shareware: case registered: case retail: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE)); - break; + V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE)); + break; default: - break; + break; } return; } @@ -772,15 +774,15 @@ void M_DrawReadThis2(void) { case retail: case commercial: - // This hack keeps us from having to change menus. - V_DrawPatchDirect (0,0,0,W_CacheLumpName("CREDIT",PU_CACHE)); - break; + // This hack keeps us from having to change menus. + V_DrawPatchDirect (0,0,0,W_CacheLumpName("CREDIT",PU_CACHE)); + break; case shareware: case registered: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP2",PU_CACHE)); - break; + V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP2",PU_CACHE)); + break; default: - break; + break; } return; } @@ -794,10 +796,10 @@ void M_DrawSound(void) V_DrawPatchDirect (60,38,0,W_CacheLumpName("M_SVOL",PU_CACHE)); M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1), - 16,snd_SfxVolume); + 16,snd_SfxVolume); M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1), - 16,snd_MusicVolume); + 16,snd_MusicVolume); } void M_Sound(int choice) @@ -810,15 +812,15 @@ void M_SfxVol(int choice) switch(choice) { case 0: - if (snd_SfxVolume) - snd_SfxVolume--; - break; + if (snd_SfxVolume) + snd_SfxVolume--; + break; case 1: - if (snd_SfxVolume < 15) - snd_SfxVolume++; - break; + if (snd_SfxVolume < 15) + snd_SfxVolume++; + break; } - + S_SetSfxVolume(snd_SfxVolume /* *8 */); } @@ -827,15 +829,15 @@ void M_MusicVol(int choice) switch(choice) { case 0: - if (snd_MusicVolume) - snd_MusicVolume--; - break; + if (snd_MusicVolume) + snd_MusicVolume--; + break; case 1: - if (snd_MusicVolume < 15) - snd_MusicVolume++; - break; + if (snd_MusicVolume < 15) + snd_MusicVolume++; + break; } - + S_SetMusicVolume(snd_MusicVolume /* *8 */); } @@ -866,14 +868,14 @@ void M_NewGame(int choice) { if (netgame && !demoplayback) { - M_StartMessage(NEWGAME,NULL,false); - return; + M_StartMessage(NEWGAME,NULL,false); + return; } - + if ( gamemode == commercial ) - M_SetupNextMenu(&NewDef); + M_SetupNextMenu(&NewDef); else - M_SetupNextMenu(&EpiDef); + M_SetupNextMenu(&EpiDef); } @@ -890,8 +892,8 @@ void M_DrawEpisode(void) void M_VerifyNightmare(int ch) { if (ch != 'y') - return; - + return; + G_DeferedInitNew(nightmare,epi+1,1); M_ClearMenus (); } @@ -900,10 +902,10 @@ void M_ChooseSkill(int choice) { if (choice == nightmare) { - M_StartMessage(NIGHTMARE,M_VerifyNightmare,true); - return; + M_StartMessage(NIGHTMARE,M_VerifyNightmare,true); + return; } - + G_DeferedInitNew(choice,epi+1,1); M_ClearMenus (); } @@ -911,21 +913,21 @@ void M_ChooseSkill(int choice) void M_Episode(int choice) { if ( (gamemode == shareware) - && choice) + && choice) { - M_StartMessage(SWSTRING,NULL,false); - M_SetupNextMenu(&ReadDef1); - return; + M_StartMessage(SWSTRING,NULL,false); + M_SetupNextMenu(&ReadDef1); + return; } // Yet another hack... if ( (gamemode == registered) - && (choice > 2)) + && (choice > 2)) { // __libclog_printf("M_Episode: 4th episode requires UltimateDOOM\n"); choice = 0; } - + epi = choice; M_SetupNextMenu(&NewDef); } @@ -935,25 +937,25 @@ void M_Episode(int choice) // // M_Options // -char detailNames[2][9] = {"M_GDHIGH","M_GDLOW"}; -char msgNames[2][9] = {"M_MSGOFF","M_MSGON"}; +char detailNames[2][9] = {"M_GDHIGH","M_GDLOW"}; +char msgNames[2][9] = {"M_MSGOFF","M_MSGON"}; void M_DrawOptions(void) { V_DrawPatchDirect (108,15,0,W_CacheLumpName("M_OPTTTL",PU_CACHE)); - + V_DrawPatchDirect (OptionsDef.x + 175,OptionsDef.y+LINEHEIGHT*detail,0, - W_CacheLumpName(detailNames[detailLevel],PU_CACHE)); + W_CacheLumpName(detailNames[detailLevel],PU_CACHE)); V_DrawPatchDirect (OptionsDef.x + 120,OptionsDef.y+LINEHEIGHT*messages,0, - W_CacheLumpName(msgNames[showMessages],PU_CACHE)); + W_CacheLumpName(msgNames[showMessages],PU_CACHE)); M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(mousesens+1), - 10,mouseSensitivity); - + 10,mouseSensitivity); + M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1), - 9,screenSize); + 9,screenSize); } void M_Options(int choice) @@ -971,11 +973,11 @@ void M_ChangeMessages(int choice) // warning: unused parameter `int choice' choice = 0; showMessages = 1 - showMessages; - + if (!showMessages) - players[consoleplayer].message = MSGOFF; + players[consoleplayer].message = MSGOFF; else - players[consoleplayer].message = MSGON ; + players[consoleplayer].message = MSGON ; message_dontfuckwithme = true; } @@ -987,8 +989,8 @@ void M_ChangeMessages(int choice) void M_EndGameResponse(int ch) { if (ch != 'y') - return; - + return; + currentMenu->lastOn = itemOn; M_ClearMenus (); D_StartTitle (); @@ -999,16 +1001,16 @@ void M_EndGame(int choice) choice = 0; if (!usergame) { - S_StartSound(NULL,sfx_oof); - return; + S_StartSound(NULL,sfx_oof); + return; } - + if (netgame) { - M_StartMessage(NETEND,NULL,false); - return; + M_StartMessage(NETEND,NULL,false); + return; } - + M_StartMessage(ENDGAME,M_EndGameResponse,true); } @@ -1071,14 +1073,14 @@ int quitsounds2[8] = void M_QuitResponse(int ch) { if (ch != 'y') - return; + return; if (!netgame) { - if (gamemode == commercial) - S_StartSound(NULL,quitsounds2[(gametic>>2)&7]); - else - S_StartSound(NULL,quitsounds[(gametic>>2)&7]); - I_WaitVBL(105); + if (gamemode == commercial) + S_StartSound(NULL,quitsounds2[(gametic>>2)&7]); + else + S_StartSound(NULL,quitsounds[(gametic>>2)&7]); + I_WaitVBL(105); } I_Quit (); } @@ -1105,13 +1107,13 @@ void M_ChangeSensitivity(int choice) switch(choice) { case 0: - if (mouseSensitivity) - mouseSensitivity--; - break; + if (mouseSensitivity) + mouseSensitivity--; + break; case 1: - if (mouseSensitivity < 9) - mouseSensitivity++; - break; + if (mouseSensitivity < 9) + mouseSensitivity++; + break; } } @@ -1131,9 +1133,9 @@ void M_ChangeDetail(int choice) /*R_SetViewSize (screenblocks, detailLevel); if (!detailLevel) - players[consoleplayer].message = DETAILHI; + players[consoleplayer].message = DETAILHI; else - players[consoleplayer].message = DETAILLO;*/ + players[consoleplayer].message = DETAILLO;*/ } @@ -1144,21 +1146,21 @@ void M_SizeDisplay(int choice) switch(choice) { case 0: - if (screenSize > 0) - { - screenblocks--; - screenSize--; - } - break; + if (screenSize > 0) + { + screenblocks--; + screenSize--; + } + break; case 1: - if (screenSize < 8) - { - screenblocks++; - screenSize++; - } - break; + if (screenSize < 8) + { + screenblocks++; + screenSize++; + } + break; } - + R_SetViewSize (screenblocks, detailLevel); } @@ -1171,54 +1173,54 @@ void M_SizeDisplay(int choice) // void M_DrawThermo -( int x, - int y, - int thermWidth, - int thermDot ) +( int x, + int y, + int thermWidth, + int thermDot ) { - int xx; - int i; + int xx; + int i; xx = x; V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERML",PU_CACHE)); xx += 8; for (i=0;ix - 10, menu->y+item*LINEHEIGHT - 1, 0, - W_CacheLumpName("M_CELL1",PU_CACHE)); + W_CacheLumpName("M_CELL1",PU_CACHE)); } void M_DrawSelCell -( menu_t* menu, - int item ) +( menu_t* menu, + int item ) { V_DrawPatchDirect (menu->x - 10, menu->y+item*LINEHEIGHT - 1, 0, - W_CacheLumpName("M_CELL2",PU_CACHE)); + W_CacheLumpName("M_CELL2",PU_CACHE)); } void M_StartMessage -( char* string, - void* routine, - boolean input ) +( char* string, + void* routine, + boolean input ) { messageLastMenuActive = menuactive; messageToPrint = 1; @@ -1247,16 +1249,16 @@ int M_StringWidth(char* string) int i; int w = 0; int c; - + for (i = 0;i < strlen(string);i++) { - c = toupper(string[i]) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE) - w += 4; - else - w += SHORT (hu_font[c]->width); + c = toupper(string[i]) - HU_FONTSTART; + if (c < 0 || c >= HU_FONTSIZE) + w += 4; + else + w += SHORT (hu_font[c]->width); } - + return w; } @@ -1270,12 +1272,12 @@ int M_StringHeight(char* string) int i; int h; int height = SHORT(hu_font[0]->height); - + h = height; for (i = 0;i < strlen(string);i++) - if (string[i] == '\n') - h += height; - + if (string[i] == '\n') + h += height; + return h; } @@ -1285,45 +1287,45 @@ int M_StringHeight(char* string) // void M_WriteText -( int x, - int y, - char* string) +( int x, + int y, + char* string) { - int w; - char* ch; - int c; - int cx; - int cy; - + int w; + char* ch; + int c; + int cx; + int cy; + ch = string; cx = x; cy = y; - + while(1) { - c = *ch++; - if (!c) - break; - if (c == '\n') - { - cx = x; - cy += 12; - continue; - } - - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c>= HU_FONTSIZE) - { - cx += 4; - continue; - } - - w = SHORT (hu_font[c]->width); - if (cx+w > SCREENWIDTH) - break; - V_DrawPatchDirect(cx, cy, 0, hu_font[c]); - cx+=w; + c = *ch++; + if (!c) + break; + if (c == '\n') + { + cx = x; + cy += 12; + continue; + } + + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c>= HU_FONTSIZE) + { + cx += 4; + continue; + } + + w = SHORT (hu_font[c]->width); + if (cx+w > SCREENWIDTH) + break; + V_DrawPatchDirect(cx, cy, 0, hu_font[c]); + cx+=w; } } @@ -1346,265 +1348,265 @@ boolean M_Responder (event_t* ev) static int lasty = 0; static int mousex = 0; static int lastx = 0; - + ch = -1; - + if (ev->type == ev_joystick && joywait < I_GetTime()) { - if (ev->data3 == -1) - { - ch = KEY_UPARROW; - joywait = I_GetTime() + 5; - } - else if (ev->data3 == 1) - { - ch = KEY_DOWNARROW; - joywait = I_GetTime() + 5; - } - - if (ev->data2 == -1) - { - ch = KEY_LEFTARROW; - joywait = I_GetTime() + 2; - } - else if (ev->data2 == 1) - { - ch = KEY_RIGHTARROW; - joywait = I_GetTime() + 2; - } - - if (ev->data1&1) - { - ch = KEY_ENTER; - joywait = I_GetTime() + 5; - } - if (ev->data1&2) - { - ch = KEY_BACKSPACE; - joywait = I_GetTime() + 5; - } + if (ev->data3 == -1) + { + ch = KEY_UPARROW; + joywait = I_GetTime() + 5; + } + else if (ev->data3 == 1) + { + ch = KEY_DOWNARROW; + joywait = I_GetTime() + 5; + } + + if (ev->data2 == -1) + { + ch = KEY_LEFTARROW; + joywait = I_GetTime() + 2; + } + else if (ev->data2 == 1) + { + ch = KEY_RIGHTARROW; + joywait = I_GetTime() + 2; + } + + if (ev->data1&1) + { + ch = KEY_ENTER; + joywait = I_GetTime() + 5; + } + if (ev->data1&2) + { + ch = KEY_BACKSPACE; + joywait = I_GetTime() + 5; + } } else { - if (ev->type == ev_mouse && mousewait < I_GetTime()) - { - mousey += ev->data3; - if (mousey < lasty-30) - { - ch = KEY_DOWNARROW; - mousewait = I_GetTime() + 5; - mousey = lasty -= 30; - } - else if (mousey > lasty+30) - { - ch = KEY_UPARROW; - mousewait = I_GetTime() + 5; - mousey = lasty += 30; - } - - mousex += ev->data2; - if (mousex < lastx-30) - { - ch = KEY_LEFTARROW; - mousewait = I_GetTime() + 5; - mousex = lastx -= 30; - } - else if (mousex > lastx+30) - { - ch = KEY_RIGHTARROW; - mousewait = I_GetTime() + 5; - mousex = lastx += 30; - } - - if (ev->data1&1) - { - ch = KEY_ENTER; - mousewait = I_GetTime() + 15; - } - - if (ev->data1&2) - { - ch = KEY_BACKSPACE; - mousewait = I_GetTime() + 15; - } - } - else - if (ev->type == ev_keydown) - { - ch = ev->data1; - } + if (ev->type == ev_mouse && mousewait < I_GetTime()) + { + mousey += ev->data3; + if (mousey < lasty-30) + { + ch = KEY_DOWNARROW; + mousewait = I_GetTime() + 5; + mousey = lasty -= 30; + } + else if (mousey > lasty+30) + { + ch = KEY_UPARROW; + mousewait = I_GetTime() + 5; + mousey = lasty += 30; + } + + mousex += ev->data2; + if (mousex < lastx-30) + { + ch = KEY_LEFTARROW; + mousewait = I_GetTime() + 5; + mousex = lastx -= 30; + } + else if (mousex > lastx+30) + { + ch = KEY_RIGHTARROW; + mousewait = I_GetTime() + 5; + mousex = lastx += 30; + } + + if (ev->data1&1) + { + ch = KEY_ENTER; + mousewait = I_GetTime() + 15; + } + + if (ev->data1&2) + { + ch = KEY_BACKSPACE; + mousewait = I_GetTime() + 15; + } + } + else + if (ev->type == ev_keydown) + { + ch = ev->data1; + } } if (ch == -1) - return false; + return false; // Save Game string input if (saveStringEnter) { - switch(ch) - { - case KEY_BACKSPACE: - if (saveCharIndex > 0) - { - saveCharIndex--; - savegamestrings[saveSlot][saveCharIndex] = 0; - } - break; - - case KEY_ESCAPE: - saveStringEnter = 0; - strcpy(&savegamestrings[saveSlot][0],saveOldString); - break; - - case KEY_ENTER: - saveStringEnter = 0; - if (savegamestrings[saveSlot][0]) - M_DoSave(saveSlot); - break; - - default: - ch = toupper(ch); - if (ch != 32) - if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE) - break; - if (ch >= 32 && ch <= 127 && - saveCharIndex < SAVESTRINGSIZE-1 && - M_StringWidth(savegamestrings[saveSlot]) < - (SAVESTRINGSIZE-2)*8) - { - savegamestrings[saveSlot][saveCharIndex++] = ch; - savegamestrings[saveSlot][saveCharIndex] = 0; - } - break; - } - return true; + switch(ch) + { + case KEY_BACKSPACE: + if (saveCharIndex > 0) + { + saveCharIndex--; + savegamestrings[saveSlot][saveCharIndex] = 0; + } + break; + + case KEY_ESCAPE: + saveStringEnter = 0; + strcpy(&savegamestrings[saveSlot][0],saveOldString); + break; + + case KEY_ENTER: + saveStringEnter = 0; + if (savegamestrings[saveSlot][0]) + M_DoSave(saveSlot); + break; + + default: + ch = toupper(ch); + if (ch != 32) + if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE) + break; + if (ch >= 32 && ch <= 127 && + saveCharIndex < SAVESTRINGSIZE-1 && + M_StringWidth(savegamestrings[saveSlot]) < + (SAVESTRINGSIZE-2)*8) + { + savegamestrings[saveSlot][saveCharIndex++] = ch; + savegamestrings[saveSlot][saveCharIndex] = 0; + } + break; + } + return true; } // Take care of any messages that need input if (messageToPrint) { - if (messageNeedsInput == true && - !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE)) - return false; - - menuactive = messageLastMenuActive; - messageToPrint = 0; - if (messageRoutine) - messageRoutine(ch); - - menuactive = false; - S_StartSound(NULL,sfx_swtchx); - return true; + if (messageNeedsInput == true && + !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE)) + return false; + + menuactive = messageLastMenuActive; + messageToPrint = 0; + if (messageRoutine) + messageRoutine(ch); + + menuactive = false; + S_StartSound(NULL,sfx_swtchx); + return true; } - + if (devparm && ch == KEY_F1) { - G_ScreenShot (); - return true; + G_ScreenShot (); + return true; } - + // F-Keys if (!menuactive) - switch(ch) - { - case KEY_MINUS: // Screen size down - if (automapactive || chat_on) - return false; - M_SizeDisplay(0); - S_StartSound(NULL,sfx_stnmov); - return true; - - case KEY_EQUALS: // Screen size up - if (automapactive || chat_on) - return false; - M_SizeDisplay(1); - S_StartSound(NULL,sfx_stnmov); - return true; - - case KEY_F1: // Help key - M_StartControlPanel (); + switch(ch) + { + case KEY_MINUS: // Screen size down + if (automapactive || chat_on) + return false; + M_SizeDisplay(0); + S_StartSound(NULL,sfx_stnmov); + return true; + + case KEY_EQUALS: // Screen size up + if (automapactive || chat_on) + return false; + M_SizeDisplay(1); + S_StartSound(NULL,sfx_stnmov); + return true; + + case KEY_F1: // Help key + M_StartControlPanel (); - if ( gamemode == retail ) - currentMenu = &ReadDef2; - else - currentMenu = &ReadDef1; - - itemOn = 0; - S_StartSound(NULL,sfx_swtchn); - return true; - - case KEY_F2: // Save - M_StartControlPanel(); - S_StartSound(NULL,sfx_swtchn); - M_SaveGame(0); - return true; - - case KEY_F3: // Load - M_StartControlPanel(); - S_StartSound(NULL,sfx_swtchn); - M_LoadGame(0); - return true; - - case KEY_F4: // Sound Volume - M_StartControlPanel (); - currentMenu = &SoundDef; - itemOn = sfx_vol; - S_StartSound(NULL,sfx_swtchn); - return true; - - case KEY_F5: // Detail toggle - M_ChangeDetail(0); - S_StartSound(NULL,sfx_swtchn); - return true; - - case KEY_F6: // Quicksave - S_StartSound(NULL,sfx_swtchn); - M_QuickSave(); - return true; - - case KEY_F7: // End game - S_StartSound(NULL,sfx_swtchn); - M_EndGame(0); - return true; - - case KEY_F8: // Toggle messages - M_ChangeMessages(0); - S_StartSound(NULL,sfx_swtchn); - return true; - - case KEY_F9: // Quickload - S_StartSound(NULL,sfx_swtchn); - M_QuickLoad(); - return true; - - case KEY_F10: // Quit DOOM - S_StartSound(NULL,sfx_swtchn); - M_QuitDOOM(0); - return true; - - case KEY_F11: // gamma toggle - usegamma++; - if (usegamma > 4) - usegamma = 0; - players[consoleplayer].message = gammamsg[usegamma]; - I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE)); - return true; - - } + if ( gamemode == retail ) + currentMenu = &ReadDef2; + else + currentMenu = &ReadDef1; + + itemOn = 0; + S_StartSound(NULL,sfx_swtchn); + return true; + + case KEY_F2: // Save + M_StartControlPanel(); + S_StartSound(NULL,sfx_swtchn); + M_SaveGame(0); + return true; + + case KEY_F3: // Load + M_StartControlPanel(); + S_StartSound(NULL,sfx_swtchn); + M_LoadGame(0); + return true; + + case KEY_F4: // Sound Volume + M_StartControlPanel (); + currentMenu = &SoundDef; + itemOn = sfx_vol; + S_StartSound(NULL,sfx_swtchn); + return true; + + case KEY_F5: // Detail toggle + M_ChangeDetail(0); + S_StartSound(NULL,sfx_swtchn); + return true; + + case KEY_F6: // Quicksave + S_StartSound(NULL,sfx_swtchn); + M_QuickSave(); + return true; + + case KEY_F7: // End game + S_StartSound(NULL,sfx_swtchn); + M_EndGame(0); + return true; + + case KEY_F8: // Toggle messages + M_ChangeMessages(0); + S_StartSound(NULL,sfx_swtchn); + return true; + + case KEY_F9: // Quickload + S_StartSound(NULL,sfx_swtchn); + M_QuickLoad(); + return true; + + case KEY_F10: // Quit DOOM + S_StartSound(NULL,sfx_swtchn); + M_QuitDOOM(0); + return true; + + case KEY_F11: // gamma toggle + usegamma++; + if (usegamma > 4) + usegamma = 0; + players[consoleplayer].message = gammamsg[usegamma]; + I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE)); + return true; + + } // Pop-up menu? if (!menuactive) { - if (ch == KEY_ESCAPE) - { - M_StartControlPanel (); - S_StartSound(NULL,sfx_swtchn); - return true; - } - return false; + if (ch == KEY_ESCAPE) + { + M_StartControlPanel (); + S_StartSound(NULL,sfx_swtchn); + return true; + } + return false; } @@ -1612,94 +1614,94 @@ boolean M_Responder (event_t* ev) switch (ch) { case KEY_DOWNARROW: - do - { - if (itemOn+1 > currentMenu->numitems-1) - itemOn = 0; - else itemOn++; - S_StartSound(NULL,sfx_pstop); - } while(currentMenu->menuitems[itemOn].status==-1); - return true; - + do + { + if (itemOn+1 > currentMenu->numitems-1) + itemOn = 0; + else itemOn++; + S_StartSound(NULL,sfx_pstop); + } while(currentMenu->menuitems[itemOn].status==-1); + return true; + case KEY_UPARROW: - do - { - if (!itemOn) - itemOn = currentMenu->numitems-1; - else itemOn--; - S_StartSound(NULL,sfx_pstop); - } while(currentMenu->menuitems[itemOn].status==-1); - return true; + do + { + if (!itemOn) + itemOn = currentMenu->numitems-1; + else itemOn--; + S_StartSound(NULL,sfx_pstop); + } while(currentMenu->menuitems[itemOn].status==-1); + return true; case KEY_LEFTARROW: - if (currentMenu->menuitems[itemOn].routine && - currentMenu->menuitems[itemOn].status == 2) - { - S_StartSound(NULL,sfx_stnmov); - currentMenu->menuitems[itemOn].routine(0); - } - return true; - + if (currentMenu->menuitems[itemOn].routine && + currentMenu->menuitems[itemOn].status == 2) + { + S_StartSound(NULL,sfx_stnmov); + currentMenu->menuitems[itemOn].routine(0); + } + return true; + case KEY_RIGHTARROW: - if (currentMenu->menuitems[itemOn].routine && - currentMenu->menuitems[itemOn].status == 2) - { - S_StartSound(NULL,sfx_stnmov); - currentMenu->menuitems[itemOn].routine(1); - } - return true; + if (currentMenu->menuitems[itemOn].routine && + currentMenu->menuitems[itemOn].status == 2) + { + S_StartSound(NULL,sfx_stnmov); + currentMenu->menuitems[itemOn].routine(1); + } + return true; case KEY_ENTER: - if (currentMenu->menuitems[itemOn].routine && - currentMenu->menuitems[itemOn].status) - { - currentMenu->lastOn = itemOn; - if (currentMenu->menuitems[itemOn].status == 2) - { - currentMenu->menuitems[itemOn].routine(1); // right arrow - S_StartSound(NULL,sfx_stnmov); - } - else - { - currentMenu->menuitems[itemOn].routine(itemOn); - S_StartSound(NULL,sfx_pistol); - } - } - return true; - + if (currentMenu->menuitems[itemOn].routine && + currentMenu->menuitems[itemOn].status) + { + currentMenu->lastOn = itemOn; + if (currentMenu->menuitems[itemOn].status == 2) + { + currentMenu->menuitems[itemOn].routine(1); // right arrow + S_StartSound(NULL,sfx_stnmov); + } + else + { + currentMenu->menuitems[itemOn].routine(itemOn); + S_StartSound(NULL,sfx_pistol); + } + } + return true; + case KEY_ESCAPE: - currentMenu->lastOn = itemOn; - M_ClearMenus (); - S_StartSound(NULL,sfx_swtchx); - return true; - + currentMenu->lastOn = itemOn; + M_ClearMenus (); + S_StartSound(NULL,sfx_swtchx); + return true; + case KEY_BACKSPACE: - currentMenu->lastOn = itemOn; - if (currentMenu->prevMenu) - { - currentMenu = currentMenu->prevMenu; - itemOn = currentMenu->lastOn; - S_StartSound(NULL,sfx_swtchn); - } - return true; - + currentMenu->lastOn = itemOn; + if (currentMenu->prevMenu) + { + currentMenu = currentMenu->prevMenu; + itemOn = currentMenu->lastOn; + S_StartSound(NULL,sfx_swtchn); + } + return true; + default: - for (i = itemOn+1;i < currentMenu->numitems;i++) - if (currentMenu->menuitems[i].alphaKey == ch) - { - itemOn = i; - S_StartSound(NULL,sfx_pstop); - return true; - } - for (i = 0;i <= itemOn;i++) - if (currentMenu->menuitems[i].alphaKey == ch) - { - itemOn = i; - S_StartSound(NULL,sfx_pstop); - return true; - } - break; - + for (i = itemOn+1;i < currentMenu->numitems;i++) + if (currentMenu->menuitems[i].alphaKey == ch) + { + itemOn = i; + S_StartSound(NULL,sfx_pstop); + return true; + } + for (i = 0;i <= itemOn;i++) + if (currentMenu->menuitems[i].alphaKey == ch) + { + itemOn = i; + S_StartSound(NULL,sfx_pstop); + return true; + } + break; + } return false; @@ -1714,7 +1716,7 @@ void M_StartControlPanel (void) { // intro might call this repeatedly if (menuactive) - return; + return; menuactive = 1; currentMenu = &MainDef; // JDC @@ -1729,36 +1731,36 @@ void M_StartControlPanel (void) // void M_Drawer (void) { - static short x; - static short y; - short i; - short max; + static short x; + static short y; + short i; + short max; char *p; int len; - char string[40]; - int start; + char string[40]; + int start; inhelpscreens = false; // Horiz. & Vertically center string and print it. if (messageToPrint) { - y = 100 - M_StringHeight(messageString)/2; - p = messageString; - len = strlen(p); - while(*p) - { + y = 100 - M_StringHeight(messageString)/2; + p = messageString; + len = strlen(p); + while(*p) + { for (i = 0;len;i++,len--) { - if (*(p+i) == '\n') - { memset(string,0,40); - strncpy(string,p,i); - p+= i+1; - len-= 1; - break; - }; - }; - + if (*(p+i) == '\n') + { memset(string,0,40); + strncpy(string,p,i); + p+= i+1; + len-= 1; + break; + }; + }; + if (len == 0) { strncpy(string,p,i); p+=i; @@ -1766,15 +1768,15 @@ void M_Drawer (void) x = 160 - M_StringWidth(string)/2; M_WriteText(x,y,string); y += SHORT(hu_font[0]->height); - }; - return; + }; + return; }; if (!menuactive) - return; + return; if (currentMenu->routine) - currentMenu->routine(); // call Draw routine + currentMenu->routine(); // call Draw routine // DRAW MENU x = currentMenu->x; @@ -1783,16 +1785,16 @@ void M_Drawer (void) for (i=0;imenuitems[i].name[0]) - V_DrawPatchDirect (x,y,0, - W_CacheLumpName(currentMenu->menuitems[i].name ,PU_CACHE)); - y += LINEHEIGHT; + if (currentMenu->menuitems[i].name[0]) + V_DrawPatchDirect (x,y,0, + W_CacheLumpName(currentMenu->menuitems[i].name ,PU_CACHE)); + y += LINEHEIGHT; } // DRAW SKULL V_DrawPatchDirect(x + SKULLXOFF,currentMenu->y - 5 + itemOn*LINEHEIGHT, 0, - W_CacheLumpName(skullName[whichSkull],PU_CACHE)); + W_CacheLumpName(skullName[whichSkull],PU_CACHE)); } @@ -1827,8 +1829,8 @@ void M_Ticker (void) { if (--skullAnimCounter <= 0) { - whichSkull ^= 1; - skullAnimCounter = 8; + whichSkull ^= 1; + skullAnimCounter = 8; } } @@ -1856,29 +1858,29 @@ void M_Init (void) switch ( gamemode ) { case commercial: - // This is used because DOOM 2 had only one HELP + // This is used because DOOM 2 had only one HELP // page. I use CREDIT as second page now, but - // kept this hack for educational purposes. - MainMenu[readthis] = MainMenu[quitdoom]; - MainDef.numitems--; - MainDef.y += 8; - NewDef.prevMenu = &MainDef; - ReadDef1.routine = M_DrawReadThis1; - ReadDef1.x = 330; - ReadDef1.y = 165; - ReadMenu1[0].routine = M_FinishReadThis; - break; + // kept this hack for educational purposes. + MainMenu[readthis] = MainMenu[quitdoom]; + MainDef.numitems--; + MainDef.y += 8; + NewDef.prevMenu = &MainDef; + ReadDef1.routine = M_DrawReadThis1; + ReadDef1.x = 330; + ReadDef1.y = 165; + ReadMenu1[0].routine = M_FinishReadThis; + break; case shareware: - // Episode 2 and 3 are handled, - // branching to an ad screen. + // Episode 2 and 3 are handled, + // branching to an ad screen. case registered: - // We need to remove the fourth episode. - EpiDef.numitems--; - break; + // We need to remove the fourth episode. + EpiDef.numitems--; + break; case retail: - // We are fine. + // We are fine. default: - break; + break; } } diff --git a/programs/games/doom/trunk/m_misc.c b/programs/games/doom/trunk/m_misc.c index d8aaeda953..5c751730fc 100644 --- a/programs/games/doom/trunk/m_misc.c +++ b/programs/games/doom/trunk/m_misc.c @@ -29,7 +29,6 @@ rcsid[] = "$Id: m_misc.c,v 1.6 1997/02/03 22:45:10 b1 Exp $"; #include #include -//#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; diff --git a/programs/games/doom/trunk/s_sound.c b/programs/games/doom/trunk/s_sound.c index d6473818ce..981fe4c821 100644 --- a/programs/games/doom/trunk/s_sound.c +++ b/programs/games/doom/trunk/s_sound.c @@ -256,11 +256,23 @@ void sound_proc(void) }; } - - if(ver< SOUND_VERSION) + + if( SOUND_VERSION>(ver&0xFFFF)) + { + 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 service version mismatch\n\r"); - printf("Installed version: %d, required version %d\n\r", + printf("Sound version obsolete\n\r"); + printf("Compatible version: %d, required version %d\n\r", ver, SOUND_VERSION); _asm { diff --git a/programs/games/doom/trunk/h/kolibri.h b/programs/games/doom/trunk/system/include/kolibri.h similarity index 62% rename from programs/games/doom/trunk/h/kolibri.h rename to programs/games/doom/trunk/system/include/kolibri.h index 78c906769e..fe96fbd1f8 100644 --- a/programs/games/doom/trunk/h/kolibri.h +++ b/programs/games/doom/trunk/system/include/kolibri.h @@ -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" } diff --git a/programs/games/doom/trunk/kolibc/include/sound.h b/programs/games/doom/trunk/system/include/sound.h similarity index 88% rename from programs/games/doom/trunk/kolibc/include/sound.h rename to programs/games/doom/trunk/system/include/sound.h index 0e9454d3ce..430c210e36 100644 --- a/programs/games/doom/trunk/kolibc/include/sound.h +++ b/programs/games/doom/trunk/system/include/sound.h @@ -7,8 +7,7 @@ extern "C" { #endif -#define SOUND_VERSION 5 - +#define SOUND_VERSION 0x0100 #define PCM_ALL 0 #define PCM_OUT 0x08000000 @@ -58,7 +57,7 @@ extern "C" #define SND_CREATE_BUFF 1 #define SND_DESTROY_BUFF 2 #define SND_SETFORMAT 3 -#define SND_GETFORMAT 4 +#define SND_GETFORMAT 4 #define SND_RESET 5 #define SND_SETPOS 6 #define SND_GETPOS 7 @@ -81,8 +80,8 @@ int _stdcall InitSound(int *version); int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf); int _stdcall DestroyBuffer(SNDBUF hBuff); -int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); -int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format); +int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); +int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format); int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); int _stdcall SetBufferPos(SNDBUF hBuff, int offset); @@ -94,12 +93,12 @@ int _stdcall SetBuffer(SNDBUF hBuff,void* buff, int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags); int _stdcall StopBuffer(SNDBUF hBuff); - + int _stdcall SetVolume(SNDBUF hBuff, int left, int right); int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); int _stdcall SetPan(SNDBUF hBuff, int pan); int _stdcall GetPan(SNDBUF hBuff, int *pan); - + int _stdcall GetMasterVol(int* vol); int _stdcall SetMasterVol(int vol); diff --git a/programs/games/doom/trunk/w_wad.c b/programs/games/doom/trunk/w_wad.c index 24f7830ce0..9fef57338a 100644 --- a/programs/games/doom/trunk/w_wad.c +++ b/programs/games/doom/trunk/w_wad.c @@ -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;