Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 323 → Rev 324

/programs/games/doom/trunk/d_net.h
File deleted
/programs/games/doom/trunk/p_local.h
File deleted
/programs/games/doom/trunk/i_video.h
File deleted
/programs/games/doom/trunk/r_bsp.h
File deleted
/programs/games/doom/trunk/d_englsh.h
File deleted
/programs/games/doom/trunk/doomstat.h
File deleted
/programs/games/doom/trunk/hu_stuff.h
File deleted
/programs/games/doom/trunk/r_draw.h
File deleted
/programs/games/doom/trunk/r_things.h
File deleted
/programs/games/doom/trunk/st_lib.h
File deleted
/programs/games/doom/trunk/d_think.h
File deleted
/programs/games/doom/trunk/m_bbox.h
File deleted
/programs/games/doom/trunk/d_textur.h
File deleted
/programs/games/doom/trunk/f_wipe.h
File deleted
/programs/games/doom/trunk/m_menu.h
File deleted
/programs/games/doom/trunk/r_segs.h
File deleted
/programs/games/doom/trunk/m_misc.h
File deleted
/programs/games/doom/trunk/v_video.h
File deleted
/programs/games/doom/trunk/z_zone.h
File deleted
/programs/games/doom/trunk/d_event.h
File deleted
/programs/games/doom/trunk/d_french.h
File deleted
/programs/games/doom/trunk/r_plane.h
File deleted
/programs/games/doom/trunk/d_player.h
File deleted
/programs/games/doom/trunk/m_cheat.h
File deleted
/programs/games/doom/trunk/r_local.h
File deleted
/programs/games/doom/trunk/doomdata.h
File deleted
/programs/games/doom/trunk/i_sound.h
File deleted
/programs/games/doom/trunk/f_finale.h
File deleted
/programs/games/doom/trunk/r_sky.h
File deleted
/programs/games/doom/trunk/p_setup.h
File deleted
/programs/games/doom/trunk/i_system.h
File deleted
/programs/games/doom/trunk/d_items.h
File deleted
/programs/games/doom/trunk/st_stuff.h
File deleted
/programs/games/doom/trunk/m_random.h
File deleted
/programs/games/doom/trunk/wi_stuff.h
File deleted
/programs/games/doom/trunk/info.h
File deleted
/programs/games/doom/trunk/m_fixed.h
File deleted
/programs/games/doom/trunk/am_map.h
File deleted
/programs/games/doom/trunk/dstrings.h
File deleted
/programs/games/doom/trunk/hu_lib.h
File deleted
/programs/games/doom/trunk/d_main.h
File deleted
/programs/games/doom/trunk/s_sound.h
File deleted
/programs/games/doom/trunk/m_argv.h
File deleted
/programs/games/doom/trunk/g_game.h
File deleted
/programs/games/doom/trunk/m_swap.h
File deleted
/programs/games/doom/trunk/p_mobj.h
File deleted
/programs/games/doom/trunk/tables.h
File deleted
/programs/games/doom/trunk/r_defs.h
File deleted
/programs/games/doom/trunk/p_tick.h
File deleted
/programs/games/doom/trunk/p_spec.h
File deleted
/programs/games/doom/trunk/sounds.h
File deleted
/programs/games/doom/trunk/r_main.h
File deleted
/programs/games/doom/trunk/w_wad.h
File deleted
/programs/games/doom/trunk/r_data.h
File deleted
/programs/games/doom/trunk/p_pspr.h
File deleted
/programs/games/doom/trunk/d_ticcmd.h
File deleted
/programs/games/doom/trunk/p_inter.h
File deleted
/programs/games/doom/trunk/doomdef.h
File deleted
/programs/games/doom/trunk/doomtype.h
File deleted
/programs/games/doom/trunk/r_state.h
File deleted
/programs/games/doom/trunk/i_net.h
File deleted
/programs/games/doom/trunk/p_saveg.h
File deleted
/programs/games/doom/trunk/kolibc/include/kolibc.h
15,9 → 15,11
typedef unsigned int fpos_t;
typedef unsigned int size_t;
 
#define NULL (void*)0
#//define NULL (void*)0
 
typedef enum SEEKPOS {SEEK_SET=0,SEEK_CUR,SEEK_END};
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
 
#define FILE_OPEN_READ 0x01
#define FILE_OPEN_WRITE 0x02
111,6 → 113,7
 
#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);
139,19 → 142,36
#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*,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 *malloc(size_t size);
extern void* realloc(void* oldmem, size_t bytes);
extern void free(void *mem);
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
#endif //kolibc_h
 
 
/programs/games/doom/trunk/kolibc/include/kolibri.h
64,6 → 64,8
 
void _stdcall InitHeap(int heap_size);
void* _stdcall UserAlloc(int size);
int _stdcall UserFree(void* p);
void _stdcall GetNotify(DWORD *event);
 
//void _stdcall CreateThread(void *fn, char *p_stack);
82,13 → 84,16
void _stdcall debug_out_hex(DWORD val);
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 read_file (const char *name,char*buff,DWORD offset, DWORD count,DWORD *reads);
int _stdcall write_file(const char *name,char*buff,int offset,int count,int *writes);
 
//void exit();
int _cdecl get_key(void);
int _stdcall get_key(int *key);
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();
/programs/games/doom/trunk/kolibc/include/mf.h
1,5 → 1,15
#include "kolibc.h"
 
 
//#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
41,7 → 51,7
typedef struct t_chunk* tchunkptr;
typedef struct t_chunk* tbinptr;
 
struct m_state
typedef struct m_state
{
dword smallmap;
dword treemap;
55,27 → 65,19
tbinptr treebins[32];
};
 
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
 
extern struct m_state ms;
void _cdecl mf_init();
void* _cdecl dlmalloc(size_t);
void* _cdecl dlrealloc(void *,size_t);
void _cdecl dlfree(void*);
 
void init_malloc(void* p);
void* mf_alloc(size_t);
void mf_free(void*);
 
#ifdef __cplusplus
}
#endif /* __cplusplus */
 
 
dword compute_tree_index(size_t s);
 
void insert_chunk(mchunkptr P, size_t S);
void insert_large_chunk(tchunkptr X, size_t S);
static void insert_chunk(mchunkptr P, size_t S);
static void insert_large_chunk(tchunkptr X, size_t S);
 
void unlink_large_chunk(tchunkptr X);
static void unlink_large_chunk(tchunkptr X);
 
//void replace_dv(mchunkptr P, size_t S);
static void* malloc_small(size_t nb);
89,3 → 91,10
#define mem2chunk(mem) (mchunkptr)((char*)mem - 8)
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
 
 
#ifdef __cplusplus
}
#endif /* __cplusplus */
 
 
 
/programs/games/doom/trunk/kolibc/src/file/fclose.c
6,13 → 6,13
{
int err;
if((file->mode & FILE_OPEN_WRITE)||
(file->mode & FILE_OPEN_APPEND)||
(file->mode & FILE_OPEN_PLUS))
err=write_buffer(file);
// if((file->mode & FILE_OPEN_WRITE)||
// (file->mode & FILE_OPEN_APPEND)||
// (file->mode & FILE_OPEN_PLUS))
// err=write_buffer(file);
free(file->buffer);
free(file->filename);
free(file);
// UserFree dlfree(file->buffer);
dlfree(file->filename);
dlfree(file);
return err == 0 ? 0:EOF;
}
}
/programs/games/doom/trunk/kolibc/src/file/fgetc.c
9,7 → 9,7
return EOF;
 
if(f->remain ==0)
{ f->filepos+=4096;
{ f->filepos+=8192;
if(!fill_buff(f))
return EOF;
};
/programs/games/doom/trunk/kolibc/src/file/fopen.c
1,58 → 1,78
 
#include "kolibri.h"
#include <string.h>
#include <malloc.h>
#include "kolibc.h"
#include "kolibri.h"
 
extern struct{int argc; char** argv;} __ARGS;
extern char *__appcwd;
extern int __appcwdlen;
 
char* getfullpath(const char* relpath){
byte prev_is_slash=0;
char* getfullpath(char* path)
{
int prev_is_slash=0;
int len=0, depth=0, i;
char* buff;
buff = (char*)malloc(strlen(relpath));
strcpy(buff, relpath);
/**********
buff = (char*)malloc(strlen(__ARGS.argv[0]) + strlen(relpath));
char c;
if(*relpath == '/') buff[0] = '\0';
else {
len = strrchr(__ARGS.argv[0], '/') - __ARGS.argv[0] + 1;
strncpy(buff, __ARGS.argv[0], len);
len= __appcwdlen;
buff = (char*)malloc(len+strlen(path)+1);
strncpy(buff, __appcwd, __appcwdlen);
if(*path == '/')
{ buff[0] = '\0';
len=0;
}
else
{
prev_is_slash = 1;
buff[len] = 0;
for(i=0; buff[i]; i++)
if(buff[i] == '/' && i < len-1) depth++;
}
for (; *relpath; relpath++){
switch (*relpath){
case '/':
prev_is_slash = 1;
buff[len++] = '/';
break;
while(c=*path++)
{
switch (c)
{
case '.':
if(*(relpath+1) == '.' && *(relpath+2) == '/' && prev_is_slash){
if(!depth) return 0;
if((*path == '.')&&
(*path+1)== '/')
{ if(!depth)
{ free(buff);
return 0;
};
buff[len-1] = 0;
len = strrchr(buff, '/') + 1 - buff;
buff[len] = 0;
depth--;
relpath += 2;
} else {
depth++;
buff[len++] = '.';
path +=2;
prev_is_slash = 1;
continue;
}
break;
if(*path == '/')
{
path++;
prev_is_slash = 1;
continue;
}
buff[len++] = c;
continue;
case '/':
prev_is_slash = 1;
buff[len++] = c;
continue;
default:
if(prev_is_slash){
depth++;
prev_is_slash = 0;
}
buff[len++] = *relpath;
break;
}
}
buff[len++] = c;
continue;
};
};
buff[len]= '\0';
*************/
return buff;
}
 
FILE* fopen(const char* filename, const char *mode)
62,6 → 82,7
char *path;
int err;
int imode;
size_t bytes;
imode=0;
if (*mode=='r')
68,21 → 89,28
{
imode=FILE_OPEN_READ;
mode++;
}else if (*mode=='w')
}
else
if (*mode=='w')
{
imode=FILE_OPEN_WRITE;
mode++;
}else if (*mode=='a')
}
else
if (*mode=='a')
{
imode=FILE_OPEN_APPEND;
mode++;
}else
}
else
return 0;
if (*mode=='t')
{
imode|=FILE_OPEN_TEXT;
mode++;
}else if (*mode=='b')
}
else
if (*mode=='b')
mode++;
if (*mode=='+')
{
114,11 → 142,11
return 0;
};
res->buffer=malloc(4096);
res->buffer=UserAlloc(8192);
res->stream=res->buffer;
res->strpos=0;
res->remain=4096;
res->buffersize=4096;
res->remain=8192;
res->buffersize=8192;
res->filesize=fileinfo.size;
res->filename=path;
res->mode=imode;
125,11 → 153,11
if (imode & FILE_OPEN_APPEND)
{ size_t bytes;
res->strpos= res->filesize & 4095;
res->strpos= res->filesize & 8191;
if (res->strpos) //not align
{
res->filepos=res->filesize & -4096; // align buffer
res->remain=4096-res->strpos;
res->filepos=res->filesize & -8192; // align buffer
res->remain=8192-res->strpos;
err=read_file(res->filename,res->buffer,
res->filesize,res->remain,&bytes);
res->stream=res->buffer+res->strpos;
139,8 → 167,14
{ size_t bytes;
err=read_file(res->filename,res->buffer,
0,4096,&bytes);
0,8192,&bytes);
res->filepos=0;
};
return res;
}
 
size_t FileSize(FILE *handle)
{
return handle->filesize;
}
/programs/games/doom/trunk/kolibc/src/file/fputc.c
12,7 → 12,7
if(!f->remain)
{ if (!write_buffer(f))
return EOF;
f->filepos+=4096;
f->filepos+=8192;
fill_buff(f);
};
30,7 → 30,7
{ size_t bytes;
int err;
 
bytes= f->filepos+4096 > f->filesize ? f->strpos:4096;
bytes= f->filepos+8192 > f->filesize ? f->strpos:8192;
err=write_file(f->filename,f->buffer,f->filepos,bytes,&bytes);
if(err)
return 0;
/programs/games/doom/trunk/kolibc/src/file/fread.c
1,15 → 1,20
#include "kolibc.h"
 
#include "kolibri.h"
#include <string.h>
 
#include "kolibc.h"
 
int fill_buff(FILE* f);
 
int fread(void* dst,size_t size,size_t count,FILE* f)
{ size_t req;
size_t cnt;
char *p = dst;
if(!((f->mode & FILE_OPEN_READ)|(f->mode & FILE_OPEN_PLUS)))
return 0;
char *p;
// if(!((f->mode & FILE_OPEN_READ)|(f->mode & FILE_OPEN_PLUS)))
// return 0;
req=count*size;
p= (char*)dst;
if (req+f->filepos+f->strpos > f->filesize)
req=f->filesize-f->filepos-f->strpos;
count=0;
16,7 → 21,7
while(req)
{
if (f->remain)
{ cnt= req > f->remain ? f->remain : req;
{ cnt= (req > f->remain) ? f->remain : req;
memcpy(p,f->stream,cnt);
p+=cnt;
f->stream+=cnt;
27,11 → 32,13
}
else
{
f->filepos+=4096;
if(!fill_buff(f)) //eof or error
f->filepos+=8192;
if(!fill_buff(f))
{ printf("error reading file %d=",f->filepos); //eof or error
break;
}
};
};
return count/size;
}
 
40,11 → 47,13
size_t bytes;
err=read_file(f->filename,f->buffer,f->filepos,
4096,&bytes);
if (err) return 0;
if(!bytes) return 0;
8192,&bytes);
if(bytes == -1)
return 0;
// if(!bytes) return 0;
f->stream = f->buffer;
f->remain = 4096;
f->remain = 8192;
f->strpos=0;
return bytes;
};
};
 
/programs/games/doom/trunk/kolibc/src/file/fseek.c
1,11 → 1,15
 
//#include <stdio.h>
#include "kolibc.h"
 
int fseek(FILE* file,long offset,int origin)
{
if (origin==SEEK_CUR)
offset+=file->filepos;
offset+=file->filepos+file->strpos;
else if (origin==SEEK_END)
offset+=file->filesize;
else if (origin!=SEEK_SET)
return EOF;
return fsetpos(file,&offset);
}
}
/programs/games/doom/trunk/kolibc/src/file/fsetpos.c
1,23 → 1,23
 
#include "kolibri.h"
#include "kolibc.h"
#include "kolibri.h"
 
int fsetpos(FILE* f,const fpos_t * pos)
{ int err;
size_t bytes;
if (*pos>=0)
{
bytes= *pos & -4096;
bytes = *pos;
bytes= *pos & -8192;
err=read_file(f->filename,f->buffer,bytes,
4096,&bytes);
if (err) return EOF;
if(!bytes) return EOF;
f->filepos= *pos & -4096;
f->strpos = *pos & 4095;
f->remain = 4096-f->strpos;
8192,&bytes);
if(bytes == -1)
return EOF;
f->filepos= *pos & -8192;
f->strpos = *pos & 8191;
f->remain = 8192-f->strpos;
f->stream = f->buffer+f->strpos;
return 0;
}
else
return EOF;
}
 
/programs/games/doom/trunk/kolibc/src/file/ftell.c
1,5 → 1,7
#include "kolibc.h"
 
long ftell(FILE* file)
{
return file->filepos+file->strpos;
}
}
 
/programs/games/doom/trunk/kolibc/src/file/fwrite.c
1,3 → 1,5
 
#include <string.h>
#include "kolibc.h"
 
int write_buffer(FILE *f);
10,6 → 12,7
 
//append mode unsupported
/************
if(!((f->mode & FILE_OPEN_WRITE)|(f->mode & FILE_OPEN_PLUS)))
return EOF;
28,11 → 31,14
}
else
{
if(!write_buffer(f))
break;
f->filepos+=4096;
// if(!write_buffer(f))
// break;
f->filepos+=8192;
fill_buff(f);
};
};
***********/
return count;
return count/size;
};
};
/programs/games/doom/trunk/kolibc/src/file/rewind.c
1,9 → 1,12
 
#include "kolibc.h"
 
int fill_buff(FILE* f);
 
void rewind(FILE* file)
{
file->filepos=0;
file->stream=file->buffer;
file->strpos=0;
file->remain=8192;
fill_buff(file);
}
}
/programs/games/doom/trunk/kolibc/src/mem/malloc.c
1,17 → 1,22
 
#include "mf.h"
void * memcpy(void * dst, void * src, size_t count);
#include "kolibri.h"
 
void * kmemcpy(void * dst, const void * src, size_t count);
 
static struct m_state ms;
 
void init_malloc(void* p)
void mf_init()
{ mchunkptr chp;
int i;
dword psize= 0x10000;
char *p;
psize-= 40;
dword psize= 0x40000;
p = 0x2600000; //(char*)UserAlloc(psize);
ms.top = (mchunkptr)p;
ms.topsize = psize;
ms.smallmap=0;
ms.treemap=0;
chp = (mchunkptr)p;
chp->head=psize|1;
25,7 → 30,7
};
}
 
void *malloc(size_t size)
void *dlmalloc(size_t size)
{ size_t nb, psize,rsize;
dword idx;
dword smallbits;
36,20 → 41,20
if (nb < 256)
{
// idx = nb >> 3;
idx = nb >> 3;
// smallbits= (-1<<idx) & ms.smallmap;
_asm
{
mov ecx, [nb]
mov ecx, [idx]
or eax, -1
shl eax, cl
and eax, [ms.smallmap]
mov [smallbits], eax
and eax, dword ptr [ms]
mov dword ptr [smallbits], eax
}
if (smallbits)
{
_asm
{ bsf eax, [smallbits]
{ bsf eax, dword ptr [smallbits]
mov [idx], eax
};
65,7 → 70,7
_asm
{
mov eax, [idx]
btr [ms.smallmap], eax
btr dword ptr [ms], eax
}
}
B->fd = F;
119,7 → 124,7
return 0;
};
 
void free(void *mem)
void dlfree(void *mem)
{ size_t psize;
size_t prevsize;
size_t nsize;
309,7 → 314,7
dword i;
_asm
{ bsf ecx,[ms.treemap]
{ bsf ecx,dword ptr [ms+4]
mov [i], ecx
}
v = t = ms.treebins[i];
481,7 → 486,7
{
mchunkptr r = chunk_plus_offset((mchunkptr)v, nb);
unlink_large_chunk(v);
if (rsize < 256)
if (rsize < 16)
{
v->head = (rsize + nb)|PINUSE_BIT|CINUSE_BIT;
((mchunkptr)((char*)v+rsize + nb))->head |= PINUSE_BIT;
491,7 → 496,7
v->head = nb|PINUSE_BIT|CINUSE_BIT;
r->head = rsize|PINUSE_BIT;
((mchunkptr)((char*)r+rsize))->prev_foot = rsize;
insert_large_chunk((tchunkptr)r, rsize);
insert_chunk((mchunkptr)r, rsize);
}
return chunk2mem(v);
}
501,10 → 506,10
static void* internal_realloc(struct m_state *m, void* oldmem,
size_t bytes);
 
void* realloc(void* oldmem, size_t bytes)
void* dlrealloc(void* oldmem, size_t bytes)
{
if (oldmem == 0)
return malloc(bytes);
return dlmalloc(bytes);
else
{
struct m_state *m = &ms;
577,7 → 582,7
if (newp != 0)
{
if (extra != 0)
free(extra);
dlfree(extra);
check_inuse_chunk(m, newp);
return chunk2mem(newp);
584,15 → 589,15
}
else
{
void* newmem = malloc(bytes);
void* newmem = dlmalloc(bytes);
if (newmem != 0)
{
size_t oc = oldsize - 4;
memcpy(newmem, oldmem, (oc < bytes)? oc : bytes);
free(oldmem);
dlfree(oldmem);
}
return newmem;
}
return 0;
}
/programs/games/doom/trunk/kolibc/src/string/doprnt.c
72,6 → 72,7
static char *exponentl(char *p, int expv, unsigned char fmtch);
 
static char NULL_REP[] = "(null)";
static char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
 
int _doprnt(char *dest, size_t maxlen, const char *fmt0, va_list argp)
{
95,11 → 96,10
char sign; /* sign prefix (' ', '+', '-', or \0) */
char softsign; /* temporary negative sign for floats */
const char *digs; /* digits for [diouxX] conversion */
char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
char *p;
digs = "0123456789abcdef";
fmt = fmt0;
digs = "0123456789abcdef";
p = dest;
 
for (cnt = 0;; ++fmt)
752,5 → 752,18
return(3);
}
 
static unsigned int strlen(const char* string)
{
int i;
i=0;
while (*string++) i++;
return i;
}
 
static char* strcpy(char* dst,const char* src)
{
char* res= dst;
while(*dst++ = *src++) ;
return res;
}
 
/programs/games/doom/trunk/kolibc/src/string/memchr.c
1,5 → 1,6
#include "string.h"
 
#if 0
void* memchr(const void* buf,int c,int count)
{
int i;
11,3 → 12,48
return (void*)0;
}
 
 
void *memset (void *dst, int val, size_t count)
{ void *start = dst;
 
while (count--)
{
*(char *)dst = (char)val;
dst = (char *)dst + 1;
}
return start;
}
 
 
int strcmp (const char * src, const char * dst)
{
int ret = 0 ;
 
while( ! (ret = *(unsigned char *)src - *(unsigned char *)dst) && *dst)
++src, ++dst;
 
if ( ret < 0 )
ret = -1 ;
else if ( ret > 0 )
ret = 1 ;
return( ret );
}
 
char *strcat (char * dst, const char * src)
{
char * cp = dst;
 
while( *cp )
cp++;
 
while( *cp++ = *src++ ) ;
 
return dst ;
}
 
int abs (int number )
{
return( number>=0 ? number : -number );
}
 
#endif
/programs/games/doom/trunk/kolibc/src/string/strlen.c
1,4 → 1,4
int strlen(const char* string)
unsigned int strlen(const char* string)
{
int i;
i=0;
/programs/games/doom/trunk/kolibc/src/string/strupr.c
1,5 → 1,4
#include "ctype.h"
#include "string.h"
#include "kolibc.h"
 
char * strupr(char *_s)
{