[Scummvm-cvs-logs] CVS: scummvm/backends/gp32 globals.h,NONE,1.1 gp32_launcher.cpp,1.1,1.2 gp32_launcher.h,1.1,1.2 gp32_main.cpp,1.2,1.3 gp32_osys.cpp,1.4,1.5 gp32std.cpp,1.1,1.2 gp32std.h,1.1,1.2 gp32std_grap.cpp,1.3,1.4 gp32std_grap.h,1.1,1.2 Makefile,1.2,1.3

Won star wonst719 at users.sourceforge.net
Fri Jan 6 04:52:37 CET 2006


Update of /cvsroot/scummvm/scummvm/backends/gp32
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19153

Modified Files:
	gp32_launcher.cpp gp32_launcher.h gp32_main.cpp gp32_osys.cpp 
	gp32std.cpp gp32std.h gp32std_grap.cpp gp32std_grap.h Makefile 
Added Files:
	globals.h 
Log Message:
* Accurate / fast gamma correction using LUT
* Enable changing FM quality and sample rate
* Saves launcher setting to SMC
* Etc.

--- NEW FILE: globals.h ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2001-2006 The ScummVM project
 * Copyright (C) 2006 Won Star - GP32 Backend
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/backends/gp32/globals.h,v 1.1 2006/01/06 12:48:47 wonst719 Exp $
 *
 */

#ifndef __GLOBALS_H
#define __GLOBALS_H

enum {
	FM_QUALITY_LOW = 0,
	FM_QUALITY_MED,
	FM_QUALITY_HI
};

struct GlobalVars {
	uint16 cpuSpeed;
	uint16 gammaRamp;
	uint8 fmQuality;
	uint32 sampleRate;
};

extern GlobalVars g_vars;

#endif

Index: gp32_launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32_launcher.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gp32_launcher.cpp	27 Nov 2005 02:35:57 -0000	1.1
+++ gp32_launcher.cpp	6 Jan 2006 12:48:47 -0000	1.2
@@ -23,9 +23,7 @@
 
 #include "stdafx.h"
 #include "common/scummsys.h"
-#include "common/scaler.h"
-#include "common/system.h"
-#include "backends/intern.h"
+#include "common/file.h"
 
 #include "base/engine.h"
 
@@ -35,17 +33,57 @@
 
 #include "backends/gp32/gfx_splash.h"
 #include "backends/gp32/gp32_launcher.h"
+#include "backends/gp32/globals.h"
 
 uint16 cpuSpeedTable[15] = {40, 66, 100, 120, 133, 144, 156, 160, 166, 172, 176, 180, 188, 192, 200};
-uint16 gammaTable[16] = {50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200};
+uint16 gammaTable[16] = {5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000};
 char *oplTable[3] = {"LOW", "MEDIUM", "HIGH"};
 uint16 sampleTable[3] = {11025, 22050, 44100};
 
 uint8 maxTable[5] = {15, 16, 3, 3, 2};
-uint8 currentSetting[5] = {3, 5, 1, 0, 0};
+uint8 currentSetting[5] = {2, 5, 1, 0, 0};
 
-int g_cpuSpeed = 120;
-int g_gammaRamp = 100;
+void writeConfigVars() {
+	Common::File file;
+
+	g_vars.cpuSpeed = cpuSpeedTable[currentSetting[0]];
+	g_vars.gammaRamp = gammaTable[currentSetting[1]];
+	g_vars.fmQuality = currentSetting[2];
+	g_vars.sampleRate = sampleTable[currentSetting[3]];
+
+	if (!file.open("scummvm.cfg", Common::File::kFileWriteMode, "gp:\\gpetc\\")) {
+		return;
+	}
+	file.writeByte(currentSetting[0]);
+	file.writeByte(currentSetting[1]);
+	file.writeByte(currentSetting[2]);
+	file.writeByte(currentSetting[3]);
+	file.close();
+}
+
+void readConfigVars() {
+	Common::File file;
+	if (!file.exists("scummvm.cfg", "gp:\\gpetc\\")) {
+		currentSetting[0] = 2;
+		currentSetting[1] = 5;
+		currentSetting[2] = 1;
+		currentSetting[3] = 0;
+		writeConfigVars();
+	} else {
+		if (!file.open("scummvm.cfg", Common::File::kFileReadMode, "gp:\\gpetc\\")) {
+			return;
+		}
+		currentSetting[0] = file.readByte();
+		currentSetting[1] = file.readByte();
+		currentSetting[2] = file.readByte();
+		currentSetting[3] = file.readByte();
+		g_vars.cpuSpeed = cpuSpeedTable[currentSetting[0]];
+		g_vars.gammaRamp = gammaTable[currentSetting[1]];
+		g_vars.fmQuality = currentSetting[2];
+		g_vars.sampleRate = sampleTable[currentSetting[3]];
+		file.close();
+	}
+}
 
 void configMenu() {
 	uint32 nKeyUD;
@@ -54,14 +92,17 @@
 	int currentSelect = 0;
 	char text[32];
 
+	// OK / CANCEL
+	currentSetting[4] = 0;
+
 	while (1) {
 		gp_fillRect(frameBuffer2, 0, 0, 320, 240, 0xffff);
 		gp_textOut(frameBuffer2, 90, 10, "Configuration Menu", 0);
 
 		gp_textOut(frameBuffer2, 30, 40, "CPU clock speed", 0);
 		gp_textOut(frameBuffer2, 30, 80, "Gamma ramp", 0);
-		gp_textOut(frameBuffer2, 30, 120, "FMOPL (AdLib) quality", gp_RGBTo16(128, 128, 128));
-		gp_textOut(frameBuffer2, 30, 160, "Sampling rate", gp_RGBTo16(128, 128, 128));
+		gp_textOut(frameBuffer2, 30, 120, "FMOPL (AdLib) quality", 0);
+		gp_textOut(frameBuffer2, 30, 160, "Sampling rate", 0);
 
 		gp_textOut(frameBuffer2, 100, 210, "OK         CANCEL", 0);
 
@@ -72,7 +113,7 @@
 
 		sprintf(text, "%d MHz", cpuSpeedTable[currentSetting[0]]);
 		gp_textOut(frameBuffer2, 220, 40, text, 0);
-		sprintf(text, "%d %%", gammaTable[currentSetting[1]]);
+		sprintf(text, "%.2f", (float)gammaTable[currentSetting[1]] / 10000);
 		gp_textOut(frameBuffer2, 220, 80, text, 0);
 		gp_textOut(frameBuffer2, 220, 120, oplTable[currentSetting[2]], gp_RGBTo16(128, 128, 128));
 		sprintf(text, "%d Hz", sampleTable[currentSetting[3]]);
@@ -91,12 +132,12 @@
 				currentSelect++;
 		}
 		if (gpd_getButtonDown(nKeyUD, GPC_VK_LEFT)) {
-			if (currentSelect <= 1)
+			if (currentSelect <= 3)
 				if (currentSetting[currentSelect] > 0)
 					currentSetting[currentSelect]--;
 		}
 		if (gpd_getButtonDown(nKeyUD, GPC_VK_RIGHT)) {
-			if (currentSelect <= 1)
+			if (currentSelect <= 3)
 				if (currentSetting[currentSelect] < maxTable[currentSelect] - 1)
 					currentSetting[currentSelect]++;
 		}
@@ -105,8 +146,7 @@
 			gpd_getButtonUp(nKeyUD, GPC_VK_FA)) {
 			if (currentSelect == 4) {
 				if (currentSetting[currentSelect] == 0) { // OK
-					g_cpuSpeed = cpuSpeedTable[currentSetting[0]];
-					g_gammaRamp = gammaTable[currentSetting[1]];
+					writeConfigVars();
 					return;
 				} else { // CANCEL
 					return;

Index: gp32_launcher.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32_launcher.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gp32_launcher.h	27 Nov 2005 02:35:57 -0000	1.1
+++ gp32_launcher.h	6 Jan 2006 12:48:47 -0000	1.2
@@ -26,9 +26,8 @@
 #include "stdafx.h"
 #include "common/scummsys.h"
 
-extern void splashScreen();
+extern void readConfigVars();
 
-extern int g_cpuSpeed;
-extern int g_gammaRamp;
+extern void splashScreen();
 
 #endif

Index: gp32_main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32_main.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gp32_main.cpp	4 Dec 2005 08:49:08 -0000	1.2
+++ gp32_main.cpp	6 Jan 2006 12:48:47 -0000	1.3
@@ -22,125 +22,21 @@
 
 #include "stdafx.h"
 #include "common/scummsys.h"
-#include "common/scaler.h"
-#include "common/system.h"
-#include "backends/intern.h"
 
-#include "base/engine.h"
+#include "common/config-manager.h"
 
 #include "backends/gp32/gp32std.h"
 #include "backends/gp32/gp32std_grap.h"
 
 #include "backends/gp32/gp32_launcher.h"
+#include "backends/gp32/globals.h"
 
-#include "backends/gp32/gp32_osys.h"
+GlobalVars g_vars;
 
 extern "C" int scummvm_main(int argc, char *argv[]);
 
-extern void gp_delay(uint32 msecs);
-
-extern "C" void cpu_speed(int MCLK, int CLKDIV, int CLKMODE); // CPU Speed control (3 int's, clock, bus, dividor)
-
-// Where's better position?
-static int CLKDIV = 0x48013;
-static int MCLK = 40000000;
-static int CLKMODE = 0;
-static int HCLK = 40000000;
-static int PCLK = 40000000;
-/*
-int gp_getPCLK() {
-   return PCLK;
-}
-
-int gp_getHCLK() {
-   return HCLK;
-}
-*/
-void gp_clockSpeedChange(int freq, int magic, int div) {
-	#define rTCFG0 (*(volatile unsigned *)0x15100000)
-	#define rTCFG1 (*(volatile unsigned *)0x15100004)
-	#define rTCNTB4 (*(volatile unsigned *)0x1510003c)
-	unsigned int pclk;
-	unsigned int prescaler0;
-
-	/* Change CPU Speed */
-	GpClockSpeedChange(freq, magic, div);
-	pclk = GpPClkGet();
-
-	/* Repair SDK timer - it forgets to set prescaler */
-	prescaler0 = (pclk / (8000 * 40)) - 1;
-	rTCFG0 = (rTCFG0 & 0xFFFFFF00) | prescaler0;
-	rTCFG1 = 0x30033;
-
-	/* Repair GpTickCountGet */
-	rTCNTB4 = pclk / 1600;
-}
-
-void gp_setCpuSpeed(int freq) {
-	switch (freq) {
-		// overclocked
-		case 168: { CLKDIV = 0x14000; MCLK = 168000000; CLKMODE = 3; break; }
-		case 172: { CLKDIV = 0x23010; MCLK = 172000000; CLKMODE = 3; break; }
-		case 176: { CLKDIV = 0x24010; MCLK = 176000000; CLKMODE = 3; break; }
-		case 180: { CLKDIV = 0x16000; MCLK = 180000000; CLKMODE = 3; break; }
-		case 184: { CLKDIV = 0x26010; MCLK = 184000000; CLKMODE = 3; break; }
-		case 188: { CLKDIV = 0x27010; MCLK = 188000000; CLKMODE = 3; break; }
-		case 192: { CLKDIV = 0x18000; MCLK = 192000000; CLKMODE = 3; break; }
-		case 196: { CLKDIV = 0x29010; MCLK = 196000000; CLKMODE = 3; break; }
-		case 200: { CLKDIV = 0x2A010; MCLK = 200000000; CLKMODE = 3; break; }
-		case 204: { CLKDIV = 0x2b010; MCLK = 204000000; CLKMODE = 3; break; }
-		case 208: { CLKDIV = 0x2c010; MCLK = 208000000; CLKMODE = 3; break; }
-		case 212: { CLKDIV = 0x2d010; MCLK = 212000000; CLKMODE = 3; break; }
-		case 216: { CLKDIV = 0x2e010; MCLK = 216000000; CLKMODE = 3; break; }
-		case 220: { CLKDIV = 0x2f010; MCLK = 220000000; CLKMODE = 3; break; }
-		case 224: { CLKDIV = 0x30010; MCLK = 224000000; CLKMODE = 3; break; }
-		case 228: { CLKDIV = 0x1e000; MCLK = 228000000; CLKMODE = 3; break; }
-		case 232: { CLKDIV = 0x32010; MCLK = 232000000; CLKMODE = 3; break; }
-		case 236: { CLKDIV = 0x33010; MCLK = 236000000; CLKMODE = 3; break; }
-		case 240: { CLKDIV = 0x20000; MCLK = 240000000; CLKMODE = 3; break; }
-		case 244: { CLKDIV = 0x35010; MCLK = 244000000; CLKMODE = 3; break; }
-		case 248: { CLKDIV = 0x36010; MCLK = 248000000; CLKMODE = 3; break; }
-		case 252: { CLKDIV = 0x22000; MCLK = 252000000; CLKMODE = 3; break; }
-		case 256: { CLKDIV = 0x38010; MCLK = 256000000; CLKMODE = 3; break; }
-
-		// normal
-//		case 166: { CLKDIV = 0x4B011; MCLK = 166000000; CLKMODE = 3; break; }
-		case 166: { CLKDIV = 0x2f001; MCLK = 165000000; CLKMODE = 3; break; }
-		case 164: { CLKDIV = 0x4a011; MCLK = 164000000; CLKMODE = 3; break; }
-		case 160: { CLKDIV = 0x48011; MCLK = 160000000; CLKMODE = 3; break; }
-//		case 156: { CLKDIV = 0x2c001; MCLK = 156000000; CLKMODE = 3; break; }
-		case 156: { CLKDIV = 0x2c001; MCLK = 156000000; CLKMODE = 3; break; }
-		case 144: { CLKDIV = 0x28001; MCLK = 144000000; CLKMODE = 3; break; }
-//		case 133: { CLKDIV = 0x3a011; MCLK = 132000000; CLKMODE = 3; break; }
-		case 133: { CLKDIV = (81 << 12) | (2 << 4) | 1; MCLK = 133500000; CLKMODE = 2; break; }
-		case 132: { CLKDIV = 0x3a011; MCLK = 132000000; CLKMODE = 3; break; }
-		case 120: { CLKDIV = 0x24001; MCLK = 120000000; CLKMODE = 2; break; }
-//		case 100: { CLKDIV = 0x2b011; MCLK = 102000000; CLKMODE=2; break; }
-		case 100: { CLKDIV =( 43 << 12) | (1 << 4) | 1; MCLK = 102000000; CLKMODE = 2; break; }
-//		case  66: { CLKDIV = 0x25002; MCLK= 67500000; CLKMODE=2; break; }
-		case  66: { CLKDIV = (37 << 12) | (0 << 4) | 2; MCLK= 67500000; CLKMODE = 2; break; }
-		case  50: { CLKDIV = 0x2a012; MCLK= 50000000; CLKMODE = 0; break; }
-//		case  40: { CLKDIV = 0x48013; MCLK= 40000000; CLKMODE = 0; break; }
-		case  40: { CLKDIV = 0x48013; MCLK= 40000000; CLKMODE = 1; break; }
-//		case  33: { CLKDIV = 0x25003; MCLK= 33750000; CLKMODE = 0; break; }
-		case  33: { CLKDIV = (37 << 12) | (0 << 4) | 3; MCLK = 33750000; CLKMODE = 2; break; }
-		case  22: { CLKDIV = 0x33023; MCLK = 22125000; CLKMODE = 0; break; }
-	}
-	if (CLKMODE==0) { HCLK = MCLK;     PCLK = MCLK; }
-	if (CLKMODE==1) { HCLK = MCLK;     PCLK = MCLK / 2; }
-	if (CLKMODE==2) { HCLK = MCLK / 2; PCLK = MCLK / 2; }
-	if (CLKMODE==3) { HCLK = MCLK / 2; PCLK = MCLK / 4; }
-	//cpu_speed(MCLK, CLKDIV, CLKMODE);
-	gp_clockSpeedChange(MCLK, CLKDIV, CLKMODE);
-}
-
-void gp_Reset() {
-   gp_setCpuSpeed(66);
-   asm volatile("swi #4\n");
-}
-
 void init() {
-	gp_setCpuSpeed(66); // Default CPU Speed
+	gp_setCpuSpeed(40); // Default CPU Speed
 
 	GpGraphicModeSet(16, NULL);
 
@@ -152,28 +48,23 @@
 	//	error("Invalid Console");
 	gp_initFrameBuffer();
 
-
 	GpFatInit();
 	GpRelativePathSet("gp:\\gpmm");
-	//ERR_CODE err_code;
-	//err_code = GpDirCreate("temp", 0);
-	//	if (err_code != SM_OK)	return;
-	g_cpuSpeed = 120;
 }
 
 void GpMain(void *arg) {
 	init();
 
+	readConfigVars();
+
 	splashScreen();
-	
+
 	//doConfig
-	gp_setCpuSpeed(g_cpuSpeed);
-	GPDEBUG("Set CPU Speed: %d", g_cpuSpeed);
+	gp_initGammaTable((float)g_vars.gammaRamp / 10000);
+	gp_setCpuSpeed(g_vars.cpuSpeed);
 
 	// FOR DEBUG PURPOSE!
 	int argc = 2;
-	//char *argv[] = { "scummvm", "playfate" };
-	//char *argv[] = { "scummvm", "-enull", "-pgp:\\game\\loomcd\\", "loomcd" };
 	//char *argv[] = { "scummvm", "-enull", "-pgp:\\game\\dott\\", "tentacle" };
 	char *argv[] = { "scummvm", "-enull", "-d3" };
 

Index: gp32_osys.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32_osys.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gp32_osys.cpp	18 Dec 2005 06:08:54 -0000	1.4
+++ gp32_osys.cpp	6 Jan 2006 12:48:47 -0000	1.5
@@ -28,6 +28,8 @@
 #include "common/scummsys.h"
 #include "common/system.h"
 
+#include "backends/gp32/globals.h"
+
 #include "common/rect.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
@@ -647,6 +649,10 @@
 
 	GPSOUNDBUF gpSoundBuf;
 
+	ConfMan.set("FM_medium_quality", (g_vars.fmQuality == FM_QUALITY_MED));
+	ConfMan.set("FM_high_quality", (g_vars.fmQuality == FM_QUALITY_HI));
+	//ConfMan.set("sample_rate", (int)g_vars.sampleRate);
+
 	if (ConfMan.hasKey("output_rate"))
 		_samplesPerSec = ConfMan.getInt("output_rate");
 

Index: gp32std.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32std.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gp32std.cpp	27 Nov 2005 02:35:57 -0000	1.1
+++ gp32std.cpp	6 Jan 2006 12:48:47 -0000	1.2
@@ -158,6 +158,10 @@
 		file->cachePos = 0;
 		mode = OPEN_W;
 		err = GpFileCreate(fileName, ALWAYS_CREATE, &file->handle);
+	} else if(tolower(openMode[0]) == 'a') {
+		warning("We do not support 'a' file open mode.");
+		free(file);
+		return NULL;
 	} else {
 		error("wrong file mode");
 	}
@@ -183,7 +187,7 @@
 /*	if (*(uint32 *)((char *)stream - sizeof(uint32)) == 0x4321) {
 		debug(0, "Double closing", __FUNCTION__);
 		return 1;
-	}			// return 1 ??
+	}
 */
 
 	if (stream->cachePos) {
@@ -214,6 +218,7 @@
 	return GpFileSeek(stream->handle, whence, offset, (long *)&dummy);
 }
 
+//TODO: read cache
 size_t gp_fread(void *ptr, size_t size, size_t n, GPFILE *stream) {
 	ulong readcount = 0;
 	ERR_CODE err = GpFileRead(stream->handle, ptr, size * n, &readcount); //fixme? size*n
@@ -483,6 +488,94 @@
 	while (GpTickCountGet() < startTime + msecs);
 }
 
+void gp_clockSpeedChange(int freq, int magic, int div) {
+	#define rTCFG0 (*(volatile unsigned *)0x15100000)
+	#define rTCFG1 (*(volatile unsigned *)0x15100004)
+	#define rTCNTB4 (*(volatile unsigned *)0x1510003c)
+	unsigned int pclk;
+	unsigned int prescaler0;
+
+	// Change CPU Speed
+	GpClockSpeedChange(freq, magic, div);
+	pclk = GpPClkGet();
+
+	// Repair SDK timer - it forgets to set prescaler
+	prescaler0 = (pclk / (8000 * 40)) - 1;
+	rTCFG0 = (rTCFG0 & 0xFFFFFF00) | prescaler0;
+	rTCFG1 = 0x30033;
+
+	// Repair GpTickCountGet
+	rTCNTB4 = pclk / 1600;
+}
+
+void gp_setCpuSpeed(int freq) {
+	// Default value for 40 mhz
+	static int CLKDIV = 0x48013;
+	static int MCLK = 40000000;
+	static int CLKMODE = 0;
+	static int HCLK = 40000000;
+	static int PCLK = 40000000;
+
+	switch (freq) {
+		// overclocked
+		case 168: { CLKDIV = 0x14000; MCLK = 168000000; CLKMODE = 3; break; }
+		case 172: { CLKDIV = 0x23010; MCLK = 172000000; CLKMODE = 3; break; }
+		case 176: { CLKDIV = 0x24010; MCLK = 176000000; CLKMODE = 3; break; }
+		case 180: { CLKDIV = 0x16000; MCLK = 180000000; CLKMODE = 3; break; }
+		case 184: { CLKDIV = 0x26010; MCLK = 184000000; CLKMODE = 3; break; }
+		case 188: { CLKDIV = 0x27010; MCLK = 188000000; CLKMODE = 3; break; }
+		case 192: { CLKDIV = 0x18000; MCLK = 192000000; CLKMODE = 3; break; }
+		case 196: { CLKDIV = 0x29010; MCLK = 196000000; CLKMODE = 3; break; }
+		case 200: { CLKDIV = 0x2A010; MCLK = 200000000; CLKMODE = 3; break; }
+		case 204: { CLKDIV = 0x2b010; MCLK = 204000000; CLKMODE = 3; break; }
+		case 208: { CLKDIV = 0x2c010; MCLK = 208000000; CLKMODE = 3; break; }
+		case 212: { CLKDIV = 0x2d010; MCLK = 212000000; CLKMODE = 3; break; }
+		case 216: { CLKDIV = 0x2e010; MCLK = 216000000; CLKMODE = 3; break; }
+		case 220: { CLKDIV = 0x2f010; MCLK = 220000000; CLKMODE = 3; break; }
+		case 224: { CLKDIV = 0x30010; MCLK = 224000000; CLKMODE = 3; break; }
+		case 228: { CLKDIV = 0x1e000; MCLK = 228000000; CLKMODE = 3; break; }
+		case 232: { CLKDIV = 0x32010; MCLK = 232000000; CLKMODE = 3; break; }
+		case 236: { CLKDIV = 0x33010; MCLK = 236000000; CLKMODE = 3; break; }
+		case 240: { CLKDIV = 0x20000; MCLK = 240000000; CLKMODE = 3; break; }
+		case 244: { CLKDIV = 0x35010; MCLK = 244000000; CLKMODE = 3; break; }
+		case 248: { CLKDIV = 0x36010; MCLK = 248000000; CLKMODE = 3; break; }
+		case 252: { CLKDIV = 0x22000; MCLK = 252000000; CLKMODE = 3; break; }
+		case 256: { CLKDIV = 0x38010; MCLK = 256000000; CLKMODE = 3; break; }
+
+		// normal
+//		case 166: { CLKDIV = 0x4B011; MCLK = 166000000; CLKMODE = 3; break; }
+		case 166: { CLKDIV = 0x2f001; MCLK = 165000000; CLKMODE = 3; break; }
+		case 164: { CLKDIV = 0x4a011; MCLK = 164000000; CLKMODE = 3; break; }
+		case 160: { CLKDIV = 0x48011; MCLK = 160000000; CLKMODE = 3; break; }
+		case 156: { CLKDIV = 0x2c001; MCLK = 156000000; CLKMODE = 3; break; }
+		case 144: { CLKDIV = 0x28001; MCLK = 144000000; CLKMODE = 3; break; }
+		case 133: { CLKDIV = 0x51021; MCLK = 133500000; CLKMODE = 2; break; }
+		case 132: { CLKDIV = 0x3a011; MCLK = 132000000; CLKMODE = 3; break; }
+		case 120: { CLKDIV = 0x24001; MCLK = 120000000; CLKMODE = 2; break; }
+		case 100: { CLKDIV = 0x2b011; MCLK = 102000000; CLKMODE = 2; break; }
+		case  66: { CLKDIV = 0x25002; MCLK = 67500000; CLKMODE = 2; break; }
+		case  50: { CLKDIV = 0x2a012; MCLK = 50000000; CLKMODE = 0; break; }
+//		case  40: { CLKDIV = 0x48013; MCLK = 40000000; CLKMODE = 0; break; }
+		case  40: { CLKDIV = 0x48013; MCLK = 40000000; CLKMODE = 1; break; }
+//		case  33: { CLKDIV = 0x25003; MCLK = 33750000; CLKMODE = 0; break; }
+		case  33: { CLKDIV = 0x25003; MCLK = 33750000; CLKMODE = 2; break; }
+		case  22: { CLKDIV = 0x33023; MCLK = 22125000; CLKMODE = 0; break; }
+		default:
+			error("Invalid CPU frequency!");
+	}
+	if (CLKMODE == 0) { HCLK = MCLK;     PCLK = MCLK; }
+	if (CLKMODE == 1) { HCLK = MCLK;     PCLK = MCLK / 2; }
+	if (CLKMODE == 2) { HCLK = MCLK / 2; PCLK = MCLK / 2; }
+	if (CLKMODE == 3) { HCLK = MCLK / 2; PCLK = MCLK / 4; }
+
+	gp_clockSpeedChange(MCLK, CLKDIV, CLKMODE);
+}
+
+void gp_Reset() {
+   gp_setCpuSpeed(66);
+   asm volatile("swi #4\n");
+}
+
 void gp_exit(int code) {
 	if (!code) {
 		printf("  ----------------------------------------");
@@ -521,7 +614,7 @@
 	va_end(marker);
 
 	_dprintf("NP:%s", s);
-	//gp_delay(50);
+	gp_delay(50);
 }
 
 void LP(const char *fmt, ...) {
@@ -534,7 +627,7 @@
 	va_end(marker);
 
 	_dprintf("LP:%s", s);
-	//gp_delay(300);
+	gp_delay(300);
 }
 
 void SP(const char *fmt, ...) {
@@ -547,7 +640,7 @@
 	va_end(marker);
 
 	_dprintf("SP:%s", s);
-	//gp_delay(50);
+	gp_delay(50);
 }
 
 void BP(const char *fmt, ...) {
@@ -560,5 +653,5 @@
 	va_end(marker);
 
 	_dprintf("BP:%s", s);
-	//gp_delay(2000);
+	gp_delay(2000);
 }

Index: gp32std.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32std.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gp32std.h	27 Nov 2005 02:35:57 -0000	1.1
+++ gp32std.h	6 Jan 2006 12:48:47 -0000	1.2
@@ -38,7 +38,7 @@
 #define LCD_WIDTH 320
 #define LCD_HEIGHT 240
 
-#define FCACHE_SIZE 8 * 1024	// speed up writes
+#define FCACHE_SIZE 8 * 1024
 
 typedef struct {
 	F_HANDLE handle;
@@ -79,6 +79,7 @@
 extern void *	gp_calloc(size_t nitems, size_t size);
 extern void 	gp_free(void *block);
 
+extern void		gp_setCpuSpeed(int freq);
 extern int		gp_printf(const char *fmt, ...);
 extern void		gp_delay(unsigned long msecs);
 extern void		gp_exit(int code);

Index: gp32std_grap.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32std_grap.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gp32std_grap.cpp	17 Dec 2005 07:33:45 -0000	1.3
+++ gp32std_grap.cpp	6 Jan 2006 12:48:47 -0000	1.4
@@ -28,7 +28,7 @@
 #include "backends/gp32/gp32std.h"
 #include "backends/gp32/gp32std_grap.h"
 
-#include "backends/gp32/gp32_launcher.h"
+#include "backends/gp32/globals.h"
 
 GPDRAWSURFACE lcdSurface[2];
 
@@ -37,6 +37,9 @@
 uint16 *frameBuffer1;
 uint16 *frameBuffer2;
 
+uint8 gammaLUT[256];
+uint8 gammaLUTInv[256];
+
 extern const unsigned char fontresEng1[];
 extern const unsigned char fontresKor1[];
 
@@ -87,15 +90,25 @@
 	}
 }
 
+void gp_initGammaTable(float value)
+{
+	for(int i = 0; i < 256; i++) {
+		if(value == 1.0f) {
+			gammaLUT[i] = i;
+			gammaLUTInv[i] = i;
+		} else {
+			gammaLUT[i] = (uint8)(pow((double)i / 256, 1 / (double)value) * 256);
+			gammaLUTInv[i] = (uint8)(pow((double)i / 256, (double)value) * 256);
+		}
+	}
+}
+
 uint16 gp_RGBTo16(uint16 r, uint16 g, uint16 b) {
 	// GP32 16bit color 5551
-	if(g_gammaRamp != 100) {
-		r *= ((float)g_gammaRamp / 100);
-		g *= ((float)g_gammaRamp / 100);
-		b *= ((float)g_gammaRamp / 100);
-		r = r >= 255 ? 255 : r;
-		g = g >= 255 ? 255 : g;
-		b = b >= 255 ? 255 : b;
+	if(g_vars.gammaRamp != 10000) {
+		r = gammaLUT[r];
+		g = gammaLUT[g];
+		b = gammaLUT[b];
 	}
 	return (((r >> 3) & 0x1F) << 11) | (((g >> 3) & 0x1F) << 6) | ((b >> 3) & 0x1F) << 1;
 }
@@ -105,10 +118,10 @@
 	*g = ((((color) >> 6) & 0x1F) << 3);	//(((color>>5)&0x3F) << 2);
 	*b = ((((color) >> 1) & 0x1F) << 3);	//((color&0x1F) << 3);
 
-	if(g_gammaRamp != 100) {
-		*r /= ((float)g_gammaRamp / 100);
-		*g /= ((float)g_gammaRamp / 100);
-		*b /= ((float)g_gammaRamp / 100);
+	if(g_vars.gammaRamp != 10000) {
+		*r = gammaLUTInv[*r];
+		*g = gammaLUTInv[*g];
+		*b = gammaLUTInv[*b];
 	}
 }
 

Index: gp32std_grap.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32std_grap.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gp32std_grap.h	27 Nov 2005 02:35:57 -0000	1.1
+++ gp32std_grap.h	6 Jan 2006 12:48:48 -0000	1.2
@@ -37,6 +37,7 @@
 
 extern void gp_textOut(uint16 *frameBuffer, int x, int y, char* lpszText, uint16 wColor);
 
+extern void gp_initGammaTable(float value);
 extern void gp_initFrameBuffer();
 extern void gp_flipScreen();
 

Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile	27 Nov 2005 02:35:57 -0000	1.2
+++ Makefile	6 Jan 2006 12:48:48 -0000	1.3
@@ -68,7 +68,7 @@
 	       		-mno-thumb-interwork \
 				-I$(GPSDK)/include \
 				-g \
-	       		-O3 \
+	       		-O2 \
 	       		-fomit-frame-pointer
 
 CPPFLAGS	=	$(CFLAGS)





More information about the Scummvm-git-logs mailing list