[Scummvm-cvs-logs] SF.net SVN: scummvm: [22556] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun May 21 08:03:02 CEST 2006


Revision: 22556
Author:   lordhoto
Date:     2006-05-21 08:02:12 -0700 (Sun, 21 May 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22556&view=rev

Log Message:
-----------
Implements kyra3 main menu drawing.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/kyra3.cpp
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/screen.h
Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2006-05-21 13:50:43 UTC (rev 22555)
+++ scummvm/trunk/engines/kyra/kyra.h	2006-05-21 15:02:12 UTC (rev 22556)
@@ -1044,6 +1044,9 @@
 	static const char *_mainMenuStrings[];
 	int handleMainMenu(WSAMovieV3 *logo);
 	void drawMainMenu(const char * const *strings, int unk1);
+	void drawMainBox(int x, int y, int w, int h, int fill);
+	
+	void gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...);
 };
 
 } // End of namespace Kyra

Modified: scummvm/trunk/engines/kyra/kyra3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.cpp	2006-05-21 13:50:43 UTC (rev 22555)
+++ scummvm/trunk/engines/kyra/kyra3.cpp	2006-05-21 15:02:12 UTC (rev 22556)
@@ -116,6 +116,27 @@
 	return 0;
 }
 
+void KyraEngine_v3::playVQA(const char *filename) {
+	VQAMovie vqa(this, _system);
+
+	uint8 pal[768];
+	memcpy(pal, _screen->_currentPalette, sizeof(pal));
+	if (_screen->_curPage == 0)
+		_screen->copyCurPageBlock(0, 0, 320, 200, _screen->getPagePtr(3));
+
+	vqa.open(filename, 0, NULL);
+	if (vqa.opened()) {
+		vqa.setX(0); vqa.setY(0);
+		vqa.setDrawPage(0);
+		vqa.play();
+		vqa.close();
+	}
+
+	if (_screen->_curPage == 0)
+		_screen->copyBlockToPage(0, 0, 0, 320, 200, _screen->getPagePtr(3));
+	_screen->setScreenPalette(pal);
+}
+
 void KyraEngine_v3::playMenuAudioFile() {
 	if (_soundDigital->isPlaying(_musicSoundChannel))
 		return;
@@ -131,6 +152,10 @@
 int KyraEngine_v3::handleMainMenu(WSAMovieV3 *logo) {
 	int command = -1;
 	
+	uint8 colorMap[16];
+	memset(colorMap, 0, sizeof(colorMap));
+	_screen->setTextColorMap(colorMap);
+	
 	const char * const *strings = &_mainMenuStrings[/*_lang*4*/0];
 	Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT);
 	int charWidthBackUp = _screen->_charWidth;
@@ -138,14 +163,13 @@
 	_screen->setScreenDim(3);
 	_screen->copyCurPageBlock(_screen->_curDim->sx, _screen->_curDim->sy, _screen->_curDim->w, _screen->_curDim->h, _screen->getPagePtr(3));
 
-//	int left = _screen->_curDim->sx << 3;
-//	int top = _screen->_curDim->sy;
-//	int right = left + (_screen->_curDim->w << 3);
-//	int bottom = top + _screen->_curDim->h;
+	int x = _screen->_curDim->sx << 3;
+	int y = _screen->_curDim->sy;
+	int width = _screen->_curDim->w << 3;
+	int height =  _screen->_curDim->h;
 
-	// XXX
-	// gui_unk1(left, top, right, bottom, 1, 0);
-	// gui_unk1(left + 1, top + 1, right - 1, bottom - 1, 0, 0);
+	drawMainBox(x, y, width, height, 1);
+	drawMainBox(x + 1, y + 1, width - 2, height - 2, 0);
 	
 	int curFrame = 29, frameAdd = 1;
 	uint32 nextRun = 0;
@@ -191,40 +215,59 @@
 }
 
 void KyraEngine_v3::drawMainMenu(const char * const *strings, int unk1) {
-#if 0
-	static const uint16 _menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0xFF, 0x00, 0x01, 0x02, 0x03 };
+	static const uint16 menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF, 0x00, 0x01, 0x02, 0x03 };
 	
-	int left = _screen->_curDim->sx << 3; int top = _screen->_curDim->sy;
-	int width = _screen->_curDim->w << 3; int height = _screen->_curDim->h;
+	int top = _screen->_curDim->sy;
+	top += menuTable[1];
 	
-	top += _menuTable[1];
-	
-	for (int i = 0; i < _menuTable[3]; ++i) {
+	for (int i = 0; i < menuTable[3]; ++i) {
 		int curY = top + i * _screen->getFontHeight();
-		// XXX
+		gui_printString(strings[i], ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3, curY, menuTable[5], 0, 5);
 	}
-#endif
 }
 
-void KyraEngine_v3::playVQA(const char *filename) {
-	VQAMovie vqa(this, _system);
+void KyraEngine_v3::drawMainBox(int x, int y, int w, int h, int fill) {
+	static const uint8 colorTable[] = { 0x16, 0x19, 0x1A, 0x16 };
+	--w; --h;
 
-	uint8 pal[768];
-	memcpy(pal, _screen->_currentPalette, sizeof(pal));
-	if (_screen->_curPage == 0)
-		_screen->copyCurPageBlock(0, 0, 320, 200, _screen->getPagePtr(3));
+	if (fill) {
+		_screen->fillRect(x, y, x+w, y+h, colorTable[0]);
+	}
+	
+	_screen->drawClippedLine(x, y+h, x+w, y+h, colorTable[1]);
+	_screen->drawClippedLine(x+w, y, x+w, y+h, colorTable[1]);
+	_screen->drawClippedLine(x, y, x+w, y, colorTable[2]);
+	_screen->drawClippedLine(x, y, x, y+h, colorTable[2]);
+	
+	_screen->drawPixel(x, y+h, colorTable[3]);
+	_screen->drawPixel(x+w, y, colorTable[3]);
+}
 
-	vqa.open(filename, 0, NULL);
-	if (vqa.opened()) {
-		vqa.setX(0); vqa.setY(0);
-		vqa.setDrawPage(0);
-		vqa.play();
-		vqa.close();
+void KyraEngine_v3::gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...) {
+	if (!string)
+		return;
+	
+	// XXX
+	
+	if (flags & 1) {
+		x -= _screen->getTextWidth(string) >> 1;
 	}
-
-	if (_screen->_curPage == 0)
-		_screen->copyBlockToPage(0, 0, 0, 320, 200, _screen->getPagePtr(3));
-	_screen->setScreenPalette(pal);
+	
+	if (flags & 2) {
+		x -= _screen->getTextWidth(string);
+	}
+	
+	if (flags & 4) {
+		_screen->printText(string, x - 1, y, 240, col2);
+		_screen->printText(string, x, y + 1, 240, col2);
+	}
+	
+	if (flags & 8) {
+		_screen->printText(string, x - 1, y, 227, col2);
+		_screen->printText(string, x, y + 1, 227, col2);
+	}
+	
+	_screen->printText(string, x, y, col1, col2);
 }
 
 } // end of namespace Kyra

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2006-05-21 13:50:43 UTC (rev 22555)
+++ scummvm/trunk/engines/kyra/screen.cpp	2006-05-21 15:02:12 UTC (rev 22556)
@@ -494,6 +494,12 @@
 	drawClippedLine(x1, y2, x2, y2, color);
 }
 
+void Screen::drawPixel(int x, int y, int color, int pageNum) {
+	debugC(9, kDebugLevelScreen, "Screen::drawPixel(%i, %i, %i, %i)", x, y, color, pageNum);
+	uint8 *dst = getPagePtr((pageNum != -1) ? pageNum : 0) + y * SCREEN_W + x;
+	*dst = color;
+}
+
 void Screen::drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2) {
 	debugC(9, kDebugLevelScreen, "Screen::drawShadedBox(%i, %i, %i, %i, %i, %i)", x1, y1, x2, y2, color1, color2);
 	assert(x1 > 0 && y1 > 0);
@@ -595,7 +601,7 @@
 		error("Invalid font data");
 	}
 	fnt->charWidthTable = fontData + READ_LE_UINT16(fontData + 8);
-	fnt->charBoxHeight = READ_LE_UINT16(fontData + 4);
+	fnt->charSizeOffset = READ_LE_UINT16(fontData + 4);
 	fnt->charBitmapOffset = READ_LE_UINT16(fontData + 6);
 	fnt->charWidthTableOffset = READ_LE_UINT16(fontData + 8);
 	fnt->charHeightTableOffset = READ_LE_UINT16(fontData + 0xC);
@@ -609,9 +615,13 @@
 }
 
 int Screen::getFontHeight() const {
-	return (int)(_fonts[_currentFont].charBoxHeight);
+	return *(_fonts[_currentFont].fontData + _fonts[_currentFont].charSizeOffset + 4);
 }
 
+int Screen::getFontWidth() const {
+	return *(_fonts[_currentFont].fontData + _fonts[_currentFont].charSizeOffset + 5);
+}
+
 int Screen::getCharWidth(uint8 c) const {
 	debugC(9, kDebugLevelScreen, "Screen::getCharWidth('%c')", c);
 	return (int)_fonts[_currentFont].charWidthTable[c] + _charWidth;
@@ -646,7 +656,7 @@
 	setTextColor(cmap, 0, 1);
 	
 	Font *fnt = &_fonts[_currentFont];
-	uint8 charHeight = *(fnt->fontData + fnt->charBoxHeight + 4);
+	uint8 charHeight = *(fnt->fontData + fnt->charSizeOffset + 4);
 	
 	if (x < 0) {
 		x = 0;
@@ -694,8 +704,9 @@
 	if (charWidth + x > SCREEN_W) {
 		return;
 	}
-	uint8 charH0 = *(fnt->fontData + fnt->charBoxHeight + 4);
+	uint8 charH0 = *(fnt->fontData + fnt->charSizeOffset + 4);
 	if (charH0 + y > SCREEN_H) {
+		printf("charH0 + y: %d + %d: %d ('%c')\n", charH0, y, charH0 + y, c);
 		return;
 	}
 	uint8 charH1 = *(fnt->fontData + fnt->charHeightTableOffset + c * 2);

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2006-05-21 13:50:43 UTC (rev 22555)
+++ scummvm/trunk/engines/kyra/screen.h	2006-05-21 15:02:12 UTC (rev 22556)
@@ -47,7 +47,7 @@
 struct Font {
 	uint8 *fontData;
 	uint8 *charWidthTable;
-	uint16 charBoxHeight;
+	uint16 charSizeOffset;
 	uint16 charBitmapOffset;
 	uint16 charWidthTableOffset;
 	uint16 charHeightTableOffset;
@@ -115,12 +115,14 @@
 	void drawClippedLine(int x1, int y1, int x2, int y2, int color);
 	void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2);
 	void drawBox(int x1, int y1, int x2, int y2, int color);
+	void drawPixel(int x, int y, int color, int pageNum = -1);
 	void setAnimBlockPtr(int size);
 	void setTextColorMap(const uint8 *cmap);
 	void setTextColor(const uint8 *cmap, int a, int b);
 	void loadFont(FontId fontId, uint8 *fontData);
 	FontId setFont(FontId fontId);
 	int getFontHeight() const;
+	int getFontWidth() const;
 	int getCharWidth(uint8 c) const;
 	int getTextWidth(const char *str) const;
 	void printText(const char *str, int x, int y, uint8 color1, uint8 color2);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list