float _bbReadFloat(){ switch( dataPtr->fieldType ){ case BBTYPE_END:RTEX( "Out of data" );return 0; case BBTYPE_INT:return (float)dataPtr++->field.INT; case BBTYPE_FLT:return dataPtr++->field.FLT; case BBTYPE_CSTR:return (float)atof( dataPtr++->field.CSTR ); default:RTEX( "Bad data type" );return 0; } }
BBStr *_bbReadStr(){ switch( dataPtr->fieldType ){ case BBTYPE_END:RTEX( "Out of data" );return 0; case BBTYPE_INT:return d_new BBStr( itoa( dataPtr++->field.INT ) ); case BBTYPE_FLT:return d_new BBStr( ftoa( dataPtr++->field.FLT ) ); case BBTYPE_CSTR:return d_new BBStr( dataPtr++->field.CSTR ); default:RTEX( "Bad data type" );return 0; } }
void bbEndGraphics(){ freeGraphics(); gx_runtime->closeGraphics( gx_graphics ); gx_graphics=gx_runtime->openGraphics( 400,300,0,0,gxGraphics::GRAPHICS_WINDOWED ); if( !gx_runtime->idle() ) RTEX( 0 ); if( gx_graphics ){ curr_clsColor=0; curr_color=0xffffffff; curr_font=gx_graphics->getDefaultFont(); bbSetBuffer( gx_graphics->getFrontCanvas() ); return; } RTEX( "Unable to set graphics mode" ); }
static void graphics( int w,int h,int d,int flags ){ freeGraphics(); gx_runtime->closeGraphics( gx_graphics ); gx_graphics=gx_runtime->openGraphics( w,h,d,gx_driver,flags ); if( !gx_runtime->idle() ) RTEX( 0 ); if( !gx_graphics ){ RTEX( "Unable to set graphics mode" ); } curr_clsColor=0; curr_color=0xffffffff; curr_font=gx_graphics->getDefaultFont(); gxCanvas *buff=(flags & gxGraphics::GRAPHICS_3D) ? gx_graphics->getBackCanvas() : gx_graphics->getFrontCanvas(); bbSetBuffer( buff ); }
int bbDrawMovie( gxMovie *movie,int x,int y,int w,int h ){ if( w<0 ) w=movie->getWidth(); if( h<0 ) h=movie->getHeight(); int playing=movie->draw( gx_canvas,x,y,w,h ); if( !gx_runtime->idle() ) RTEX( 0 ); return playing; }
static inline void debugMode( int n ){ if( debug ){ if( n<1 || n>gfx_modes.size() ){ RTEX( "Illegal graphics mode index" ); } } }
static void endPrinting( gxCanvas *c ){ c->setViewport( p_vpx,p_vpy,p_vpw,p_vph ); c->setHandle( p_hx,p_hy ); c->setOrigin( p_ox,p_oy ); if( c==gx_canvas ) c->setColor( curr_color ); if( !gx_runtime->idle() ) RTEX( 0 ); }
int bbWaitMouse() { for(;;) { if( !gx_runtime->idle() ) RTEX( 0 ); if( int key=gx_mouse->getKey() ) return key; gx_runtime->delay( 20 ); } }
static inline void debugDriver( int n ){ if( debug ){ if( n<1 || n>gx_runtime->numGraphicsDrivers() ){ RTEX( "Illegal graphics driver index" ); } } }
int bbWaitJoy( int port ) { if( port<0 || port>=gx_joysticks.size() ) return 0; for(;;) { if( !gx_runtime->idle() ) RTEX( 0 ); if( int key=gx_joysticks[port]->getKey() ) return key; gx_runtime->delay( 20 ); } }
int bbHostIP( int index ){ if( debug ){ if( index<1 || index>host_ips.size() ){ RTEX( "Host index out of range" ); } } return host_ips[index-1]; }
int bbWaitKey() { for(;;) { if( !gx_runtime->idle() ) RTEX( 0 ); if( int key=gx_keyboard->getKey( ) ) { if( key=gx_input->toAscii( key ) ) return key; } gx_runtime->delay( 20 ); } }
TCPStream * bbAcceptTCPStream( TCPServer *server ){ debugTCPServer( server ); if( !gx_runtime->idle() ) RTEX( 0 ); if( TCPStream *tcp=server->accept() ){ tcp_set.insert( tcp ); return tcp; } return 0; }
void bbGraphics( int w,int h,int d,int mode ){ int flags=0; switch( mode ){ case 0:flags|=debug ? gxGraphics::GRAPHICS_WINDOWED : 0 ;break; case 1:break; case 2:flags|=gxGraphics::GRAPHICS_WINDOWED;break; case 3:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED;break; case 6:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; case 7:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; default:RTEX( "Illegal Graphics mode" ); } graphics( w,h,d,flags ); }
bbImage *bbLoadAnimImage( BBStr *s,int w,int h,int first,int cnt ){ string t=*s;delete s; if( cnt<1 ) RTEX( "Illegal frame count" ); if( first<0 ) RTEX( "Illegal first frame" ); gxCanvas *pic=gx_graphics->loadCanvas( t,gxCanvas::CANVAS_NONDISPLAY ); if( !pic ) return 0; //frames per row, per picture int fpr=pic->getWidth()/w; int fpp=pic->getHeight()/h*fpr; if( first+cnt>fpp ){ gx_graphics->freeCanvas( pic ); RTEX( "Not enough frames in bitmap" ); } //x,y of first frame... vector<gxCanvas*> frames; int src_x=first%fpr*w,src_y=first/fpr*h; for( int k=0;k<cnt;++k ){ gxCanvas *c=gx_graphics->createCanvas( w,h,0 ); if( !c ){ for( --k;k>=0;--k ) gx_graphics->freeCanvas( frames[k] ); gx_graphics->freeCanvas( pic );return 0; } c->blit( 0,0,pic,src_x,src_y,w,h,true ); if( auto_dirty ) c->backup(); if( auto_midhandle ) c->setHandle( c->getWidth()/2,c->getHeight()/2 ); frames.push_back( c ); src_x+=w;if( src_x+w>pic->getWidth() ){ src_x=0;src_y+=h; } } gx_graphics->freeCanvas( pic ); bbImage *i=d_new bbImage( frames ); image_set.insert( i ); return i; }
void bbGraphics3D( int w,int h,int d,int mode ){ int flags=gxGraphics::GRAPHICS_3D; switch( mode ){ case 0:flags|=(debug && bbWindowed3D()) ? gxGraphics::GRAPHICS_WINDOWED : 0 ;break; case 1:break; case 2:flags|=gxGraphics::GRAPHICS_WINDOWED;break; case 3:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED;break; case 6:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; case 7:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; default:RTEX( "Illegal Graphics3D mode" ); } graphics( w,h,d,flags ); extern void blitz3d_open(); blitz3d_open(); }
void _bbVecBoundsEx(){ RTEX( "Blitz array index out of bounds" ); }
void PosixFileSystem::closeDir( BBDir *dir ){ RTEX( "PosixFileSystem::closeDir not implemented" ); }
BBDir *PosixFileSystem::verifyDir( BBDir *d ){ RTEX( "PosixFileSystem::verifyDir not implemented" ); }
BBDir *PosixFileSystem::openDir( const std::string &name,int flags ){ RTEX( "PosixFileSystem::openDir not implemented" ); }
int PosixFileSystem::getFileSize( const std::string &name )const{ RTEX( "PosixFileSystem::getFileSize not implemented" ); }
bool PosixFileSystem::deleteFile( const std::string &file ){ RTEX( "PosixFileSystem::deleteFile not implemented" ); }
bool PosixFileSystem::deleteDir( const std::string &dir ){ RTEX( "PosixFileSystem::deleteDir not implemented" ); }
static inline void debugDir( gxDir *d ){ if( debug ){ if( !gx_filesys->verifyDir( d ) ) RTEX( "Directory does not exist" ); } }
static void procNotFound(){ RTEX( "User lib function not found" ); }
void _bbArrayBoundsEx(){ RTEX( "Array index out of bounds" ); }
void _bbNullObjEx(){ RTEX( "Object does not exist" ); }
bool PosixFileSystem::renameFile( const std::string &src,const std::string &dest ){ RTEX( "PosixFileSystem::renameFile not implemented" ); }
static inline void debugFile( bbFile *f ){ if( debug ){ if( !file_set.count( f ) ) RTEX( "File does not exist" ); } }
std::string PosixFileSystem::getCurrentDir()const{ RTEX( "PosixFileSystem::getCurrentDir not implemented" ); }