/** * Highlights the currently active cell. */ static void DrawMouse( void ) { // FBDrawVLine( mouse_x * 32 + 15, mouse_y * 32 + 4, 24, GREEN ); // FBDrawHLine( mouse_x * 32 + 4, mouse_y * 32 + 15, 24, GREEN ); FBFillRect( mouse_x * 32 + 4, mouse_y * 32 + 15, 24, 2, GREEN ); FBFillRect( mouse_x * 32 + 15, mouse_y * 32 + 4, 2, 24, GREEN ); }
void DrawMaze( void ) { int x; int y; unsigned char *p = maze; for ( y = 0; y < MAZEH; y++ ) { for ( x = 0; x < MAZEW; x++ ) { switch ( *p ) { case '#' : FBFillRect( x*32, y*32, 32, 32, STEELBLUE ); break; case '.' : FBCopyImage( x*32, y*32, 32, 32, futter ); break; case 'z' : FBFillRect( x*32, y*32, 32, 32, 0 ); break; default : FBFillRect( x*32, y*32, 32, 32, BLACK ); break; } p++; } } FBDrawFx2Logo( LOGO_X, LOGO_Y ); }
static void LocalSave( void ) { int x; char *user; int i; localuser=-1; for( i=0; i < 8; i++ ) if ( score > hsc[i].points ) break; if ( i==8 ) return; Fx2PigPause(); FBFillRect( 500,32,3*52,4*52+4,BLACK ); FBFillRect( 150,420,470,64,BLACK ); FBDrawRect( 149,419,472,66,WHITE ); FBDrawRect( 148,418,474,68,WHITE ); x=FBDrawString( 154,420,64,"name : ",WHITE,0); user=FBEnterWord(154+x,420,64,9,WHITE); Fx2PigResume(); if ( i < 7 ) memmove( hsc+i+1,hsc+i,sizeof(HScore)*(7-i) ); strcpy(hsc[i].name,user); hsc[i].points=score; localuser=i; }
void Startbildschirm() { int i; char tlevel[ 64 ]; // int x,y; // for (y=0; y<576; y=y+56) // { // for (x=0; x<720; x=x+64) // { // FB2CopyImage( x, y, 32, 28, man, 2); // } // } static int bx[] = { 64,32,0,0,0,32,64,64,64,32,0,128,160,192,192,192,192,192,160,128,128,128, 128,256,256,256,256,256,288,320,320,320,320,384,416,448,448,448,448,448,416, 384,384,384,384,512,544,576,224,224,224,224,224,256,288,288,256,288,288,256, 352,352,352,352,352,384,416,416,416,416,416,384,480,480,480,480,480,512,512, 544,544,576,576,576,576,576 }; static int by[] = { 0,0,0,28,56,56,56,84,112,112,112,0,0,0,28,56,84,112,112,112,84,56,28,0,28,56, 84,112,56,0,28,84,112,0,0,0,28,56,84,112,112,112,84,56,28,56,56,56,312,284,256, 228,200,200,200,228,256,284,312,312,312,284,256,228,200,200,200,228,256,284,312, 256,200,228,256,284,312,228,256,256,284,200,228,256,284,312 }; for (i=0;i<86;i++) { FBCopyImage(bx[i]+56,by[i]+118, 32, 28, wall ); } FBFillRect( 55, 365, 200 , 40, BLACK ); sprintf(tlevel,"%d",max_level); FBDrawString( 75,370, 30, tlevel, WHITE, BLACK ); FBDrawString( 120,370, 30, "Level gefunden", WHITE, BLACK); #ifdef USEX FBFlushGrafic(); #endif while( actcode != RC_OK ) { if (i>87) { i=0;} else {i++;} if (i<86) {FBCopyImage( bx[i]+56,by[i]+118, 32, 28, box );} if (i>=1 && i-1<=85) { FBCopyImage( bx[i-1]+56,by[i-1]+118, 32, 28, man );} if (i>=2 && i-2<=85) { FBCopyImage( bx[i-2]+56,by[i-2]+118, 32, 28, wall );} #ifdef USEX FBFlushGrafic(); #endif RcGetActCode( ); sleep(1); } FBFillRect( 0, 0, 720 , 576, BLACK ); }
int InitLemm( void ) { int i; #ifdef USEX FBFlushGrafic(); #endif FBFillRect( 0, 0, 720, 576, STEELBLUE ); FBFillRect( 60, 448, 300, 100, BLACK ); if ( !bgImage ) { FBDrawString(64,482,32,"Initialize...",WHITE,0); FBDrawFx2Logo( 320, 486 ); #ifdef USEX FBFlushGrafic(); #endif initNumbers(); if ( LoadPics() == -1 ) return -1; bgImage=malloc(1600*160); SoundStart(); } if ( !bgImage ) return -1; for( i=0; i<12; i++ ) svdimage[i]=malloc(32*48); for( i=0; i<320; i+=32 ) inSc( 19, 0, i+main_x, 352, 1 ); inSc( 29, 0, 66+main_x, 370, 1 ); inSc( 29, 1, 100+main_x, 372, 1 ); inSc( 8, 0, 134+main_x, 372, 0 ); // explosion inSc( 4, 10, 166+main_x, 374, 1 ); // lemming2 inSc( 29, 2, 200+main_x, 368, 1 ); inSc( 29, 3, 234+main_x, 368, 1 ); inSc( 29, 4, 264+main_x, 372, 1 ); inSc( 5, 2, 292+main_x, 368, 1 ); inSc( 20, 0, 320+main_x, 352, 1 ); FBDrawString(44,390,48,"-",GREEN,0); FBDrawString(76,390,48,"+",GREEN,0); return 0; }
/** * Draws the complete board according to the values of the cells * and the fx logo * * Possible field values: * # : inactive cell (not reachable with mouse) * ' ' : field which is not on the board * n,b,B: empty field * x : cell with a tux * s : selected cell with a tux */ void DrawBoard(void) { int x; int y; unsigned char *p = maze; for( y = 0; y < MAZEH; y++ ) { for( x = 0; x < MAZEW; x++, p++ ) { switch ( *p ) { case '#' : FBFillRect( x*32, y*32, 32, 32, STEELBLUE ); break; case ' ' : FBFillRect( x*32, y*32, 32, 32, BLACK ); break; case 'n' : FBCopyImage( x*32, y*32, 32, 32, dout ); break; case 'b' : FBCopyImage( x*32, y*32, 32, 32, dout ); break; case 'B' : FBCopyImage( x*32, y*32, 32, 32, dout ); break; case 'x' : FBCopyImage ( x*32, y*32, 32, 32, dtux ); break; case 's' : FBCopyImage( x*32, y*32, 32, 32, dselectedtux ); break; } } } // draw white frame around board FBDrawRect( 3*32-3, 3*32-3, 9*32+5, 9*32+5, WHITE ); FBDrawRect( 3*32-4, 3*32-4, 9*32+7, 9*32+7, WHITE ); FBDrawString( LOGO_X-90, LOGO_Y, 32, "powered by", WHITE, 0 ); FBDrawFx2Logo( LOGO_X, LOGO_Y ); FBDrawString( LOGO_X-90, LOGO_Y+70, 32, "brought to you by", WHITE, 0 ); FBDrawString( LOGO_X-80, LOGO_Y+110, 32, "ChakaZulu", WHITE, 0 ); gettimeofday(&starttv,0); DrawMouse(); }
void DrawScore( void ) { char tmoves[ 64 ]; char tpushes[ 64 ]; sprintf(tmoves,"%d",moves); FBDrawString( 100, 480, 30, "Moves", WHITE, 0 ); FBFillRect( 100, 510, 30, 30, BLACK ); FBDrawString( 100, 510, 30, tmoves, WHITE, 0 ); sprintf(tpushes,"%d",pushes); FBDrawString( 160, 480, 30, "Pushes", WHITE, 0 ); FBFillRect( 160, 510, 30, 30, BLACK ); FBDrawString( 160, 510, 30, tpushes, WHITE, 0 ); }
static void ShowHScore( HScore *g ) { int i; int x; char pp[64]; FBFillRect( 0, 0, 720, 576, BLACK ); #ifdef HAVE_CURL if ( g==ihsc ) FBDrawString( 190, 32, 64, "Internet HighScore", RED, BLACK ); else #endif FBDrawString( 220, 32, 64, "HighScore", RED, BLACK ); for( i=0; i < 8; i++ ) { FBDrawString( 100, 100+i*48, 48, g[i].name, WHITE, 0 ); sprintf(pp,"%ld",g[i].points); x = FBDrawString( 400, 100+i*48, 48, pp, BLACK, BLACK ); FBDrawString( 500-x, 100+i*48, 48, pp, WHITE, BLACK ); } #if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE) FBFlushGrafic(); #endif while( realcode != 0xee ) RcGetActCode(); }
void CTable::ShowHelp() { const int Hx = 100; const int Hy = 100; const int Hwidth = 520; const int Hheight = 376; FBFillRect( Hx+8, Hy+8, Hwidth, Hheight, Convert_24_8( 0,0,0) ); FBFillRect( Hx, Hy, Hwidth, Hheight, 19 ); FBDrawHLine( Hx + 5, Hy + 55, 400, Convert_24_8( 255,255,255) ); FBDrawHLine( Hx + 5, Hy + 56, 400, Convert_24_8( 255,255,255) ); FBDrawString( Hx + 5, Hy + 5, 48, "Solitair for D-BOX", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 60, 32, "TheMoon, 2003", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 102, 32, "Key mappings:", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 135, 32, "(Red)", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 105, Hy + 135, 32, "- Restart game", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 168, 32, "(Blue)", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 105, Hy + 168, 32, "- Wizard", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 201, 32, "(?)", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 105, Hy + 201, 32, "- Help screen", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 234, 32, "(Home)", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 105, Hy + 234, 32, "- Exit", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 267, 32, "(1 - 7)", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 105, Hy + 267, 32, "- Tableau", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 300, 32, "(-) (+)", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 105, Hy + 300, 32, "- Change selection", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 333, 32, "DBOX", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 105, Hy + 333, 32, "- Setup menu", Convert_24_8( 255,255,255), 0 ); }
void DrawBoard( void ) { int x; int y; FBFillRect( 0, 0, 720, 576, BLACK ); for( y = 0; y < 6; y++ ) { for( x = 0; x < 7; x++ ) { FBCopyImage( x*48+64, y*48+96, 48, 48, dout ); } } FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE, dred, 0,0,0); FBDrawFx2Logo( LOGO_X, LOGO_Y ); gettimeofday(&starttv,0); }
static void Fall( int x, unsigned char *dr, char v ) { int y; for( y=0; y<6; y++ ) { if ( maze[ (5-y)*7 + x ] ) break; if(y) { msleep(100); FBCopyImage( x*48+64+6, y*48+48+4, 36, 40, dgray ); maze[ (6-y)*7 + x ] = 0; } else FBFillRect( x*48+64+6, y*48+48+4, 36, 40, BLACK ); maze[ (5-y)*7 + x ] = v; FBOverlayImage( x*48+64+6, y*48+96+4, 36, 40, 0, 0, WHITE, dr, dgray, dgray, dgray); #ifdef HAVE_SPARK_HARDWARE FBFlushGrafic(); #endif } }
static void SaveServices( void ) { FILE *fp; Channel *ch; int i; int n; int nr; char *p; char *p2; int perc; int lp=-1; FBDrawString( 62, 160, 32, "save",BLACK,GRAY); #ifdef USEX FBFlushGrafic(); #endif fp = fopen( CONFIGDIR "/zapit/services.xml", "w" ); if ( !fp ) return; FBFillRect( 96, 226, 508, 24, WHITE ); FBFillRect( 100, 230, 500, 16, GRAY2 ); for( n=0; n<num_lines; n++ ) { perc=n*500/num_lines; if ( perc != lp ) { FBFillRect( 100, 230, perc, 16, GRAY ); #ifdef USEX FBFlushGrafic(); #endif } nr=0; ch=tv_ch; for( i=0; i<num_ch_tv;i++ ) if ( tv_ch[i].line == lines[n] ) break; if ( i==num_ch_tv ) { ch=radio_ch; for( i=0; i<num_ch_radio;i++ ) if ( radio_ch[i].line == lines[n] ) break; if ( i == num_ch_radio ) ch=0; else nr=i; } else nr=i; if ( !ch ) { fprintf(fp,"%s",lines[n]); continue; } p=strstr(lines[n],"serviceType="); p+=14; *p = ch[nr].flag; p2=strstr(lines[n],"channelNR="); p2+=11; for( p=lines[n]; p!=p2; p++ ) fprintf(fp,"%c",*p); fprintf(fp,"%d",nr+1); p=strchr(p,'"'); for( ; *p; p++ ) fprintf(fp,"%c",*p); } fclose(fp); }
static void SaveGame( void ) { #ifdef HAVE_CURL CURL *curl; CURLcode res; FILE *fp; char url[ 512 ]; char *user=0; char luser[ 32 ]; int x; int n; char *p; struct timeval tv; unsigned long chk=0; doexit=0; #endif // HAVE_CURL if ( score < 31 ) return; LocalSave(); #ifdef HAVE_CURL LocalSave(); if ( !use_ihsc ) return; for( x=0; x < 8; x++ ) { if ( score > ihsc[x].points ) break; } if ( x == 8 ) return; FBDrawString( 100,230,64,"Inet-Send Highscore ? (OK/BLUE)",GREEN,0); #if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE) FBFlushGrafic(); #endif while( realcode != 0xee ) RcGetActCode(); actcode=0xee; while( !doexit ) { tv.tv_sec = 0; tv.tv_usec = 100000; select( 0,0,0,0, &tv ); RcGetActCode(); if ( actcode == RC_BLUE ) return; if ( actcode == RC_OK ) break; } if ( doexit ) return; if ( localuser != -1 ) { strcpy(luser,hsc[localuser].name); user=luser; } else { Fx2PigPause(); FBFillRect( 500,32,3*52,4*52+4,BLACK ); FBFillRect( 150,420,470,64,BLACK ); FBDrawRect( 149,419,472,66,WHITE ); FBDrawRect( 148,418,474,68,WHITE ); x=FBDrawString( 154,420,64,"name : ",WHITE,0); user=FBEnterWord(154+x,420,64,9,WHITE); Fx2PigResume(); } n=FBDrawString( 210,360,48,"sending",BLACK,WHITE); /* clean name */ x = strlen(user); p=user; for( p=user; *p; x--, p++ ) { if (( *p == ' ' ) || ( *p == '&' ) || ( *p == '/' )) memcpy(p,p+1,x); } chk=BuildCheck( user, score ); sprintf(url,"%s/games/tetris.php?action=put&user=%s&score=%ld&chk=%lu", hscore,user,score,chk); curl = curl_easy_init(); if ( !curl ) return; fp = fopen( "/var/tmp/trash", "w"); if ( !fp ) { curl_easy_cleanup(curl); return; } curl_easy_setopt( curl, CURLOPT_URL, url ); curl_easy_setopt( curl, CURLOPT_FILE, fp ); curl_easy_setopt( curl, CURLOPT_NOPROGRESS, TRUE ); if ( proxy_addr ) { curl_easy_setopt( curl, CURLOPT_PROXY, proxy_addr ); if ( proxy_user ) curl_easy_setopt( curl, CURLOPT_PROXYUSERPWD, proxy_user ); } res = curl_easy_perform(curl); FBFillRect( 210,360,n,48,GRAY); if ( !res ) FBDrawString( 210,360,48,"success",GREEN,GRAY); else FBDrawString( 210,360,48,"failed",RED,GRAY); curl_easy_cleanup(curl); fclose( fp ); unlink( "/var/tmp/trash" ); LoadHScore(); return; #endif // HAVE_CURL }
void MoveMouse() { static int locked = 0; int dx=0; int dy=0; char zug=' '; if ( locked ) { locked--; actcode=0xee; return; } switch( actcode ) { case RC_RIGHT : // Pinguin nach rechts if ( man_x+1 < MAZEW ) { dx = 1; dy = 0; zug = 'r'; locked=1; } break; case RC_LEFT : // Pinguin nach links if ( man_x > 1 ) { dx = -1; dy = 0; zug = 'l'; locked=1; } break; case RC_DOWN : // Pinguin nach unten if ( man_y+1 < MAZEH ) { dx = 0; dy = 1; zug = 'd'; locked=1; } break; case RC_UP : // Pinguin nach oben if ( man_y > 1 ) { dx = 0; dy = -1; zug = 'u'; locked=1; } break; case RC_MINUS : // letzte Züge rückgängig machen if (moves>0) { if (getField(man_x,man_y)=='@') { setField(man_x,man_y,' '); } else { setField(man_x,man_y,'.'); } if (Zuege[moves]=='r' || Zuege[moves]=='R') { man_x--; dx=1; } else if (Zuege[moves]=='l' || Zuege[moves]=='L') { man_x++; dx=-1; } else if (Zuege[moves]=='u' || Zuege[moves]=='U') { man_y++; dy=-1; } else if (Zuege[moves]=='d' || Zuege[moves]=='D') { man_y--; dy=1; } if (getField(man_x,man_y)==' ') { setField(man_x,man_y,'@'); } else { setField(man_x,man_y,'+'); } if (isupper(Zuege[moves])) { if (getField(man_x+2*dx,man_y+2*dy)=='$') { setField(man_x+2*dx,man_y+2*dy,' '); } else { setField(man_x+2*dx,man_y+2*dy,'.'); } if (getField(man_x+dx,man_y+dy)==' ') { setField(man_x+dx,man_y+dy,'$'); } else { setField(man_x+dx,man_y+dy,'*'); } pushes--; } moves--; dx=0; dy=0; DrawBoard(); DrawScore(); } locked=1; break; case RC_PLUS : // Rückgängig rückgängig machen if (Zuege[moves+1]!=' ') { if (Zuege[moves+1]=='r' || Zuege[moves+1]=='R') { dx=1; } else if (Zuege[moves+1]=='l' || Zuege[moves+1]=='L') { dx=-1; } else if (Zuege[moves+1]=='u' || Zuege[moves+1]=='U') { dy=-1; } else if (Zuege[moves+1]=='d' || Zuege[moves+1]=='D') { dy=1; } } locked=1; break; case RC_RED : // vorheriges Level - bei angefangenem Level nachfragen, ob wirklich sicher if (moves!=0) { FBFillRect( 160, 70, 400, 436, B ); FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 ); FBDrawString( 160,110, 30, "ROT abbruch", WHITE, 0 ); FBDrawString( 160,140, 30, "OK naechstes Level", WHITE, 0 ); #ifdef USEX FBFlushGrafic(); #endif actcode=0xee; while( actcode != RC_OK && actcode != RC_RED ) { RcGetActCode(); } } if (actcode == RC_OK || moves==0) { if (level > 0) { level--; BoardInitialize(); } else { level = max_level-1; BoardInitialize(); } } else { FBFillRect( 0, 0, 720, 576, BLACK ); DrawBoard(); DrawScore(); } locked=1; break; case RC_GREEN : // naechstes Level - bei angefangenem Level nachfragen, ob wirklich sicher if (moves!=0) { FBFillRect( 160, 70, 400, 436, B ); FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 ); FBDrawString( 160,110, 30, "ROT abbruch", WHITE, 0 ); FBDrawString( 160,140, 30, "OK vorheriges Level", WHITE, 0 ); #ifdef USEX FBFlushGrafic(); #endif actcode=0xee; while( actcode != RC_OK && actcode != RC_RED ) { RcGetActCode(); } } if (actcode == RC_OK || moves==0) { if (level+1 < max_level) { level++; BoardInitialize(); } else { level = 0; BoardInitialize(); } } else { FBFillRect( 0, 0, 720, 576, BLACK ); DrawBoard(); DrawScore(); } locked=1; break; case RC_YELLOW : // Randfelder ('a') aus-/einblenden if (Rand == 0) { Rand = 1; } else { Rand = 0; } locked=1; FBFillRect( 0, 0, 720, 576, BLACK ); DrawBoard(); DrawScore(); FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 ); break; case RC_BLUE : // Level von vorne beginnen - bei angefangenem Level nachfragen, ob wirklich sicher if (moves!=0) { FBFillRect( 160, 70, 400, 436, B ); FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 ); FBDrawString( 160,110, 30, "ROT abbruch", WHITE, 0 ); FBDrawString( 160,140, 30, "OK vorheriges Level", WHITE, 0 ); #ifdef USEX FBFlushGrafic(); #endif actcode=0xee; while( actcode != RC_OK && actcode != RC_RED ) { RcGetActCode(); } } if (actcode == RC_OK || moves==0) { BoardInitialize(); } else { FBFillRect( 0, 0, 720, 576, BLACK ); DrawBoard(); DrawScore(); } locked=1; break; case RC_HELP : // Hilfe anzeigen locked=1; FBFillRect( 160, 70, 400, 436, B ); FBDrawString( 160, 70, 30, "ROT vorheriges Level", WHITE, 0 ); FBDrawString( 160,100, 30, "GRUEN naechstes Level", WHITE, 0 ); FBDrawString( 160,130, 30, "GELB Rand ein/aus", WHITE, 0 ); FBDrawString( 160,160, 30, "BLAU Level neu starten", WHITE, 0 ); FBDrawString( 160,190, 30, "MINUS Zug zurueck", WHITE, 0 ); FBDrawString( 160,220, 30, "PLUS Zug vor", WHITE, 0 ); FBDrawString( 160,260, 30, "HOME Spiel beenden", WHITE, 0 ); FBDrawString( 160,290, 30, "STUMM Spiel aus-/einblenden", WHITE, 0 ); FBDrawString( 160,330, 30, "HILFE diese Hilfe", WHITE, 0 ); FBDrawString( 160,370, 30, "OK weiter", WHITE, 0 ); #ifdef USEX FBFlushGrafic(); #endif actcode=0xee; while( actcode != RC_OK ) { RcGetActCode( ); } FBFillRect( 0, 0, 720, 576, BLACK ); DrawBoard(); DrawScore(); FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 ); break; } if (dx != 0 || dy != 0) // Soll Pinguin verschoben werden? { if (getField(man_x+dx, man_y+dy) == ' ') // Zug auf leeres Feld - keine Kiste vorhanden { if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');} else {setField(man_x,man_y,'.');} DrawField(man_x, man_y); man_x += dx; dx = 0; man_y += dy; dy = 0; setField(man_x,man_y,'@'); DrawField(man_x, man_y); moves++; DrawScore(); } else if (getField(man_x+dx, man_y+dy) == '.') // Zug auf Zielfeld - keine Kiste vorhanden { if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');} else {setField(man_x,man_y,'.');} DrawField(man_x, man_y); man_x += dx; dx = 0; man_y += dy; dy = 0; setField(man_x,man_y,'+'); DrawField(man_x, man_y); moves++; DrawScore(); } else if (getField(man_x+dx, man_y+dy) == '$' && getField(man_x+(2*dx), man_y+(2*dy)) == ' ') // Zug auf Feld mit Kiste - Kiste auf leeres Feld { setField(man_x+(2*dx), man_y+(2*dy),'$'); setField(man_x+dx, man_y+dy,' '); DrawField(man_x+(2*dx), man_y+(2*dy)); if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');} else {setField(man_x,man_y,'.');} DrawField(man_x, man_y); man_x += dx; dx = 0; man_y += dy; dy = 0; setField(man_x,man_y,'@'); DrawField(man_x, man_y); moves++; pushes++; zug = toupper (zug); DrawScore(); } else if (getField(man_x+dx, man_y+dy) == '$' && getField(man_x+(2*dx), man_y+(2*dy)) == '.') // Zug auf Feld mit Kiste - Kiste auf Zielfeld { setField(man_x+(2*dx), man_y+(2*dy),'*'); setField(man_x+dx, man_y+dy,' '); DrawField(man_x+(2*dx), man_y+(2*dy)); if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');} else {setField(man_x,man_y,'.');} DrawField(man_x, man_y); man_x += dx; dx = 0; man_y += dy; dy = 0; setField(man_x,man_y,'@'); DrawField(man_x, man_y); moves++; pushes++; zug = toupper (zug); DrawScore(); } else if (getField(man_x+dx, man_y+dy) == '*' && getField(man_x+(2*dx), man_y+(2*dy)) == ' ') // Zug auf Zielfeld mit Kiste - Kiste auf leeres Feld { setField(man_x+(2*dx), man_y+(2*dy),'$'); setField(man_x+dx, man_y+dy,'.'); DrawField(man_x+(2*dx), man_y+(2*dy)); if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');} else {setField(man_x,man_y,'.');} DrawField(man_x, man_y); man_x += dx; dx = 0; man_y += dy; dy = 0; setField(man_x,man_y,'+'); DrawField(man_x, man_y); moves++; pushes++; zug = toupper (zug); DrawScore(); } else if (getField(man_x+dx, man_y+dy) == '*' && getField(man_x+(2*dx), man_y+(2*dy)) == '.') // Zug auf Zielfeld mit Kiste - Kiste auf Zielfeld { setField(man_x+(2*dx), man_y+(2*dy),'*'); setField(man_x+dx, man_y+dy,'.'); DrawField(man_x+(2*dx), man_y+(2*dy)); if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');} else {setField(man_x,man_y,'.');} DrawField(man_x, man_y); man_x += dx; dx = 0; man_y += dy; dy = 0; setField(man_x,man_y,'+'); DrawField(man_x, man_y); moves++; pushes++; zug = toupper (zug); DrawScore(); } else { zug = ' '; } } if (zug !=' ') { Zuege[moves]=zug; } if (win() == 1) // durch letzten Zug gewonnen? { if (level+1 < max_level) { level++; } else { level = 0; } doexit=1; } #ifdef USEX FBFlushGrafic(); #endif return; }
void DrawFill( void ) { FBFillRect( STATUS_X, STATUS_Y, pices, 4, GREEN ); FBFillRect( STATUS_X, STATUS_Y+6, (timeleft/TPF), 4, RED ); }
void MoveMouse( void ) { static int locked = 0; int k; if ( locked ) { locked--; actcode=0xee; return; } k=0; switch( actcode ) { case RC_7 : k++; case RC_6 : k++; case RC_5 : k++; case RC_4 : k++; case RC_3 : k++; case RC_2 : k++; case RC_1 : k++; break; } if ( k ) ipos=k-1; switch( actcode ) { case RC_RIGHT : if ( ipos < 6 ) { FBFillRect( ipos*48+64+6, 48+4, 36, 40, BLACK ); ipos++; FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE, dred, 0,0,0); locked=1; } break; case RC_LEFT : if ( ipos > 0 ) { FBFillRect( ipos*48+64+6, 48+4, 36, 40, BLACK ); ipos--; FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE, dred, 0,0,0); locked=1; } break; case RC_7 : case RC_6 : case RC_5 : case RC_4 : case RC_3 : case RC_2 : case RC_1 : case RC_OK : locked=1; if ( maze[ipos+35] ) break; Fall( ipos, dred, 1 ); k=TestGameOver( 1 ); if ( GameOver(1) ) return; MyPlay(); if ( GameOver(2) ) return; ipos=3; FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE, dred, 0,0,0); break; } }
void InitLevel( void ) { int i; char text[64]; in_level=0; pause=0; killall=0; action=0; lem_in=0; lem_run=0; afunc=-1; main_x=660; memset(deko,0,sizeof(deko)); memset(bgImage,STEELBLUE,1600*160); deko[0]=CreateSprite(0,0,main_x+160,80); // cursor deko[0]->anilocked=1; switch( level ) { case 1 : case 4 : case 6 : /* deko */ deko[1]=CreateSprite(1,0,726,39); // tor deko[1]->anilocked=1; deko[1]->backlocked=1; /* zielhaus */ deko[2]=CreateSprite(7,0,871,106); // haus deko[2]->anilocked=1; deko[2]->backlocked=1; deko[3]=CreateSprite(2,0,876,108); // flamme deko[3]->backlocked=1; deko[4]=CreateSprite(2,3,902,108); // flamme deko[4]->backlocked=1; MirrorSprite( deko[4] ); /* setup */ memset(lemm,0,sizeof(lemm)); memset(portfolio,0,sizeof(portfolio)); switch( level ) { case 6 : portfolio[7]=2; portfolio[3]=2; portfolio[2]=2; break; case 1 : portfolio[7]=10; #if 1 portfolio[6]=10; portfolio[4]=10; portfolio[3]=10; portfolio[2]=10; #endif break; case 4 : portfolio[2]=5; break; } haus_x=889; haus_y1=117; haus_y2=135; to_rescue=level==6?39:5; newspeed=level==6?1:50; lem_cnt=level==6?40:10; break; case 2 : /* deko */ deko[1]=CreateSprite(1,0,726,7); // tor deko[1]->anilocked=1; deko[1]->backlocked=1; /* zielhaus */ deko[2]=CreateSprite(7,1,700,128); // haus deko[2]->anilocked=1; deko[2]->backlocked=1; deko[3]=CreateSprite(2,0,704,129); // flamme deko[3]->backlocked=1; deko[4]=CreateSprite(2,3,731,129); // flamme deko[4]->backlocked=1; MirrorSprite( deko[4] ); /* setup */ memset(lemm,0,sizeof(lemm)); memset(portfolio,0,sizeof(portfolio)); portfolio[3]=4; haus_x=718; haus_y1=139; haus_y2=157; to_rescue=25; newspeed=50; lem_cnt=50; break; case 3 : /* deko */ deko[1]=CreateSprite(1,0,726,23); // tor deko[1]->anilocked=1; deko[1]->backlocked=1; /* zielhaus */ deko[2]=CreateSprite(7,1,1000,128); // haus deko[2]->anilocked=1; deko[2]->backlocked=1; deko[3]=CreateSprite(2,0,1004,129); // flamme deko[3]->backlocked=1; deko[4]=CreateSprite(2,3,1031,129); // flamme deko[4]->backlocked=1; MirrorSprite( deko[4] ); /* setup */ memset(lemm,0,sizeof(lemm)); memset(portfolio,0,sizeof(portfolio)); portfolio[3]=2; portfolio[7]=2; haus_x=1018; haus_y1=139; haus_y2=157; to_rescue=50; newspeed=50; lem_cnt=50; break; case 5 : /* deko */ deko[1]=CreateSprite(1,0,712,3); // tor deko[1]->anilocked=1; deko[1]->backlocked=1; /* zielhaus */ deko[2]=CreateSprite(7,1,1150,117); // haus deko[2]->anilocked=1; deko[2]->backlocked=1; deko[3]=CreateSprite(2,0,1154,118); // flamme deko[3]->backlocked=1; deko[4]=CreateSprite(2,3,1181,118); // flamme deko[4]->backlocked=1; MirrorSprite( deko[4] ); /* feuer */ deko[5]=CreateSprite(9,0,849,39); // feuer deko[6]=CreateSprite(9,0,979,39); // feuer deko[7]=CreateSprite(9,0,880,66); // feuer deko[8]=CreateSprite(9,0,880,107); // feuer deko[9]=CreateSprite(9,0,979,131); // feuer deko[10]=CreateSprite(9,0,1002,86); // feuer /* setup */ memset(lemm,0,sizeof(lemm)); memset(portfolio,0,sizeof(portfolio)); portfolio[2]=5; portfolio[3]=3; haus_x=1168; haus_y1=128; haus_y2=146; to_rescue=30; newspeed=50; lem_cnt=50; break; } minspeed=newspeed; DrawLevelIntoBg(); /* copy level to screen */ CopyBg2Screen( main_x, 0, 328, 160 ); SpritesGetBackground(); DrawSprites(); /* Draw Menu-Item-Numbers */ for( i=0; i<8; i++ ) DrawNumber( 106+i*32, 389, portfolio[i] ); DrawNumber( 42, 389, newspeed ); DrawNumber( 74, 389, 100-newspeed ); DrawInfo(3); /* show level info */ FBFillRect( 60, 448, 200, 100, BLACK ); sprintf(text,"Lemmings : %d ",lem_cnt); FBDrawString(64,450,32,text,WHITE,0); sprintf(text,"%d%% to be saved ",to_rescue*100/lem_cnt); FBDrawString(64,482,32,text,WHITE,0); sprintf(text,"Release Rate %d ",100-newspeed); FBDrawString(64,514,32,text,WHITE,0); SoundPlay( SND_LETSGO ); }
bool CTable::Setup() { const int Hx = 100; const int Hy = 100; const int Hwidth = 520; const int Hheight = 376; bool SomeChanges = true; bool FirstRun = true; int loiShowCards = ShowCards; while( 1 ) { timeval tv; tv.tv_sec = 0; tv.tv_usec = 60000; select( 0, 0, 0, 0, &tv ); /* 60ms pause */ RcGetActCode(); if( false == FirstRun && realcode == 0xee ) continue; switch( actcode ) { case RC_OK : ShowCards = loiShowCards; return true; break; case RC_RIGHT : case RC_LEFT : if( 3 == loiShowCards ) loiShowCards = 1; else loiShowCards = 3; SomeChanges = true; break; case RC_SETUP : if( FirstRun ) break; RcGetActCode(); return false; break; } if( SomeChanges ) { unsigned char FC = Convert_24_8( 0,0,128); unsigned char BC = Convert_24_8( 255,255,0); if( FirstRun ) { FBFillRect( Hx+8, Hy+8, Hwidth, Hheight, Convert_24_8( 0,0,0) ); FBFillRect( Hx, Hy, Hwidth, Hheight, 19 ); } FBDrawHLine( Hx + 5, Hy + 55, 400, Convert_24_8( 255,255,255) ); FBDrawHLine( Hx + 5, Hy + 56, 400, Convert_24_8( 255,255,255) ); FBDrawString( Hx + 5, Hy + 5, 48, "Setup", Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 102, 32, "Open cards:", Convert_24_8( 255,255,255), 0 ); FBFillRect( Hx + 150, Hy + 102, 100, 32, loiShowCards==3?BC:19 ); FBFillRect( Hx + 260, Hy + 102, 100, 32, loiShowCards==1?BC:19 ); FBDrawString( Hx + 160, Hy + 102, 32, "3 Cards", loiShowCards==3?FC:Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 270, Hy + 102, 32, "1 Card", loiShowCards==1?FC:Convert_24_8( 255,255,255), 0 ); FBDrawString( Hx + 5, Hy + 333, 24, "(OK) - Accept changes, (DBOX) - Cancel", Convert_24_8( 255,255,255), 0 ); #if defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE) FBFlushGrafic(); #endif } SomeChanges = false; FirstRun = false; } return false; }
static void SortBouquet( Channel *ch, int num ) { int i; int color; int p1=0; int pos=0; int w=0; int redraw=0; int mode=0; int x; int x2; struct timeval tv; Channel chs; char text[16]; FBFillRect( 0,0,720,576,BLACK); FBDrawString( 200, 32, 48, ch==tv_ch?"TV bouquet":"Radio bouquet",RED,0); while( realcode != 0xee ) RcGetActCode(); actcode=0xee; while( !doexit ) { if ( w ) FBFillRect( 150, 90, w+150, 44*9+48, BLACK ); w=0; for( i=p1; i<p1+10; i++ ) { sprintf(text,"%d",i+1); x2=FBDrawString( 150,90+(i-p1)*44,48,text,BLACK,0); FBDrawString( 260-x2,90+(i-p1)*44,48,text,GRAY,0); color= ch[i].flag == '0' ? GRAY : GRAY2; if ( i== pos ) color=mode?RED:WHITE; x=FBDrawString( 300,90+(i-p1)*44,48,ch[i].name,color,0); if ( x > w ) w=x; } FBDrawString( 50, 100, 32, "OK select",GRAY,0); FBFillRect( 50, 142, 8, 8, BLUE ); FBDrawString( 62, 130, 32, "hide/show",GRAY,0); FBFillRect( 50, 172, 8, 8, RED ); FBDrawString( 62, 160, 32, "save",GRAY,0); FBFillRect( 50, 202, 8, 8, YELLOW ); FBDrawString( 62, 190, 32, ch==tv_ch?"radio":"tv",GRAY,0); #ifdef USEX FBFlushGrafic(); #endif while( realcode != 0xee ) RcGetActCode(); redraw=0; while( !doexit && !redraw ) { tv.tv_sec = 0; tv.tv_usec = 200000; select( 0,0,0,0,&tv ); actcode=0xee; RcGetActCode(); if ( actcode == 0xee ) continue; switch( actcode ) { case RC_UP : if ( pos == 0 ) continue; pos--; if ( mode ) { memcpy(&chs,ch+pos+1,sizeof(Channel)); memcpy(ch+pos+1,ch+pos,sizeof(Channel)); memcpy(ch+pos,&chs,sizeof(Channel)); } if ( pos < p1 ) { p1 -= 9; redraw=1; if ( p1 < 0 ) p1 = 0; } else { if ( mode ) { FBDrawString( 300,90+(pos+1-p1)*44,48, ch[pos].name, BLACK,0); FBDrawString( 300,90+(pos-p1)*44,48, ch[pos+1].name, BLACK,0); } color= ch[pos+1].flag == '0' ? GRAY : GRAY2; FBDrawString( 300,90+(pos+1-p1)*44,48,ch[pos+1].name, color,0); color=mode?RED:WHITE; FBDrawString( 300,90+(pos-p1)*44,48,ch[pos].name, color,0); } break; case RC_DOWN : if ( pos == num-1 ) continue; pos++; if ( mode ) { memcpy(&chs,ch+pos-1,sizeof(Channel)); memcpy(ch+pos-1,ch+pos,sizeof(Channel)); memcpy(ch+pos,&chs,sizeof(Channel)); } if ( pos > p1+9 ) { p1 += 9; redraw=1; if ( p1 > num-10 ) p1 = num-10; } else { if ( mode ) { FBDrawString( 300,90+(pos-1-p1)*44,48, ch[pos].name, BLACK,0); FBDrawString( 300,90+(pos-p1)*44,48, ch[pos-1].name, BLACK,0); } color= ch[pos-1].flag == '0' ? GRAY : GRAY2; FBDrawString( 300,90+(pos-1-p1)*44,48,ch[pos-1].name, color,0); color=mode?RED:WHITE; FBDrawString( 300,90+(pos-p1)*44,48,ch[pos].name, color,0); } break; case RC_BLUE : ch[pos].flag = ch[pos].flag == '0' ? '1' : '0'; break; case RC_OK : color=mode?WHITE:RED; FBDrawString( 300,90+(pos-p1)*44,48,ch[pos].name, color,0); mode=!mode; break; case RC_RED : doexit=1; break; case RC_YELLOW : doexit=2; break; } #ifdef USEX FBFlushGrafic(); #endif while( realcode != 0xee ) RcGetActCode(); } } }
void BoardInitialize() { char* verz = DATADIR "/sokoban/"; char* verz2 = CONFIGDIR "/sokoban/"; FILE *Datei=0; int x,y,z; int i; char* d; if (levelverz[level]==1) { d = malloc (strlen(verz)+strlen(levelname[level])+1); strcpy (d,verz); strcat (d,levelname[level]); } else { d = malloc (strlen(verz2)+strlen(levelname[level])+1); strcpy (d,verz2); strcat (d,levelname[level]); } FBFillRect( 0, 0, 720, 576, BLACK ); Datei = fopen(d, "r"); free(d); if ( !Datei ) { // installation error doexit=4; FBDrawString( 200, 510, 30, "Installation Error. Cant find Level", WHITE, 0 ); return; } MAZEW = 0; MAZEH = 0; for (y=0; y<18; y++) { for (x=0; x<22; x++) { setField(x, y, 'a'); } } x=0; y=0; while(!feof(Datei)) { z = fgetc(Datei); if (z!='#' && z!='.' && z!='$' && z!='@' && z!='+' && z!='*' && z!=' ' && z!=0x0d && z!=0x0a) { MAZEH=y; break; } else if (z == 0x0d) { z=fgetc(Datei); for (i=x; board[i][y] != '#' && i > 3; i--) {x=i;} if (MAZEW < x) {MAZEW = x;} y++; x=0; MAZEH=y; } else if (z == 0x0a) { for (i=x; board[i][y] != '#' && i > 3; i--) {x=i;} if (MAZEW < x) {MAZEW = x;} y++; x=0; MAZEH=y; } else { if (y<18 && x<22) { setField(x, y, z); if ((z=='@') || (z=='+')) { man_x = x; man_y = y; } } x++; } } fclose(Datei); ox = (720 - (MAZEW*32))/2; oy = (576 - (MAZEH*28))/2; for (y=0; y<18; y++) { for (x=0; x<22; x++) { if (getField(x, y) != '#') {setField (x, y, 'a');} else break; } for (x=21; x>=0; x--) { if (getField(x, y) != '#') {setField (x, y, 'a');} else break; } } for (x=0; x<22; x++) { for (y=0; y<18; y++) { if (getField(x, y) != '#') {setField (x, y, 'a');} else break; } for (y=17; y>=0; y--) { if (getField(x, y) != '#') {setField (x, y, 'a');} else break; } } moves = 0; pushes = 0; DrawBoard(); DrawScore(); FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 ); for (i=0; i<=1500;i++) { Zuege[i]=' '; } }