/*

	gfx.c - graphics controlling routines

*/


void setBitMapPtrs(void)
{
    /* to be called whenever bitmaps are allocated/moved */

	/* Bitplane 1 (the screen copy) will be completely set,
	   so that the colours used for black and white will be
	   (binary) 10 (2 dec) and 11 (3 dec). This way we still
	   have the real background colour (colour 0) for the border.
	*/
    bwBitMap.Planes[0] = z80Mem + SP_SCREENOFFSET;
    bwBitMap.Planes[1] = z80Mem + SP_SCRCOPYOFFSET;

}   /* end of setBplAddrs */



void getRasters(void)
{
    /* depends on allocMemory */

    InitBitMap(&bwBitMap, SPSCR_BWDEPTH, SPSCR_WIDTH, SPSCR_HEIGHT);
    setBitMapPtrs();

    InitRastPort(&bwRPort);
    bwRPort.BitMap = &bwBitMap;

}   /* End of getRasters */



void setDisplayMode(char select)
{
    /* depends on getRasters and getCopLists */

    UWORD col = 0;
    struct UCopList *copPtr = NULL;

    switch (select) {
    case 'B':
	col = bwModeColors[0];
	copPtr = bwCopList;
	/* set bitplane 2 */
	SetWrMsk(&bwRPort, 2); /* affect bitplane 1 only */
	SetRast(&bwRPort, 2);	  /* set bitplane 1 */
	SetWrMsk(&bwRPort, 1); /* affect bitplane 0 only */
	break;
    }

    if (copPtr != NULL) {
	Forbid();
	screenVP->UCopIns = copPtr;
	Permit();
    }
	/* Set colour 0 of intuition screen, so you can't see the
	   edge where the speccy screen begins. */
    SetRGB4CM(screenVP->ColorMap, 0, (col & 0x0f00) >> 8,
	(col & 0x00f0) >> 4, col & 0x000f );

    MakeScreen(emulScreen);
    RethinkDisplay();

}   /* End of setDisplayMode */

