コード例 #1
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_dolinesegment(Lcd *x, Symbol *s, short argc, Atom *argv)
{
	PaletteHandle pH;
	RGBColor fColor;
	GrafPort *gp;
	RgnHandle cur;
	long fromx,fromy,tox,toy,color;
	short save;
	
	EnterCallback();
	
	fromx = argv->a_w.w_long;
	fromy = (argv+1)->a_w.w_long;
	tox = (argv+2)->a_w.w_long;
	toy = (argv+3)->a_w.w_long;
	color = (argv+4)->a_w.w_long;
	
#ifdef debug
	post("Segment");
#endif
	gp = patcher_setport(x->lcd_box.b_patcher);

	if (gp) {
		if (!box_nodraw((void *)x)) {
			// save=lockout_set(1);
			MoveTo(x->lcd_box.b_rect.left+1+(short)fromx,x->lcd_box.b_rect.top+1+(short)fromy);
			x->lcd_where.h = (short)fromx;
			x->lcd_where.v = (short)fromy;
			
			if (color)
				x->lcd_pIndex = (short)color & (numPaletteColors-1);

			cur = NewRgn();
			GetClip(cur);
			SetClip(x->lcd_region);

			setUpPalette(x,&fColor,&pH);

		//	LCD_MoveTo(x,(long)(x->lcd_where.h),(long)(x->lcd_where.v));
			
			LineTo(x->lcd_box.b_rect.left+1+(short)tox,x->lcd_box.b_rect.top+1+(short)toy);
			x->lcd_where.h = (short)tox;
			x->lcd_where.v = (short)toy;

			restorePalette(x,&fColor,&pH);
			SetClip(cur);
			DisposeRgn(cur);
			// lockout_set(save);

		}
		SetPort(gp);
	}
	ExitCallback();
}
コード例 #2
0
ファイル: VGAdriver.cpp プロジェクト: levex/LevOS
void VGA_deinit()
{
	memcpyTF((char*)VGA_address, vidmem, 256*1024);
	write_registers(mode_80_25_text);
	restorePalette(savedPalette);
	_isVGA = false;
	DebugReset();
	//restorefont((char*)g_8x8_font);
	//write_font(g_8x8_font, 8);
	//memset((char*)0xB8000, 0, 64*1024);
	DebugClrScr(0x17);
}
コード例 #3
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_doframeOval(Lcd *x, Symbol *s, short argc, Atom *argv)
{
	long left, top, right, bottom, color;
	PaletteHandle pH;
	RGBColor fColor;
	GrafPort *gp;
	RgnHandle cur;
	Rect	 b,r;
	
	EnterCallback();
	
	// I'm suspicious of (argv++)->thing in Code Warrior
	left = argv->a_w.w_long;
	top = (argv+1)->a_w.w_long;
	right = (argv+2)->a_w.w_long;
	bottom = (argv+3)->a_w.w_long;
	color = (argv+4)->a_w.w_long;
#ifdef debug
	post("frameOval");
#endif
	gp = patcher_setport(x->lcd_box.b_patcher);

	if (gp) {
		if (!box_nodraw((void *)x)) {

			if (color)  // sde 11/1
				x->lcd_pIndex = (short)color & (numPaletteColors-1);

			cur = NewRgn();
			GetClip(cur);
			SetClip(x->lcd_region);
			setUpPalette(x,&fColor,&pH);
			
			r = x->lcd_box.b_rect;
			b.left = r.left + (short)left;
			b.top  = r.top + (short)top;
			b.right = r.left + (short)right;
			b.bottom = r.top + (short)bottom;
			FrameOval(&b);

			restorePalette(x,&fColor,&pH);
			SetClip(cur);
			DisposeRgn(cur);
		}
		SetPort(gp);
	}
	ExitCallback();
}
コード例 #4
0
ファイル: gui_hof.cpp プロジェクト: CatalystG/scummvm
int GUI_HoF::loadMenu(Button *caller) {
	updateSaveFileList(_vm->_targetName);

	if (!_vm->_menuDirectlyToLoad) {
		updateMenuButton(caller);
		restorePage1(_vm->_screenBuffer);
		backUpPage1(_vm->_screenBuffer);
	}

	_savegameOffset = 0;
	setupSavegameNames(_loadMenu, 5);
	initMenu(_loadMenu);
	_isLoadMenu = true;
	_noLoadProcess = false;
	_vm->_gameToLoad = -1;
	updateAllMenuButtons();

	_screen->updateScreen();
	while (_isLoadMenu) {
		processHighlights(_loadMenu);
		getInput();
	}

	if (_noLoadProcess) {
		if (!_vm->_menuDirectlyToLoad) {
			restorePage1(_vm->_screenBuffer);
			backUpPage1(_vm->_screenBuffer);
			initMenu(*_currentMenu);
			updateAllMenuButtons();
		}
	} else if (_vm->_gameToLoad >= 0) {
		restorePage1(_vm->_screenBuffer);
		restorePalette();
		_vm->loadGameStateCheck(_vm->_gameToLoad);
		if (_vm->_gameToLoad == 0) {
			_restartGame = true;
			for (int i = 0; i < 23; ++i)
				_vm->resetCauldronStateTable(i);
			_vm->runStartScript(1, 1);
		}
		_displayMenu = false;
		_loadedSave = true;
	}

	return 0;
}
コード例 #5
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_doLineTo(Lcd *x, Symbol *s, short argc, Atom *argv)
{
	PaletteHandle pH;
	RGBColor fColor;
	GrafPort *gp;
	RgnHandle cur;
	long deltaX, deltaY;
	
	EnterCallback();
	deltaX = argv->a_w.w_long;
	deltaY = (argv+1)->a_w.w_long;
#ifdef debug
	post("LineTo");
#endif
	gp = patcher_setport(x->lcd_box.b_patcher);

	if (gp) {
		if (!box_nodraw((void *)x)) {
			cur = NewRgn();
			GetClip(cur);
			SetClip(x->lcd_region);
			setUpPalette(x,&fColor,&pH);

			LCD_MoveTo(x,(long)(x->lcd_where.h),(long)(x->lcd_where.v));
			LineTo(x->lcd_box.b_rect.left+1+(short)deltaX,x->lcd_box.b_rect.top+1+(short)deltaY);
			x->lcd_where.h = (short)deltaX;
			x->lcd_where.v = (short)deltaY;

			restorePalette(x,&fColor,&pH);
			SetClip(cur);
			DisposeRgn(cur);
		}
		SetPort(gp);
	}
	ExitCallback();
}
コード例 #6
0
Font::Font (const char* fileName){

	File* file;
	//unsigned char* blank;
	int fileSize;
	int count, size;
	unsigned short width, height;
	// Load font from a font file

	try {

		file = new File(fileName, false);

	} catch (int e) {
		#ifdef CASIO
			casioQuit(fileName);
		#endif
		throw e;

	}

	fileSize = file->getSize();

	nCharacters = 128;


	file->seek(20, true);
	lineHeight = file->loadChar() << 1;


	// Create blank character data

	//blank = new unsigned char[3];
	//memset(blank, 0, 3);
	// Load characters
	addobj(0,&ramid);
	for (count = 0; count < 128;++count){
		//characters[count].palette=paletteF;
		if (file->tell() >= fileSize) {
			nCharacters = count;
			break;
		}
		size = file->loadShort();
		if (size > 4) {
			unsigned char* pixels=(unsigned char *)alloca(size);
			file->loadRLE(size,pixels);
			width = pixels[0];
			width |= pixels[1] << 8;
			height = pixels[2];
			height |= pixels[3] << 8;
			if ((size - 4) >= (width * height)){
				//characters[count] = createSurface(pixels + 4, width, height);
				characters[count].pix=(unsigned char *)objs[ramid].ptr+objs[ramid].size;
				resizeobj(ramid,objs[ramid].size+(width*height));
				memcpy(characters[count].pix,pixels+4,width*height);
				characters[count].w=width;
				characters[count].h=height;
			}else{
				//characters[count] = createSurface(blank, 3, 1);
				characters[count].w=3;
				characters[count].h=1;
				characters[count].pix=(unsigned char *)blankFont;
			}
			//delete[] pixels;
		}else{
			//characters[count] = createSurface(blank, 3, 1);
			characters[count].w=3;
			characters[count].h=1;
			characters[count].pix=(unsigned char *)blankFont;
		}

		//SDL_SetColorKey(characters[count], SDL_SRCCOLORKEY, 0);
		characters[count].flags=miniS_COLKEY;
		characters[count].colkey=0;
	}
	//delete[] blank;
	delete file;
	// Create ASCII->font map
	for (count = 0; count < 33; count++) map[count] = 0;
	map[33] = 107; // !
	map[34] = 116; // "
	map[35] = 0; // #
	map[36] = 63; // $
	map[37] = 0; // %
	map[38] = 0; // &
	map[39] = 115; // '
	map[40] = 111; // (
	map[41] = 112; // )
	map[42] = 0; // *
	map[43] = 105; // +
	map[44] = 101; // ,
	map[45] = 104; // -
	map[46] = 102; // .
	map[47] = 108; // /
	for (count = 48; count < 58; count++) map[count] = count + 5;  // Numbers
	map[58] = 114; // :
	map[59] = 113; // ;
	map[60] = 0; // <
	map[61] = 106; // =
	map[62] = 0; // >
	map[63] = 103; // ?
	map[64] = 0; // @
	for (count = 65; count < 91; count++) map[count] = count - 38; // Upper-case letters
	for (; count < 97; count++) map[count] = 0;
	for (; count < 123; count++) map[count] = count - 96; // Lower-case letters
	for (; count < 128; count++) map[count] = 0;

	for (count = 0; count < 128; count++) {

		if (map[count] >= nCharacters) map[count] = 0;

	}
	restorePalette();

}
コード例 #7
0
/**
 * Load a font from a .000 file.
 *
 * @param bonus whether to use FONTS.000 or BONUS.000
 */
Font::Font (bool bonus) {

	File* file;
	//unsigned char* pixels;
	int fileSize;
	int count, width, height;

	// Load font from FONTS.000 or BONUS.000

	try {

		file = new File(bonus? F_BONUS: F_FONTS, false);

	} catch (int e) {

		throw e;

	}


	fileSize = file->getSize();

	nCharacters = file->loadShort(256);

	if (bonus) {

		count = file->loadShort();
		nCharacters -= count;

		// Skip sprites

		for (; count > 0; count--) {

			file->seek(4, false);

			width = file->loadShort();
			if (width == 0xFFFF) width = 0;

			file->seek((width << 2) + file->loadShort(), false);

		}

	}

	// Load characters
	addobj(0,&ramid);
	for (count = 0; count < nCharacters; count++) {

		if (file->tell() >= fileSize) {

			nCharacters = count;

			break;

		}

		width = file->loadShort(SW);
		height = file->loadShort(SH);

		if (bonus) width = (width + 3) & ~3;
		else width <<= 2;

		file->seek(4, false);
		unsigned char * pixels=(unsigned char *)objs[ramid].ptr+objs[ramid].size;
		resizeobj(ramid,objs[ramid].size+(width*height));
		file->loadPixels(width * height,pixels);

		//characters[count] = createSurface(pixels, width, height);
		characters[count].w=width;
		characters[count].h=height;
		characters[count].pix=pixels;
		//SDL_SetColorKey(characters[count], SDL_SRCCOLORKEY, 254);
		characters[count].colkey=254;
		characters[count].flags=miniS_COLKEY;
		//characters[count].palette=paletteF;
		//delete[] pixels;
	}
	delete file;
	lineHeight = characters[0].h;
	// Create blank character data
	//pixels = new unsigned char[3];
	//memset(pixels, 254, 3);
	//characters[nCharacters] = createSurface(pixels, 3, 1);
	characters[nCharacters].w=3;
	characters[nCharacters].h=1;
	characters[nCharacters].pix=(unsigned char *)blankFont;
	//SDL_SetColorKey(characters[nCharacters], SDL_SRCCOLORKEY, 254);
	characters[nCharacters].colkey=0;
	characters[nCharacters].flags=0;//miniS_COLKEY;
	//characters[nCharacters].palette=paletteF;
	//delete[] pixels;
	// Create ASCII->font map
	count = 0;
	if (bonus) {
		for (; count < 42; count++) map[count] = nCharacters;
		map[count++] = 37; // *
		for (; count < 46; count++) map[count] = nCharacters;
		map[count++] = 39; // .
		map[count++] = 38; // /
		for (; count < 59; count++) map[count] = count - 22; // Numbers and :

	} else {

		for (; count < 37; count++) map[count] = nCharacters;
		map[count++] = 36; // %
		for (; count < 48; count++) map[count] = nCharacters;
		for (; count < 58; count++) map[count] = count - 22; // Numbers

	}

	for (; count < 65; count++) map[count] = nCharacters;
	for (; count < 91; count++) map[count] = count - 65; // Upper-case letters
	for (; count < 97; count++) map[count] = nCharacters;
	for (; count < 123; count++) map[count] = count - 97; // Lower-case letters
	for (; count < 128; count++) map[count] = nCharacters;

	nCharacters++;

	for (count = 0; count < 128; count++) {

		if (map[count] >= nCharacters) map[count] = 0;

	}

	restorePalette();

}
コード例 #8
0
/**
 * Create a font from the panel pixel data.
 *
 * @param pixels Panel pixel data
 * @param big Whether to use the small or the big font
 */
Font::Font (unsigned char* pixels, bool big) {

	//unsigned char* chrPixels;
	int count, y;

	if (big) lineHeight = 8;
	else lineHeight = 7;

	//chrPixels =(unsigned char *)alloca(8*lineHeight);//new unsigned char[8 * lineHeight];
	addobj(40*8*lineHeight,&ramid);
	for (count = 0; count < 40; count++) {

		for (y = 0; y < lineHeight; y++)
			memcpy(objs[ramid].ptr + (y * 8)+(count*8*lineHeight), pixels + (count * 8) + (y * SW), 8);

		//characters[count] = createSurface(chrPixels, 8, lineHeight);
		characters[count].w=8;
		characters[count].h=lineHeight;
		characters[count].pix=(unsigned char*)objs[ramid].ptr+(count*8*lineHeight);
		//characters[count].palette=paletteF;
		if (big){
			//SDL_SetColorKey(characters[count], SDL_SRCCOLORKEY, 31);
			characters[count].flags=miniS_COLKEY;
			characters[count].colkey=31;
		}else{
			characters[count].flags=0;
		}

	}

	nCharacters= 40;

	//delete[] chrPixels;


	// Create ASCII->font map

	if (big) {

		// Goes " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:."

		for (count = 0; count < 45; count++) map[count] = 0;
		map[count++] = 37;
		map[count++] = 39;
		for (; count < 48; count++) map[count] = 0;
		for (; count < 58; count++) map[count] = count - 47; // Numbers
		map[count++] = 38;
		for (; count < 65; count++) map[count] = 0;
		for (; count < 91; count++) map[count] = count - 54; // Upper-case letters
		for (; count < 97; count++) map[count] = 0;
		for (; count < 123; count++) map[count] = count - 86; // Lower-case letters
		for (; count < 128; count++) map[count] = 0;

	} else {

		// Goes " 0123456789oo" (where oo = infinity)
		// Use :; to represent the infinity symbol

		for (count = 0; count < 48; count++) map[count] = 0;
		for (; count < 60; count++) map[count] = count - 47; // Numbers and :;
		for (; count < 128; count++) map[count] = 0;

	}

	restorePalette();

}
コード例 #9
0
ファイル: gui_hof.cpp プロジェクト: CatalystG/scummvm
int GUI_HoF::optionsButton(Button *button) {
	PauseTimer pause(*_vm->_timer);

	_restartGame = false;
	_reloadTemporarySave = false;

	updateButton(&_vm->_inventoryButtons[0]);

	if (!_screen->isMouseVisible() && button)
		return 0;

	_vm->showMessage(0, 0xCF);

	if (_vm->_mouseState < -1) {
		_vm->_mouseState = -1;
		_screen->setMouseCursor(1, 1, _vm->getShapePtr(0));
		return 0;
	}

	int oldHandItem = _vm->_itemInHand;
	_screen->setMouseCursor(0, 0, _vm->getShapePtr(0));
	_vm->displayInvWsaLastFrame();
	_displayMenu = true;

	for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) {
		_menuButtons[i].data0Val1 = _menuButtons[i].data1Val1 = _menuButtons[i].data2Val1 = 4;
		_menuButtons[i].data0Callback = _redrawShadedButtonFunctor;
		_menuButtons[i].data1Callback = _menuButtons[i].data2Callback = _redrawButtonFunctor;
	}

	initMenuLayout(_mainMenu);
	initMenuLayout(_gameOptions);
	initMenuLayout(_audioOptions);
	initMenuLayout(_choiceMenu);
	_loadMenu.numberOfItems = 6;
	initMenuLayout(_loadMenu);
	initMenuLayout(_saveMenu);
	initMenuLayout(_savenameMenu);
	initMenuLayout(_deathMenu);

	_currentMenu = &_mainMenu;

	if (_vm->_menuDirectlyToLoad) {
		backUpPage1(_vm->_screenBuffer);
		setupPalette();

		_loadedSave = false;

		loadMenu(0);

		if (_loadedSave) {
			if (_restartGame)
				_vm->_itemInHand = kItemNone;
		} else {
			restorePage1(_vm->_screenBuffer);
			restorePalette();
		}

		resetState(-1);
		_vm->_menuDirectlyToLoad = false;
		return 0;
	}

	if (!button) {
		_currentMenu = &_deathMenu;
		_isDeathMenu = true;
	} else {
		_isDeathMenu = false;
	}

	backUpPage1(_vm->_screenBuffer);
	setupPalette();
	initMenu(*_currentMenu);
	_madeSave = false;
	_loadedSave = false;
	updateAllMenuButtons();

	if (_isDeathMenu) {
		while (!_screen->isMouseVisible())
			_screen->showMouse();
	}

	while (_displayMenu) {
		processHighlights(*_currentMenu);
		getInput();
	}

	if (_vm->_runFlag && !_loadedSave && !_madeSave) {
		restorePalette();
		restorePage1(_vm->_screenBuffer);
	}

	if (_vm->_runFlag)
		updateMenuButton(&_vm->_inventoryButtons[0]);

	resetState(oldHandItem);

	if (!_loadedSave && _reloadTemporarySave) {
		_vm->_unkSceneScreenFlag1 = true;
		_vm->loadGameStateCheck(999);
		//_vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(999));
		_vm->_unkSceneScreenFlag1 = false;
	}

	return 0;
}
コード例 #10
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_drawTxt(Lcd *x, char *stng)     /* drawn in response to update event */
{
	GrafPort *gp;
	short		chars;
	Rect	r,area;
	PaletteHandle pH;
	RGBColor fColor;
	RgnHandle cur;
	short		font,size;
	
	gp = patcher_setport(x->lcd_box.b_patcher);
	if (gp) {
		font = gp->txFont;
		size = gp->txSize;
		r = x->lcd_box.b_rect;
		if (x->f_width == -1) { /* window not visible before */
			if (!x->font && !x->f_size) {
				x->font = font;
				x->f_size = size;
			}
			LCD_calcfont(x);
			LCD_resize(x);
		}
		TextFont(x->font);
		TextSize(x->f_size);

		if ((x->lcd_row+1)<=x->rows) {
			if (!box_nodraw((void *)x)) {
				/* chars = x->cols-x->lcd_col;  DDZ removed this stuff */
				if (/* chars > 0 */ 1) {
#ifdef never
					MoveTo(	(x->lcd_col*x->f_width)+r.left+BORDER_WIDTH,
							(x->lcd_row+1)*x->f_height+(x->lcd_row)*x->f_lineSpace+r.top-x->f_descent);

					/* erase area where we will write */
					area.top = (x->lcd_row*x->f_height)+r.top+BORDER_HEIGHT;
					area.bottom = ((x->lcd_row+1)*x->f_height)+r.top+BORDER_HEIGHT;
					area.left = (x->lcd_col*x->f_width)+r.left+BORDER_WIDTH;
					area.right = ((x->lcd_col+chars)*x->f_width)+r.left+BORDER_WIDTH;
#else
					MoveTo(x->lcd_where.h+r.left+BORDER_WIDTH,x->lcd_where.v+r.top);
#endif
					/* chars = MIN(chars,(short)strlen(stng)); */
					chars = strlen(stng);  /* DDZ just made it draw any string */
					
					cur = NewRgn();
					GetClip(cur);
					SetClip(x->lcd_region);
#ifdef never
					EraseRect(&area);
#endif
					setUpPalette(x,&fColor,&pH);

					DrawText(stng,0,chars);
					x->lcd_where.h += TextWidth(stng,0,chars);
					restorePalette(x,&fColor,&pH);
					SetClip(cur);
					DisposeRgn(cur);
					x->lcd_col += chars;		/* advance cursor */
					if (x->lcd_col > x->cols-1 )
						x->lcd_col--;			/* make it stick to last col */
				}
			}
		}
		TextFont(font);
		TextSize(size);

		SetPort(gp);
	}
}
コード例 #11
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_doreson(Lcd *x, Symbol *s, short argc, Atom *argv)
{
	short i,x1,y1,y2,height,width;
	double	freq,ampl,band;
	Rect	r;
	PaletteHandle pH;
	RGBColor fColor;
	GrafPort *gp;
	RgnHandle cur;
	Rect	 b;
	double xscale;
	double bscale;
	double yscale;				
	
	EnterCallback();

	if((argc%3)!=0)
	{
		post("bad number of resonance parameters %d", argc);
	} else {
		gp = patcher_setport(x->lcd_box.b_patcher);

		if (gp) {
			if (!box_nodraw((void *)x)) {
				cur = NewRgn();
				GetClip(cur);
				SetClip(x->lcd_region);
				setUpPalette(x,&fColor,&pH);
				
				r = x->lcd_box.b_rect;
				width	= r.right-r.left;
				height	= r.bottom-r.top;
				xscale=width/(x->reson_sampleRate);
				bscale = (0.1*height);
				yscale = height/x->reson_spectScale;
				for (i=0;i<argc;i++)
				{
					freq = (double)argv[i].a_w.w_float;
					ampl =argv[++i].a_w.w_float;
					if(ampl<0.0f)
						ampl = -ampl;
					ampl = 20.0*log10(ampl);
					band = (double)argv[++i].a_w.w_float;
					if(freq>0.0 && freq<(x->reson_sampleRate)	&& band>0.0)
					{
						x1 = (freq*xscale);
						{
							float ydisp = ampl*yscale;
							if(ydisp>(r.bottom-r.top))
								y1 = r.bottom -r. top;
							else
								y1= ydisp;
						}
						y2 = bscale*3.1415926/sqrt(MINMAX(band,0.1,40.0));
				
						if (x->lcd_debug)
							post("x1: %d y1: %d y2: %d",x1,y1,y2);
								
						MoveTo(r.left+x1,r.top+y1);
						Line(0,y2);
					}
				}
		
				restorePalette(x,&fColor,&pH);
				SetClip(cur);
				DisposeRgn(cur);
			}
			SetPort(gp);
		}
	
	}
	ExitCallback();
}