
/*
  File: include/basic/win32/typesport.h
  Description: Custom types, including operating system dependancies
  Part of the Mantis project
  (c) 2002 Lycos Inc.

  This file is distributed for the sole purpose of allowing you to write
  software to interface with Sonique 2 and other Mantis programs. It is
  not to be modified or used for any other purpose without written
  authorization.

  If you redistribute this file, it must be in the original package
  complete with all other files provided, including the usage agreement.

  Do not remove this notice.
*/

#ifndef	_WIN32_TYPES_H__
#define _WIN32_TYPES_H__

#ifdef DEBUG_INCLUDE_ORDER
#pragma message("Including " __FILE__ "\n" )
#endif

#if _MSC_VER > 1000
#pragma once
#endif


#define WIN32_LEAN_AND_MEAN

#define ASMIMPORT(x) x
#define QW(number) number

#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0400

#include <windows.h>
#include <stdio.h>
#include <process.h>
#include <math.h>
#include <crtdbg.h>
#include "print.h"

typedef signed		__int64		int64;
typedef unsigned	__int64		uint64;
typedef signed		long		int32;
typedef unsigned	long		uint32;
typedef signed		short		int16;
typedef unsigned	short		uint16;
typedef	signed		char		int8;
typedef unsigned	char		uint8;
typedef char*					string;


#ifndef lenof
#define lenof(x) (sizeof(x)/sizeof(*(x)))
#endif//lenof
#ifndef strlenof
#define strlenof(x) (lenof(x)-1)
#endif//lenof


#define CONSTSTR(s,t) ((sizeof(t)==sizeof(char))?(t*)(s):(t*)(L##s))
#define CONSTCHAR(c,t) ((sizeof(t)==sizeof(char))?(t)(c):(t)(L##c)) 

#define EMMS() __asm emms


#ifndef __PLACEMENT_NEW_INLINE
#define __PLACEMENT_NEW_INLINE
inline void* __cdecl  operator new		(	size_t, void * data	) {return (data);	}
inline void  __cdecl  operator delete	(	void *, void *		) {return;			}
#endif


#define isfinite(n) _finite(n)
#define isnan(n) _isnan(n)





#ifdef _DEBUG


#pragma warning( push )
#pragma warning( disable : 4127 4800 )
inline void DBG_ASSERT( bool do_assert, char* szfile, int line )
{
	if( do_assert && (1 == _CrtDbgReport(_CRT_ASSERT, szfile, line, NULL, NULL)))
		_CrtDbgBreak();
}
#pragma warning(pop)


#define COMPILE_MSG__(file,linenum,msg)  message( file "(" #linenum ") : message\n   ^---- "  msg )
#define COMPILE_MSG_(num,msg) COMPILE_MSG__(__FILE__,num,msg)
#define COMPILE_MSG(msg) COMPILE_MSG_(__LINE__,msg)

// moved this warning out
#define ASSERT(x)	DBG_ASSERT(!(x),__FILE__,__LINE__)
#define VERIFY(x)	DBG_ASSERT(!(x),__FILE__,__LINE__)
#define ASSERT_BREAK(x) { if( !(x) && IsDebuggerPresent() ) __asm{ int 3 }; }

#else // ! _DEBUG

#define ASSERT(x)
#define ASSERT_BREAK(x)
#define VERIFY(x) (void)(x)
#define COMPILE_MSG(msg)

#endif // _DEBUG


#ifdef _DEBUG
#include <stdarg.h>

// in debug.cpp part of basic
void debug_dbgout( const char* szformat, ... );

#define TRACE0(x)  debug_dbgout("%s",x) 
#define TRACE1(x,y) debug_dbgout(x,(y)) 
#define TRACE2(x,y,z) debug_dbgout(x,(y),(z)) 
#define TRACE3(x,y,z,i) debug_dbgout(x,(y),(z),(i)) 
#define TRACE4(x,y,z,i,j) debug_dbgout(x,(y),(z),(i),(j)) 
#define TRACE5(x,y,z,i,j,k) debug_dbgout(x,(y),(z),(i),(j),(k)) 
#define TRACE6(x,y,z,i,j,k,l) debug_dbgout(x,(y),(z),(i),(j),(k),(l)) 
#else
#define TRACE0(x)
#define TRACE1(x,y)
#define TRACE2(x,y,z)
#define TRACE3(x,y,z,i)
#define TRACE4(x,y,z,i,j)
#define TRACE5(x,y,z,i,j,k)
#define TRACE6(x,y,z,i,j,k,l)

#endif


#ifdef DEBUG_INCLUDE_ORDER
#pragma message("Done including " __FILE__ "\n" )
#endif

#endif
