English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 21 July 2013, 19:44   #1
Sparticle
Registered User
 
Join Date: May 2009
Location: Leicester/U.K
Posts: 36
Background Image and Bobs!!

Hi all,

I'm tying to do a port of a simple game i made for windows to an amiga.
Its just a simple simon type of game, where you have to remember the sequence of flahing lights.

At the minute im just trying to build the framework for the game. All is going well except when I draw a bob, the background image colours show through the bobs image. If I draw the bob on its own it's displayed as i intend it to be.The bob was drawn using the same palette as the backgrounds.

Does Anyone have any ideas why this might be happening?

Thanks.
Sparticle is offline  
Old 21 July 2013, 21:11   #2
Codetapper
2 contact me: email only!

Codetapper's Avatar
 
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,164
What language are you using? It sounds like you are not blitting each bitplane or have the minterms set incorrectly. Pasting a code sample will definitely help.
Codetapper is offline  
Old 22 July 2013, 04:25   #3
Sparticle
Registered User
 
Join Date: May 2009
Location: Leicester/U.K
Posts: 36
Hi Codetrapper.
Sorry, I forget to mention that Im using mostly c wrapped up in c++ classes and using hisoft c++ for the compiler.

The code is a bit messy as its mostly snippets from various tutorials from the net.

Anyway, Thanks for your reply.

Heres the code:

GameEngine::GameEngine()
{

m_Cia = (struct CIA *) CIAAPRA;
m_NumOfColours = LORES_COLOURS;
m_Depth = 5;
m_Width = 320;
m_Height = 256;
m_RastWidth = ((m_Width)*(2));//?
m_RastHeight = ((m_Height)*(2));//?
m_PosX = 0;
m_PosY = 0;
m_Run = FALSE;
m_MousePosX = 0;
m_MousePosY = 0;

// Default colours
m_ColourTable[0]=0x000; /* Colour 0, Black */
m_ColourTable[1]=0x800; /* Colour 1, Red */
m_ColourTable[2]=0xF00; /* Colour 2, Light red */
m_ColourTable[3]=0x080; /* Colour 3, Green */
m_ColourTable[4]=0x0F0; /* Colour 4, Light green */
m_ColourTable[5]=0x008; /* Colour 5, Blue */
m_ColourTable[6]=0x00F; /* Colour 6, Light Blue */
m_ColourTable[7]=0xFFF; /* Colour 7, White */


}
//*************************************
GameEngine::~GameEngine()
{
//CleanUp();
}
//*************************************
void GameEngine::Start()
{
//*************************************
WORD Sbuffer[4*40*3]; // ?
WORD Cmask[4*40]; // ?
WORD Bline[4]; // ?
WORD *d = (WORD*)&bbfData;
struct VSprite v =
{
NULL, // Struct VSprite *NextSprite
NULL, // Struct VSprite *PrevSprite
NULL, // Struct VSprite *DrawPath
NULL, // Struct VSprite *ClearPath

0, // WORD OldY
0, // WORD OldX
0, // WORD Flags
60, // WORD Y
10, // WORD X
41, // WORD Height
4, // WORD Width
2, // WORD Depth
1, // WORD MeMask
1, // WORD HitMask
(WORD*)bbfData, // WORD *ImageData
&Bline[0], // WORD* BorderLine
&Cmask[0], // WORD* CollMask
(WORD*)&BackGround3PaletteRGB32, // WORD* SprColors
NULL, // struct Bob* VSBob
0x0019, // BYTE PlanePick
0x0000, // BYTE PlaneOnOff
NULL // VUserStuff VUserExt
};

struct Bob b =
{
SAVEBACK | OVERLAY,
&Sbuffer[0],
&Cmask[0],
NULL,NULL,
&v,
NULL,NULL,NULL
};
struct VSprite s1,s2;
struct GelsInfo gelsinfo;
struct collTable Ctable;

//WORD dx,dy,x;

gelsinfo.nextLine = NULL;
gelsinfo.lastColor = NULL;
gelsinfo.collHandler = &Ctable;
InitGels(&s1,&s2,&gelsinfo);
m_RastPort.GelsInfo = &gelsinfo;


v.VSBob = &b;
InitMasks(&v);
AddBob(&b,&m_RastPort);


UBYTE value = 0, old_value = 0;
BYTE dx=0, dy=0;
m_Run = TRUE;
LoadRGB32(&m_ViewPort,BackGround3PaletteRGB32);

MakeVPort( &m_View, &m_ViewPort );


DrawImage( &m_RastPort, &BackGround3, 0,0 );
while(m_Run)
{
old_value = value;
value = GetMouse( (UBYTE)MOUSE_PORT, &dx, &dy );



if( value != old_value )
{

if( value & LEFT_BUTTON )
SetRun(FALSE);
LoadView( m_OldView );
CleanUp();

if( value & RIGHT_BUTTON )
{
SetRun(FALSE);
LoadView( m_OldView );
CleanUp();
}
}

MrgCop( &m_View );
LoadView( &m_View );
SortGList(&m_RastPort);

DrawGList(&m_RastPort,&m_ViewPort);
WaitTOF();
}
}
//*************************************
void GameEngine::CleanUp()
{


int loop;

/* Free automatically allocated display structures: */
FreeVPortCopLists( &m_ViewPort );
FreeCprList( m_View.LOFCprList );

/* Deallocate the display memory, BitPlane for BitPlane: */
for( loop = 0; loop < m_Depth; loop++ )
if( m_BitMap.Planes[ loop ] )
FreeRaster( m_BitMap.Planes[ loop ], m_RastWidth, m_RastHeight );

/* Deallocate the ColorMap: */
if( m_ViewPort.ColorMap ) FreeColorMap( m_ViewPort.ColorMap );

/* Close the Graphics library: */

// If the GfxBase library is open, close it.
if (m_GfxBase)
{
CloseLibrary( (struct Library *)m_GfxBase);
}
if (m_IntuitionBase)
{
CloseLibrary( (struct Library *)m_IntuitionBase);
}

exit(0);

}
//*************************************
BOOL GameEngine::Initialize()
{
BOOL result = TRUE;
UWORD *pointer;
int loop;

/* Open the Intuition library: */
m_IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 0L );
if( !m_IntuitionBase )
{

printf( "Could NOT open the Intuition library!" );
result = FALSE;
}

/* Open the Graphics library: */
m_GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library", 0 );
if( !m_GfxBase )
{
printf( "Could NOT open the Graphics library!" );
result = FALSE;
}

if(result)
{
/* Save the current View, so we can restore it later: */
m_OldView = m_GfxBase->ActiView;


/* 1. Prepare the View structure, and give it a pointer to */
/* the first ViewPort: */
InitView( &m_View );
m_View.ViewPort = &m_ViewPort;


/* 2. Prepare the ViewPort structure, and set some important values: */
InitVPort( &m_ViewPort );
m_ViewPort.DWidth = m_Width; /* Set the width. */
m_ViewPort.DHeight = m_Height; /* Set the height. */
m_ViewPort.DxOffset = m_PosX; /* Set the display X offset. */
m_ViewPort.DyOffset = m_PosY; /* Set the display Y offset. */
m_ViewPort.RasInfo = &m_RasInfo; /* Give it a pointer to RasInfo. */
m_ViewPort.Modes = NULL; /* Low resolution. */


/* 3. Get a colour map, link it to the ViewPort, and prepare it: */
m_ViewPort.ColorMap = (struct ColorMap *) GetColorMap( m_NumOfColours );
if( m_ViewPort.ColorMap == NULL )
printf( "Could NOT get a ColorMap!" );

/* Get a pointer to the colour map: */
pointer = (UWORD *) m_ViewPort.ColorMap->ColorTable;

/* Set the colours: */
for( loop = 0; loop < m_NumOfColours; loop++ )
*pointer++ = m_ColourTable[ loop ];


/* 4. Prepare the BitMap: */
InitBitMap( &m_BitMap, m_Depth, m_RastHeight, m_RastWidth );

/* Allocate memory for the Raster: */
for( loop = 0; loop < m_Depth; loop++ )
{
m_BitMap.Planes[ loop ] = (PLANEPTR) AllocRaster( m_RastWidth, m_RastHeight );
if( m_BitMap.Planes[ loop ] == NULL )
printf( "Could NOT allocate enough memory for the raster!" );

/* Clear the display memory with help of the Blitter: */
BltClear( m_BitMap.Planes[ loop ], RASSIZE( m_RastWidth, m_RastHeight ), 0);
}


/* 5. Prepare the RasInfo structure: */
m_RasInfo.BitMap = &m_BitMap; /* Pointer to the BitMap structure. */
m_RasInfo.RxOffset = 0; /* The top left corner of the Raster */
m_RasInfo.RyOffset = 0; /* should be at the top left corner */
/* of the display. */
m_RasInfo.Next = NULL; /* Single playfield - only one */


/* 6. Create the display: */
MakeVPort( &m_View, &m_ViewPort );
MrgCop( &m_View );


/* 7. Prepare the RastPort, and give it a pointer to the BitMap. */
InitRastPort( &m_RastPort );
m_RastPort.BitMap = &m_BitMap;

}
else
{
CleanUp();
}
return result;


}
Sparticle is offline  
Old 29 July 2013, 11:22   #4
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,650
Quote:
Originally Posted by Sparticle View Post
0x0019, // BYTE PlanePick
0x0000, // BYTE PlaneOnOff
I have never used the graphics.library GELs system myself, but are you sure that the PlanePick/PlaneOnOff fields are correct? As far as I understand it will only draw plane 0, 3 and 4 and fill the rest with zero?
phx is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitter Objects (bobs) Lonewolf10 Coders. Tutorials 3 22 February 2013 22:24
FS: A4000/30 plus bits and bobs Interceptor MarketPlace 0 22 October 2011 22:52
FS: Various bits n bobs jujasi MarketPlace 0 12 July 2009 19:13
Workbench background image? Fingerlickin_B project.ClassicWB 6 07 October 2008 15:14
Bobs Garden Big-Byte Amiga scene 7 26 October 2002 11:24

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 14:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.08119 seconds with 15 queries