User Tag List

Results 1 to 5 of 5

Thread: rotate_trans_sprite() halts gcc compiler (MSYS, MinGW)

  1. #1
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,762
    Level
    21
    vBActivity - Bars
    Lv. Percent
    69.14%

    rotate_trans_sprite() halts gcc compiler (MSYS, MinGW)

    Calling this function:

    rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));

    ..causes the compiler to halt (Error 1).

    I checked the allegro changelog, and it is absolutely in 4.0 and later, so...what's likely causing this?

    Full function:



    Spoiler: show
    Code:
    void do_drawbitmapr(BITMAP *bmp, int *sdci, int xoffset, int yoffset)
    {
        //sdci[1]=layer
        //sdci[2]=bitmap
        //sdci[3]=sourcex
        //sdci[4]=sourcey
        //sdci[5]=sourcew
        //sdci[6]=sourceh
        //sdci[7]=destx
        //sdci[8]=desty
        //sdci[9]=destw
        //sdci[10]=desth
        //sdci[11]=rotation
        //sdci[12]=mask
        
        int bitmapIndex = sdci[2]/10000;
        int sx = sdci[3]/10000;
        int sy = sdci[4]/10000;
        int sw = sdci[5]/10000;
        int sh = sdci[6]/10000;
        int dx = sdci[7]/10000;
        int dy = sdci[8]/10000;
        int dw = sdci[9]/10000;
        int dh = sdci[10]/10000;
        float rot = sdci[11]/10000;
        bool masked = (sdci[12] != 0);
    
    	//bugfix
    	sx = vbound(sx, 0, 512);
    	sy = vbound(sy, 0, 512);
    	sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
    	sh = vbound(sh, 0, 512 - sy);
    
        
        if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
            return;
            
        bool stretched = (sw != dw || sh != dh);
        
        BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
        
        if(!sourceBitmap)
        {
            Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
            Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
            return;
        }
        
        BITMAP* subBmp = 0;
        
        if(rot != 0)
        {
            subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
            
            if(!subBmp)
            {
            }
        }
        
        
        dx = dx + xoffset;
        dy = dy + yoffset;
        
        if(stretched)
        {
            if(masked)
            {
                if(rot != 0)
                {	
    		masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
    		rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
    	    }
                else
                    masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
            }
            else
            {
                if(rot != 0)
                {
                    stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
                    rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
                }
                else
                    stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
            }
        }
        else
        {
            if(masked)
            {
                if(rot != 0)
                {
                    masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
                    rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
                }
                else
                    masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
            }
            else
            {
                if(rot != 0)
                {
                    blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
                    rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
                }
                else
                    blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
            }
        }
        
        //cleanup
        if(subBmp)
        {
            script_drawing_commands.ReleaseSubBitmap(subBmp);
        }
    }

  2. #2
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,958
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.12%
    Linker or compiler error?

    Make sure that your paths are correct and it is linking against the allegro 4.2.2fixed lib; if it is a compiler error then it's not finding the declaration perhaps... Without any actual errors I can only guess.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  3. #3
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,762
    Level
    21
    vBActivity - Bars
    Lv. Percent
    69.14%
    Quote Originally Posted by Gleeok View Post
    Linker or compiler error?

    Make sure that your paths are correct and it is linking against the allegro 4.2.2fixed lib; if it is a compiler error then it's not finding the declaration perhaps... Without any actual errors I can only guess.


    Hmm... I'll look into it. @DarkDragon set p a repo with VS2016 projects, so I may shift to using that.

    In the interim, would you mind proofing this?

    DrawSpriteEx (Revised)
    Spoiler: show
    Code:
    void do_drawbitmapexr(BITMAP *bmp, int *sdci, int xoffset, int yoffset)
    {
    	//sdci[1]=layer
    	//sdci[2]=bitmap
    	//sdci[3]=sourcex
    	//sdci[4]=sourcey
    	//sdci[5]=sourcew
    	//sdci[6]=sourceh
    	//sdci[7]=destx
    	//sdci[8]=desty
    	//sdci[9]=destw
    	//sdci[10]=desth
    	//sdci[11]=rotation
    	//scdi[12] = effect
    	//sdci[13]=mask
    
    	int bitmapIndex = sdci[2]/10000;
    	int sx = sdci[3]/10000;
    	int sy = sdci[4]/10000;
    	int sw = sdci[5]/10000;
    	int sh = sdci[6]/10000;
    	int dx = sdci[7]/10000;
    	int dy = sdci[8]/10000;
    	int dw = sdci[9]/10000;
    	int dh = sdci[10]/10000;
    	float rot = sdci[11]/10000;
    	int mode = sdci[12]/10000;
    	bool masked = (sdci[13] != 0);
    
    	//bugfix
    	sx = vbound(sx, 0, 512);
    	sy = vbound(sy, 0, 512);
    	sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
    	sh = vbound(sh, 0, 512 - sy);
    
    
    	if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
    	return;
    
    	bool stretched = (sw != dw || sh != dh);
    
    	BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
        
    	if(!sourceBitmap)
    	{
    		Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
    		Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
    		return;
    	}
        
    	BITMAP* subBmp = 0;
        
    	if(rot != 0 || mode != 0)
    	{
    		subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
            
    		if(!subBmp)
    		{
    		}
    	}
        
        
    	dx = dx + xoffset;
    	dy = dy + yoffset;
        
    	if(stretched) {
    		if(masked) {	
    			if ( rot == 0 ) { //if not rotated
    				switch(mode) {
    					case 1:
    					//transparent
    					masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
    					draw_trans_sprite(bmp, subBmp, dx, dy);
    					break;
    					
    					
    					case 2: 
    						//pivot?
    					break;
    					
    					case 0: 
    						//no effect
    					masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
    					break;
    					
    				}
    			} //end if not rotated
    			
    			if ( rot != 0 ) { //if rotated
    				switch(mode){
    					case 1: 
    						//transparent
    					break;
    					
    					case 2: 
    						//pivot?
    					break;
    					
    					case 0: 
    						//no effect.
    					masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
    					rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
    					break;
    				
    				}
    			}
    		} //end if masked
    		
    		else //not masked {
    			
    			if(rot == 0) { //no rotaion
    				
    				switch(mode){
    					
    					case 1:
    						//translucent
    					stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
    					draw_trans_sprite(bmp, subBmp, dx, dy);
    					break;
    					
    					case 2: 
    						//pivot?
    					break;
    					
    					case 0: 
    						//no effect
    						stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
    					break;
    				}
    			} //end if not rotated
    			
    			if ( rot != 0 ) { //if rotated
    				
    				switch(mode){
    					
    					case 1: 
    						//translucent
    					break;
    					
    					case 2: 
    						//pivot?
    					break;
    					
    					case 0: 
    						//no effect
    					stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
    					rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(mode));
    					break;
    				}
    			} //end if rotated
    		} //end if stretched, but not masked
    		
    	else { //not stretched
    		
    		if(masked) { //if masked, but not stretched
    			
    			if ( rot == 0 ) { //no rotation
    				switch(mode){
    					
    					case 1: 
    						//translucent
    					masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
    					draw_trans_sprite(bmp, subBmp, dx, dy);
    					break;
    					
    					case 2: 
    						//pivot?
    					break;
    					
    					case 0: 
    						//no effect
    						masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
    					break;
    				}
    			} //end no rotation
    			
    			if ( rot != 0 ) { //rotated, masked
    				switch(mode){
    					
    					case 1: 
    						//translucent
    					break;
    					
    					case 2: 
    						//pivot?
    					break;
    					
    					case 0: 
    						//no effects
    					masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
    					rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(mode));  
    					break;
    				}
    			} //end rtated, masked
    		} //end if masked
    
    		else { //not masked, and not stretched
    			
    			if(rot == 0) { //not rotated
    				switch(mode){
    					
    					case 1: 
    						//translucent
    					blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);   
    					draw_trans_sprite(bmp, subBmp, dx, dy);
    					break;
    					
    					case 2: 
    						//pivot?
    					break;
    					
    					case 0: // no effects
    					blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
    					break;
    				}
    			} //end if not rotated
    			
    			if ( rot != 0 ) { //rotated
    				switch(mode){
    					
    					case 1: 
    						//translucent
    					break;
    					
    					case 2: 
    						//pivot;
    					break;
    					
    					case 0:
    						//no effects
    					blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
    					rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(mode));
    					break;
    				}
    			} //end if rotated
    		} //end if not masked
    	} //end if not stretched
        
    	//cleanup
    	if(subBmp) {
    		script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
    	}
    }


    I pletely rewrote my approach, as you can see. Is there anything going on with this that would not be legal?

  4. #4
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,432
    Level
    24
    vBActivity - Bars
    Lv. Percent
    69.93%
    It's in 4.4, not 4.2.

  5. #5
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,762
    Level
    21
    vBActivity - Bars
    Lv. Percent
    69.14%
    Quote Originally Posted by Saffith View Post
    It's in 4.4, not 4.2.

    That is what I initially thought, but the Allegro chagelog references it in 3.9x. I'll do some more hunting, to verify.

    We do eventually need to update to 4.4 anyway, but perhaps I can integrate it somehow for the present.
    @Grayswandir has also been asking about updating to 4.4.

    Is there any chance that you could make a list of anything in 4.2 that we've modified, so that I can begin working on moving to 4.4, without blindly stumbling about, looking for patches?

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social