int CPROC TableDraw( PCOMMON pf ) { Image surface = GetFrameSurface( pf ); // and then I can draw like cards or something here? { int s, f; for( s = 0; s < 4; s++ ) for( f = 0; f < 13; f++ ) { if( l.card_image[s][f] ) BlotImage( surface, l.card_image[s][f], f * l.step_x, s * l.step_y ); } BlatColor( surface, 300, 10, l.width + l.step_x * 1, l.height, GetBaseColor( NORMAL ) ); BlatColor( surface, 300, 90, l.width + l.step_x * 4, l.height, GetBaseColor( NORMAL ) ); for( s = 0; s < l.nHand; s++ ) { BlotImage( surface, l.hand_image[s], 300 + s * l.step_x, 10 ); } for( s = 0; s < l.nTable; s++ ) { BlotImage( surface, l.table_image[s], 300 + s * l.step_x, 90 ); } { PTEXT hand_string = NULL; TEXTCHAR output[128]; GetPokerHandName( l.hand, &hand_string ); if( hand_string ) { snprintf( output, sizeof( output ), WIDE("%s "), GetText( hand_string ) ); PutString( surface, 50, 200, GetBaseColor( TEXTCOLOR ), GetBaseColor( NORMAL ), output ); } else PutString( surface, 50, 200, GetBaseColor( TEXTCOLOR ), GetBaseColor( NORMAL ), WIDE("Uhh no hand?!") ); LineRelease( hand_string ); } //UpdateFrame( pf, 0, 0, 0, 0 ); } return 1; }
void DrawReel( int nReel ) { int n; int i; n = nReel; { IMAGE_RECTANGLE rect; rect.x = REEL_OFSX + REEL_STEPX * n; rect.y = REEL_OFSY; rect.width = REEL_WIDTH; rect.height = REEL_HEIGHT; //#ifndef __ARM__ //SetImageBound( g.surface, &rect ); //#endif // for( i = 0; i < NUM_PICS+2; i++ ) for( i = 0; i < NUM_PICS; i++ ) { BlotImage( g.surface, g.reel[n][i], REEL_OFSX + REEL_STEPX*n, (REEL_OFSY-96) + g.ofs + i*96 ); } } //#ifndef __ARM__ //FixImagePosition( g.surface ); //#endif }
void CPROC DrawImage( uintptr_t psv, PRENDERER out ) { PIMAGE_DISPLAY pdi = (PIMAGE_DISPLAY)psv; BlotImage( GetDisplayImage( pdi->display ), pdi->Loaded, 0, 0 ); UpdateDisplay( pdi->display ); }
int main( void ) { uint32_t width, height; uint32_t imagecount = 0; uint32_t testimagesatinitialization = 0; Image blank; srand( time( NULL ) ); for(width=0; width< NUM_REELS; width++) { g.uiSpeedCounter[width] = 0; g.uiSpeedStep[width] = 2; g.idx[width]= 0; } g.pdi = GetDisplayInterface(); g.pii = GetImageInterface(); //SetSystemLog( SYSLOG_FILE, stdout ); SetSystemLoggingLevel( 1000 + LOG_NOISE); GetDisplaySize( &width, &height );; g.render = OpenDisplaySizedAt( 0, width, height, 0, 0 ); UpdateDisplay(g.render); g.surface = GetDisplayImage( g.render ); SetMouseHandler( g.render, MouseMethod, 0 ); // blank = LoadImageFile( WIDE("blankimage.jpg")); blank = MakeImageFile(96,96); ClearImageTo( blank, BASE_COLOR_CYAN ); g.playagain=LoadImageFile( WIDE("%images%/playagain.jpg")); g.playing =LoadImageFile( WIDE("%images%/playing.jpg")); g.background = LoadImageFile( WIDE("%images%/background.jpg") ); // g.background = blank; g.strip = LoadImageFile( WIDE("%images%/slot_strip.jpg") ); g.nReels = NUM_REELS; { Image icons[NUM_ICONS]; int n, m; INDEX idx; for( n = 0; n < NUM_ICONS; n++ ) { icons[n] = MakeSubImage( g.strip, 96 * n, 0, 96, 96 ); } n = width = imagecount = height = 0; while(imagecount < NUM_IMAGES ) { idx = rand()%NUM_ICONS; g.images[imagecount] = icons[idx]; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; for( m = 0; m < (( rand()%2 ) ); m++) { g.images[imagecount] = blank; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; } if( testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } } if( !testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } for( n = 0; n < NUM_BLURS; n++ ) { g.blurs[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); g.dodges[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); for( m = 0; m < NUM_IMAGES; m++ ) { idx = rand()%NUM_IMAGES; g.reel[0][m] = g.images[idx]; } Blur( g.blurs[n], g.reel[0] ); DodgeEx( g.dodges[n], g.reel[0] , 2); } for( n = 0; n < NUM_REELS; n++) { g.subsurface[n] = MakeSubImage( g.surface , REEL_OFSX + REEL_STEPX * n , REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS_IN_WINDOW) ); g.testsurface[n] = MakeSubImage( g.surface, REEL_OFSX + REEL_STEPX * n + 480, REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS) ); } g.statussurface = MakeSubImage( g.surface , 490, 10 , 140, 68 ); g.backgroundsurface = MakeSubImage( g.surface , 0, 0 , 640, 460 ); } g.flags.bBackgroundInitialized = 0; ThreadTo( ReadInput, 0 ); { uint32_t start = GetTickCount(); xlprintf(LOG_NOISE)("Started at %lu" , start); g.ofs = 0; while( 1 ) { if( g.flags.bSpinning ) { DrawSpinningReels(FALSE); } #ifndef __ARM__ // scale to approx unit speeds.. WakeableSleep( 250 ); //WakeableSleep( 33); #endif } } CloseDisplay( g.render ); UnmakeImageFile( g.strip ); return 0; }
int CPROC MouseMethod( uintptr_t psv, int32_t x, int32_t y, uint32_t b ) { if( !g.flags.bSpinning ) { if( !b ) { g.ofs = -7; DrawReels(); } else if( b == 1 ) { if( g.ofs == -7 ) { int n; if( !g.flags.bBackgroundInitialized) { ClearImageTo( g.backgroundsurface, BASE_COLOR_BLACK ); BlotImage( g.backgroundsurface, g.background, 0, 0 ); g.flags.bBackgroundInitialized = 1; } for( n = 0; n < NUM_REELS; n++ ) { g.bReelSpinning[n] = 1; } g.flags.bSpinning = 1; if( 0 )//yucky. real cheesey. { int n, i; for( n = 0; n < g.nReels; n++ ) for( i = 0; i < NUM_PICS+2; i++ ) { g.reel[n][i] = g.images[rand()%10]; } } DrawSpinningReels(TRUE); } } } else { if( b ) { int reel = (x - REEL_OFSX) / REEL_STEPX; if( reel >= 0 && reel < NUM_REELS ) { if( g.bReelSpinning[reel] ) { g.bReelSpinning[reel] = 0; g.ofs = -32; // DrawReel(reel); UpdateDisplayPortion( g.render , REEL_OFSX , REEL_OFSY , REEL_STEPX*(reel) , REEL_WIDTH ); g.ofs = 7; // DrawReel(reel); UpdateDisplayPortion( g.render , REEL_OFSX , REEL_OFSY , REEL_STEPX*(reel) , REEL_WIDTH ); WakeableSleep( 100 ); g.ofs = 0; // DrawReel(reel); UpdateDisplayPortion( g.render , REEL_OFSX , REEL_OFSY , REEL_STEPX*(reel) , REEL_WIDTH ); { int n; for( n = 0; n < NUM_REELS; n++ ) if( g.bReelSpinning[n] ) break; if( n == NUM_REELS ) { g.flags.bSpinning = 0; SyncRender( g.render); // SetReelSpeedStep(); } } } } } } return 1; }
void Render( PRENDERER r, int output ) { int a,b; Image surface = GetDisplayImage( r ); RCOORD aspect; if( !output_surface ) output_surface = MakeImageFile( surface->width, surface->height ); aspect = (RCOORD)output_surface->width / (RCOORD)output_surface->height; ofsx = (output_surface->width/2); ofsy = (output_surface->height/2); dx = display_scale*4.0 / (RCOORD)output_surface->width; dy = display_scale*4.0 / (RCOORD)output_surface->height; if( !drawn ) { drawn = 1; ClearImage( output_surface); _ii1_max_iter = 0; _ii2_max_iter = 0; { RCOORD dam, dbm; dam = ( mx - ofsx ) * dx + xorg; dbm = ( my - ofsy ) * dy + yorg; for( a = 0; a < output_surface->width; a++ ) { for( b = 0; b < output_surface->height; b++ ) { RCOORD da, db; RCOORD rda, rdb; int r, g = 0, bl = 0; int direction; //rda = ( ( b *2 ) / (RCOORD)output_surface->height) * sin(3.14159/2 + ( ( a * 2*3.14159 ) / (RCOORD)output_surface->width)); //rdb = ( ( b *2 ) / (RCOORD)output_surface->height) * cos(3.14159/2 + ( ( a * 2*3.14159 ) / (RCOORD)output_surface->width)); //da = ( rda ) + xorg; //db = ( rdb ) + yorg; da = aspect * ( a - ofsx ) * dx + xorg; db = ( b - ofsy ) * dy + yorg; //if( (r = IsInfinite( dam, dbm, da, db )) == -1 ) r = 0; /* // draw just in range of the cursor if( !( ( (mx - a) > -20) && ( (mx-a) < 20 ) && ( (my - b) > -20 ) && ( (my - b) < 20 ) ) ) { continue; } */ //if( (g = IsInfinite2( dam, dbm, da, db )) == -1 ) // g = 0; bl = IsInfinite2( 0, 0, da, db, &direction ); if( (direction) < 0 ) { r = ( -bl ); bl = 0; } else if( bl < 0 ) { g = 32; bl = 0; //r = 0; } else if( bl != 0 ) { //r = 0; bl = bl; } //else // r = 0; if( g == 255 ) { int a = 3; } { // point pair horiz -0.123 (R) 0.35071355833500363833634934966131 // 0.422(I) 0.64961527075646859365525325998975 // // point pair vert -0.563(R) 0.75033325929216279143681201481957 0(I) /*distance to next 0.49986672471039669667784846697923*/ // point pair vert -1.563(R) 1.2501999840025594881146604817988 0(I) /* to next 0.1125178884860932415243100526011 */ // next is -1.857 (R) 1.3627178724886527296389705343999 0(I) RCOORD unity = da*da + db*db; RCOORD offset_unity = (da+0.123)*(da+0.123) + db*db; if( unity < 0.564 && unity >= 0.562 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_WHITE, 64, 256 ) ); else if( offset_unity < 0.422 && offset_unity >= 0.420 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_WHITE, 64, 256 ) ); else if( unity < 1.001 && unity >= 0.999 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_WHITE, 138, 256 ) ); else if( unity < 1.564 && unity >= 1.562 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_WHITE, 64, 256 ) ); else if( unity < 1.868 && unity >= 1.866 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_WHITE, 64, 256 ) ); else if( da >= -0.125 && da <= -0.122 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_BLUE, 64, 256 ) ); else if( da >= -0.001 && da <= 0.001 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_GREEN, 64, 256 ) ); else if( db >= -0.001 && db <= 0.001 ) plot( output_surface, a, b, ColorAverage( Color(r,g,bl), BASE_COLOR_ORANGE, 64, 256 ) ); else plot( output_surface, a, b, Color(r,g,bl) ); } } } } ii1_max_iter = _ii1_max_iter; ii2_max_iter = _ii1_max_iter; if( output ) { // actually put the changes on the screen.... PutString( output_surface, 10, 10, BASE_COLOR_WHITE, BASE_COLOR_BLACK, "Alt+TAB and select application,\nThen Press ALT+F4 to Exit. " ); } } BlotImage( surface, output_surface, 0, 0 ); { { RCOORD dam, dbm; dam = ( mx - ofsx ) * dx + xorg; dbm = ( my - ofsy ) * dy + yorg; for( a = -20; a <= 20; a++ ) { for( b = -20; b <= 20; b++ ) { RCOORD da, db; int r, g = 0, bl = 0; int direction; float v1[3]; float v2[3]; da = aspect * ( mx + a - ofsx ) * dx + xorg; db = ( my + b - ofsy ) * dy + yorg; r = 0; bl = IsInfinite2( 0, 0, da, db, &direction ); if( (direction) < 0 ) { v1[vForward] = bl * 0.05; r = ( bl ); bl = 0; } else if( bl < 0 ) { v1[vForward] = 0.5; g = 32; bl = 0; //r = 0; } else if( bl != 0 ) { v1[vForward] = bl * 0.04; //r = 0; bl = bl; } //else // r = 0; if( g == 255 ) { int a = 3; } glBegin( GL_LINES ); v2[vRight] = v1[vRight] = ( mx + a ) * 0.1; v2[vUp] = v1[vUp] = ( my + b ) * 0.1; v2[vForward] = 0; glColor4ub( r*0xFF,g,bl,255 ); glVertex3fv( v1 ); glVertex3fv( v2 ); glEnd(); //plot( output_surface, a, b, Color(r,g,bl) ); } } } } { RCOORD da, db; int r, g, bl = 0; int iter; da = aspect * ( mx - ofsx ) * dx + xorg; db = ( my - ofsy ) * dy + yorg; //iter = DrawInfinite2( output_surface, 0, 0, da, db, dx, dy, ofsx, ofsy ); iter = GLDrawInfinite2( output_surface, 0, 0, da, db, dx, dy, ofsx, ofsy ); if( 0 ) { TEXTCHAR buf[256]; snprintf( buf,256, "%d %d,%d = %g, %g", iter, mx, my, da, db ); PutString( output_surface, 10, 50, BASE_COLOR_WHITE, BASE_COLOR_BLACK, buf ); } } }