diff --git a/bbruntime/basic.cpp b/bbruntime/basic.cpp index 6fe240d7..c0883eee 100644 --- a/bbruntime/basic.cpp +++ b/bbruntime/basic.cpp @@ -476,7 +476,7 @@ BBStr *_bbReadStr(){ } int _bbAbs( int n ){ - return n>=0 ? n : -n; + return n & 0x7FFFFFFF; } int _bbSgn( int n ){ diff --git a/bbruntime/bbmath.cpp b/bbruntime/bbmath.cpp index 48b96eeb..c0b85ea3 100644 --- a/bbruntime/bbmath.cpp +++ b/bbruntime/bbmath.cpp @@ -31,7 +31,18 @@ float bbClamp( float v, float lo, float hi){ if (lo > hi){ std::swap(lo,hi); } - return (float)max(lo, min(v, hi)); + if (v < lo){ + return lo; + } else if (v > hi){ + return hi; + } else{ + return v; + } +} + +int bbIsNaN( float n ){ + unsigned int i = *((unsigned int*)(void*)&n); + return ((i&0x7F800000)==0x7F800000) && ((i&(~0xFF800000)) != 0); } //return rand float from 0...1 @@ -88,6 +99,7 @@ void math_link( void (*rtSym)( const char *sym,void *pc ) ){ rtSym( "#Min#n#m",bbMin ); rtSym( "#Max#n#m",bbMax ); rtSym( "#Clamp#v#lo#hi",bbClamp ); + rtSym( "%IsNaN#n",bbIsNaN ); rtSym( "#Rnd#from#to=0",bbRnd ); rtSym( "%Rand%from%to=1",bbRand ); rtSym( "SeedRnd%seed",bbSeedRnd ); diff --git a/bbruntime_dll/bbruntime_dll.cpp b/bbruntime_dll/bbruntime_dll.cpp index f1a696f9..02e09ba6 100644 --- a/bbruntime_dll/bbruntime_dll.cpp +++ b/bbruntime_dll/bbruntime_dll.cpp @@ -4,10 +4,6 @@ #include "bbruntime_dll.h" #include "../debugger/debugger.h" -#ifdef PRODEMO -#include "../shareprot/shareprot.h" -#endif - using namespace std; #include @@ -39,12 +35,6 @@ static void rtSym( const char *sym,void *pc ){ syms[sym]=pc; } -#ifdef PRODEMO -static void killer(){ - ExitProcess( -1 ); -} -#endif - static void _cdecl seTranslator( unsigned int u,EXCEPTION_POINTERS* pExp ){ switch( u ){ case EXCEPTION_INT_DIVIDE_BY_ZERO: @@ -118,10 +108,6 @@ void Runtime::execute( void (*pc)(),const char *args,Debugger *dbg ){ while( params.size() && params[params.size()-1]==' ' ) params=params.substr( 0,params.size()-1 ); if( gx_runtime=gxRuntime::openRuntime( hinst,params,dbg ) ){ - -#ifdef PRODEMO - shareProtCheck( killer ); -#endif bbruntime_run( gx_runtime,pc,debug ); gxRuntime *t=gx_runtime; diff --git a/blitz/main.cpp b/blitz/main.cpp index 29962ee5..7eadcc60 100644 --- a/blitz/main.cpp +++ b/blitz/main.cpp @@ -130,11 +130,6 @@ static void versInfo(){ cout<<"Linker version:"<EnableWindow(0); @@ -94,22 +94,7 @@ void aboutBlitz( bool delay ){ t+="Blitz2D"; #endif -#ifdef EDU - t+=" - Educational Version"; -#else -#ifdef DEMO - t+=" - Demo Version\n\n"; - /* - int n=shareProtCheck(); - if( n>1 ) t+=itoa(n)+" runs left"; - else if( n ) t+=itoa(n)+" run left"; - else t+="expired"; - t+=")\n\n"; - */ -#else - t+=" - Release Version\n\n"; -#endif -#endif +t+=" - Release Version\n\n"; about.GetDlgItem( IDC_PRODUCT )->SetWindowText( t.c_str() ); @@ -117,20 +102,6 @@ void aboutBlitz( bool delay ){ t="Runtime V"+itoa((VERSION&0xffff)/1000)+"."+itoa((VERSION&0xffff)%1000); about.GetDlgItem( IDC_VERSION )->SetWindowText( t.c_str() ); -#ifdef DEMO - - if( delay ){ - about.GetDlgItem( IDOK )->ShowWindow( SW_HIDE ); - about.GetDlgItem( IDC_PROGRESS1 )->ShowWindow( SW_SHOW ); - for( int k=0;k<100;++k ){ - ((CProgressCtrl*)about.GetDlgItem( IDC_PROGRESS1 ))->SetPos( k+1 ); - about.wait( 50 ); - } - about.GetDlgItem( IDOK )->ShowWindow( SW_SHOW ); - } - -#endif - about.GetDlgItem( IDC_PROGRESS1 )->ShowWindow( SW_HIDE ); about.wait(); about.EndDialog(0); diff --git a/blitzide/about.h b/blitzide/about.h index 41751087..c652d68e 100644 --- a/blitzide/about.h +++ b/blitzide/about.h @@ -2,6 +2,6 @@ #ifndef ABOUT_H #define ABOUT_H -void aboutBlitz( bool delay ); +void aboutBlitz(); #endif \ No newline at end of file diff --git a/blitzide/blitzide.cpp b/blitzide/blitzide.cpp index 7f6ead66..a9413ed9 100644 --- a/blitzide/blitzide.cpp +++ b/blitzide/blitzide.cpp @@ -24,10 +24,6 @@ BOOL BlitzIDE::InitInstance(){ mainFrame=new MainFrame(); m_pMainWnd = mainFrame; -#ifdef DEMO - aboutBlitz( true ); -#endif - mainFrame->LoadFrame( IDR_MAINFRAME ); mainFrame->MoveWindow( CRect( prefs.win_rect ) ); mainFrame->ShowWindow( m_nCmdShow ); diff --git a/blitzide/blitzide.rc b/blitzide/blitzide.rc index d2326906..57e603b5 100644 --- a/blitzide/blitzide.rc +++ b/blitzide/blitzide.rc @@ -295,11 +295,11 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION CAPTION "About Blitz" FONT 10, "MS Sans Serif" BEGIN - DEFPUSHBUTTON "Okee Dokee!",IDOK,79,150,50,14 + DEFPUSHBUTTON "Okay then..",IDOK,79,150,50,14 CONTROL 132,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE,11, 5,64,32 - CTEXT "BlitzPlus - Demo Version",IDC_PRODUCT,78,7,139,8 - CTEXT "IDE V1.1 Runtime V1.1 Linker V1.1",IDC_VERSION,78,27, + CTEXT "",IDC_PRODUCT,78,7,139,8 + CTEXT "",IDC_VERSION,78,27, 139,8 CTEXT "Copyright Blitz Research Ltd",IDC_STATIC,78,17,139,8 CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | diff --git a/blitzide/editor.cpp b/blitzide/editor.cpp index faddcad4..9aaaf9fb 100644 --- a/blitzide/editor.cpp +++ b/blitzide/editor.cpp @@ -5,11 +5,7 @@ static bool locked; -#ifdef DEMO -static const int TEXTLIMIT=16384; -#else static const int TEXTLIMIT=1024*1024-1; -#endif static const UINT wm_Find=RegisterWindowMessage( FINDMSGSTRING ); diff --git a/blitzide/mainframe.cpp b/blitzide/mainframe.cpp index 61da64ff..38b57ee2 100644 --- a/blitzide/mainframe.cpp +++ b/blitzide/mainframe.cpp @@ -734,10 +734,6 @@ void MainFrame::programCompile(){ } void MainFrame::programPublish(){ -#ifdef DEMO - MessageBox( "Create Executable unavailable in demo version","Sorry!",MB_TOPMOST|MB_SETFOREGROUND|MB_ICONINFORMATION ); - return; -#endif Editor *e=getEditor();if( !e ) return; if( prefs.prg_debug ){ string t= @@ -796,7 +792,7 @@ void MainFrame::helpForward(){ } void MainFrame::helpAbout(){ - aboutBlitz( false ); + aboutBlitz(); } void MainFrame::ctrlTab(){ diff --git a/compiler/codegen.h b/compiler/codegen.h index d29615d2..fe022f00 100644 --- a/compiler/codegen.h +++ b/compiler/codegen.h @@ -12,11 +12,11 @@ enum{ IR_JSR,IR_RET,IR_AND,IR_LOR,IR_OR,IR_XOR,IR_SHL,IR_SHR,IR_SAR, IR_CALL,IR_RETURN,IR_CAST, - IR_NEG,IR_ADD,IR_SUB,IR_MUL,IR_DIV, + IR_NEG,IR_ADD,IR_SUB,IR_MUL,IR_DIV,IR_POWTWO, IR_SETEQ,IR_SETNE,IR_SETLT,IR_SETGT,IR_SETLE,IR_SETGE, IR_FCALL,IR_FRETURN,IR_FCAST, - IR_FNEG,IR_FADD,IR_FSUB,IR_FMUL,IR_FDIV, + IR_FNEG,IR_FADD,IR_FSUB,IR_FMUL,IR_FDIV,IR_FPOWTWO, IR_FSETEQ,IR_FSETNE,IR_FSETLT,IR_FSETGT,IR_FSETLE,IR_FSETGE, }; diff --git a/compiler/codegen_x86/codegen_x86.cpp b/compiler/codegen_x86/codegen_x86.cpp index 8c443f58..c0f8aea6 100644 --- a/compiler/codegen_x86/codegen_x86.cpp +++ b/compiler/codegen_x86/codegen_x86.cpp @@ -117,6 +117,7 @@ Tile *Codegen_x86::munchUnary( TNode *t ){ string s; switch( t->op ){ case IR_NEG:s="\tneg\t%l\n";break; + case IR_POWTWO:s="\timul\t%l,%l\n";break; default:return 0; } return d_new Tile( s,munchReg( t->l ) ); @@ -228,6 +229,7 @@ Tile *Codegen_x86::munchFPUnary( TNode *t ){ string s; switch( t->op ){ case IR_FNEG:s="\tfchs\n";break; + case IR_FPOWTWO:s="\tfmulp\tst(0)\n";break; default:return 0; } return d_new Tile( s,munchFP( t->l ) ); @@ -420,7 +422,7 @@ Tile *Codegen_x86::munchReg( TNode *t ){ case IR_CONST: q=d_new Tile( "\tmov\t%l,"+itoa(t->iconst)+"\n" ); break; - case IR_NEG: + case IR_NEG:case IR_POWTWO: q=munchUnary( t ); break; case IR_AND:case IR_LOR:case IR_OR:case IR_XOR: @@ -463,7 +465,7 @@ Tile *Codegen_x86::munchFP( TNode *t ){ s="\tpush\t%l\n\tfild\t[esp]\n\tpop\t%l\n"; q=d_new Tile( s,munchReg( t->l ) ); break; - case IR_FNEG: + case IR_FNEG:case IR_FPOWTWO: q=munchFPUnary( t ); break; case IR_FADD:case IR_FSUB:case IR_FMUL:case IR_FDIV: diff --git a/compiler/exprnode.cpp b/compiler/exprnode.cpp index 5313af75..2e65f8fb 100644 --- a/compiler/exprnode.cpp +++ b/compiler/exprnode.cpp @@ -321,6 +321,7 @@ ExprNode *UniExprNode::semant( Environ *e ){ case '-':e=d_new IntConstNode( -c->intValue() );break; case ABS:e=d_new IntConstNode( c->intValue()>=0 ? c->intValue() : -c->intValue() );break; case SGN:e=d_new IntConstNode( c->intValue()>0 ? 1 : (c->intValue()<0 ? -1 : 0) );break; + case POWTWO:e=d_new IntConstNode( c->intValue()*c->intValue() );break; } }else{ switch( op ){ @@ -328,6 +329,7 @@ ExprNode *UniExprNode::semant( Environ *e ){ case '-':e=d_new FloatConstNode( -c->floatValue() );break; case ABS:e=d_new FloatConstNode( c->floatValue()>=0 ? c->floatValue() : -c->floatValue() );break; case SGN:e=d_new FloatConstNode( c->floatValue()>0 ? 1 : (c->floatValue()<0 ? -1 : 0) );break; + case POWTWO:e=d_new FloatConstNode( c->floatValue()*c->floatValue() );break; } } delete this; @@ -345,6 +347,7 @@ TNode *UniExprNode::translate( Codegen *g ){ case '-':n=IR_NEG;break; case ABS:return call( "__bbAbs",l ); case SGN:return call( "__bbSgn",l ); + case POWTWO:return d_new TNode(IR_POWTWO, l); } }else{ switch( op ){ @@ -352,6 +355,7 @@ TNode *UniExprNode::translate( Codegen *g ){ case '-':n=IR_FNEG;break; case ABS:return fcall( "__bbFAbs",l ); case SGN:return fcall( "__bbFSgn",l ); + case POWTWO:return d_new TNode(IR_FPOWTWO, l); } } return d_new TNode( n,l,0 ); diff --git a/compiler/parser.cpp b/compiler/parser.cpp index ffc43b05..8f4160bf 100644 --- a/compiler/parser.cpp +++ b/compiler/parser.cpp @@ -2,12 +2,9 @@ #include "std.h" #include #include "parser.h" +#include -#ifdef DEMO -static const int TEXTLIMIT=16384; -#else static const int TEXTLIMIT=1024*1024-1; -#endif enum{ STMTS_PROG,STMTS_BLOCK,STMTS_LINE @@ -84,11 +81,6 @@ void Parser::parseStmtSeq( StmtSeqNode *stmts,int scope, bool debug){ int pos=toker->pos(); -#ifdef DEMO - if( Toker::chars_toked>TEXTLIMIT ){ - ex( "Demo version source limit exceeded" ); - } -#endif switch( toker->curr() ){ case INCLUDE: { @@ -668,7 +660,7 @@ ExprNode *Parser::parseUniExpr( bool opt ){ result=parseUniExpr( false ); result=d_new AfterNode( result ); break; - case '+':case '-':case '~':case ABS:case SGN: + case '+':case '-':case '~':case ABS:case SGN:case POWTWO: toker->next(); result=parseUniExpr( false ); if( c=='~' ){ @@ -683,11 +675,6 @@ ExprNode *Parser::parseUniExpr( bool opt ){ return result; } -// Don't ask me what this does. Thanks Juan! -float stuff(unsigned int i){ - return *((float*)(void*)&i); -} - ExprNode *Parser::parsePrimary( bool opt ){ a_ptr expr; @@ -748,10 +735,7 @@ ExprNode *Parser::parsePrimary( bool opt ){ result=d_new FloatConstNode( 3.1415926535897932384626433832795f ); toker->next();break; case INFINITY: - result=d_new FloatConstNode( stuff(0x7F800000) ); - toker->next();break; - case NANCONST: - result=d_new FloatConstNode( stuff(0x7FFFFFFF) ); + result=d_new FloatConstNode(INFINITY); toker->next();break; case BBTRUE: result=d_new IntConstNode( 1 ); diff --git a/compiler/toker.cpp b/compiler/toker.cpp index 5d9b93b7..026e5dc2 100644 --- a/compiler/toker.cpp +++ b/compiler/toker.cpp @@ -81,7 +81,8 @@ static void makeKeywords(){ alphaTokes["Null"]=NULLCONST; alphaTokes["Infinity"]=INFINITY; - alphaTokes["NaN"]=NANCONST; + + alphaTokes["PowTwo"]=POWTWO; map::const_iterator it; for( it=alphaTokes.begin();it!=alphaTokes.end();++it ){ diff --git a/compiler/toker.h b/compiler/toker.h index f74205ff..577d9234 100644 --- a/compiler/toker.h +++ b/compiler/toker.h @@ -29,7 +29,7 @@ enum{ AND,OR,LOR,XOR,NOT,SHL,SHR,SAR, LE,GE,NE, - IDENT,INTCONST,BINCONST,HEXCONST,FLOATCONST,STRINGCONST,NULLCONST,INFINITY,NANCONST + IDENT,INTCONST,BINCONST,HEXCONST,FLOATCONST,STRINGCONST,NULLCONST,INFINITY,POWTWO }; class Toker{ diff --git a/config/config.h b/config/config.h index 28f408c3..e9d52a02 100644 --- a/config/config.h +++ b/config/config.h @@ -10,18 +10,6 @@ #define PRO_F 0 #endif -#ifdef DEMO -#define DEMO_F 0x080000 -#else -#define DEMO_F 0 -#endif - -#ifdef EDU -#define EDU_F 0x200000 -#else -#define EDU_F 0 -#endif - -#define VERSION (BASE_VER|PRO_F|DEMO_F|EDU_F) +#define VERSION (BASE_VER|PRO_F) #endif diff --git a/linker/image_util.cpp b/linker/image_util.cpp index 99cf71aa..aa28072b 100644 --- a/linker/image_util.cpp +++ b/linker/image_util.cpp @@ -2,8 +2,6 @@ #include "std.h" #include "image_util.h" -#ifndef DEMO - #pragma pack( push,1 ) struct Head{ short machine,num_sects; @@ -360,6 +358,3 @@ void closeImage(){ delete[] stub; img_file=0; } - -#endif - diff --git a/linker/linker.cpp b/linker/linker.cpp index c4c8c2a3..985572e8 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -130,11 +130,7 @@ int Linker::version(){ } bool Linker::canCreateExe(){ -#ifdef DEMO - return false; -#else return true; -#endif } Module *Linker::createModule(){ @@ -151,10 +147,6 @@ Linker *_cdecl linkerGetLinker(){ bool BBModule::createExe( const char *exe_file,const char *dll_file ){ -#ifdef DEMO - return false; -#else - //find proc address of bbWinMain HMODULE hmod=LoadLibrary( dll_file );if( !hmod ) return false; int proc=(int)GetProcAddress( hmod,"_bbWinMain@0" ); @@ -210,5 +202,5 @@ bool BBModule::createExe( const char *exe_file,const char *dll_file ){ closeImage(); return true; -#endif + }