Example #1
0
//this is a setter function to change the color scheme
//it also handles all the regeneration and refreshing
void MandelbrotViewer::setColorScheme(int newScheme) {
    scheme = newScheme;
    initPalette();
    changeColor();
    updateMandelbrot();
    refreshWindow();
}
Example #2
0
int main(void) {
  int errorCode;
  FrameworkWindow *projectWindow;

  if(!initGlobalScreen(&newScreen)) {
    errorCode = -1;
    goto error;
  }

  initPalette(getGlobalViewPort());

  projectWindow = newProjectWindow();
  if(!projectWindow) {
    errorCode = -2;
    goto error_closeScreen;
  }
    
  runMainLoop(projectWindow);

closeScreen:
  closeGlobalScreen();
done:
  return 0;

error_closeScreen:
  closeGlobalScreen();
error:
  return errorCode;
}
Example #3
0
void MandelbrotViewer::incIterations() {
    //if iterations is in the hundreds, add 100
    //if iterations is in the thousands, add 1000, etc.
    int magnitude = (int) log10(max_iter);
    unsigned int inc = pow(10, magnitude);
    max_iter += inc;
    initPalette();
}
Example #4
0
/**
 * Initialize graphics device.
 *
 * @see deinit_video()
 */
int GfxMgr::initVideo() {
	if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))
		initPalette(vgaPalette, 256, 8);
	else if (_vm->_renderMode == Common::kRenderEGA)
		initPalette(egaPalette);
	else
		initPalette(newPalette);

	if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
		return errNotEnoughMemory;

	gfxSetPalette();

	setCursor(_vm->_renderMode == Common::kRenderAmiga);

	return errOK;
}
Example #5
0
void MandelbrotViewer::lockColor() {
    if (color_locked) {
        color_locked = false;
        initPalette();
        changeColor();
        updateMandelbrot();
        refreshWindow();
    } else {
        color_locked = true;
    }
}
Example #6
0
void MandelbrotViewer::decIterations() {
    //if iterations is in the hundreds, subtract 100
    //if iterations is in the thousands, subtract 1000, etc.
    if (max_iter > 100) {
        int magnitude = (int) log10(max_iter);
        unsigned int dec = pow(10, magnitude);
        if (dec == max_iter) dec /= 10;
        max_iter -= dec;
        initPalette();
    }
}
Example #7
0
//Gets AGIPAL Data
void GfxMgr::setAGIPal(int p0) {
	//If 0 from savefile, do not use
	if (p0 == 0)
		return;

	char filename[15];
	sprintf(filename, "pal.%d", p0);

	Common::File agipal;
	if (!agipal.open(filename)) {
		warning("Couldn't open AGIPAL palette file '%s'. Not changing palette", filename);
		return; // Needed at least by Naturette 3 which uses AGIPAL but provides no palette files
	}

	//Chunk0 holds colors 0-7
	agipal.read(&_agipalPalette[0], 24);

	//Chunk1 is the same as the chunk0

	//Chunk2 chunk holds colors 8-15
	agipal.seek(24, SEEK_CUR);
	agipal.read(&_agipalPalette[24], 24);

	//Chunk3 is the same as the chunk2

	//Chunks4-7 are duplicates of chunks0-3

	if (agipal.eos() || agipal.err()) {
		warning("Couldn't read AGIPAL palette from '%s'. Not changing palette", filename);
		return;
	}

	// Use only the lowest 6 bits of each color component (Red, Green and Blue)
	// because VGA used only 6 bits per color component (i.e. VGA had 18-bit colors).
	// This should now be identical to the original AGIPAL-hack's behavior.
	bool validVgaPalette = true;
	for (int i = 0; i < 16 * 3; i++) {
		if (_agipalPalette[i] >= (1 << 6)) {
			_agipalPalette[i] &= 0x3F; // Leave only the lowest 6 bits of each color component
			validVgaPalette = false;
		}
	}

	if (!validVgaPalette)
		warning("Invalid AGIPAL palette (Over 6 bits per color component) in '%s'. Using only the lowest 6 bits per color component", filename);

	_agipalFileNum = p0;

	initPalette(_agipalPalette);
	gfxSetPalette();

	debug(1, "Using AGIPAL palette from '%s'", filename);
}
Example #8
0
/**
 * Initialize graphics device.
 *
 * @see deinit_video()
 */
int GfxMgr::initVideo() {
	if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))
		initPalette(vgaPalette, 256, 8);
	else if (_vm->_renderMode == Common::kRenderEGA)
		initPalette(egaPalette);
	else if (_vm->_renderMode == Common::kRenderAmiga) {
		if (!ConfMan.getBool("altamigapalette")) {
			// Set the correct Amiga palette
			if (_vm->getVersion() < 0x2936)
				// TODO: This palette isn't used for Apple IIGS games yet, as
				// we don't set a separate render mode for them yet
				initPalette(amigaAgiPaletteV1, 16, 4);
			else if (_vm->getVersion() == 0x2936)
				initPalette(amigaAgiPaletteV2, 16, 4);
			else if (_vm->getVersion() > 0x2936)
				initPalette(amigaAgiPaletteV3, 16, 4);
		} else
			// Set the old common alternative Amiga palette
			initPalette(altAmigaPalette);
	} else
		error("initVideo: Unhandled render mode");

	if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
		return errNotEnoughMemory;

	gfxSetPalette();

	setCursor(_vm->_renderMode == Common::kRenderAmiga);

	return errOK;
}
Example #9
0
void R_init_grDevices(DllInfo *dll)
{
    initPalette();
    R_registerRoutines(dll, NULL, CallEntries, NULL, ExtEntries);
    R_useDynamicSymbols(dll, FALSE);
    R_forceSymbols(dll, TRUE);

#ifdef HAVE_AQUA
/* R.app will run event loop, so if we are running under that we don't
   need to run one here */
    if(useaqua) setup_RdotApp();
#endif
}
Example #10
0
//resets the mandelbrot to generate the starting area
void MandelbrotViewer::resetMandelbrot() {
    area.top = -1;
    area.height = 2;
    area_inc = area.height/res_height;
    area.width = area_inc * res_width;
    area.left = -0.5 - area.width/2.0;

    max_iter = 100;
    last_max_iter = 100;
    color_multiple = 1;
    rotation = 0;
    color_locked = false;
    initPalette();
}
Example #11
0
/**
 * Initialize graphics device.
 *
 * @see deinit_video()
 */
int GfxMgr::initVideo() {
	// Set up palettes
	initPalette(_paletteTextMode, PALETTE_EGA);

	switch (_vm->_renderMode) {
	case Common::kRenderEGA:
		initPalette(_paletteGfxMode, PALETTE_EGA);
		break;
	case Common::kRenderCGA:
		initPalette(_paletteGfxMode, PALETTE_CGA, 4, 8);
		break;
	case Common::kRenderVGA:
		initPalette(_paletteGfxMode, PALETTE_VGA, 256, 8);
		break;
	case Common::kRenderAmiga:
		if (!ConfMan.getBool("altamigapalette")) {
			// Set the correct Amiga palette depending on AGI interpreter version
			if (_vm->getVersion() < 0x2936)
				initPalette(_paletteGfxMode, PALETTE_AMIGA_V1, 16, 4);
			else if (_vm->getVersion() == 0x2936)
				initPalette(_paletteGfxMode, PALETTE_AMIGA_V2, 16, 4);
			else if (_vm->getVersion() > 0x2936)
				initPalette(_paletteGfxMode, PALETTE_AMIGA_V3, 16, 4);
		} else {
			// Set the old common alternative Amiga palette
			initPalette(_paletteGfxMode, PALETTE_AMIGA_ALT);
		}
		break;
	case Common::kRenderApple2GS:
		switch (_vm->getGameID()) {
		case GID_SQ1:
			// Special one, only used for Space Quest 1 on Apple IIgs. Is the same as Amiga v1 palette
			initPalette(_paletteGfxMode, PALETTE_APPLE_II_GS_SQ1, 16, 4);
			break;
		default:
			// Regular "standard" Apple IIgs palette, used by everything else
			initPalette(_paletteGfxMode, PALETTE_APPLE_II_GS, 16, 4);
			break;
		}
		break;
	case Common::kRenderAtariST:
		initPalette(_paletteGfxMode, PALETTE_ATARI_ST, 16, 3);
		break;
	case Common::kRenderMacintosh:
		switch (_vm->getGameID()) {
		case GID_KQ3:
		case GID_PQ1:
			initPaletteCLUT(_paletteGfxMode, PALETTE_MACINTOSH_CLUT, 16);
			break;
		case GID_GOLDRUSH:
			// We use the common KQ3/PQ1 palette at the moment.
			// It seems the Gold Rush palette, that came with the game is quite ugly.
			initPaletteCLUT(_paletteGfxMode, PALETTE_MACINTOSH_CLUT, 16);
			break;
		case GID_SQ2:
			initPaletteCLUT(_paletteGfxMode, PALETTE_MACINTOSH_CLUT3, 16);
			break;
		default:
			initPaletteCLUT(_paletteGfxMode, PALETTE_MACINTOSH_CLUT3, 16);
			break;
		}
		break;
	default:
		error("initVideo: unsupported render mode");
		break;
	}

	// set up mouse cursors
	switch (_vm->_renderMode) {
	case Common::kRenderEGA:
	case Common::kRenderCGA:
	case Common::kRenderVGA:
		initMouseCursor(&_mouseCursor, MOUSECURSOR_SCI, 11, 16, 1, 1);
		initMouseCursor(&_mouseCursorBusy, MOUSECURSOR_SCI_BUSY, 15, 16, 7, 8);
		break;
	case Common::kRenderAmiga:
		initMouseCursor(&_mouseCursor, MOUSECURSOR_AMIGA, 8, 11, 1, 1);
		initMouseCursor(&_mouseCursorBusy, MOUSECURSOR_AMIGA_BUSY, 13, 16, 7, 8);
		break;
	case Common::kRenderApple2GS:
		// had no special busy mouse cursor
		initMouseCursor(&_mouseCursor, MOUSECURSOR_APPLE_II_GS, 9, 11, 1, 1);
		initMouseCursor(&_mouseCursorBusy, MOUSECURSOR_SCI_BUSY, 15, 16, 7, 8);
		break;
	case Common::kRenderAtariST:
		initMouseCursor(&_mouseCursor, MOUSECURSOR_ATARI_ST, 11, 16, 1, 1);
		initMouseCursor(&_mouseCursorBusy, MOUSECURSOR_SCI_BUSY, 15, 16, 7, 8);
		break;
	case Common::kRenderMacintosh:
		// It looks like Atari ST + Macintosh used the same standard mouse cursor
		// TODO: Verify by checking actual hardware
		initMouseCursor(&_mouseCursor, MOUSECURSOR_ATARI_ST, 11, 16, 1, 1);
		initMouseCursor(&_mouseCursorBusy, MOUSECURSOR_MACINTOSH_BUSY, 10, 14, 7, 8);
		break;
	default:
		error("initVideo: unsupported render mode");
		break;
	}

	_pixels = SCRIPT_WIDTH * SCRIPT_HEIGHT;
	_visualScreen = (byte *)calloc(_pixels, 1);
	_priorityScreen = (byte *)calloc(_pixels, 1);
	_activeScreen = _visualScreen;
	//_activeScreen = _priorityScreen;

	_displayPixels = DISPLAY_WIDTH * DISPLAY_HEIGHT;
	_displayScreen = (byte *)calloc(_displayPixels, 1);

	initGraphics(DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_WIDTH > 320);

	setPalette(true); // set gfx-mode palette

	// set up mouse cursor palette
	CursorMan.replaceCursorPalette(MOUSECURSOR_PALETTE, 1, ARRAYSIZE(MOUSECURSOR_PALETTE) / 3);
	setMouseCursor();

	return errOK;
}