diff options
Diffstat (limited to 'backends/platform')
82 files changed, 2278 insertions, 3458 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index aba31320ea..902599d50f 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -134,6 +134,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :  	_enable_zoning(false),  	_mixer(0),  	_shake_offset(0), +	_queuedEventTime(0),  	_event_queue_lock(createMutex()),  	_touch_pt_down(),  	_touch_pt_scroll(), diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index f39a8f1144..47a6515a2a 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -220,6 +220,8 @@ public:  private:  	Common::Queue<Common::Event> _event_queue; +	Common::Event _queuedEvent; +	uint32 _queuedEventTime;  	MutexRef _event_queue_lock;  	Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt; diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index 2a16e69411..a58b93e3bb 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -211,11 +211,13 @@ static const Common::KeyCode jkeymap[] = {  };  // floating point. use sparingly -template <class T> +template<class T>  static inline T scalef(T in, float numerator, float denominator) {  	return static_cast<float>(in) * numerator / denominator;  } +static const int kQueuedInputEventDelay = 50; +  void OSystem_Android::setupKeymapper() {  #ifdef ENABLE_KEYMAPPER  	using namespace Common; @@ -225,22 +227,19 @@ void OSystem_Android::setupKeymapper() {  	HardwareKeySet *keySet = new HardwareKeySet();  	keySet->addHardwareKey( -		new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)", -				kTriggerLeftKeyType, -				kVirtualKeyboardActionType)); +		new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)"));  	mapper->registerHardwareKeySet(keySet); -	Keymap *globalMap = new Keymap("global"); +	Keymap *globalMap = new Keymap(kGlobalKeymapName);  	Action *act; -	act = new Action(globalMap, "VIRT", "Display keyboard", -						kVirtualKeyboardActionType); +	act = new Action(globalMap, "VIRT", "Display keyboard");  	act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));  	mapper->addGlobalKeymap(globalMap); -	mapper->pushKeymap("global"); +	mapper->pushKeymap(kGlobalKeymapName);  #endif  } @@ -601,13 +600,18 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,  			lockMutex(_event_queue_lock); +			if (_queuedEventTime) +				_event_queue.push(_queuedEvent); +  			if (!_touchpad_mode)  				_event_queue.push(e);  			e.type = down;  			_event_queue.push(e); +  			e.type = up; -			_event_queue.push(e); +			_queuedEvent = e; +			_queuedEventTime = getMillis() + kQueuedInputEventDelay;  			unlockMutex(_event_queue_lock);  		} @@ -702,9 +706,14 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,  				lockMutex(_event_queue_lock); +				if (_queuedEventTime) +					_event_queue.push(_queuedEvent); +  				_event_queue.push(e); +  				e.type = up; -				_event_queue.push(e); +				_queuedEvent = e; +				_queuedEventTime = getMillis() + kQueuedInputEventDelay;  				unlockMutex(_event_queue_lock);  				return; @@ -800,6 +809,13 @@ bool OSystem_Android::pollEvent(Common::Event &event) {  	lockMutex(_event_queue_lock); +	if (_queuedEventTime && (getMillis() > _queuedEventTime)) { +		event = _queuedEvent; +		_queuedEventTime = 0; +		unlockMutex(_event_queue_lock); +		return true; +	} +  	if (_event_queue.empty()) {  		unlockMutex(_event_queue_lock);  		return false; diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index e211e5941f..95c96e0d25 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -61,7 +61,7 @@ static inline GLfixed xdiv(int numerator, int denominator) {  	return (numerator << 16) / denominator;  } -template <class T> +template<class T>  static T nextHigher2(T k) {  	if (k == 0)  		return 1; diff --git a/backends/platform/bada/application.cpp b/backends/platform/bada/application.cpp index bf585d2782..ba8e544983 100644 --- a/backends/platform/bada/application.cpp +++ b/backends/platform/bada/application.cpp @@ -68,7 +68,7 @@ void BadaScummVM::OnUserEventReceivedN(RequestId requestId,  		// assertion failure termination  		String *message = NULL;  		if (args) { -			message = (String*)args->GetAt(0); +			message = (String *)args->GetAt(0);  		}  		if (!message) {  			message = new String("Unknown error"); diff --git a/backends/platform/bada/audio.cpp b/backends/platform/bada/audio.cpp index b868e91357..65a5a80fa5 100644 --- a/backends/platform/bada/audio.cpp +++ b/backends/platform/bada/audio.cpp @@ -238,7 +238,7 @@ void AudioThread::OnAudioOutBufferEndReached(Osp::Media::AudioOut &src) {  void AudioThread::OnTimerExpired(Timer &timer) {  	if (_ready < NUM_AUDIO_BUFFERS) {  		uint len = _audioBuffer[_head].GetCapacity(); -		int samples = _mixer->mixCallback((byte*)_audioBuffer[_head].GetPointer(), len); +		int samples = _mixer->mixCallback((byte *)_audioBuffer[_head].GetPointer(), len);  		if (samples) {  			_head = (_head + 1) % NUM_AUDIO_BUFFERS;  			_ready++; diff --git a/backends/platform/bada/fs.cpp b/backends/platform/bada/fs.cpp index 0ae0cde43d..37ca496d18 100644 --- a/backends/platform/bada/fs.cpp +++ b/backends/platform/bada/fs.cpp @@ -170,17 +170,17 @@ uint32 BadaFileStream::read(void *ptr, uint32 len) {  			uint32 available = bufferLength - bufferIndex;  			if (len <= available) {  				// use allocation -				memcpy((byte*)ptr, &buffer[bufferIndex], len); +				memcpy((byte *)ptr, &buffer[bufferIndex], len);  				bufferIndex += len;  				result = len;  			} else {  				// use remaining allocation -				memcpy((byte*)ptr, &buffer[bufferIndex], available); +				memcpy((byte *)ptr, &buffer[bufferIndex], available);  				uint32 remaining = len - available;  				result = available;  				if (remaining) { -					result += file->Read(((byte*)ptr) + available, remaining); +					result += file->Read(((byte *)ptr) + available, remaining);  				}  				bufferIndex = bufferLength = 0;  			} @@ -192,11 +192,11 @@ uint32 BadaFileStream::read(void *ptr, uint32 len) {  				if (bufferLength < len) {  					len = bufferLength;  				} -				memcpy((byte*)ptr, buffer, len); +				memcpy((byte *)ptr, buffer, len);  				result = bufferIndex = len;  			}  		} else { -			result = file->Read((byte*)ptr, len); +			result = file->Read((byte *)ptr, len);  			bufferIndex = bufferLength = 0;  		}  	} else { diff --git a/backends/platform/bada/missing.cpp b/backends/platform/bada/missing.cpp index a5433ec61a..10d45ca4b5 100644 --- a/backends/platform/bada/missing.cpp +++ b/backends/platform/bada/missing.cpp @@ -96,7 +96,7 @@ int sprintf(char *str, const char *format, ...) {  char *strdup(const char *strSource) {  	char *buffer;  	int len = strlen(strSource) + 1; -	buffer = (char*)malloc(len); +	buffer = (char *)malloc(len);  	if (buffer) {  		memcpy(buffer, strSource, len);  	} diff --git a/backends/platform/bada/portdefs.h b/backends/platform/bada/portdefs.h index 7d85a9ec35..813c5acde3 100644 --- a/backends/platform/bada/portdefs.h +++ b/backends/platform/bada/portdefs.h @@ -65,9 +65,9 @@ void stderr_vfprintf(void*, const char *format, va_list ap);  #undef fputs  #undef fflush -#define stderr (void*)0 -#define stdout (void*)1 -#define stdin	 (void*)2 +#define stderr (void *)0 +#define stdout (void *)1 +#define stdin	 (void *)2  #define fputs(str, file)  #define fflush(file)  #define sscanf simple_sscanf diff --git a/backends/platform/dc/audio.cpp b/backends/platform/dc/audio.cpp index 35cb51f349..4f01531486 100644 --- a/backends/platform/dc/audio.cpp +++ b/backends/platform/dc/audio.cpp @@ -59,7 +59,7 @@ void OSystem_Dreamcast::checkSound()    if (n<100)      return; -  _mixer->mixCallback((byte*)temp_sound_buffer, +  _mixer->mixCallback((byte *)temp_sound_buffer,  		      2*SAMPLES_TO_BYTES(n));    if (fillpos+n > curr_ring_buffer_samples) { diff --git a/backends/platform/dc/dcloader.cpp b/backends/platform/dc/dcloader.cpp index 675f7ad8c7..56193c282a 100644 --- a/backends/platform/dc/dcloader.cpp +++ b/backends/platform/dc/dcloader.cpp @@ -385,8 +385,8 @@ void *DLObject::symbol(const char *name)    for (int c = symbol_cnt; c--; s++)      if ((s->st_info>>4 == 1 || s->st_info>>4 == 2) &&         strtab[s->st_name] == '_' && !strcmp(name, strtab+s->st_name+1)) { -      DBG(("=> %p\n", (void*)s->st_value)); -      return (void*)s->st_value; +      DBG(("=> %p\n", (void *)s->st_value)); +      return (void *)s->st_value;      }    seterror("Symbol \"%s\" not found.", name); diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 76658c6590..e886b55869 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -334,8 +334,8 @@ void OSystem_Dreamcast::updateScreenTextures(void)      unsigned short *dst = (unsigned short *)screen_tx[_screen_buffer];      unsigned char *src = screen; -    // while ((*((volatile unsigned int *)(void*)0xa05f810c) & 0x3ff) != 200); -    // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff0000; +    // while ((*((volatile unsigned int *)(void *)0xa05f810c) & 0x3ff) != 200); +    // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff0000;      if (_screenFormat == 0)        for ( int y = 0; y<_screen_h; y++ ) @@ -379,7 +379,7 @@ void OSystem_Dreamcast::updateScreenPolygons(void)    struct polygon_list mypoly;    struct packed_colour_vertex_list myvertex; -  // *((volatile unsigned int *)(void*)0xa05f8040) = 0x00ff00; +  // *((volatile unsigned int *)(void *)0xa05f8040) = 0x00ff00;    mypoly.cmd =      TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST| @@ -395,7 +395,7 @@ void OSystem_Dreamcast::updateScreenPolygons(void)    mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0;    ta_begin_frame(); -  // *((volatile unsigned int *)(void*)0xa05f8040) = 0x0000ff; +  // *((volatile unsigned int *)(void *)0xa05f8040) = 0x0000ff;    ta_commit_list(&mypoly);    myvertex.cmd = TA_CMD_VERTEX; @@ -493,12 +493,12 @@ void OSystem_Dreamcast::updateScreenPolygons(void)      _softkbd.draw(330.0*sin(0.013*_softkbd_motion) - 320.0, 200.0,  		  120-_softkbd_motion); -  // *((volatile unsigned int *)(void*)0xa05f8040) = 0xffff00; +  // *((volatile unsigned int *)(void *)0xa05f8040) = 0xffff00;    drawMouse(_ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_buf, _ms_visible); -  // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff00ff; +  // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff00ff;    ta_commit_frame(); -  // *((volatile unsigned int *)(void*)0xa05f8040) = 0x0; +  // *((volatile unsigned int *)(void *)0xa05f8040) = 0x0;    _last_screen_refresh = Timer();  } diff --git a/backends/platform/ds/arm7/source/main.cpp b/backends/platform/ds/arm7/source/main.cpp index 2e9cacc669..6e714b22fa 100644 --- a/backends/platform/ds/arm7/source/main.cpp +++ b/backends/platform/ds/arm7/source/main.cpp @@ -46,10 +46,10 @@  #include "cartreset_nolibfat.h" -#define TOUCH_CAL_X1 (*(vs16*)0x027FFCD8) -#define TOUCH_CAL_Y1 (*(vs16*)0x027FFCDA) -#define TOUCH_CAL_X2 (*(vs16*)0x027FFCDE) -#define TOUCH_CAL_Y2 (*(vs16*)0x027FFCE0) +#define TOUCH_CAL_X1 (*(vs16 *)0x027FFCD8) +#define TOUCH_CAL_Y1 (*(vs16 *)0x027FFCDA) +#define TOUCH_CAL_X2 (*(vs16 *)0x027FFCDE) +#define TOUCH_CAL_Y2 (*(vs16 *)0x027FFCE0)  #define SCREEN_WIDTH    256  #define SCREEN_HEIGHT   192  s32 TOUCH_WIDTH  = TOUCH_CAL_X2 - TOUCH_CAL_X1; @@ -71,10 +71,10 @@ int temp;  int adpcmBufferNum = 0;  // those are pixel positions of the two points you click when calibrating -#define TOUCH_CNTRL_X1   (*(vu8*)0x027FFCDC) -#define TOUCH_CNTRL_Y1   (*(vu8*)0x027FFCDD) -#define TOUCH_CNTRL_X2   (*(vu8*)0x027FFCE2) -#define TOUCH_CNTRL_Y2   (*(vu8*)0x027FFCE3) +#define TOUCH_CNTRL_X1   (*(vu8 *)0x027FFCDC) +#define TOUCH_CNTRL_Y1   (*(vu8 *)0x027FFCDD) +#define TOUCH_CNTRL_X2   (*(vu8 *)0x027FFCE2) +#define TOUCH_CNTRL_Y2   (*(vu8 *)0x027FFCE3)  ////////////////////////////////////////////////////////////////////// @@ -330,7 +330,7 @@ void performSleep() {  //  int saveInts = REG_IE;  //  REG_IE = (1 << 22) | IRQ_VBLANK;		// Lid open -//  *((u32*) (0x0380FFF8)) = *((u32*) (0x0380FFF8)) | (REG_IE & REG_IF); +//  *((u32 *) (0x0380FFF8)) = *((u32 *) (0x0380FFF8)) | (REG_IE & REG_IF);  //  VBLANK_INTR_WAIT_FLAGS = IRQ_VBLANK; diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp index 0076b302fd..1e8d56615d 100644 --- a/backends/platform/ds/arm9/source/blitters.cpp +++ b/backends/platform/ds/arm9/source/blitters.cpp @@ -222,8 +222,8 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3      u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0;      u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2; -    ((u32*)dest)[0] = d10; -    ((u32*)dest)[1] = d32; +    ((u32 *)dest)[0] = d10; +    ((u32 *)dest)[1] = d32;  }  #else  static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4, @@ -290,7 +290,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3  	gd0 = DIV_BY_5[gd0]; gd1 = DIV_BY_5[gd1];  	bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1];      u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0; -    ((u32*)dest)[0] = d10; +    ((u32 *)dest)[0] = d10;      u32 d2 = 2*s2 + 2*s3 +   s3;      u32 d3 =   s3 + 4*s4; @@ -307,7 +307,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3      bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3];      u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2; -    ((u32*)dest)[1] = d32; +    ((u32 *)dest)[1] = d32;  }  // Can't work in place @@ -377,7 +377,7 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStri  void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette) {  	u16 fastRam[256];      for (size_t i = 0; i < 128; ++i) -        ((u32*)fastRam)[i] = ((const u32*)palette)[i]; +        ((u32 *)fastRam)[i] = ((const u32*)palette)[i];  	for (size_t i = 0; i < 200; ++i) {  		Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam); diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index dfd906d816..cedbdcb167 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -926,7 +926,7 @@ void displayMode16Bit() {  	SUB_BG0_Y0 = 0;  	consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false, true); -//	consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(4), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); +//	consoleInitDefault((u16 *)SCREEN_BASE_BLOCK_SUB(4), (u16 *)CHAR_BASE_BLOCK_SUB(0), 16);  	for (int r = 0; r < 32 * 32; r++) {  		((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r] = buffer[r]; @@ -2414,7 +2414,7 @@ void initHardware() {  	BG_PALETTE[255] = RGB15(31,31,31);//by default font will be rendered with color 255  	//consoleInit() is a lot more flexible but this gets you up and running quick -//	consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(1), 16); +//	consoleInitDefault((u16 *)SCREEN_BASE_BLOCK(0), (u16 *)CHAR_BASE_BLOCK(1), 16);  	//consolePrintSet(0, 6);  	//irqs are nice @@ -2886,7 +2886,7 @@ void dsExceptionHandler() {  	setExceptionHandler(NULL);  	u32	currentMode = getCPSR() & 0x1f; -	u32 thumbState = ((*(u32*)0x027FFD90) & 0x20); +	u32 thumbState = ((*(u32 *)0x027FFD90) & 0x20);  	u32 codeAddress, exceptionAddress = 0; diff --git a/backends/platform/gph/caanoo-bundle.mk b/backends/platform/gph/caanoo-bundle.mk index 8aabca9028..2cf8e62b37 100755 --- a/backends/platform/gph/caanoo-bundle.mk +++ b/backends/platform/gph/caanoo-bundle.mk @@ -14,11 +14,11 @@ caanoo-bundle: $(EXECUTABLE)  	echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" -	$(CP) $(srcdir)/backends/platform/gph/devices/caanoo/scummvm.gpe $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ +	$(CP) $(srcdir)/dists/gph/caanoo/scummvm.gpe $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/  	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/  	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ @@ -45,11 +45,11 @@ caanoo-bundle-debug: $(EXECUTABLE)  	echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" -	$(CP) $(srcdir)/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ +	$(CP) $(srcdir)/dists/gph/caanoo/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe +	$(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/  	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/  	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ diff --git a/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe b/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe deleted file mode 100644 index 63ce193ca8..0000000000 --- a/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM via GDB (so make sure you have a terminal open or serial). -# Oh, and GDB installed of course ;) -gdb --args ./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/caanoo/scummvm.gpe b/backends/platform/gph/devices/caanoo/scummvm.gpe deleted file mode 100644 index 37d0f65d18..0000000000 --- a/backends/platform/gph/devices/caanoo/scummvm.gpe +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/common/README-GPH b/backends/platform/gph/devices/common/README-GPH deleted file mode 100644 index ea196f6649..0000000000 --- a/backends/platform/gph/devices/common/README-GPH +++ /dev/null @@ -1,60 +0,0 @@ -ScummVM - GPH DEVICE SPECIFIC README ------------------------------------------------------------------------- - -Contents: - -    * About the backend/port <#About_the_backendport> -    * Supported audio options <#Supported_audio_options> -    * Credits <#Credits> - ------------------------------------------------------------------------- - -Please refer to the: - -GPH ScummVM Forum: <http://forums.scummvm.org/viewforum.php?f=14> - -WiKi: (Select your device) - -<http://wiki.scummvm.org/index.php/GP2X> -<http://wiki.scummvm.org/index.php/GP2XWiz> -<http://wiki.scummvm.org/index.php/Caanoo> - -for the most current information on the port and any updates to this -documentation. - -The wiki includes detailed instructions on how to use the port and  -control information. - ------------------------------------------------------------------------- -About the backend/port - -This is the readme for the official GPH ScummVM backend (also known as -the GP2X port/GP2XWiz port or Caanoo port). - -This is an SVN test release of ScummVM for GPH devices, it would be -appreciated if this SVN test distribution was not mirrored and that -people be directed to http://scummvm.distant-earth.com/ instead for -updated SVN builds. - -Fully supported official releases of the GPH ScummVM backend are made in -line with main official releases and are avalalble from the ScummVM -downloads page <http://www.scummvm.org/downloads.php> for the GP2X,  -GP2XWiz and Caanoo. - ------------------------------------------------------------------------- -Supported audio options - -Raw audio. -MP3 audio. -OGG Vorbis audio. - -FLAC audio is currently unsupported. - -For best results use uncompressed audio in games. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -Portions of the GPH backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/gph/devices/common/scummvm.ini b/backends/platform/gph/devices/common/scummvm.ini deleted file mode 100644 index c9cce92379..0000000000 --- a/backends/platform/gph/devices/common/scummvm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[info] -name="ScummVM" -path="/scummvm/scummvm.gpe" -icon="/scummvm/scummvm.png" -title="/scummvm/scummvmb.png" diff --git a/backends/platform/gph/devices/common/scummvm.png b/backends/platform/gph/devices/common/scummvm.png Binary files differdeleted file mode 100644 index 128e59efc4..0000000000 --- a/backends/platform/gph/devices/common/scummvm.png +++ /dev/null diff --git a/backends/platform/gph/devices/common/scummvmb.png b/backends/platform/gph/devices/common/scummvmb.png Binary files differdeleted file mode 100644 index 24a27bc0e1..0000000000 --- a/backends/platform/gph/devices/common/scummvmb.png +++ /dev/null diff --git a/backends/platform/gph/devices/gp2x/mmuhack/Makefile b/backends/platform/gph/devices/gp2x/mmuhack/Makefile deleted file mode 100644 index a35d5c2a98..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -TARGET  = mmuhack -INCLUDE = -I/opt/gcc-3.4.4-glibc-2.3.6/arm-open2x-linux/sys-include -CFLAGS  = -O2 -DMODULE -D__KERNEL__ ${INCLUDE} -CC	= arm-open2x-linux-gcc - -all: ${TARGET}.o - -${TARGET}.o: ${TARGET}.c - -clean: -	rm -rf ${TARGET}.o diff --git a/backends/platform/gph/devices/gp2x/mmuhack/README b/backends/platform/gph/devices/gp2x/mmuhack/README deleted file mode 100644 index 6db7d81845..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/README +++ /dev/null @@ -1,116 +0,0 @@ -PLEASE NOTE:  - -The binary object 'mmuhack.o' is stored in the source tree as it is very awkward to -build it manually each time and would require the use of 2 toolchains to do so. - -Notes on how to rebuild from the included source can be found below. - -About ------ - -This is a module for GP2X 2.4 based Linux kernel, created for developers to use in their -programs. - -Normally the upper 32MB is uncached. This means that reads/writes on the memory -are always done via the physical memory modules rather than the much faster -memory built into the processor (called 'cache'). Access to the upper 32MB can -be sped up by Squidge's MMU hack. The easiest way to use the MMU hack is to add -and load the MMU hack kernel module into your program. - -Note: Building this module requries a GP2X 'kernel' toolchain (i.e. GCC 2.95.* -for the GP2X stock, 3.* for Open2X). - -You can't build this module with the GCC 4 based application toolchains. - -Operation ---------- - -When loaded into kernel, this module creates /dev/mmuhack device. Whenever -a program opens that device using open() call, the module traverses all -memory, which was allocated in 0x02000000-0x03ffffff range by the program via -using mmap() system call. While doing that, it marks all encountered memory -as bufferable and cacheable. - -The most common use of this is to remove the framebuffer access bottleneck. -Note that, however, by making the framebuffer cacheable you can cause display -artifacts. This can happen because parts of your framebuffer may stay in CPU -cache and not to be written back to the physical memory. The display -controller only fetches data from the physical memory, so you get incomplete -image (the memory will most likely contain data from previous frame, so these -artifacts are better visible during fade effects). The easy way to fix this -is by using a special ARM Linux system call, which flushes the cache (forces -the CPU to write data in cache to the physical memory (see section "Flushing -the cache")). - -Using this module affects the whole upper memory area. But in some situations -this may be not desirable, for example when using ARM940 core in your program -(ether using 940 libraries like ogg940 and gpu940, or using your custom code, -which needs uncacheable memory for communication and such). If you need part -of your upper memory to be cached, and other part not, you should mmap() that -memory (which you want to be uncached) _after_ doing open("/dev/mmuhack"). -Another way is to modify mmuhack.c to suit your needs and rebuild the module. - - -Usage ------ - -The very first thing to do is to load the kernel module (mmuhack.o) into the -running kernel. But before that you should try to unload mmuhack module, -because other program might have left a different version loaded with -different memory configuration, which may not suit your program. - -system("/sbin/rmmod mmuhack"); -system("/sbin/insmod mmuhack.o"); - -Now you can assume the module is loaded into kernel and open /dev/mmuhack -device. You don't need to worry about previous calls failing, because in that -case open() will simply fail and nothing bad will happen. - -IMPORTANT: you _must_ do the open() call _after_ you initialize your graphics -library or allocate your memory, because it can only work with memory which is -already allocated, it won't affect memory you or your lib allocates after the -open() call. - -int mmufd = open("/dev/mmuhack", O_RDWR); -if(mmufd < 0) -{ -  printf("MMU hack failed"); -} -else -{ -  printf("MMU hack loaded"); -  close(mmufd); -} - -If the above call succeeded, you are all done. -I recommend to unload the module when your program exits, because the other -program may want to load a different mmuhack.o and may fail, because you left -your mmuhack.o loaded (it does not get unloaded automatically on exit). - -system("/sbin/rmmod mmuhack"); - - -Flushing the cache ------------------- - -If using mmuhack.o causes your program to display artifacts (see "Operation" -section for explanation), you will need to flush the CPU cache. This should -be done after finishing every frame and just before flipping your display -buffer/surface. You will need to add flush_uppermem_cache.s file to your -Makefile/project and add a call to flush_uppermem_cache() just before final -framebuffer flip or blit. - -flush_uppermem_cache() has 3 parameters. First param is the start address, -second param is the end address, third one should always be 0. The addresses -should be virtual ones (most often pointers to the start/end of your -framebuffer). Example: - -flush_uppermem_cache(screen_surface->pixels, screen_surface->pixels + 320*240, 0); - - -Credits -------- - -Original idea/implementation: Squidge (this whole thing is also known as squidgehack) -Kernel module: NK -Documentation: notaz diff --git a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h b/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h deleted file mode 100644 index d01548e474..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - -void flush_uppermem_cache(void *start_address, void *end_address, int flags); - -#ifdef __cplusplus -} -#endif diff --git a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s b/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s deleted file mode 100644 index 265908e1fd..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s +++ /dev/null @@ -1,5 +0,0 @@ -.global flush_uppermem_cache @ void *start_address, void *end_address, int flags - -flush_uppermem_cache: -    swi #0x9f0002 -    bx lr diff --git a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c b/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c deleted file mode 100644 index 2e38bdb284..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c +++ /dev/null @@ -1,126 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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. - * - */ - -#include <linux/config.h> -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/miscdevice.h> -#include <asm/memory.h> - -#define MMUHACK_MINOR 225 -#define DEVICE_NAME "mmuhack" - -#if __GNUC__ == 3 -#include <linux/version.h> -static const char __module_kernel_version_gcc3[] __attribute__((__used__)) __attribute__((section(".modinfo"))) = -"kernel_version=" UTS_RELEASE; -#endif - -static ssize_t mmuhack_open(struct inode *inode, struct file *filp) -{ -    unsigned int *pgtable; -	unsigned int *cpt; -    int i, j; -	int ttb; -	int ret = -EFAULT; - -	// get the pointer to the translation table base... -	asm volatile( -		"stmdb sp!, {r0}\n\t" -		"mrc p15, 0, r0, c2, c0, 0\n\t" -		"mov %0, r0\n\t" -		"ldmia sp!, {r0}\n\t": "=r"(ttb) -	); - -	pgtable = __va(ttb); - -    for (i = 0; i < 4096; i ++) if ( (pgtable[i] & 3) == 1 ) { -		cpt = __va(pgtable[i] & 0xfffffc00); - -		for (j = 0; j < 256; j ++) {/* -			if ( (cpt[j] & 0xfe00000f) == 0x02000002 ) { -				// set C and B bits in upper 32MB memory area... -				printk("Set C&B bits %08x\n",cpt[j]); -				cpt[j] |= 0xFFC; -				ret = 0; -			} -					   */ -			if (((cpt[j] & 0xff000000) == 0x02000000) && ((cpt[j] & 12)==0) ) -			{ -				//printk("Set C&B bits %08x\n",cpt[j]); -				cpt[j] |= 0xFFC; -			} -			//if ((a>=0x31 && a<=0x36) && ((cpt[i] & 12)==0)) -			if (((cpt[j] & 0xff000000) == 0x03000000) && ((cpt[j] & 12)==0)) -			{ -				//printk("Set C&B bits %08x\n",cpt[j]); -				//printf("SDL   c and b bits not set, overwriting\n"); -				cpt[j] |= 0xFFC; -			} -		} -    } - -	// drain the write buffer and flush the tlb caches... -	asm volatile( -		"stmdb sp!, {r0}\n\t" -		"mov    r0, #0\n\t" -		"mcr    15, 0, r0, cr7, cr10, 4\n\t" -		"mcr    15, 0, r0, cr8, cr7, 0\n\t" -		"ldmia sp!, {r0}\n\t" -	); - -	if (ret == 0) -		printk("MMU hack applied.\n"); - -	return 0; -} - -static struct file_operations mmuhack_fops = { -    owner:      THIS_MODULE, -    open:       mmuhack_open, -}; - - -static struct miscdevice mmuhack = { -    MMUHACK_MINOR, DEVICE_NAME, &mmuhack_fops -}; - -static int __init mmuhack_init(void) -{ -	misc_register(&mmuhack); -/* -	printk("MMSP2 MMU Hack module.\n"); -*/ -    return 0; -} - -static void __exit mmuhack_exit(void) -{ -    misc_deregister(&mmuhack); -/* -	printk(KERN_ALERT "MMU Hack module removed.\n"); -*/ -} - -module_init(mmuhack_init); -module_exit(mmuhack_exit); diff --git a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o b/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o Binary files differdeleted file mode 100644 index 475f4a54ae..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o +++ /dev/null diff --git a/backends/platform/gph/devices/gp2x/scummvm.gpe b/backends/platform/gph/devices/gp2x/scummvm.gpe deleted file mode 100644 index 51a49f7560..0000000000 --- a/backends/platform/gph/devices/gp2x/scummvm.gpe +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# Remount SD with forced Sync, does this really work? -mount -o sync,remount /dev/mmcsd/disc0/part1 /mnt/sd/ - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc  - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe b/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe deleted file mode 100644 index 63ce193ca8..0000000000 --- a/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM via GDB (so make sure you have a terminal open or serial). -# Oh, and GDB installed of course ;) -gdb --args ./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/gp2xwiz/scummvm.gpe b/backends/platform/gph/devices/gp2xwiz/scummvm.gpe deleted file mode 100644 index 59ff562aeb..0000000000 --- a/backends/platform/gph/devices/gp2xwiz/scummvm.gpe +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc  - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/gp2x-bundle.mk b/backends/platform/gph/gp2x-bundle.mk index 810ff8b8f0..9fcb379e04 100644 --- a/backends/platform/gph/gp2x-bundle.mk +++ b/backends/platform/gph/gp2x-bundle.mk @@ -12,15 +12,15 @@ gp2x-bundle: $(EXECUTABLE)  	echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" -	$(CP) $(srcdir)/backends/platform/gph/devices/gp2x/scummvm.gpe $(bundle_name)/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/ -	$(CP) $(srcdir)/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o $(bundle_name)/ +	$(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name) +	$(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name) +	$(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name) +	$(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name) -	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ -	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ +	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name) +	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)  	$(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/engine-data -	$(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ +	$(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)  	$(STRIP) $(EXECUTABLE) -o $(bundle_name)/$(EXECUTABLE) @@ -39,18 +39,19 @@ gp2x-bundle-debug: $(EXECUTABLE)  	$(MKDIR) "$(bundle_name)"  	$(MKDIR) "$(bundle_name)/saves"  	$(MKDIR) "$(bundle_name)/engine-data" +	$(MKDIR) "$(bundle_name)/lib"  	echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" -	$(CP) $(srcdir)/backends/platform/gph/devices/gp2x/scummvm.gpe $(bundle_name)/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/ -	$(CP) $(srcdir)/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o $(bundle_name)/ +	$(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name) +	$(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name) +	$(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name) +	$(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name) -	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ -	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ +	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name) +	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)  	$(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/engine-data -	$(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ +	$(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)  	$(INSTALL) -c -m 777 $(srcdir)/$(EXECUTABLE) $(bundle_name)/$(EXECUTABLE) diff --git a/backends/platform/gph/gp2xwiz-bundle.mk b/backends/platform/gph/gp2xwiz-bundle.mk index 65e2952fde..4f49850813 100755 --- a/backends/platform/gph/gp2xwiz-bundle.mk +++ b/backends/platform/gph/gp2xwiz-bundle.mk @@ -13,11 +13,11 @@ gp2xwiz-bundle: $(EXECUTABLE)  	echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" -	$(CP) $(srcdir)/backends/platform/gph/devices/gp2xwiz/scummvm.gpe $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ +	$(CP) $(srcdir)/dists/gph/gp2xwiz/scummvm.gpe $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/  	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/  	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ @@ -47,11 +47,11 @@ gp2xwiz-bundle-debug: $(EXECUTABLE)  	echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" -	$(CP) $(srcdir)/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ +	$(CP) $(srcdir)/dists/gph/gp2xwiz/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe +	$(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/  	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/  	$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ diff --git a/backends/platform/iphone/blit.cpp b/backends/platform/iphone/blit.cpp deleted file mode 100644 index 58de22bf75..0000000000 --- a/backends/platform/iphone/blit.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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. - * - */ - -#include "common/scummsys.h" -#include "blit_arm.h" - -void blitLandscapeScreenRect16bpp(uint16 *dst, uint16 *src, int width, int height, int screenWidth, int screenHeight) -{ -	for (int x = width; x > 0; x--) { -		for (int y = height; y > 0; y--) { -			*(dst++) = *src; -			src += screenWidth; -		} -		dst -= screenHeight + height; -		src += 1 - height * screenWidth; -	} -} - -void blitLandscapeScreenRect8bpp(uint16 *dst, byte *src, int width, int height, uint16 *palette, int screenWidth, int screenHeight) -{ -	for (int x = width; x > 0; x--) { -		for (int y = height; y > 0; y--) { -			*(dst++) = palette[*src]; -			src += screenWidth; -		} -		dst -= screenHeight + height; -		src += 1 - height * screenWidth; -	} -} diff --git a/backends/platform/iphone/blit_arm.h b/backends/platform/iphone/blit_arm.h deleted file mode 100644 index 77bb3578ab..0000000000 --- a/backends/platform/iphone/blit_arm.h +++ /dev/null @@ -1,35 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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. - * - */ - -extern "C" void blitLandscapeScreenRect16bpp(uint16 *dst, uint16 *src, -                                            int width, -                                            int height, -                                            int screenWidth, -                                            int screenHeight); - -extern "C" void blitLandscapeScreenRect8bpp(uint16 *dst, -                                            byte *src, -                                            int width, -                                            int height, -                                            uint16 *palette, -                                            int screenWidth, -                                            int screenHeight); diff --git a/backends/platform/iphone/blit_arm.s b/backends/platform/iphone/blit_arm.s deleted file mode 100644 index 04f9a87614..0000000000 --- a/backends/platform/iphone/blit_arm.s +++ /dev/null @@ -1,137 +0,0 @@ -@ ScummVM - Graphic Adventure Engine -@ -@ ScummVM is the legal property of its developers, whose names -@ are too numerous to list here. Please refer to the COPYRIGHT -@ file distributed with this source distribution. -@ -@ 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. -@ -@ @author Robin Watts (robin@wss.co.uk) - -	.text - -	.global	_blitLandscapeScreenRect16bpp -	.global	_blitLandscapeScreenRect8bpp - - -_blitLandscapeScreenRect16bpp: -	@ r0 = dst -	@ r1 = src -	@ r2 = w -	@ r3 = h -	@ <> = _screenWidth -	@ <> = _screenHeight -	mov		r12,r13 -	stmfd	r13!,{r4-r11,r14} -	ldmfd	r12,{r12,r14}		@ r12 = _screenWidth -					@ r14 = _screenHeight -	add	r14,r14,r3		@ r14 = _screenHeight + h -	mvn	r11,#0 -	mla	r11,r3,r12,r11		@ r11= _screenWidth*h-1 -	add	r12,r12,r12 -xloop: -	subs	r4,r3,#5		@ r4 = y = h -	ble		thin -yloop: -	ldrh	r5, [r1],r12		@ r5 = *src    src += _screenWidth -	ldrh	r6, [r1],r12		@ r6 = *src    src += _screenWidth -	ldrh	r7, [r1],r12		@ r7 = *src    src += _screenWidth -	ldrh	r8, [r1],r12		@ r8 = *src    src += _screenWidth -	ldrh	r9, [r1],r12		@ r9 = *src    src += _screenWidth -	ldrh	r10,[r1],r12		@ r10= *src    src += _screenWidth -	subs	r4,r4,#6 -	strh	r5, [r0],#2		@ *dst++ = r5 -	strh	r6, [r0],#2		@ *dst++ = r6 -	strh	r7, [r0],#2		@ *dst++ = r7 -	strh	r8, [r0],#2		@ *dst++ = r8 -	strh	r9, [r0],#2		@ *dst++ = r9 -	strh	r10,[r0],#2		@ *dst++ = r10 -	bgt		yloop -thin: -	adds	r4,r4,#5 -	beq		lineend -thin_loop: -	ldrh	r5,[r1],r12		@ r5 = *src    src += _screenWidth -	subs	r4,r4,#1 -	strh	r5,[r0],#2		@ *dst++ = r5 -	bgt	thin_loop -lineend: -	sub	r0,r0,r14,LSL #1	@ dst -= _screenHeight + h -	sub	r1,r1,r11,LSL #1	@ src += 1-_screenWidth*h -	subs	r2,r2,#1 -	bgt	xloop - -	ldmfd	r13!,{r4-r11,PC} - -_blitLandscapeScreenRect8bpp: -	@ r0 = dst -	@ r1 = src -	@ r2 = w -	@ r3 = h -	@ <> = _palette -	@ <> = _screenWidth -	@ <> = _screenHeight -	mov		r12,r13 -	stmfd	r13!,{r4-r11,r14} -	ldmfd	r12,{r11,r12,r14}	@ r11 = _palette -					@ r12 = _screenWidth -					@ r14 = _screenHeight -	add		r14,r14,r3		@ r14 = _screenHeight + h -	mvn		r6,#0 -	mla		r6,r3,r12,r6		@ r6 = _screenWidth*h-1 -xloop8: -	mov		r4,r3			@ r4 = y = h -	subs	r4,r3,#4		@ r4 = y = h -	ble		thin8 -yloop8: -	ldrb	r5, [r1],r12		@ r5 = *src    src += _screenWidth -	ldrb	r7, [r1],r12		@ r7 = *src    src += _screenWidth -	ldrb	r8, [r1],r12		@ r8 = *src    src += _screenWidth -	ldrb	r9, [r1],r12		@ r9 = *src    src += _screenWidth -	ldrb	r10,[r1],r12		@ r10= *src    src += _screenWidth -	add	r5, r5, r5 -	add	r7, r7, r7 -	add	r8, r8, r8 -	add	r9, r9, r9 -	add	r10,r10,r10 -	ldrh	r5, [r11,r5] -	ldrh	r7, [r11,r7] -	ldrh	r8, [r11,r8] -	ldrh	r9, [r11,r9] -	ldrh	r10,[r11,r10] -	subs	r4,r4,#5 -	strh	r5, [r0],#2		@ *dst++ = r5 -	strh	r7, [r0],#2		@ *dst++ = r7 -	strh	r8, [r0],#2		@ *dst++ = r8 -	strh	r9, [r0],#2		@ *dst++ = r9 -	strh	r10,[r0],#2		@ *dst++ = r10 -	bgt	yloop8 -thin8: -	adds	r4,r4,#4 -	beq		lineend8 -thin_loop8: -	ldrb	r5,[r1],r12		@ r5 = *src    src += _screenWidth -	add	r5,r5,r5 -	ldrh	r5,[r11,r5] -	subs	r4,r4,#1 -	strh	r5,[r0],#2		@ *dst++ = r5 -	bgt	thin_loop8 -lineend8: -	sub	r0,r0,r14,LSL #1	@ dst -= _screenHeight + h -	sub	r1,r1,r6		@ src += 1-_screenWidth*h -	subs	r2,r2,#1 -	bgt	xloop8 - -	ldmfd	r13!,{r4-r11,PC} diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 0cbcb77bcb..6e97d9d853 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -20,6 +20,10 @@   *   */ +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H + +#include "graphics/surface.h"  enum InputEvent {  	kInputMouseDown, @@ -41,43 +45,52 @@ enum ScreenOrientation {  	kScreenOrientationFlippedLandscape  }; -typedef enum -{ +enum UIViewSwipeDirection {  	kUIViewSwipeUp = 1,  	kUIViewSwipeDown = 2,  	kUIViewSwipeLeft = 4,  	kUIViewSwipeRight = 8 -} UIViewSwipeDirection; +}; -#ifdef IPHONE_OFFICIAL -void iphone_main(int argc, char **argv); -#endif +enum GraphicsModes { +	kGraphicsModeLinear = 0, +	kGraphicsModeNone = 1 +}; -// We need this to be able to call functions from/in Objective-C. -#ifdef  __cplusplus -extern "C" { -#endif +struct VideoContext { +	VideoContext() : screenWidth(), screenHeight(), overlayVisible(false), +	                 overlayWidth(), overlayHeight(), mouseX(), mouseY(), +	                 mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(), +	                 mouseIsVisible(), graphicsMode(kGraphicsModeLinear), shakeOffsetY() { +	} -// On the C++ side -#ifndef IPHONE_OFFICIAL -void iphone_main(int argc, char *argv[]); -#endif +	// Game screen state +	uint screenWidth, screenHeight; +	Graphics::Surface screenTexture; + +	// Overlay state +	bool overlayVisible; +	uint overlayWidth, overlayHeight; +	Graphics::Surface overlayTexture; + +	// Mouse cursor state +	uint mouseX, mouseY; +	int mouseHotspotX, mouseHotspotY; +	uint mouseWidth, mouseHeight; +	bool mouseIsVisible; + +	// Misc state +	GraphicsModes graphicsMode; +	int shakeOffsetY; +};  // On the ObjC side -void iPhone_updateScreen(int mouseX, int mouseY); -void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2); -void iPhone_updateOverlayRect(unsigned short* screen, int x1, int y1, int x2, int y2); -void iPhone_initSurface(int width, int height); -bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY); -const char* iPhone_getDocumentsDir(); +void iPhone_updateScreen(); +bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); +const char *iPhone_getDocumentsDir();  bool iPhone_isHighResDevice(); -int iPhone_getScreenHeight(); -int iPhone_getScreenWidth(); -void iPhone_enableOverlay(int state); -void iPhone_setMouseCursor(short* buffer, int width, int height); +void iPhone_setMouseCursor(unsigned short *buffer);  uint getSizeNextPOT(uint size); -#ifdef __cplusplus -}  #endif diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h index eecad09398..2d1238c92f 100644 --- a/backends/platform/iphone/iphone_keyboard.h +++ b/backends/platform/iphone/iphone_keyboard.h @@ -20,17 +20,22 @@   *   */ -#import <UIKit/UIKit.h> -#import <UIKit/UITextView.h> +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H + +#include <UIKit/UIKit.h> +#include <UIKit/UITextView.h>  @interface SoftKeyboard : UIView {  	id inputDelegate; -	UITextView* inputView; +	UITextView *inputView;  }  - (id)initWithFrame:(CGRect)frame; -- (UITextView*)inputView; +- (UITextView *)inputView;  - (void)setInputDelegate:(id)delegate;  - (void)handleKeyPress:(unichar)c;  @end + +#endif diff --git a/backends/platform/iphone/iphone_keyboard.m b/backends/platform/iphone/iphone_keyboard.mm index 1624d02977..b00930ab31 100644 --- a/backends/platform/iphone/iphone_keyboard.m +++ b/backends/platform/iphone/iphone_keyboard.mm @@ -20,7 +20,7 @@   *   */ -#import "iphone_keyboard.h" +#include "iphone_keyboard.h"  @interface UITextInputTraits  - (void)setAutocorrectionType:(int)type; @@ -29,17 +29,17 @@  @end  @interface TextInputHandler : UITextView { -	SoftKeyboard* softKeyboard; +	SoftKeyboard *softKeyboard;  } -- (id)initWithKeyboard:(SoftKeyboard*)keyboard; +- (id)initWithKeyboard:(SoftKeyboard *)keyboard;  @end  @implementation TextInputHandler -- (id)initWithKeyboard:(SoftKeyboard*)keyboard; { +- (id)initWithKeyboard:(SoftKeyboard *)keyboard; {  	self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)];  	softKeyboard = keyboard; @@ -80,7 +80,7 @@  	return self;  } -- (UITextView*)inputView { +- (UITextView *)inputView {  	return inputView;  } diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.mm index c2ec328bf5..20406e6342 100644 --- a/backends/platform/iphone/iphone_main.m +++ b/backends/platform/iphone/iphone_main.mm @@ -20,38 +20,41 @@   *   */ -#import <UIKit/UIKit.h> -#import <Foundation/NSThread.h> +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include <UIKit/UIKit.h> +#include <Foundation/NSThread.h>  #include "iphone_video.h"  void iphone_main(int argc, char *argv[]);  @interface iPhoneMain : UIApplication { -	UIWindow* _window; -	iPhoneView* _view; +	UIWindow *_window; +	iPhoneView *_view;  } -- (void) mainLoop: (id)param; -- (iPhoneView*) getView; -- (UIWindow*) getWindow; +- (void)mainLoop:(id)param; +- (iPhoneView *)getView; +- (UIWindow *)getWindow;  - (void)didRotate:(NSNotification *)notification;  @end  static int gArgc; -static char** gArgv; +static char **gArgv; -int main(int argc, char** argv) { +int main(int argc, char **argv) {  	gArgc = argc;  	gArgv = argv; -    NSAutoreleasePool *autoreleasePool = [ -        [ NSAutoreleasePool alloc ] init -    ]; +	NSAutoreleasePool *autoreleasePool = [ +		[NSAutoreleasePool alloc] init +	]; -    int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); -    [ autoreleasePool release ]; -    return returnCode; +	int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); +	[autoreleasePool release]; +	return returnCode;  }  @implementation iPhoneMain @@ -63,14 +66,14 @@ int main(int argc, char** argv) {  	return self;  } -- (void) mainLoop: (id)param { +- (void)mainLoop:(id)param {  	[[NSAutoreleasePool alloc] init];  	iphone_main(gArgc, gArgv);  	exit(0);  } -- (iPhoneView*) getView { +- (iPhoneView *)getView {  	return _view;  } @@ -78,38 +81,36 @@ int main(int argc, char** argv) {  	CGRect  rect = [[UIScreen mainScreen] bounds];  	// hide the status bar -    [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; -    [application setStatusBarHidden:YES animated:YES]; +	[application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; +	[application setStatusBarHidden:YES animated:YES];  	_window = [[UIWindow alloc] initWithFrame:rect];  	[_window retain]; -	_view = [[iPhoneView alloc] initWithFrame: rect]; +	_view = [[iPhoneView alloc] initWithFrame:rect];  	_view.multipleTouchEnabled = YES; -	[_window setContentView: _view]; +	[_window setContentView:_view];    	[_window addSubview:_view];  	[_window makeKeyAndVisible];  	[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];  	[[NSNotificationCenter defaultCenter] addObserver:self -											 selector:@selector(didRotate:) -												 name:@"UIDeviceOrientationDidChangeNotification" object:nil]; +	                                         selector:@selector(didRotate:) +	                                             name:@"UIDeviceOrientationDidChangeNotification" +	                                           object:nil];  	[NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil];  } -- (void)applicationDidResume -{ +- (void)applicationDidResume {  } -- (void)applicationWillSuspend -{ +- (void)applicationWillSuspend {  } -- (void)applicationWillTerminate -{ +- (void)applicationWillTerminate {  }  - (void)applicationSuspend:(struct __GSEvent *)event { @@ -122,14 +123,14 @@ int main(int argc, char** argv) {  	// Workaround, need to "hide" and unhide the statusbar to properly remove it,  	// since the Springboard has put it back without apparently flagging our application. -    [self setStatusBarHidden:YES animated:YES]; -    [self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; -    [self setStatusBarHidden:YES animated:YES]; +	[self setStatusBarHidden:YES animated:YES]; +	[self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; +	[self setStatusBarHidden:YES animated:YES];  }  - (void)didRotate:(NSNotification *)notification { -	int screenOrientation = [[UIDevice currentDevice] orientation]; -	[_view deviceOrientationChanged: screenOrientation]; +	UIDeviceOrientation screenOrientation = [[UIDevice currentDevice] orientation]; +	[_view deviceOrientationChanged:screenOrientation];  }  - (UIWindow*) getWindow { diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 223f025978..1d9d7e7d35 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -20,48 +20,52 @@   *   */ -#ifndef _IPHONE_VIDEO__H -#define _IPHONE_VIDEO__H +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H -#import <UIKit/UIKit.h> -#import <Foundation/Foundation.h> -#import <QuartzCore/QuartzCore.h> +#include <UIKit/UIKit.h> +#include <Foundation/Foundation.h> +#include <QuartzCore/QuartzCore.h> -#import <OpenGLES/EAGL.h> -#import <OpenGLES/ES1/gl.h> -#import <OpenGLES/ES1/glext.h> +#include <OpenGLES/EAGL.h> +#include <OpenGLES/ES1/gl.h> +#include <OpenGLES/ES1/glext.h> -#import "iphone_keyboard.h" +#include "iphone_keyboard.h" +#include "iphone_common.h" -@interface iPhoneView : UIView -{ -	void* _screenSurface; -	NSMutableArray* _events; -	SoftKeyboard* _keyboardView; -	CALayer* _screenLayer; +@interface iPhoneView : UIView { +	VideoContext _videoContext; -	int _widthOffset; -	int _heightOffset; +	NSMutableArray *_events; +	SoftKeyboard *_keyboardView; -	EAGLContext* _context; +	EAGLContext *_context;  	GLuint _viewRenderbuffer;  	GLuint _viewFramebuffer; -	GLint _backingWidth; -	GLint _backingHeight; -	GLint _visibleWidth; -	GLint _visibleHeight;  	GLuint _screenTexture;  	GLuint _overlayTexture;  	GLuint _mouseCursorTexture; + +	UIDeviceOrientation _orientation; + +	GLfloat _gameScreenVertCoords[4 * 2]; +	GLfloat _gameScreenTexCoords[4 * 2]; + +	GLfloat _overlayVertCoords[4 * 2]; +	GLfloat _overlayTexCoords[4 * 2];  }  - (id)initWithFrame:(struct CGRect)frame; -- (void)drawRect:(CGRect)frame; +- (VideoContext *)getVideoContext; -- (void *)getSurface; +- (void)drawRect:(CGRect)frame;  - (void)initSurface; +- (void)setViewTransformation; + +- (void)setGraphicsMode;  - (void)updateSurface;  - (void)updateMainSurface; @@ -69,11 +73,11 @@  - (void)updateMouseSurface;  - (void)clearColorBuffer; --(void)updateMouseCursor; +- (void)updateMouseCursor;  - (id)getEvent; -- (void)deviceOrientationChanged:(int)orientation; +- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation;  - (void)applicationSuspend; @@ -81,6 +85,6 @@  @end +extern iPhoneView *g_iPhoneViewInstance; - -#endif /* _IPHONE_VIDEO__H */ +#endif diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m deleted file mode 100644 index eb16676428..0000000000 --- a/backends/platform/iphone/iphone_video.m +++ /dev/null @@ -1,756 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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. - * - */ - -#include "iphone_video.h" -#include "iphone_common.h" - -static iPhoneView *sharedInstance = nil; -static int _width = 0; -static int _height = 0; -static int _fullWidth; -static int _fullHeight; -static CGRect _screenRect; - -static char* _textureBuffer = 0; -static int _textureWidth = 0; -static int _textureHeight = 0; - -static char* _overlayTexBuffer = 0; -static int _overlayTexWidth = 0; -static int _overlayTexHeight = 0; -static int _overlayWidth = 0; -static int _overlayHeight = 0; -static float _overlayPortraitRatio = 1.0f; - -NSLock* _lock = nil; -static int _needsScreenUpdate = 0; -static int _overlayIsEnabled = 0; - -static UITouch* _firstTouch = NULL; -static UITouch* _secondTouch = NULL; - -static short* _mouseCursor = NULL; -static int _mouseCursorHeight = 0; -static int _mouseCursorWidth = 0; -static int _mouseX = 0; -static int _mouseY = 0; - -// static long lastTick = 0; -// static int frames = 0; - -#define printOpenGLError() printOglError(__FILE__, __LINE__) - -int printOglError(const char *file, int line) -{ -	int     retCode = 0; - -	// returns 1 if an OpenGL error occurred, 0 otherwise. -	GLenum glErr = glGetError(); -	while( glErr != GL_NO_ERROR) -	{ -		fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line ); -		retCode = 1; -		glErr = glGetError(); -	} -	return retCode; -} - -void iPhone_setMouseCursor(short* buffer, int width, int height) { -	_mouseCursor = buffer; - -	_mouseCursorWidth = width; -	_mouseCursorHeight = height; - -	[sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; -} - -void iPhone_enableOverlay(int state) { -	_overlayIsEnabled = state; - -	[sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; -} - -int iPhone_getScreenHeight() { -	return _overlayHeight; -} - -int iPhone_getScreenWidth() { -	return _overlayWidth; -} - -bool iPhone_isHighResDevice() { -	return _fullHeight > 480; -} - -void iPhone_updateScreen(int mouseX, int mouseY) { -	//printf("Mouse: (%i, %i)\n", mouseX, mouseY); - -	//_mouseX = _overlayHeight - (float)mouseX / _width * _overlayHeight; -	//_mouseY = (float)mouseY / _height * _overlayWidth; - -	//_mouseX = _overlayHeight - mouseX; -	//_mouseY = mouseY; - -	_mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _overlayHeight; -	_mouseY = mouseY / (float)_overlayHeight * _overlayWidth; - -	if (!_needsScreenUpdate) { -		_needsScreenUpdate = 1; -		[sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; -	} -} - -void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2) { -	int y; -	for (y = y1; y < y2; ++y) -		memcpy(&_textureBuffer[(y * _textureWidth + x1 )* 2], &screen[y * _width + x1], (x2 - x1) * 2); -} - -void iPhone_updateOverlayRect(unsigned short* screen, int x1, int y1, int x2, int y2) { -	int y; -	//printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); -	for (y = y1; y < y2; ++y) -		memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1 )* 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); -} - -void iPhone_initSurface(int width, int height) { -	_width = width; -	_height = height; -	[sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; -} - -bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY) { -	id event = [sharedInstance getEvent]; -	if (event == nil) { -		return false; -	} - -	id type = [event objectForKey:@"type"]; - -	if (type == nil) { -		printf("fetchEvent says: No type!\n"); -		return false; -	} - -	*outEvent = [type intValue]; -	*outX = [[event objectForKey:@"x"] floatValue]; -	*outY = [[event objectForKey:@"y"] floatValue]; -	return true; -} - -uint getSizeNextPOT(uint size) { -    if ((size & (size - 1)) || !size) { -        int log = 0; - -        while (size >>= 1) -            ++log; - -        size = (2 << log); -    } - -    return size; -} - -const char* iPhone_getDocumentsDir() { -	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); -	NSString *documentsDirectory = [paths objectAtIndex:0]; -	return [documentsDirectory UTF8String]; -} - -bool getLocalMouseCoords(CGPoint *point) { -	if (_overlayIsEnabled) { -		point->x = point->x / _overlayHeight; -		point->y = point->y / _overlayWidth; -	} else { -		if (point->x < _screenRect.origin.x || point->x >= _screenRect.origin.x + _screenRect.size.width || -			point->y < _screenRect.origin.y || point->y >= _screenRect.origin.y + _screenRect.size.height) { -				return false; -		} - -		point->x = (point->x - _screenRect.origin.x) / _screenRect.size.width; -		point->y = (point->y - _screenRect.origin.y) / _screenRect.size.height; -	} - -	return true; -} - - -@implementation iPhoneView - -+ (Class) layerClass -{ -	return [CAEAGLLayer class]; -} - -- (id)initWithFrame:(struct CGRect)frame { -	self = [super initWithFrame: frame]; - -	if([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) -	{ -		if([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) -		{ -			//self.contentScaleFactor = [[UIScreen mainScreen] scale]; -		} -	} - -	_fullWidth = frame.size.width; -	_fullHeight = frame.size.height; -	_screenLayer = nil; - -	sharedInstance = self; - -	_lock = [NSLock new]; -	_keyboardView = nil; -	_context = nil; -	_screenTexture = 0; -	_overlayTexture = 0; -	_mouseCursorTexture = 0; - -	return self; -} - --(void) dealloc { -	[super dealloc]; - -	if (_keyboardView != nil) { -		[_keyboardView dealloc]; -	} - -	if (_screenTexture) -		free(_textureBuffer); - -	free(_overlayTexBuffer); -} - -- (void *)getSurface { -	return _screenSurface; -} - -- (void)drawRect:(CGRect)frame { -	// if (lastTick == 0) { -	//	lastTick = time(0); -	// } -	// -	// frames++; -	// if (time(0) > lastTick) { -	//	lastTick = time(0); -	//	printf("FPS: %i\n", frames); -	//	frames = 0; -	// } -} - -- (void)updateSurface { -	if (!_needsScreenUpdate) { -		return; -	} -	_needsScreenUpdate = 0; - -	if (_overlayIsEnabled) { -		glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); -	} - -	[self updateMainSurface]; - -	if (_overlayIsEnabled) { -		[self updateOverlaySurface]; -		[self updateMouseSurface]; -	} - -	glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); -	[_context presentRenderbuffer:GL_RENDERBUFFER_OES]; - -} - --(void)updateMouseCursor { -	if (_mouseCursorTexture == 0) { -		glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); -		glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); -		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); -		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); -	} - -	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_mouseCursorWidth), getSizeNextPOT(_mouseCursorHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); - -	free(_mouseCursor); -	_mouseCursor = NULL; -} - -- (void)updateMainSurface { -	GLfloat vertices[] = { -		0.0f + _heightOffset, 0.0f + _widthOffset, -		_visibleWidth - _heightOffset, 0.0f + _widthOffset, -		0.0f + _heightOffset,  _visibleHeight - _widthOffset, -		_visibleWidth - _heightOffset,  _visibleHeight - _widthOffset -	}; - -	float texWidth = _width / (float)_textureWidth; -	float texHeight = _height / (float)_textureHeight; - -	const GLfloat texCoords[] = { -		texWidth, 0.0f, -		0.0f, 0.0f, -		texWidth, texHeight, -		0.0f, texHeight -	}; - -	glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); -	glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); - -	glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); - -	// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases -	// due to the iPhone internals having to convert the whole texture back from its internal format when used. -	// In the future we could use several tiled textures instead. -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _textureWidth, _textureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _textureBuffer); printOpenGLError(); -	glDisable(GL_BLEND); -	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)updateOverlaySurface { -	GLfloat vertices[] = { -		0.0f, 0.0f, -		_overlayHeight, 0.0f, -		0.0f,  _overlayWidth * _overlayPortraitRatio, -		_overlayHeight,  _overlayWidth * _overlayPortraitRatio -	}; - -	float texWidth = _overlayWidth / (float)_overlayTexWidth; -	float texHeight = _overlayHeight / (float)_overlayTexHeight; - -	const GLfloat texCoords[] = { -		texWidth, 0.0f, -		0.0f, 0.0f, -		texWidth, texHeight, -		0.0f, texHeight -	}; - -	glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); -	glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); - -	glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); -	glEnable(GL_BLEND); -	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)updateMouseSurface { - -	int width = _mouseCursorWidth / (float)_backingWidth * _backingHeight; -	int height = _mouseCursorHeight / (float)_backingHeight * _backingWidth; - -	GLfloat vertices[] = { -		_mouseX, _mouseY, -		_mouseX + height, _mouseY, -		_mouseX, _mouseY + width, -		_mouseX + height,  _mouseY + width -	}; - -	//printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight); - -	float texWidth = _mouseCursorWidth / (float)getSizeNextPOT(_mouseCursorWidth); -	float texHeight = _mouseCursorHeight / (float)getSizeNextPOT(_mouseCursorHeight); - -	const GLfloat texCoords[] = { -		texWidth, 0.0f, -		0.0f, 0.0f, -		texWidth, texHeight, -		0.0f, texHeight -	}; - -	glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); -	glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); - -	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); -	glEnable(GL_BLEND); -	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)initSurface { -	_textureWidth = getSizeNextPOT(_width); -	_textureHeight = getSizeNextPOT(_height); - -	UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; - -	//printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _textureWidth, _textureHeight); - -	if (_context == nil) { -		orientation = UIDeviceOrientationLandscapeRight; -		CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer; - -		eaglLayer.opaque = YES; -		eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: -										[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; - -		_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; -		if (!_context || [EAGLContext setCurrentContext:_context]) { -			glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); -			glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); - -			glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); -			glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); -			[_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer]; -			glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - -			glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_backingWidth); printOpenGLError(); -			glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_backingHeight); printOpenGLError(); - -			if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { -				NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); -				return; -			} - -			_overlayHeight = _backingWidth; -			_overlayWidth = _backingHeight; -			_overlayTexWidth = getSizeNextPOT(_overlayHeight); -			_overlayTexHeight = getSizeNextPOT(_overlayWidth); - -			int textureSize = _overlayTexWidth * _overlayTexHeight * 2; -			_overlayTexBuffer = (char *)malloc(textureSize); -			memset(_overlayTexBuffer, 0, textureSize); - -			glViewport(0, 0, _backingWidth, _backingHeight); printOpenGLError(); -			glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); - -			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - -			glEnable(GL_TEXTURE_2D); printOpenGLError(); -			glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); -			glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); -		} -	} - -	glMatrixMode(GL_PROJECTION); -	glLoadIdentity(); - -	if (orientation ==  UIDeviceOrientationLandscapeRight) { -		glRotatef(-90, 0, 0, 1); printOpenGLError(); -	} else if (orientation == UIDeviceOrientationLandscapeLeft) { -		glRotatef(90, 0, 0, 1); printOpenGLError(); -	} else { -		glRotatef(180, 0, 0, 1); printOpenGLError(); -	} - -	glOrthof(0, _backingWidth, 0, _backingHeight, 0, 1); printOpenGLError(); - -	if (_screenTexture > 0) { -		glDeleteTextures(1, &_screenTexture); printOpenGLError(); -	} - -	glGenTextures(1, &_screenTexture); printOpenGLError(); -	glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); -	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); -	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); - -	if (_overlayTexture > 0) { -		glDeleteTextures(1, &_overlayTexture); printOpenGLError(); -	} - -	glGenTextures(1, &_overlayTexture); printOpenGLError(); -	glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); -	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); -	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); - -	if (_textureBuffer) { -		free(_textureBuffer); -	} - -	int textureSize = _textureWidth * _textureHeight * 2; -	_textureBuffer = (char*)malloc(textureSize); -	memset(_textureBuffer, 0, textureSize); - -	glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - -	[self clearColorBuffer]; - -	if (_keyboardView != nil) { -		[_keyboardView removeFromSuperview]; -		[[_keyboardView inputView] removeFromSuperview]; -	} - -	if (orientation == UIDeviceOrientationLandscapeLeft || orientation ==  UIDeviceOrientationLandscapeRight) { -		_visibleHeight = _backingHeight; -		_visibleWidth = _backingWidth; - -		float ratioDifference = ((float)_height / (float)_width) / ((float)_fullWidth / (float)_fullHeight); -		int rectWidth, rectHeight; -		if (ratioDifference < 1.0f) { -			rectWidth = _fullWidth * ratioDifference; -			rectHeight = _fullHeight; -			_widthOffset = (_fullWidth - rectWidth) / 2; -			_heightOffset = 0; -		} else { -			rectWidth = _fullWidth; -			rectHeight = _fullHeight / ratioDifference; -			_heightOffset = (_fullHeight - rectHeight) / 2; -			_widthOffset = 0; -		} - -		//printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth, rectHeight); -		_screenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth, rectHeight); -		_overlayPortraitRatio = 1.0f; -	} else { -		float ratio = (float)_height / (float)_width; -		int height = _fullWidth * ratio; -		//printf("Making rect (%u, %u)\n", _fullWidth, height); -		_screenRect = CGRectMake(0, 0, _fullWidth - 1, height - 1); - -		_visibleHeight = height; -		_visibleWidth = _backingWidth; -		_heightOffset = 0.0f; -		_widthOffset = 0.0f; - -		CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); -		if (_keyboardView == nil) { -			_keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; -			[_keyboardView setInputDelegate:self]; -		} - -		[self addSubview:[_keyboardView inputView]]; -		[self addSubview: _keyboardView]; -		[[_keyboardView inputView] becomeFirstResponder]; -		_overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; -	} -} - -- (void)clearColorBuffer { -	// The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. -	int clearCount = 5; -	while (clearCount-- > 0) { -		glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); -		[_context presentRenderbuffer:GL_RENDERBUFFER_OES]; -	} -} - -- (id)getEvent { -	if (_events == nil || [_events count] == 0) { -		return nil; -	} - - -	id event = [_events objectAtIndex: 0]; - -	[_events removeObjectAtIndex: 0]; - -	return event; -} - -- (void)addEvent:(NSDictionary*)event { - -	if (_events == nil) -		_events = [[NSMutableArray alloc] init]; - -	[_events addObject: event]; -} - -- (void)deviceOrientationChanged:(int)orientation { -	[self addEvent: -		[[NSDictionary alloc] initWithObjectsAndKeys: -		 [NSNumber numberWithInt:kInputOrientationChanged], @"type", -		 [NSNumber numberWithFloat:(float)orientation], @"x", -		 [NSNumber numberWithFloat:0], @"y", -		 nil -		] -	]; -} - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ -	NSSet *allTouches = [event allTouches]; - -	switch ([allTouches count]) { -		case 1: -		{ -			UITouch *touch = [touches anyObject]; -			CGPoint point = [touch locationInView:self]; -			if (!getLocalMouseCoords(&point)) -				return; - -			_firstTouch = touch; -			[self addEvent: -			 [[NSDictionary alloc] initWithObjectsAndKeys: -			  [NSNumber numberWithInt:kInputMouseDown], @"type", -			  [NSNumber numberWithFloat:point.x], @"x", -			  [NSNumber numberWithFloat:point.y], @"y", -			  nil -			  ] -			 ]; -			break; -		} -		case 2: -		{ -			UITouch *touch = [touches anyObject]; -			CGPoint point = [touch locationInView:self]; -			if (!getLocalMouseCoords(&point)) -				return; - -			_secondTouch = touch; -			[self addEvent: -			 [[NSDictionary alloc] initWithObjectsAndKeys: -			  [NSNumber numberWithInt:kInputMouseSecondDown], @"type", -			  [NSNumber numberWithFloat:point.x], @"x", -			  [NSNumber numberWithFloat:point.y], @"y", -			  nil -			  ] -			 ]; -			break; -		} -	} -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ -	//NSSet *allTouches = [event allTouches]; - -	for (UITouch* touch in touches) { -		if (touch == _firstTouch) { - -			CGPoint point = [touch locationInView:self]; -			if (!getLocalMouseCoords(&point)) -				return; - -			[self addEvent: -			 [[NSDictionary alloc] initWithObjectsAndKeys: -			  [NSNumber numberWithInt:kInputMouseDragged], @"type", -			  [NSNumber numberWithFloat:point.x], @"x", -			  [NSNumber numberWithFloat:point.y], @"y", -			  nil -			  ] -			 ]; - -		} else if (touch == _secondTouch) { - -			CGPoint point = [touch locationInView:self]; -			if (!getLocalMouseCoords(&point)) -				return; - -			[self addEvent: -			 [[NSDictionary alloc] initWithObjectsAndKeys: -			  [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", -			  [NSNumber numberWithFloat:point.x], @"x", -			  [NSNumber numberWithFloat:point.y], @"y", -			  nil -			  ] -			 ]; - -		} -	} -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ -	NSSet *allTouches = [event allTouches]; - -	switch ([allTouches count]) { -		case 1: -		{ -			UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; -			CGPoint point = [touch locationInView:self]; -			if (!getLocalMouseCoords(&point)) -				return; - -			[self addEvent: -			 [[NSDictionary alloc] initWithObjectsAndKeys: -			  [NSNumber numberWithInt:kInputMouseUp], @"type", -			  [NSNumber numberWithFloat:point.x], @"x", -			  [NSNumber numberWithFloat:point.y], @"y", -			  nil -			  ] -			 ]; -			break; -		} -		case 2: -		{ -			UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; -			CGPoint point = [touch locationInView:self]; -			if (!getLocalMouseCoords(&point)) -				return; - -			[self addEvent: -			 [[NSDictionary alloc] initWithObjectsAndKeys: -			  [NSNumber numberWithInt:kInputMouseSecondUp], @"type", -			  [NSNumber numberWithFloat:point.x], @"x", -			  [NSNumber numberWithFloat:point.y], @"y", -			  nil -			  ] -			 ]; -			break; -		} -	} -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - -} - -- (void)handleKeyPress:(unichar)c { -	[self addEvent: -		[[NSDictionary alloc] initWithObjectsAndKeys: -		 [NSNumber numberWithInt:kInputKeyPressed], @"type", -		 [NSNumber numberWithFloat:(float)c], @"x", -		 [NSNumber numberWithFloat:0], @"y", -		 nil -		] -	]; -} - -- (BOOL)canHandleSwipes { -	return TRUE; -} - -- (int)swipe:(int)num withEvent:(struct __GSEvent *)event { -	//printf("swipe: %i\n", num); - -	[self addEvent: -		[[NSDictionary alloc] initWithObjectsAndKeys: -		 [NSNumber numberWithInt:kInputSwipe], @"type", -		 [NSNumber numberWithFloat:(float)num], @"x", -		 [NSNumber numberWithFloat:0], @"y", -		 nil -		] -	]; -} - -- (void)applicationSuspend { -	[self addEvent: -		[[NSDictionary alloc] initWithObjectsAndKeys: -		 [NSNumber numberWithInt:kInputApplicationSuspended], @"type", -		 [NSNumber numberWithFloat:0], @"x", -		 [NSNumber numberWithFloat:0], @"y", -		 nil -		] -	]; -} - -- (void)applicationResume { -	[self addEvent: -		[[NSDictionary alloc] initWithObjectsAndKeys: -		 [NSNumber numberWithInt:kInputApplicationResumed], @"type", -		 [NSNumber numberWithFloat:0], @"x", -		 [NSNumber numberWithFloat:0], @"y", -		 nil -		] -	]; -} - -@end diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm new file mode 100644 index 0000000000..cdd8d68b31 --- /dev/null +++ b/backends/platform/iphone/iphone_video.mm @@ -0,0 +1,853 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "iphone_video.h" + +#include "graphics/colormasks.h" + +iPhoneView *g_iPhoneViewInstance = nil; +static int _fullWidth; +static int _fullHeight; +static CGRect _gameScreenRect; + +static CGRect _overlayRect; + +static int _needsScreenUpdate = 0; + +static UITouch *_firstTouch = NULL; +static UITouch *_secondTouch = NULL; + +static unsigned short *_mouseCursor = NULL; + +static GLint _renderBufferWidth; +static GLint _renderBufferHeight; + +static int _scaledShakeOffsetY; + +#if 0 +static long lastTick = 0; +static int frames = 0; +#endif + +#define printOpenGLError() printOglError(__FILE__, __LINE__) + +int printOglError(const char *file, int line) { +	int retCode = 0; + +	// returns 1 if an OpenGL error occurred, 0 otherwise. +	GLenum glErr = glGetError(); +	while (glErr != GL_NO_ERROR) { +		fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line); +		retCode = 1; +		glErr = glGetError(); +	} +	return retCode; +} + +void iPhone_setMouseCursor(unsigned short *buffer) { +	_mouseCursor = buffer; +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; +} + +bool iPhone_isHighResDevice() { +	return _fullHeight > 480; +} + +void iPhone_updateScreen() { +	//printf("Mouse: (%i, %i)\n", mouseX, mouseY); +	if (!_needsScreenUpdate) { +		_needsScreenUpdate = 1; +		[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; +	} +} + +bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { +	id event = [g_iPhoneViewInstance getEvent]; +	if (event == nil) { +		return false; +	} + +	id type = [event objectForKey:@"type"]; + +	if (type == nil) { +		printf("fetchEvent says: No type!\n"); +		return false; +	} + +	*outEvent = [type intValue]; +	*outX = [[event objectForKey:@"x"] intValue]; +	*outY = [[event objectForKey:@"y"] intValue]; +	return true; +} + +uint getSizeNextPOT(uint size) { +	if ((size & (size - 1)) || !size) { +		int log = 0; + +		while (size >>= 1) +			++log; + +		size = (2 << log); +	} + +	return size; +} + +const char *iPhone_getDocumentsDir() { +	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); +	NSString *documentsDirectory = [paths objectAtIndex:0]; +	return [documentsDirectory UTF8String]; +} + +@implementation iPhoneView + ++ (Class)layerClass { +	return [CAEAGLLayer class]; +} + +- (VideoContext *)getVideoContext { +	return &_videoContext; +} + +- (void)createContext { +	CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + +	eaglLayer.opaque = YES; +	eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: +	                                [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; + +	_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + +	// In case creating the OpenGL ES context failed, we will error out here. +	if (_context == nil) { +		fprintf(stderr, "Could not create OpenGL ES context\n"); +		exit(-1); +	} + +	if ([EAGLContext setCurrentContext:_context]) { +		glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); +		glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); + +		glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); +		glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); +		[_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer]; + +		glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + +		// Retrieve the render buffer size. This *should* match the frame size, +		// i.e. _fullWidth and _fullHeight. +		glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); +		glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); + +		if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { +			NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); +			return; +		} + +		_videoContext.overlayHeight = _renderBufferWidth; +		_videoContext.overlayWidth = _renderBufferHeight; +		uint overlayTextureWidth = getSizeNextPOT(_videoContext.overlayHeight); +		uint overlayTextureHeight = getSizeNextPOT(_videoContext.overlayWidth); + +		// Since the overlay size won't change the whole run, we can +		// precalculate the texture coordinates for the overlay texture here +		// and just use it later on. +		_overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)overlayTextureWidth; +		_overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)overlayTextureHeight; + +		_videoContext.overlayTexture.create(overlayTextureWidth, overlayTextureHeight, Graphics::createPixelFormat<5551>()); + +		glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); +		glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); + +		glEnable(GL_BLEND); +		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + +		glEnable(GL_TEXTURE_2D); printOpenGLError(); +		glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); +		glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); +	} +} + +- (id)initWithFrame:(struct CGRect)frame { +	self = [super initWithFrame: frame]; + +	if ([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) { +		if ([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) { +			//self.contentScaleFactor = [[UIScreen mainScreen] scale]; +		} +	} + +	_fullWidth = (int)frame.size.width; +	_fullHeight = (int)frame.size.height; + +	g_iPhoneViewInstance = self; + +	_keyboardView = nil; +	_screenTexture = 0; +	_overlayTexture = 0; +	_mouseCursorTexture = 0; + +	_gameScreenVertCoords[0] = _gameScreenVertCoords[1] = +	    _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = +	    _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = +	    _gameScreenVertCoords[6] = _gameScreenVertCoords[7] = 0; + +	_gameScreenTexCoords[0] = _gameScreenTexCoords[1] = +	    _gameScreenTexCoords[2] = _gameScreenTexCoords[3] = +	    _gameScreenTexCoords[4] = _gameScreenTexCoords[5] = +	    _gameScreenTexCoords[6] = _gameScreenTexCoords[7] = 0; + +	_overlayVertCoords[0] = _overlayVertCoords[1] = +	    _overlayVertCoords[2] = _overlayVertCoords[3] = +	    _overlayVertCoords[4] = _overlayVertCoords[5] = +	    _overlayVertCoords[6] = _overlayVertCoords[7] = 0; + +	_overlayTexCoords[0] = _overlayTexCoords[1] = +	    _overlayTexCoords[2] = _overlayTexCoords[3] = +	    _overlayTexCoords[4] = _overlayTexCoords[5] = +	    _overlayTexCoords[6] = _overlayTexCoords[7] = 0; + +	// Initialize the OpenGL ES context +	[self createContext]; + +	return self; +} + +- (void)dealloc { +	[super dealloc]; + +	if (_keyboardView != nil) { +		[_keyboardView dealloc]; +	} + +	_videoContext.screenTexture.free(); +	_videoContext.overlayTexture.free(); +} + +- (void)drawRect:(CGRect)frame { +#if 0 +	if (lastTick == 0) { +		lastTick = time(0); +	} + +	frames++; +	if (time(0) > lastTick) { +		lastTick = time(0); +		printf("FPS: %i\n", frames); +		frames = 0; +	} +#endif +} + +- (void)setFilterModeForTexture:(GLuint)tex { +	if (!tex) +		return; + +	glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); + +	GLint filter = GL_LINEAR; + +	switch (_videoContext.graphicsMode) { +	case kGraphicsModeLinear: +		filter = GL_LINEAR; +		break; + +	case kGraphicsModeNone: +		filter = GL_NEAREST; +		break; +	} + +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); +} + +- (void)setGraphicsMode { +	[self setFilterModeForTexture:_screenTexture]; +	[self setFilterModeForTexture:_overlayTexture]; +	[self setFilterModeForTexture:_mouseCursorTexture]; +} + +- (void)updateSurface { +	if (!_needsScreenUpdate) { +		return; +	} +	_needsScreenUpdate = 0; + +	glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); + +	[self updateMainSurface]; + +	if (_videoContext.overlayVisible) +		[self updateOverlaySurface]; + +	if (_videoContext.mouseIsVisible) +		[self updateMouseSurface]; + +	glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); +	[_context presentRenderbuffer:GL_RENDERBUFFER_OES]; + +} + +- (void)updateMouseCursor { +	if (_mouseCursorTexture == 0) { +		glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); +		[self setFilterModeForTexture:_mouseCursorTexture]; +	} + +	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); +	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_videoContext.mouseWidth), getSizeNextPOT(_videoContext.mouseHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); + +	free(_mouseCursor); +	_mouseCursor = NULL; +} + +- (void)updateMainSurface { +	glVertexPointer(2, GL_FLOAT, 0, _gameScreenVertCoords); printOpenGLError(); +	glTexCoordPointer(2, GL_FLOAT, 0, _gameScreenTexCoords); printOpenGLError(); + +	glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); + +	// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases +	// due to the iPhone internals having to convert the whole texture back from its internal format when used. +	// In the future we could use several tiled textures instead. +	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.pixels); printOpenGLError(); +	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)updateOverlaySurface { +	glVertexPointer(2, GL_FLOAT, 0, _overlayVertCoords); printOpenGLError(); +	glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError(); + +	glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); +	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.pixels); printOpenGLError(); +	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)updateMouseSurface { +	int width = _videoContext.mouseWidth; +	int height = _videoContext.mouseHeight; + +	int mouseX = _videoContext.mouseX; +	int mouseY = _videoContext.mouseY; + +	int hotspotX = _videoContext.mouseHotspotX; +	int hotspotY = _videoContext.mouseHotspotY; + +	CGRect *rect; +	int maxWidth, maxHeight; + +	if (!_videoContext.overlayVisible) { +		rect = &_gameScreenRect; +		maxWidth = _videoContext.screenWidth; +		maxHeight = _videoContext.screenHeight; +	} else { +		rect = &_overlayRect; +		maxWidth = _videoContext.overlayWidth; +		maxHeight = _videoContext.overlayHeight; +	} + +	const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; +	const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; + +	mouseX = (int)(mouseX * scaleX); +	mouseY = (int)(mouseY * scaleY); +	hotspotX = (int)(hotspotX * scaleX); +	hotspotY = (int)(hotspotY * scaleY); +	width = (int)(width * scaleX); +	height = (int)(height * scaleY); + +	mouseX -= hotspotX; +	mouseY -= hotspotY; + +	mouseX += (int)CGRectGetMinX(*rect); +	mouseY += (int)CGRectGetMinY(*rect); + +	GLfloat vertices[] = { +		// Top left +		mouseX        , mouseY, +		// Top right +		mouseX + width, mouseY, +		// Bottom left +		mouseX        , mouseY + height, +		// Bottom right +		mouseX + width, mouseY + height +	}; + +	//printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight); + +	float texWidth = _videoContext.mouseWidth / (float)getSizeNextPOT(_videoContext.mouseWidth); +	float texHeight = _videoContext.mouseHeight / (float)getSizeNextPOT(_videoContext.mouseHeight); + +	const GLfloat texCoords[] = { +		// Top left +		0       , 0, +		// Top right +		texWidth, 0, +		// Bottom left +		0       , texHeight, +		// Bottom right +		texWidth, texHeight +	}; + +	glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); +	glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); + +	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); +	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)setUpOrientation:(UIDeviceOrientation)orientation width:(int *)width height:(int *)height { +	_orientation = orientation; + +	glMatrixMode(GL_PROJECTION); +	glLoadIdentity(); + +	// We always force the origin (0,0) to be in the upper left corner. +	switch (_orientation) { +	case UIDeviceOrientationLandscapeRight: +		glRotatef( 90, 0, 0, 1); printOpenGLError(); +		glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + +		*width = _renderBufferHeight; +		*height = _renderBufferWidth; +		break; + +	case UIDeviceOrientationLandscapeLeft: +		glRotatef(-90, 0, 0, 1); printOpenGLError(); +		glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + +		*width = _renderBufferHeight; +		*height = _renderBufferWidth; +		break; + +	case UIDeviceOrientationPortrait: +	default: +		// We must force the portrait orientation here, since we might not know +		// the real orientation. +		_orientation = UIDeviceOrientationPortrait; + +		glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); + +		*width = _renderBufferWidth; +		*height = _renderBufferHeight; +		break; +	} +} + +- (void)initSurface { +	uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth); +	uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight); + +	_gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)screenTexWidth; +	_gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)screenTexHeight; + +	int screenWidth, screenHeight; +	[self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight]; + +	if (_screenTexture > 0) { +		glDeleteTextures(1, &_screenTexture); printOpenGLError(); +	} + +	glGenTextures(1, &_screenTexture); printOpenGLError(); +	[self setFilterModeForTexture:_screenTexture]; + +	if (_overlayTexture > 0) { +		glDeleteTextures(1, &_overlayTexture); printOpenGLError(); +	} + +	glGenTextures(1, &_overlayTexture); printOpenGLError(); +	[self setFilterModeForTexture:_overlayTexture]; + +	_videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>()); + +	glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + +	[self clearColorBuffer]; + +	if (_keyboardView != nil) { +		[_keyboardView removeFromSuperview]; +		[[_keyboardView inputView] removeFromSuperview]; +	} + +	float overlayPortraitRatio; + +	if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation ==  UIDeviceOrientationLandscapeRight) { +		GLfloat gameScreenRatio = (GLfloat)_videoContext.screenWidth / (GLfloat)_videoContext.screenHeight; +		GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; + +		// These are the width/height according to the portrait layout! +		int rectWidth, rectHeight; +		int xOffset, yOffset; + +		if (gameScreenRatio < screenRatio) { +			// When the game screen ratio is less than the screen ratio +			// we need to scale the width, since the game screen was higher +			// compared to the width than our output screen is. +			rectWidth = (int)(screenHeight * gameScreenRatio); +			rectHeight = screenHeight; +			xOffset = (screenWidth - rectWidth) / 2; +			yOffset = 0; +		} else { +			// When the game screen ratio is bigger than the screen ratio +			// we need to scale the height, since the game screen was wider +			// compared to the height than our output screen is. +			rectWidth = screenWidth; +			rectHeight = (int)(screenWidth / gameScreenRatio); +			xOffset = 0; +			yOffset = (screenHeight - rectHeight) / 2; +		} + +		//printf("Rect: %i, %i, %i, %i\n", xOffset, yOffset, rectWidth, rectHeight); +		_gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); +		overlayPortraitRatio = 1.0f; +	} else { +		float ratio = (float)_videoContext.screenHeight / (float)_videoContext.screenWidth; +		int height = (int)(screenWidth * ratio); +		//printf("Making rect (%u, %u)\n", screenWidth, height); +		_gameScreenRect = CGRectMake(0, 0, screenWidth, height); + +		CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); +		if (_keyboardView == nil) { +			_keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; +			[_keyboardView setInputDelegate:self]; +		} + +		[self addSubview:[_keyboardView inputView]]; +		[self addSubview: _keyboardView]; +		[[_keyboardView inputView] becomeFirstResponder]; +		overlayPortraitRatio = (_videoContext.overlayHeight * ratio) / _videoContext.overlayWidth; +	} + +	_overlayRect = CGRectMake(0, 0, screenWidth, screenHeight * overlayPortraitRatio); + +	_gameScreenVertCoords[0] = _gameScreenVertCoords[4] = CGRectGetMinX(_gameScreenRect); +	_gameScreenVertCoords[1] = _gameScreenVertCoords[3] = CGRectGetMinY(_gameScreenRect); +	_gameScreenVertCoords[2] = _gameScreenVertCoords[6] = CGRectGetMaxX(_gameScreenRect); +	_gameScreenVertCoords[5] = _gameScreenVertCoords[7] = CGRectGetMaxY(_gameScreenRect); + +	_overlayVertCoords[2] = _overlayVertCoords[6] = CGRectGetMaxX(_overlayRect); +	_overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect); + +	[self setViewTransformation]; +} + +- (void)setViewTransformation { +	// Set the modelview matrix. This matrix will be used for the shake offset +	// support. +	glMatrixMode(GL_MODELVIEW); +	glLoadIdentity(); + +	// Scale the shake offset according to the overlay size. We need this to +	// adjust the overlay mouse click coordinates when an offset is set. +	_scaledShakeOffsetY = (int)(_videoContext.shakeOffsetY / (GLfloat)_videoContext.screenHeight * CGRectGetHeight(_overlayRect)); + +	// Apply the shakeing to the output screen. +	glTranslatef(0, -_scaledShakeOffsetY, 0); +} + +- (void)clearColorBuffer { +	// The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. +	int clearCount = 5; +	while (clearCount-- > 0) { +		glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); +		[_context presentRenderbuffer:GL_RENDERBUFFER_OES]; +	} +} + +- (id)getEvent { +	if (_events == nil || [_events count] == 0) { +		return nil; +	} + +	id event = [_events objectAtIndex: 0]; + +	[_events removeObjectAtIndex: 0]; + +	return event; +} + +- (void)addEvent:(NSDictionary *)event { +	if (_events == nil) +		_events = [[NSMutableArray alloc] init]; + +	[_events addObject: event]; +} + +/** + * Converts portrait mode coordinates into rotated mode coordinates. + */ +- (bool)convertToRotatedCoords:(CGPoint)point result:(CGPoint *)result { +	switch (_orientation) { +	case UIDeviceOrientationLandscapeLeft: +		result->x = point.y; +		result->y = _renderBufferWidth - point.x; +		return true; + +	case UIDeviceOrientationLandscapeRight: +		result->x = _renderBufferHeight - point.y; +		result->y = point.x; +		return true; + +	case UIDeviceOrientationPortrait: +		result->x = point.x; +		result->y = point.y; +		return true; + +	default: +		return false; +	} +} + +- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y { +	if (![self convertToRotatedCoords:point result:&point]) +		return false; + +	CGRect *area; +	int width, height, offsetY; +	if (_videoContext.overlayVisible) { +		area = &_overlayRect; +		width = _videoContext.overlayWidth; +		height = _videoContext.overlayHeight; +		offsetY = _scaledShakeOffsetY; +	} else { +		area = &_gameScreenRect; +		width = _videoContext.screenWidth; +		height = _videoContext.screenHeight; +		offsetY = _videoContext.shakeOffsetY; +	} + +	point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); +	point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); + +	*x = (int)(point.x * width); +	// offsetY describes the translation of the screen in the upward direction, +	// thus we need to add it here. +	*y = (int)(point.y * height + offsetY); + +	// Clip coordinates +	if (*x < 0 || *x > width || *y < 0 || *y > height) +		return false; + +	return true; +} + +- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation { +	switch (orientation) { +	case UIDeviceOrientationLandscapeLeft: +	case UIDeviceOrientationLandscapeRight: +	case UIDeviceOrientationPortrait: +		_orientation = orientation; +		break; + +	default: +		return; +	} + +	[self addEvent: +		[[NSDictionary alloc] initWithObjectsAndKeys: +		 [NSNumber numberWithInt:kInputOrientationChanged], @"type", +		 [NSNumber numberWithInt:orientation], @"x", +		 [NSNumber numberWithInt:0], @"y", +		 nil +		] +	]; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { +	NSSet *allTouches = [event allTouches]; +	int x, y; + +	switch ([allTouches count]) { +	case 1: { +		UITouch *touch = [touches anyObject]; +		CGPoint point = [touch locationInView:self]; +		if (![self getMouseCoords:point eventX:&x eventY:&y]) +			return; + +		_firstTouch = touch; +		[self addEvent: +		 [[NSDictionary alloc] initWithObjectsAndKeys: +		  [NSNumber numberWithInt:kInputMouseDown], @"type", +		  [NSNumber numberWithInt:x], @"x", +		  [NSNumber numberWithInt:y], @"y", +		  nil +		  ] +		 ]; +		break; +		} + +	case 2: { +		UITouch *touch = [touches anyObject]; +		CGPoint point = [touch locationInView:self]; +		if (![self getMouseCoords:point eventX:&x eventY:&y]) +			return; + +		_secondTouch = touch; +		[self addEvent: +		 [[NSDictionary alloc] initWithObjectsAndKeys: +		  [NSNumber numberWithInt:kInputMouseSecondDown], @"type", +		  [NSNumber numberWithInt:x], @"x", +		  [NSNumber numberWithInt:y], @"y", +		  nil +		  ] +		 ]; +		break; +		} +	} +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { +	//NSSet *allTouches = [event allTouches]; +	int x, y; + +	for (UITouch *touch in touches) { +		if (touch == _firstTouch) { +			CGPoint point = [touch locationInView:self]; +			if (![self getMouseCoords:point eventX:&x eventY:&y]) +				return; + +			[self addEvent: +			 [[NSDictionary alloc] initWithObjectsAndKeys: +			  [NSNumber numberWithInt:kInputMouseDragged], @"type", +			  [NSNumber numberWithInt:x], @"x", +			  [NSNumber numberWithInt:y], @"y", +			  nil +			  ] +			 ]; +		} else if (touch == _secondTouch) { +			CGPoint point = [touch locationInView:self]; +			if (![self getMouseCoords:point eventX:&x eventY:&y]) +				return; + +			[self addEvent: +			 [[NSDictionary alloc] initWithObjectsAndKeys: +			  [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", +			  [NSNumber numberWithInt:x], @"x", +			  [NSNumber numberWithInt:y], @"y", +			  nil +			  ] +			 ]; +		} +	} +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { +	NSSet *allTouches = [event allTouches]; +	int x, y; + +	switch ([allTouches count]) { +	case 1: { +		UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; +		CGPoint point = [touch locationInView:self]; +		if (![self getMouseCoords:point eventX:&x eventY:&y]) +			return; + +		[self addEvent: +		 [[NSDictionary alloc] initWithObjectsAndKeys: +		  [NSNumber numberWithInt:kInputMouseUp], @"type", +		  [NSNumber numberWithInt:x], @"x", +		  [NSNumber numberWithInt:y], @"y", +		  nil +		  ] +		 ]; +		break; +		} + +	case 2: { +		UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; +		CGPoint point = [touch locationInView:self]; +		if (![self getMouseCoords:point eventX:&x eventY:&y]) +			return; + +		[self addEvent: +		 [[NSDictionary alloc] initWithObjectsAndKeys: +		  [NSNumber numberWithInt:kInputMouseSecondUp], @"type", +		  [NSNumber numberWithInt:x], @"x", +		  [NSNumber numberWithInt:y], @"y", +		  nil +		  ] +		 ]; +		break; +		} +	} +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { +} + +- (void)handleKeyPress:(unichar)c { +	[self addEvent: +		[[NSDictionary alloc] initWithObjectsAndKeys: +		 [NSNumber numberWithInt:kInputKeyPressed], @"type", +		 [NSNumber numberWithInt:c], @"x", +		 [NSNumber numberWithInt:0], @"y", +		 nil +		] +	]; +} + +- (BOOL)canHandleSwipes { +	return TRUE; +} + +- (int)swipe:(int)num withEvent:(struct __GSEvent *)event { +	//printf("swipe: %i\n", num); + +	[self addEvent: +		[[NSDictionary alloc] initWithObjectsAndKeys: +		 [NSNumber numberWithInt:kInputSwipe], @"type", +		 [NSNumber numberWithInt:num], @"x", +		 [NSNumber numberWithInt:0], @"y", +		 nil +		] +	]; + +	return 0; +} + +- (void)applicationSuspend { +	[self addEvent: +		[[NSDictionary alloc] initWithObjectsAndKeys: +		 [NSNumber numberWithInt:kInputApplicationSuspended], @"type", +		 [NSNumber numberWithInt:0], @"x", +		 [NSNumber numberWithInt:0], @"y", +		 nil +		] +	]; +} + +- (void)applicationResume { +	[self addEvent: +		[[NSDictionary alloc] initWithObjectsAndKeys: +		 [NSNumber numberWithInt:kInputApplicationResumed], @"type", +		 [NSNumber numberWithInt:0], @"x", +		 [NSNumber numberWithInt:0], @"y", +		 nil +		] +	]; +} + +@end diff --git a/backends/platform/iphone/module.mk b/backends/platform/iphone/module.mk index 9768e6ded4..ea5115782f 100644 --- a/backends/platform/iphone/module.mk +++ b/backends/platform/iphone/module.mk @@ -7,8 +7,7 @@ MODULE_OBJS := \  	osys_video.o \  	iphone_main.o \  	iphone_video.o \ -	iphone_keyboard.o \ -	blit_arm.o +	iphone_keyboard.o  # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.  MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 1ab1db0f27..85efbda208 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -40,98 +40,66 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) {  		_timerCallbackNext = curTime + _timerCallbackTimer;  	} -	if (_queuedInputEvent.type != (Common::EventType)0 && curTime >= _queuedEventTime) { +	if (_queuedInputEvent.type != Common::EVENT_INVALID && curTime >= _queuedEventTime) {  		event = _queuedInputEvent; -		_queuedInputEvent.type = (Common::EventType)0; +		_queuedInputEvent.type = Common::EVENT_INVALID;  		return true;  	}  	int eventType; -	float xUnit, yUnit; - -	if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) { -		int x = 0; -		int y = 0; -		switch (_screenOrientation) { -			case kScreenOrientationPortrait: -				if (_overlayVisible) { -					x = (int)(xUnit * _overlayWidth); -					y = (int)(yUnit * _overlayHeight); -				} else { -					x = (int)(xUnit * _screenWidth); -					y = (int)(yUnit * _screenHeight); -				} -				break; -			case kScreenOrientationLandscape: -				if (_overlayVisible) { -					x = (int)(yUnit * _overlayWidth); -					y = (int)((1.0 - xUnit) * _overlayHeight); -				} else { -					x = (int)(yUnit * _screenWidth); -					y = (int)((1.0 - xUnit) * _screenHeight); -				} -				break; -			case kScreenOrientationFlippedLandscape: -				if (_overlayVisible) { -					x = (int)((1.0 - yUnit) * _overlayWidth); -					y = (int)(xUnit * _overlayHeight); -				} else { -					x = (int)((1.0 - yUnit) * _screenWidth); -					y = (int)(xUnit * _screenHeight); -				} -				break; -		} +	int x, y; +	if (iPhone_fetchEvent(&eventType, &x, &y)) {  		switch ((InputEvent)eventType) { -			case kInputMouseDown: -				if (!handleEvent_mouseDown(event, x, y)) -					return false; -				break; +		case kInputMouseDown: +			if (!handleEvent_mouseDown(event, x, y)) +				return false; +			break; -			case kInputMouseUp: +		case kInputMouseUp:  			if (!handleEvent_mouseUp(event, x, y))  				return false; -				break; - -			case kInputMouseDragged: -				if (!handleEvent_mouseDragged(event, x, y)) -					return false; -				break; -			case kInputMouseSecondDragged: -				if (!handleEvent_mouseSecondDragged(event, x, y)) -					return false; -				break; -			case kInputMouseSecondDown: -				_secondaryTapped = true; -				if (!handleEvent_secondMouseDown(event, x, y)) -					return false; -				break; -			case kInputMouseSecondUp: -				_secondaryTapped = false; -				if (!handleEvent_secondMouseUp(event, x, y)) -					return false; -				break; -			case kInputOrientationChanged: -				handleEvent_orientationChanged((int)xUnit); -				return false; -				break; +			break; -			case kInputApplicationSuspended: -				suspendLoop(); +		case kInputMouseDragged: +			if (!handleEvent_mouseDragged(event, x, y)) +				return false; +			break; +		case kInputMouseSecondDragged: +			if (!handleEvent_mouseSecondDragged(event, x, y)) +				return false; +			break; +		case kInputMouseSecondDown: +			_secondaryTapped = true; +			if (!handleEvent_secondMouseDown(event, x, y)) +				return false; +			break; +		case kInputMouseSecondUp: +			_secondaryTapped = false; +			if (!handleEvent_secondMouseUp(event, x, y))  				return false; -				break; +			break; +		case kInputOrientationChanged: +			handleEvent_orientationChanged(x); +			return false; +			break; -			case kInputKeyPressed: -				handleEvent_keyPressed(event, (int)xUnit); -				break; +		case kInputApplicationSuspended: +			suspendLoop(); +			return false; +			break; -			case kInputSwipe: -				if (!handleEvent_swipe(event, (int)xUnit)) -					return false; -				break; +		case kInputKeyPressed: +			handleEvent_keyPressed(event, x); +			break; + +		case kInputSwipe: +			if (!handleEvent_swipe(event, x)) +				return false; +			break; -			default: -				break; +		default: +			break;  		}  		return true; @@ -154,8 +122,8 @@ bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) {  	if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_LBUTTONDOWN; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  		return true;  	} else {  		_lastMouseDown = getMillis(); @@ -170,20 +138,19 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) {  		_secondaryTapped = false;  		if (!handleEvent_secondMouseUp(event, x, y))  			return false; -	} -	else if (_mouseClickAndDragEnabled) { +	} else if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_LBUTTONUP; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  	} else {  		if (getMillis() - _lastMouseDown < 250) {  			event.type = Common::EVENT_LBUTTONDOWN; -			event.mouse.x = _mouseX; -			event.mouse.y = _mouseY; +			event.mouse.x = _videoContext->mouseX; +			event.mouse.y = _videoContext->mouseY;  			_queuedInputEvent.type = Common::EVENT_LBUTTONUP; -			_queuedInputEvent.mouse.x = _mouseX; -			_queuedInputEvent.mouse.y = _mouseY; +			_queuedInputEvent.mouse.x = _videoContext->mouseX; +			_queuedInputEvent.mouse.y = _videoContext->mouseY;  			_lastMouseTap = getMillis();  			_queuedEventTime = _lastMouseTap + kQueuedInputEventDelay;  		} else @@ -200,14 +167,13 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in  	if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_LBUTTONUP; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  		_queuedInputEvent.type = Common::EVENT_RBUTTONDOWN; -		_queuedInputEvent.mouse.x = _mouseX; -		_queuedInputEvent.mouse.y = _mouseY; -	} -	else +		_queuedInputEvent.mouse.x = _videoContext->mouseX; +		_queuedInputEvent.mouse.y = _videoContext->mouseY; +	} else  		return false;  	return true; @@ -216,9 +182,9 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in  bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int y) {  	int curTime = getMillis(); -	if (curTime - _lastSecondaryDown < 400 ) { +	if (curTime - _lastSecondaryDown < 400) {  		//printf("Right tap!\n"); -		if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) { +		if (curTime - _lastSecondaryTap < 400 && !_videoContext->overlayVisible) {  			//printf("Right escape!\n");  			event.type = Common::EVENT_KEYDOWN;  			_queuedInputEvent.type = Common::EVENT_KEYUP; @@ -231,11 +197,11 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int  		} else if (!_mouseClickAndDragEnabled) {  			//printf("Rightclick!\n");  			event.type = Common::EVENT_RBUTTONDOWN; -			event.mouse.x = _mouseX; -			event.mouse.y = _mouseY; +			event.mouse.x = _videoContext->mouseX; +			event.mouse.y = _videoContext->mouseY;  			_queuedInputEvent.type = Common::EVENT_RBUTTONUP; -			_queuedInputEvent.mouse.x = _mouseX; -			_queuedInputEvent.mouse.y = _mouseY; +			_queuedInputEvent.mouse.x = _videoContext->mouseX; +			_queuedInputEvent.mouse.y = _videoContext->mouseY;  			_lastSecondaryTap = curTime;  			_queuedEventTime = curTime + kQueuedInputEventDelay;  		} else { @@ -245,8 +211,8 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int  	}  	if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_RBUTTONUP; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  	}  	return true; @@ -262,17 +228,17 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y  	//printf("Mouse dragged at (%u, %u)\n", x, y);  	int mouseNewPosX;  	int mouseNewPosY; -	if (_touchpadModeEnabled ) { +	if (_touchpadModeEnabled) {  		int deltaX = _lastPadX - x;  		int deltaY = _lastPadY - y;  		_lastPadX = x;  		_lastPadY = y; -		mouseNewPosX = (int)(_mouseX - deltaX / 0.5f); -		mouseNewPosY = (int)(_mouseY - deltaY / 0.5f); +		mouseNewPosX = (int)(_videoContext->mouseX - deltaX / 0.5f); +		mouseNewPosY = (int)(_videoContext->mouseY - deltaY / 0.5f); -		int widthCap = _overlayVisible ? _overlayWidth : _screenWidth; -		int heightCap = _overlayVisible ? _overlayHeight : _screenHeight; +		int widthCap = _videoContext->overlayVisible ? _videoContext->overlayWidth : _videoContext->screenWidth; +		int heightCap = _videoContext->overlayVisible ? _videoContext->overlayHeight : _videoContext->screenHeight;  		if (mouseNewPosX < 0)  			mouseNewPosX = 0; @@ -319,12 +285,9 @@ bool OSystem_IPHONE::handleEvent_mouseSecondDragged(Common::Event &event, int x,  		if (absX < kMaxDeviation && vecY >= kNeededLength) {  			// Swipe down -			event.type = Common::EVENT_KEYDOWN; -			_queuedInputEvent.type = Common::EVENT_KEYUP; +			event.type = Common::EVENT_MAINMENU; +			_queuedInputEvent.type = Common::EVENT_INVALID; -			event.kbd.flags = _queuedInputEvent.kbd.flags = 0; -			event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_F5; -			event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_F5;  			_queuedEventTime = getMillis() + kQueuedInputEventDelay;  			return true;  		} @@ -371,26 +334,26 @@ void  OSystem_IPHONE::handleEvent_orientationChanged(int orientation) {  	ScreenOrientation newOrientation;  	switch (orientation) { -		case 1: -			newOrientation = kScreenOrientationPortrait; -			break; -		case 3: -			newOrientation = kScreenOrientationLandscape; -			break; -		case 4: -			newOrientation = kScreenOrientationFlippedLandscape; -			break; -		default: -			return; +	case 1: +		newOrientation = kScreenOrientationPortrait; +		break; +	case 3: +		newOrientation = kScreenOrientationLandscape; +		break; +	case 4: +		newOrientation = kScreenOrientationFlippedLandscape; +		break; +	default: +		return;  	}  	if (_screenOrientation != newOrientation) {  		_screenOrientation = newOrientation; -		iPhone_initSurface(_screenWidth, _screenHeight); +		updateOutputSurface();  		dirtyFullScreen(); -		if (_overlayVisible) +		if (_videoContext->overlayVisible)  			dirtyFullOverlayScreen();  		updateScreen();  	} @@ -403,50 +366,50 @@ void  OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPresse  	// We remap some of the iPhone keyboard keys.  	// The first ten here are the row of symbols below the numeric keys.  	switch (keyPressed) { -		case 45: -			keyPressed = Common::KEYCODE_F1; -			ascii = Common::ASCII_F1; -			break; -		case 47: -			keyPressed = Common::KEYCODE_F2; -			ascii = Common::ASCII_F2; -			break; -		case 58: -			keyPressed = Common::KEYCODE_F3; -			ascii = Common::ASCII_F3; -			break; -		case 59: -			keyPressed = Common::KEYCODE_F4; -			ascii = Common::ASCII_F4; -			break; -		case 40: -			keyPressed = Common::KEYCODE_F5; -			ascii = Common::ASCII_F5; -			break; -		case 41: -			keyPressed = Common::KEYCODE_F6; -			ascii = Common::ASCII_F6; -			break; -		case 36: -			keyPressed = Common::KEYCODE_F7; -			ascii = Common::ASCII_F7; -			break; -		case 38: -			keyPressed = Common::KEYCODE_F8; -			ascii = Common::ASCII_F8; -			break; -		case 64: -			keyPressed = Common::KEYCODE_F9; -			ascii = Common::ASCII_F9; -			break; -		case 34: -			keyPressed = Common::KEYCODE_F10; -			ascii = Common::ASCII_F10; -			break; -		case 10: -			keyPressed = Common::KEYCODE_RETURN; -			ascii = Common::ASCII_RETURN; -			break; +	case 45: +		keyPressed = Common::KEYCODE_F1; +		ascii = Common::ASCII_F1; +		break; +	case 47: +		keyPressed = Common::KEYCODE_F2; +		ascii = Common::ASCII_F2; +		break; +	case 58: +		keyPressed = Common::KEYCODE_F3; +		ascii = Common::ASCII_F3; +		break; +	case 59: +		keyPressed = Common::KEYCODE_F4; +		ascii = Common::ASCII_F4; +		break; +	case 40: +		keyPressed = Common::KEYCODE_F5; +		ascii = Common::ASCII_F5; +		break; +	case 41: +		keyPressed = Common::KEYCODE_F6; +		ascii = Common::ASCII_F6; +		break; +	case 36: +		keyPressed = Common::KEYCODE_F7; +		ascii = Common::ASCII_F7; +		break; +	case 38: +		keyPressed = Common::KEYCODE_F8; +		ascii = Common::ASCII_F8; +		break; +	case 64: +		keyPressed = Common::KEYCODE_F9; +		ascii = Common::ASCII_F9; +		break; +	case 34: +		keyPressed = Common::KEYCODE_F10; +		ascii = Common::ASCII_F10; +		break; +	case 10: +		keyPressed = Common::KEYCODE_RETURN; +		ascii = Common::ASCII_RETURN; +		break;  	}  	event.type = Common::EVENT_KEYDOWN;  	_queuedInputEvent.type = Common::EVENT_KEYUP; @@ -460,60 +423,60 @@ void  OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPresse  bool OSystem_IPHONE::handleEvent_swipe(Common::Event &event, int direction) {  	Common::KeyCode keycode = Common::KEYCODE_INVALID;  	switch (_screenOrientation) { -		case kScreenOrientationPortrait: -			switch ((UIViewSwipeDirection)direction) { -				case kUIViewSwipeUp: -					keycode = Common::KEYCODE_UP; -					break; -				case kUIViewSwipeDown: -					keycode = Common::KEYCODE_DOWN; -					break; -				case kUIViewSwipeLeft: -					keycode = Common::KEYCODE_LEFT; -					break; -				case kUIViewSwipeRight: -					keycode = Common::KEYCODE_RIGHT; -					break; -				default: -					return false; -			} +	case kScreenOrientationPortrait: +		switch ((UIViewSwipeDirection)direction) { +		case kUIViewSwipeUp: +			keycode = Common::KEYCODE_UP; +			break; +		case kUIViewSwipeDown: +			keycode = Common::KEYCODE_DOWN;  			break; -		case kScreenOrientationLandscape: -			switch ((UIViewSwipeDirection)direction) { -				case kUIViewSwipeUp: -					keycode = Common::KEYCODE_LEFT; -					break; -				case kUIViewSwipeDown: -					keycode = Common::KEYCODE_RIGHT; -					break; -				case kUIViewSwipeLeft: -					keycode = Common::KEYCODE_DOWN; -					break; -				case kUIViewSwipeRight: -					keycode = Common::KEYCODE_UP; -					break; -				default: -					return false; -			} +		case kUIViewSwipeLeft: +			keycode = Common::KEYCODE_LEFT;  			break; -		case kScreenOrientationFlippedLandscape: -			switch ((UIViewSwipeDirection)direction) { -				case kUIViewSwipeUp: -					keycode = Common::KEYCODE_RIGHT; -					break; -				case kUIViewSwipeDown: -					keycode = Common::KEYCODE_LEFT; -					break; -				case kUIViewSwipeLeft: -					keycode = Common::KEYCODE_UP; -					break; -				case kUIViewSwipeRight: -					keycode = Common::KEYCODE_DOWN; -					break; -				default: -					return false; -			} +		case kUIViewSwipeRight: +			keycode = Common::KEYCODE_RIGHT;  			break; +		default: +			return false; +		} +		break; +	case kScreenOrientationLandscape: +		switch ((UIViewSwipeDirection)direction) { +		case kUIViewSwipeUp: +			keycode = Common::KEYCODE_LEFT; +			break; +		case kUIViewSwipeDown: +			keycode = Common::KEYCODE_RIGHT; +			break; +		case kUIViewSwipeLeft: +			keycode = Common::KEYCODE_DOWN; +			break; +		case kUIViewSwipeRight: +			keycode = Common::KEYCODE_UP; +			break; +		default: +			return false; +		} +		break; +	case kScreenOrientationFlippedLandscape: +		switch ((UIViewSwipeDirection)direction) { +		case kUIViewSwipeUp: +			keycode = Common::KEYCODE_RIGHT; +			break; +		case kUIViewSwipeDown: +			keycode = Common::KEYCODE_LEFT; +			break; +		case kUIViewSwipeLeft: +			keycode = Common::KEYCODE_UP; +			break; +		case kUIViewSwipeRight: +			keycode = Common::KEYCODE_DOWN; +			break; +		default: +			return false; +		} +		break;  	}  	event.kbd.keycode = _queuedInputEvent.kbd.keycode = keycode; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 4bc567c39d..dabf73bf58 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -45,7 +45,9 @@  const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = { -	{0, 0, 0} +	{ "linear", "Linear filtering", kGraphicsModeLinear }, +	{ "none", "No filtering", kGraphicsModeNone }, +	{ 0, 0, 0 }  };  AQCallbackStruct OSystem_IPHONE::s_AudioQueue; @@ -53,28 +55,24 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL;  void *OSystem_IPHONE::s_soundParam = NULL;  OSystem_IPHONE::OSystem_IPHONE() : -	_mixer(NULL), _offscreen(NULL), -	_overlayVisible(false), _fullscreen(NULL), -	_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), -	_secondaryTapped(false), _lastSecondaryTap(0), +	_mixer(NULL), _gameScreenRaw(NULL), +	_mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), +	_mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),  	_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),  	_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),  	_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), -	_overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) -{ -	_queuedInputEvent.type = (Common::EventType)0; -	_lastDrawnMouseRect = Common::Rect(0, 0, 0, 0); - +	_mouseCursorPaletteEnabled(false) { +	_queuedInputEvent.type = Common::EVENT_INVALID;  	_touchpadModeEnabled = !iPhone_isHighResDevice();  	_fsFactory = new POSIXFilesystemFactory(); +	initVideoContext();  }  OSystem_IPHONE::~OSystem_IPHONE() {  	AudioQueueDispose(s_AudioQueue.queue, true);  	delete _mixer; -	delete _offscreen; -	delete _fullscreen; +	free(_gameScreenRaw);  }  int OSystem_IPHONE::timerHandler(int t) { @@ -102,26 +100,50 @@ void OSystem_IPHONE::initBackend() {  }  bool OSystem_IPHONE::hasFeature(Feature f) { -	return false; +	switch (f) { +	case kFeatureCursorPalette: +		return true; + +	default: +		return false; +	}  }  void OSystem_IPHONE::setFeatureState(Feature f, bool enable) { +	switch (f) { +	case kFeatureCursorPalette: +		if (_mouseCursorPaletteEnabled != enable) { +			_mouseNeedTextureUpdate = true; +			_mouseDirty = true; +			_mouseCursorPaletteEnabled = enable; +		} +		break; + +	default: +		break; +	}  }  bool OSystem_IPHONE::getFeatureState(Feature f) { -	return false; +	switch (f) { +	case kFeatureCursorPalette: +		return _mouseCursorPaletteEnabled; + +	default: +		return false; +	}  }  void OSystem_IPHONE::suspendLoop() {  	bool done = false;  	int eventType; -	float xUnit, yUnit; +	int x, y;  	uint32 startTime = getMillis();  	stopSoundsystem();  	while (!done) { -		if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) +		if (iPhone_fetchEvent(&eventType, &x, &y))  			if ((InputEvent)eventType == kInputApplicationResumed)  				done = true;  		usleep(100000); @@ -226,7 +248,6 @@ Common::String OSystem_IPHONE::getDefaultConfigFileName() {  #endif  } -  void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {  	// Get URL of the Resource directory of the .app bundle  	CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); @@ -272,7 +293,7 @@ void iphone_main(int argc, char *argv[]) {  	}  #ifdef IPHONE_OFFICIAL -	chdir( iPhone_getDocumentsDir() ); +	chdir(iPhone_getDocumentsDir());  #else  	system("mkdir " SCUMMVM_ROOT_PATH);  	system("mkdir " SCUMMVM_SAVE_PATH); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 37896cceeb..180d3e9d06 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -20,6 +20,9 @@   *   */ +#ifndef BACKENDS_PLATFORM_IPHONE_OSYS_MAIN_H +#define BACKENDS_PLATFORM_IPHONE_OSYS_MAIN_H +  #include "graphics/surface.h"  #include "iphone_common.h"  #include "backends/base-backend.h" @@ -42,16 +45,15 @@  typedef void (*SoundProc)(void *param, byte *buf, int len);  typedef int (*TimerProc)(int interval); -typedef struct AQCallbackStruct { -    AudioQueueRef queue; -    uint32 frameCount; -    AudioQueueBufferRef buffers[AUDIO_BUFFERS]; -    AudioStreamBasicDescription dataFormat; -} AQCallbackStruct; +struct AQCallbackStruct { +	AudioQueueRef queue; +	uint32 frameCount; +	AudioQueueBufferRef buffers[AUDIO_BUFFERS]; +	AudioStreamBasicDescription dataFormat; +};  class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager {  protected: -  	static const OSystem::GraphicsMode s_supportedGraphicsModes[];  	static AQCallbackStruct s_AudioQueue;  	static SoundProc s_soundCallback; @@ -59,33 +61,28 @@ protected:  	Audio::MixerImpl *_mixer; -	Graphics::Surface _framebuffer; -	byte *_offscreen; -	OverlayColor  *_overlayBuffer; -	uint16 _overlayHeight; -	uint16 _overlayWidth; +	VideoContext *_videoContext; -	uint16 *_fullscreen; +	Graphics::Surface _framebuffer; +	byte *_gameScreenRaw; -	uint16  _palette[256]; -	bool _overlayVisible; -	uint16 _screenWidth; -	uint16 _screenHeight; +	// For use with the game texture +	uint16  _gamePalette[256]; +	// For use with the mouse texture +	uint16  _gamePaletteRGBA5551[256];  	struct timeval _startTime;  	uint32 _timeSuspended; -	bool _mouseVisible; +	bool _mouseCursorPaletteEnabled; +	uint16 _mouseCursorPalette[256];  	byte *_mouseBuf;  	byte _mouseKeyColor; -	uint _mouseWidth, _mouseHeight; -	uint _mouseX, _mouseY; -	int _mouseHotspotX, _mouseHotspotY;  	bool _mouseDirty; +	bool _mouseNeedTextureUpdate;  	long _lastMouseDown;  	long _lastMouseTap;  	long _queuedEventTime; -	Common::Rect _lastDrawnMouseRect;  	Common::Event _queuedInputEvent;  	bool _secondaryTapped;  	long _lastSecondaryDown; @@ -121,7 +118,6 @@ public:  	virtual bool getFeatureState(Feature f);  	virtual const GraphicsMode *getSupportedGraphicsModes() const;  	virtual int getDefaultGraphicsMode() const; -	bool setGraphicsMode(const char *name);  	virtual bool setGraphicsMode(int mode);  	virtual int getGraphicsMode() const;  	virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); @@ -154,6 +150,7 @@ public:  	virtual void warpMouse(int x, int y);  	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); +	virtual void setCursorPalette(const byte *colors, uint start, uint num);  	virtual bool pollEvent(Common::Event &event);  	virtual uint32 getMillis(); @@ -167,7 +164,7 @@ public:  	static void mixCallback(void *sys, byte *samples, int len);  	virtual void setupMixer(void);  	virtual void setTimerCallback(TimerProc callback, int interval); - 	virtual int getScreenChangeID() const { return _screenChangeCount; } +	virtual int getScreenChangeID() const { return _screenChangeCount; }  	virtual void quit();  	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); @@ -183,15 +180,15 @@ public:  	virtual void logMessage(LogMessageType::Type type, const char *message);  protected: +	void initVideoContext(); +	void updateOutputSurface(); +  	void internUpdateScreen();  	void dirtyFullScreen();  	void dirtyFullOverlayScreen(); -	void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h);  	void suspendLoop(); -	void drawDirtyRect(const Common::Rect& dirtyRect); -	void drawDirtyOverlayRect(const Common::Rect& dirtyRect); -	void drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect); -	void updateHardwareSurfaceForRect(const Common::Rect& updatedRect); +	void drawDirtyRect(const Common::Rect &dirtyRect); +	void updateMouseTexture();  	static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);  	static int timerHandler(int t); @@ -208,3 +205,5 @@ protected:  	bool handleEvent_mouseDragged(Common::Event &event, int x, int y);  	bool handleEvent_mouseSecondDragged(Common::Event &event, int x, int y);  }; + +#endif diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp deleted file mode 100644 index fa425b108a..0000000000 --- a/backends/platform/iphone/osys_video.cpp +++ /dev/null @@ -1,503 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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. - * - */ - -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include "osys_main.h" - -const OSystem::GraphicsMode* OSystem_IPHONE::getSupportedGraphicsModes() const { -	return s_supportedGraphicsModes; -} - - -int OSystem_IPHONE::getDefaultGraphicsMode() const { -	return -1; -} - -bool OSystem_IPHONE::setGraphicsMode(const char *mode) { -	return true; -} - -bool OSystem_IPHONE::setGraphicsMode(int mode) { -	return true; -} - -int OSystem_IPHONE::getGraphicsMode() const { -	return -1; -} - -void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { -	//printf("initSize(%i, %i)\n", width, height); - -	_screenWidth = width; -	_screenHeight = height; - -	free(_offscreen); - -	_offscreen = (byte *)malloc(width * height); -	bzero(_offscreen, width * height); - -	//free(_overlayBuffer); - -	int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor); -	//_overlayBuffer = (OverlayColor *)malloc(fullSize); -	clearOverlay(); - -	free(_fullscreen); - -	_fullscreen = (uint16 *)malloc(fullSize); -	bzero(_fullscreen, fullSize); - -	iPhone_initSurface(width, height); - -	if (_overlayBuffer == NULL) { -		_overlayHeight = iPhone_getScreenHeight(); -		_overlayWidth = iPhone_getScreenWidth(); - -		printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight); -		_overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth]; -	} - -	_fullScreenIsDirty = false; -	dirtyFullScreen(); -	_mouseVisible = false; -	_screenChangeCount++; -	updateScreen(); -} - -int16 OSystem_IPHONE::getHeight() { -	return _screenHeight; -} - -int16 OSystem_IPHONE::getWidth() { -	return _screenWidth; -} - -void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { -	assert(start + num <= 256); -	const byte *b = colors; - -	for (uint i = start; i < start + num; ++i) { -		_palette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); -		b += 3; -	} - -	dirtyFullScreen(); -} - -void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { -	assert(start + num <= 256); -	byte *b = colors; - -	for (uint i = start; i < start + num; ++i) { -		Graphics::colorToRGB<Graphics::ColorMasks<565> >(_palette[i], b[0], b[1], b[2]); -		b += 3; -	} -} - -void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { -	//printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); -	//Clip the coordinates -	if (x < 0) { -		w += x; -		buf -= x; -		x = 0; -	} - -	if (y < 0) { -		h += y; -		buf -= y * pitch; -		y = 0; -	} - -	if (w > _screenWidth - x) { -		w = _screenWidth - x; -	} - -	if (h > _screenHeight - y) { -		h = _screenHeight - y; -	} - -	if (w <= 0 || h <= 0) -		return; - -	if (!_fullScreenIsDirty) { -		_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); -	} - - -	byte *dst = _offscreen + y * _screenWidth + x; -	if (_screenWidth == pitch && pitch == w) -		memcpy(dst, buf, h * w); -	else { -		do { -			memcpy(dst, buf, w); -			buf += pitch; -			dst += _screenWidth; -		} while (--h); -	} -} - -void OSystem_IPHONE::clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h) { -	if (x < 0) { -		w += x; -		x = 0; -	} - -	if (y < 0) { -		h += y; -		y = 0; -	} - -	if (w > _screenWidth - x) -		w = _screenWidth - x; - -	if (h > _screenHeight - y) -		h = _screenHeight - y; - -	if (w < 0) { -		w = 0; -	} - -	if (h < 0) { -		h = 0; -	} -} - -void OSystem_IPHONE::updateScreen() { -	//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); - -	if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) -		return; - -	internUpdateScreen(); -	_fullScreenIsDirty = false; -	_fullScreenOverlayIsDirty = false; - -	iPhone_updateScreen(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY); -} - -void OSystem_IPHONE::internUpdateScreen() { -	int16 mouseX = _mouseX - _mouseHotspotX; -	int16 mouseY = _mouseY - _mouseHotspotY; -	int16 mouseWidth = _mouseWidth; -	int16 mouseHeight = _mouseHeight; - -	clipRectToScreen(mouseX, mouseY, mouseWidth, mouseHeight); - -	Common::Rect mouseRect(mouseX, mouseY, mouseX + mouseWidth, mouseY + mouseHeight); - -	if (_mouseDirty) { -		if (!_fullScreenIsDirty) { -			_dirtyRects.push_back(_lastDrawnMouseRect); -			_dirtyRects.push_back(mouseRect); -		} -		if (!_fullScreenOverlayIsDirty && _overlayVisible) { -			_dirtyOverlayRects.push_back(_lastDrawnMouseRect); -			_dirtyOverlayRects.push_back(mouseRect); -		} -		_mouseDirty = false; -		_lastDrawnMouseRect = mouseRect; -	} - -	while (_dirtyRects.size()) { -		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); - -		//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - -		drawDirtyRect(dirtyRect); - -		if (_overlayVisible) -			drawDirtyOverlayRect(dirtyRect); -		else -			drawMouseCursorOnRectUpdate(dirtyRect, mouseRect); - -		updateHardwareSurfaceForRect(dirtyRect); -	} - -	if (_overlayVisible) { -		while (_dirtyOverlayRects.size()) { -			Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); - -			//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - -			drawDirtyOverlayRect(dirtyRect); -			//drawMouseCursorOnRectUpdate(dirtyRect, mouseRect); -			//updateHardwareSurfaceForRect(dirtyRect); -		} -	} -} - -void OSystem_IPHONE::drawDirtyRect(const Common::Rect& dirtyRect) { -	int h = dirtyRect.bottom - dirtyRect.top; -	int w = dirtyRect.right - dirtyRect.left; - -	byte  *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; -	uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; -	for (int y = h; y > 0; y--) { -		for (int x = w; x > 0; x--) -			*dst++ = _palette[*src++]; - -		dst += _screenWidth - w; -		src += _screenWidth - w; -	} -} - -void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect& dirtyRect) { -	// int h = dirtyRect.bottom - dirtyRect.top; -	// -	// uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left]; -	// uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; -	// int x = (dirtyRect.right - dirtyRect.left) * 2; -	// for (int y = h; y > 0; y--) { -	// 	memcpy(dst, src, x); -	// 	src += _screenWidth; -	// 	dst += _screenWidth; -	// } -	iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); -} - -void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect) { -	//draw mouse on top -	if (_mouseVisible && (updatedRect.intersects(mouseRect))) { -		int srcX = 0; -		int srcY = 0; -		int left = _mouseX - _mouseHotspotX; -		if (left < 0) { -			srcX -= left; -			left = 0; -		} -		int top = _mouseY - _mouseHotspotY; -		if (top < 0) { -			srcY -= top; -			top = 0; -		} - -		int bottom = top + _mouseHeight; -		if (bottom > _screenWidth) -			bottom = _screenWidth; - -		int displayWidth = _mouseWidth; -		if (_mouseWidth + left > _screenWidth) -			displayWidth = _screenWidth - left; - -		int displayHeight = _mouseHeight; -		if (_mouseHeight + top > _screenHeight) -			displayHeight = _screenHeight - top; - -		byte *src = &_mouseBuf[srcY * _mouseWidth + srcX]; -		uint16 *dst = &_fullscreen[top * _screenWidth + left]; -		for (int y = displayHeight; y > srcY; y--) { -			for (int x = displayWidth; x > srcX; x--) { -				if (*src != _mouseKeyColor) -					*dst = _palette[*src]; -				dst++; -				src++; -			} -			dst += _screenWidth - displayWidth + srcX; -			src += _mouseWidth - displayWidth + srcX; -		} -	} -} - -void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect& updatedRect) { -	iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom ); -} - -Graphics::Surface *OSystem_IPHONE::lockScreen() { -	//printf("lockScreen()\n"); - -	_framebuffer.pixels = _offscreen; -	_framebuffer.w = _screenWidth; -	_framebuffer.h = _screenHeight; -	_framebuffer.pitch = _screenWidth; -	_framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); - -	return &_framebuffer; -} - -void OSystem_IPHONE::unlockScreen() { -	//printf("unlockScreen()\n"); -	dirtyFullScreen(); -} - -void OSystem_IPHONE::setShakePos(int shakeOffset) { -	//printf("setShakePos(%i)\n", shakeOffset); -} - -void OSystem_IPHONE::showOverlay() { -	//printf("showOverlay()\n"); -	_overlayVisible = true; -	dirtyFullOverlayScreen(); -	updateScreen(); -	iPhone_enableOverlay(true); -} - -void OSystem_IPHONE::hideOverlay() { -	//printf("hideOverlay()\n"); -	_overlayVisible = false; -	_dirtyOverlayRects.clear(); -	dirtyFullScreen(); -	iPhone_enableOverlay(false); -} - -void OSystem_IPHONE::clearOverlay() { -	//printf("clearOverlay()\n"); -	bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); -	dirtyFullOverlayScreen(); -} - -void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { -	//printf("grabOverlay()\n"); -	int h = _overlayHeight; -	OverlayColor *src = _overlayBuffer; - -	do { -		memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); -		src += _overlayWidth; -		buf += pitch; -	} while (--h); -} - -void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { -	//printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); - -	//Clip the coordinates -	if (x < 0) { -		w += x; -		buf -= x; -		x = 0; -	} - -	if (y < 0) { -		h += y; -		buf -= y * pitch; -		y = 0; -	} - -	if (w > _overlayWidth - x) -		w = _overlayWidth - x; - -	if (h > _overlayHeight - y) -		h = _overlayHeight - y; - -	if (w <= 0 || h <= 0) -		return; - -	if (!_fullScreenOverlayIsDirty) { -		_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); -	} - -	OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); -	if (_overlayWidth == pitch && pitch == w) -		memcpy(dst, buf, h * w * sizeof(OverlayColor)); -	else { -		do { -			memcpy(dst, buf, w * sizeof(OverlayColor)); -			buf += pitch; -			dst += _overlayWidth; -		} while (--h); -	} -} - -int16 OSystem_IPHONE::getOverlayHeight() { -	return _overlayHeight; -} - -int16 OSystem_IPHONE::getOverlayWidth() { -	return _overlayWidth; -} - -bool OSystem_IPHONE::showMouse(bool visible) { -	bool last = _mouseVisible; -	_mouseVisible = visible; -	_mouseDirty = true; - -	return last; -} - -void OSystem_IPHONE::warpMouse(int x, int y) { -	//printf("warpMouse()\n"); - -	_mouseX = x; -	_mouseY = y; -	_mouseDirty = true; -} - -void OSystem_IPHONE::dirtyFullScreen() { -	if (!_fullScreenIsDirty) { -		_dirtyRects.clear(); -		_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight)); -		_fullScreenIsDirty = true; -	} -} - -void OSystem_IPHONE::dirtyFullOverlayScreen() { -	if (!_fullScreenOverlayIsDirty) { -		_dirtyOverlayRects.clear(); -		_dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight)); -		_fullScreenOverlayIsDirty = true; -	} -} - -void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { -	//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - -	int texWidth = getSizeNextPOT(w); -	int texHeight = getSizeNextPOT(h); -	int bufferSize =  texWidth * texHeight * sizeof(int16); -	int16* mouseBuf = (int16*)malloc(bufferSize); -	memset(mouseBuf, 0, bufferSize); - -	for (uint x = 0; x < w; ++x) { -		for (uint y = 0; y < h; ++y) { -			byte color = buf[y * w + x]; -			if (color != keycolor) -				mouseBuf[y * texWidth + x] = _palette[color] | 0x1; -			else -				mouseBuf[y * texWidth + x] = 0x0; -		} -	} - -	iPhone_setMouseCursor(mouseBuf, w, h); - -	if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { -		free(_mouseBuf); -		_mouseBuf = NULL; -	} - -	if (_mouseBuf == NULL) -		_mouseBuf = (byte *)malloc(w * h); - -	_mouseWidth = w; -	_mouseHeight = h; - -	_mouseHotspotX = hotspotX; -	_mouseHotspotY = hotspotY; - -	_mouseKeyColor = (byte)keycolor; - -	memcpy(_mouseBuf, buf, w * h); - -	_mouseDirty = true; -} diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm new file mode 100644 index 0000000000..7e2b1eee07 --- /dev/null +++ b/backends/platform/iphone/osys_video.mm @@ -0,0 +1,418 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "osys_main.h" + +#include "iphone_video.h" + +void OSystem_IPHONE::initVideoContext() { +	_videoContext = [g_iPhoneViewInstance getVideoContext]; +} + +const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { +	return s_supportedGraphicsModes; +} + +int OSystem_IPHONE::getDefaultGraphicsMode() const { +	return kGraphicsModeLinear; +} + +bool OSystem_IPHONE::setGraphicsMode(int mode) { +	switch (mode) { +	case kGraphicsModeNone: +	case kGraphicsModeLinear: +		_videoContext->graphicsMode = (GraphicsModes)mode; +		[g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; +		return true; + +	default: +		return false; +	} +} + +int OSystem_IPHONE::getGraphicsMode() const { +	return _videoContext->graphicsMode; +} + +void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { +	//printf("initSize(%i, %i)\n", width, height); + +	_videoContext->screenWidth = width; +	_videoContext->screenHeight = height; +	_videoContext->shakeOffsetY = 0; + +	free(_gameScreenRaw); + +	_gameScreenRaw = (byte *)malloc(width * height); +	bzero(_gameScreenRaw, width * height); + +	updateOutputSurface(); + +	clearOverlay(); + +	_fullScreenIsDirty = false; +	dirtyFullScreen(); +	_videoContext->mouseIsVisible = false; +	_mouseCursorPaletteEnabled = false; +	_screenChangeCount++; + +	updateScreen(); +} + +void OSystem_IPHONE::updateOutputSurface() { +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; +} + +int16 OSystem_IPHONE::getHeight() { +	return _videoContext->screenHeight; +} + +int16 OSystem_IPHONE::getWidth() { +	return _videoContext->screenWidth; +} + +void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { +	assert(start + num <= 256); +	const byte *b = colors; + +	for (uint i = start; i < start + num; ++i) { +		_gamePalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); +		_gamePaletteRGBA5551[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(b[0], b[1], b[2]); +		b += 3; +	} + +	dirtyFullScreen(); +} + +void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { +	assert(start + num <= 256); +	byte *b = colors; + +	for (uint i = start; i < start + num; ++i) { +		Graphics::colorToRGB<Graphics::ColorMasks<565> >(_gamePalette[i], b[0], b[1], b[2]); +		b += 3; +	} +} + +void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +	//printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); +	//Clip the coordinates +	if (x < 0) { +		w += x; +		buf -= x; +		x = 0; +	} + +	if (y < 0) { +		h += y; +		buf -= y * pitch; +		y = 0; +	} + +	if (w > (int)_videoContext->screenWidth - x) { +		w = _videoContext->screenWidth - x; +	} + +	if (h > (int)_videoContext->screenHeight - y) { +		h = _videoContext->screenHeight - y; +	} + +	if (w <= 0 || h <= 0) +		return; + +	if (!_fullScreenIsDirty) { +		_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); +	} + + +	byte *dst = _gameScreenRaw + y * _videoContext->screenWidth + x; +	if ((int)_videoContext->screenWidth == pitch && pitch == w) +		memcpy(dst, buf, h * w); +	else { +		do { +			memcpy(dst, buf, w); +			buf += pitch; +			dst += _videoContext->screenWidth; +		} while (--h); +	} +} + +void OSystem_IPHONE::updateScreen() { +	//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); + +	if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) +		return; + +	internUpdateScreen(); +	_mouseDirty = false; +	_fullScreenIsDirty = false; +	_fullScreenOverlayIsDirty = false; + +	iPhone_updateScreen(); +} + +void OSystem_IPHONE::internUpdateScreen() { +	if (_mouseNeedTextureUpdate) { +		updateMouseTexture(); +		_mouseNeedTextureUpdate = false; +	} + +	while (_dirtyRects.size()) { +		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); + +		//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); +		drawDirtyRect(dirtyRect); +		// TODO: Implement dirty rect code +		//updateHardwareSurfaceForRect(dirtyRect); +	} + +	if (_videoContext->overlayVisible) { +		// TODO: Implement dirty rect code +		_dirtyOverlayRects.clear(); +		/*while (_dirtyOverlayRects.size()) { +			Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); + +			//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); +			drawDirtyOverlayRect(dirtyRect); +		}*/ +	} +} + +void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { +	int h = dirtyRect.bottom - dirtyRect.top; +	int w = dirtyRect.right - dirtyRect.left; + +	byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; +	byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top); +	for (int y = h; y > 0; y--) { +		uint16 *dst = (uint16 *)dstRaw; +		for (int x = w; x > 0; x--) +			*dst++ = _gamePalette[*src++]; + +		dstRaw += _videoContext->screenTexture.pitch; +		src += _videoContext->screenWidth - w; +	} +} + +Graphics::Surface *OSystem_IPHONE::lockScreen() { +	//printf("lockScreen()\n"); + +	_framebuffer.pixels = _gameScreenRaw; +	_framebuffer.w = _videoContext->screenWidth; +	_framebuffer.h = _videoContext->screenHeight; +	_framebuffer.pitch = _videoContext->screenWidth; +	_framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); + +	return &_framebuffer; +} + +void OSystem_IPHONE::unlockScreen() { +	//printf("unlockScreen()\n"); +	dirtyFullScreen(); +} + +void OSystem_IPHONE::setShakePos(int shakeOffset) { +	//printf("setShakePos(%i)\n", shakeOffset); +	_videoContext->shakeOffsetY = shakeOffset; +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; +	// HACK: We use this to force a redraw. +	_mouseDirty = true; +} + +void OSystem_IPHONE::showOverlay() { +	//printf("showOverlay()\n"); +	_videoContext->overlayVisible = true; +	dirtyFullOverlayScreen(); +	updateScreen(); +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; +} + +void OSystem_IPHONE::hideOverlay() { +	//printf("hideOverlay()\n"); +	_videoContext->overlayVisible = false; +	_dirtyOverlayRects.clear(); +	dirtyFullScreen(); +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; +} + +void OSystem_IPHONE::clearOverlay() { +	//printf("clearOverlay()\n"); +	bzero(_videoContext->overlayTexture.getBasePtr(0, 0), _videoContext->overlayTexture.h * _videoContext->overlayTexture.pitch); +	dirtyFullOverlayScreen(); +} + +void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { +	//printf("grabOverlay()\n"); +	int h = _videoContext->overlayHeight; + +	const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0); +	do { +		memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor)); +		src += _videoContext->overlayTexture.pitch; +		buf += pitch; +	} while (--h); +} + +void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +	//printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); + +	//Clip the coordinates +	if (x < 0) { +		w += x; +		buf -= x; +		x = 0; +	} + +	if (y < 0) { +		h += y; +		buf -= y * pitch; +		y = 0; +	} + +	if (w > (int)_videoContext->overlayWidth - x) +		w = _videoContext->overlayWidth - x; + +	if (h > (int)_videoContext->overlayHeight - y) +		h = _videoContext->overlayHeight - y; + +	if (w <= 0 || h <= 0) +		return; + +	if (!_fullScreenOverlayIsDirty) { +		_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); +	} + +	byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); +	do {  +		memcpy(dst, buf, w * sizeof(OverlayColor)); +		buf += pitch; +		dst += _videoContext->overlayTexture.pitch; +	} while (--h); +} + +int16 OSystem_IPHONE::getOverlayHeight() { +	return _videoContext->overlayHeight; +} + +int16 OSystem_IPHONE::getOverlayWidth() { +	return _videoContext->overlayWidth; +} + +bool OSystem_IPHONE::showMouse(bool visible) { +	bool last = _videoContext->mouseIsVisible; +	_videoContext->mouseIsVisible = visible; +	_mouseDirty = true; + +	return last; +} + +void OSystem_IPHONE::warpMouse(int x, int y) { +	//printf("warpMouse()\n"); + +	_videoContext->mouseX = x; +	_videoContext->mouseY = y; +	_mouseDirty = true; +} + +void OSystem_IPHONE::dirtyFullScreen() { +	if (!_fullScreenIsDirty) { +		_dirtyRects.clear(); +		_dirtyRects.push_back(Common::Rect(0, 0, _videoContext->screenWidth, _videoContext->screenHeight)); +		_fullScreenIsDirty = true; +	} +} + +void OSystem_IPHONE::dirtyFullOverlayScreen() { +	if (!_fullScreenOverlayIsDirty) { +		_dirtyOverlayRects.clear(); +		_dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext->overlayWidth, _videoContext->overlayHeight)); +		_fullScreenOverlayIsDirty = true; +	} +} + +void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +	//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); + +	if (_mouseBuf != NULL && (_videoContext->mouseWidth != w || _videoContext->mouseHeight != h)) { +		free(_mouseBuf); +		_mouseBuf = NULL; +	} + +	if (_mouseBuf == NULL) +		_mouseBuf = (byte *)malloc(w * h); + +	_videoContext->mouseWidth = w; +	_videoContext->mouseHeight = h; + +	_videoContext->mouseHotspotX = hotspotX; +	_videoContext->mouseHotspotY = hotspotY; + +	_mouseKeyColor = (byte)keycolor; + +	memcpy(_mouseBuf, buf, w * h); + +	_mouseDirty = true; +	_mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { +	assert(start + num <= 256); + +	for (uint i = start; i < start + num; ++i, colors += 3) +		_mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]); +	 +	// FIXME: This is just stupid, our client code seems to assume that this +	// automatically enables the cursor palette. +	_mouseCursorPaletteEnabled = true; + +	if (_mouseCursorPaletteEnabled) +		_mouseDirty = _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::updateMouseTexture() { +	int texWidth = getSizeNextPOT(_videoContext->mouseWidth); +	int texHeight = getSizeNextPOT(_videoContext->mouseHeight); +	int bufferSize = texWidth * texHeight * sizeof(int16); +	uint16 *mouseBuf = (uint16 *)malloc(bufferSize); +	memset(mouseBuf, 0, bufferSize); + +	const uint16 *palette; +	if (_mouseCursorPaletteEnabled) +		palette = _mouseCursorPalette; +	else +		palette = _gamePaletteRGBA5551; + +	for (uint x = 0; x < _videoContext->mouseWidth; ++x) { +		for (uint y = 0; y < _videoContext->mouseHeight; ++y) { +			const byte color = _mouseBuf[y * _videoContext->mouseWidth + x]; +			if (color != _mouseKeyColor) +				mouseBuf[y * texWidth + x] = palette[color] | 0x1; +			else +				mouseBuf[y * texWidth + x] = 0x0; +		} +	} + +	iPhone_setMouseCursor(mouseBuf); +} diff --git a/backends/platform/linuxmoto/hardwarekeys.cpp b/backends/platform/linuxmoto/hardwarekeys.cpp index e10e39a23d..da093c6508 100644 --- a/backends/platform/linuxmoto/hardwarekeys.cpp +++ b/backends/platform/linuxmoto/hardwarekeys.cpp @@ -33,60 +33,59 @@ struct Key {  	KeyCode keycode;  	uint16 ascii;  	const char *desc; -	KeyType preferredAction;  	bool shiftable;  };  static const Key keys[] = { -	{ "FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", kActionKeyType, false }, -	{ "CAMERA", KEYCODE_PAUSE, 0, "Camera", kActionKeyType, false }, -	{ "HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", kStartKeyType, false }, -	{ "CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", kActionKeyType, false }, -	{ "PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false }, -	{ "MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false }, +	{ "FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", false }, +	{ "CAMERA", KEYCODE_PAUSE, 0, "Camera", false }, +	{ "HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", false }, +	{ "CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", false }, +	{ "PLUS", KEYCODE_PLUS, '+', "+", false }, +	{ "MINUS", KEYCODE_MINUS, '-', "-", false },  #ifdef MOTOMAGX -	{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, -	{"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, -	{"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, -	{"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, -	{"LEFTSOFT", KEYCODE_F9, ASCII_F9, "LeftSoft", kActionKeyType, false}, -	{"RIGHTSOFT", KEYCODE_F11, ASCII_F11, "RightSoft", kActionKeyType, false}, -	{"0", KEYCODE_0, '0', "0", kActionKeyType, false}, -	{"1", KEYCODE_1, '1', "1", kActionKeyType, false}, -	{"2", KEYCODE_2, '2', "2", kActionKeyType, false}, -	{"3", KEYCODE_3, '3', "3", kActionKeyType, false}, -	{"4", KEYCODE_4, '4', "4", kActionKeyType, false}, -	{"5", KEYCODE_5, '5', "5", kActionKeyType, false}, -	{"6", KEYCODE_6, '6', "6", kActionKeyType, false}, -	{"7", KEYCODE_7, '7', "7", kActionKeyType, false}, -	{"8", KEYCODE_8, '8', "8", kActionKeyType, false}, -	{"9", KEYCODE_9, '9', "9", kActionKeyType, false}, +	{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, +	{"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, +	{"HASH", KEYCODE_HASH, '#', "#", false}, +	{"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, +	{"LEFTSOFT", KEYCODE_F9, ASCII_F9, "LeftSoft", false}, +	{"RIGHTSOFT", KEYCODE_F11, ASCII_F11, "RightSoft", false}, +	{"0", KEYCODE_0, '0', "0", false}, +	{"1", KEYCODE_1, '1', "1", false}, +	{"2", KEYCODE_2, '2', "2", false}, +	{"3", KEYCODE_3, '3', "3", false}, +	{"4", KEYCODE_4, '4', "4", false}, +	{"5", KEYCODE_5, '5', "5", false}, +	{"6", KEYCODE_6, '6', "6", false}, +	{"7", KEYCODE_7, '7', "7", false}, +	{"8", KEYCODE_8, '8', "8", false}, +	{"9", KEYCODE_9, '9', "9", false},  #endif  #ifdef MOTOEZX -	{ "a", KEYCODE_a, 'a', "a", kActionKeyType, true }, -	{ "b", KEYCODE_b, 'b', "b", kActionKeyType, true }, -	{ "c", KEYCODE_c, 'c', "c", kActionKeyType, true }, -	{ "d", KEYCODE_d, 'd', "d", kActionKeyType, true }, -	{ "e", KEYCODE_e, 'e', "e", kActionKeyType, true }, -	{ "f", KEYCODE_f, 'f', "f", kActionKeyType, true }, -	{ "g", KEYCODE_g, 'g', "g", kActionKeyType, true }, -	{ "h", KEYCODE_h, 'h', "h", kActionKeyType, true }, -	{ "i", KEYCODE_i, 'i', "i", kActionKeyType, true }, -	{ "j", KEYCODE_j, 'j', "j", kActionKeyType, true }, +	{ "a", KEYCODE_a, 'a', "a", true }, +	{ "b", KEYCODE_b, 'b', "b", true }, +	{ "c", KEYCODE_c, 'c', "c", true }, +	{ "d", KEYCODE_d, 'd', "d", true }, +	{ "e", KEYCODE_e, 'e', "e", true }, +	{ "f", KEYCODE_f, 'f', "f", true }, +	{ "g", KEYCODE_g, 'g', "g", true }, +	{ "h", KEYCODE_h, 'h', "h", true }, +	{ "i", KEYCODE_i, 'i', "i", true }, +	{ "j", KEYCODE_j, 'j', "j", true },  #endif  	// Numeric keypad  	// Arrows + Home/End pad -	{"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, -	{"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, -	{"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, -	{"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, +	{"UP", KEYCODE_UP, 0, "Up", false}, +	{"DOWN", KEYCODE_DOWN, 0, "Down", false}, +	{"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, +	{"LEFT", KEYCODE_LEFT, 0, "Left", false},  	// Function keys  	// Miscellaneous function keys -	{0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} +	{0, KEYCODE_INVALID, 0, 0, false}  };  struct Mod { @@ -106,9 +105,8 @@ static const Mod modifiers[] = {  	{ KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true },  	{ 0, 0, 0, false }  }; -#endif -  Common::HardwareKeySet *OSystem_LINUXMOTO::getHardwareKeySet() {  	return OSystem_SDL::getHardwareKeySet();  } +#endif diff --git a/backends/platform/linuxmoto/linuxmoto-sdl.h b/backends/platform/linuxmoto/linuxmoto-sdl.h index 97262ccbca..9a0be56e11 100644 --- a/backends/platform/linuxmoto/linuxmoto-sdl.h +++ b/backends/platform/linuxmoto/linuxmoto-sdl.h @@ -29,8 +29,10 @@ class OSystem_LINUXMOTO : public OSystem_POSIX {  public:  	virtual void initBackend(); +#ifdef ENABLE_KEYMAPPER  	// FIXME: This just calls parent methods, is it needed?  	virtual Common::HardwareKeySet *getHardwareKeySet(); +#endif  };  #endif diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index f33aa24278..453c70c45f 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -28,9 +28,10 @@  namespace Maemo {  enum ModelType { -	kModelTypeN800 = 1, -	kModelTypeN810 = 2, -	kModelTypeN900 = 4, +	kModelType770 = 1 << 0, +	kModelTypeN800 = 1 << 1, +	kModelTypeN810 = 1 << 2, +	kModelTypeN900 = 1 << 3,  	kModelTypeInvalid = 0  }; @@ -38,15 +39,22 @@ struct Model {  	const char *hwId;  	ModelType modelType;  	const char *hwAlias; -	bool hwKeyboard; +	bool hasHwKeyboard; +	bool hasMenuKey;  };  static const Model models[] = { -	{"RX-34", kModelTypeN800, "N800", false}, -	{"RX-44", kModelTypeN810, "N810", true}, -	{"RX-48", kModelTypeN810, "N810W", true}, -	{"RX-51", kModelTypeN900, "N900", true}, -	{0, kModelTypeInvalid, 0, true} +	{"SU-18", kModelType770, "770", false, true}, +	{"RX-34", kModelTypeN800, "N800", false, true}, +	{"RX-44", kModelTypeN810, "N810", true, true}, +	{"RX-48", kModelTypeN810, "N810W", true, true}, +	{"RX-51", kModelTypeN900, "N900", true, false}, +	{0, kModelTypeInvalid, 0, true, true} +}; + +enum CustomEventType { +	kEventClickMode = 1, +	kEventInvalid = 0  };  } // namespace Maemo diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h new file mode 100644 index 0000000000..e1337515a7 --- /dev/null +++ b/backends/platform/maemo/maemo-keys.h @@ -0,0 +1,139 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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. + * + */ + +#if defined(MAEMO) +#if defined(ENABLE_KEYMAPPER) + +#ifndef PLATFORM_SDL_MAEMO_KEYS_H +#define PLATFORM_SDL_MAEMO_KEYS_H + +#include "common/keyboard.h" + +#include "backends/keymapper/hardware-key.h" + +namespace Common { + +static const ModifierTableEntry maemoModifiers[] = { +	{ 0, "", "", false }, +	{ KBD_CTRL, "C+", "Ctrl+", false }, +	{ KBD_SHIFT, "", "", true }, +	{ KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, +	{ 0, 0, 0, false } +}; + +static const KeyTableEntry maemoKeys[] = { +	{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, +	{"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, +	{"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, +	{"RETURN", KEYCODE_RETURN, ASCII_RETURN, "MCenter", false}, +	{"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, +	{"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, +	{"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, +	{"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, +	{"HASH", KEYCODE_HASH, '#', "#", false}, +	{"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, +	{"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, +	{"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, +	{"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, +	{"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, +	{"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, +	{"PLUS", KEYCODE_PLUS, '+', "+", false}, +	{"COMMA", KEYCODE_COMMA, ',', ",", false}, +	{"MINUS", KEYCODE_MINUS, '-', "-", false}, +	{"PERIOD", KEYCODE_PERIOD, '.', ".", false}, +	{"SLASH", KEYCODE_SLASH, '/', "/", false}, +	{"0", KEYCODE_0, '0', "0", false}, +	{"1", KEYCODE_1, '1', "1", false}, +	{"2", KEYCODE_2, '2', "2", false}, +	{"3", KEYCODE_3, '3', "3", false}, +	{"4", KEYCODE_4, '4', "4", false}, +	{"5", KEYCODE_5, '5', "5", false}, +	{"6", KEYCODE_6, '6', "6", false}, +	{"7", KEYCODE_7, '7', "7", false}, +	{"8", KEYCODE_8, '8', "8", false}, +	{"9", KEYCODE_9, '9', "9", false}, +	{"COLON", KEYCODE_COLON, ':', ":", false}, +	{"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, +	{"LESS", KEYCODE_LESS, '<', "<", false}, +	{"EQUALS", KEYCODE_EQUALS, '=', "=", false}, +	{"GREATER", KEYCODE_GREATER, '>', ">", false}, +	{"QUESTION", KEYCODE_QUESTION, '?', "?", false}, +	{"AT", KEYCODE_AT, '@', "@", false}, + +	{"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, +	{"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, +	{"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, +	{"CARET", KEYCODE_CARET, '^', "^", false}, +	{"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, +	{"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, +	{"a", KEYCODE_a, 'a', "a", true}, +	{"b", KEYCODE_b, 'b', "b", true}, +	{"c", KEYCODE_c, 'c', "c", true}, +	{"d", KEYCODE_d, 'd', "d", true}, +	{"e", KEYCODE_e, 'e', "e", true}, +	{"f", KEYCODE_f, 'f', "f", true}, +	{"g", KEYCODE_g, 'g', "g", true}, +	{"h", KEYCODE_h, 'h', "h", true}, +	{"i", KEYCODE_i, 'i', "i", true}, +	{"j", KEYCODE_j, 'j', "j", true}, +	{"k", KEYCODE_k, 'k', "k", true}, +	{"l", KEYCODE_l, 'l', "l", true}, +	{"m", KEYCODE_m, 'm', "m", true}, +	{"n", KEYCODE_n, 'n', "n", true}, +	{"o", KEYCODE_o, 'o', "o", true}, +	{"p", KEYCODE_p, 'p', "p", true}, +	{"q", KEYCODE_q, 'q', "q", true}, +	{"r", KEYCODE_r, 'r', "r", true}, +	{"s", KEYCODE_s, 's', "s", true}, +	{"t", KEYCODE_t, 't', "t", true}, +	{"u", KEYCODE_u, 'u', "u", true}, +	{"v", KEYCODE_v, 'v', "v", true}, +	{"w", KEYCODE_w, 'w', "w", true}, +	{"x", KEYCODE_x, 'x', "x", true}, +	{"y", KEYCODE_y, 'y', "y", true}, +	{"z", KEYCODE_z, 'z', "z", true}, +	{"DELETE", KEYCODE_DELETE, 0, "Del", false}, + +	{"KP_ENTER", KEYCODE_KP_ENTER, 0, "Enter", false}, + +	// Arrows + Home/End pad +	{"UP", KEYCODE_UP, 0, "Up", false}, +	{"DOWN", KEYCODE_DOWN, 0, "Down", false}, +	{"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, +	{"LEFT", KEYCODE_LEFT, 0, "Left", false}, + +	// Function keys +	{"MENU", KEYCODE_F11, 0, "Menu", false}, +	{"HOME", KEYCODE_F12, 0, "Home", false}, +	{"FULLSCREEN", KEYCODE_F13, 0, "FullScreen", false}, +	{"ZOOMPLUS", KEYCODE_F14, 0, "Zoom+", false}, +	{"ZOOMMINUS", KEYCODE_F15, 0, "Zoom-", false}, + +	{0, KEYCODE_INVALID, 0, 0, false} +}; + +} // namespace Common + +#endif // ifndef PLATFORM_SDL_MAEMO_KEYS_H + +#endif // if defined(ENABLE_KEYMAPPER) +#endif // if defined(MAEMO) diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 454a13631c..209e527e3f 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -28,9 +28,13 @@  #include "common/config-manager.h"  #include "backends/platform/maemo/maemo.h" +#include "backends/platform/maemo/maemo-keys.h"  #include "backends/events/maemosdl/maemosdl-events.h"  #include "backends/graphics/maemosdl/maemosdl-graphics.h" +#include "backends/keymapper/keymapper.h" +#include "backends/keymapper/keymapper-defaults.h"  #include "common/textconsole.h" +#include "common/translation.h"  #include <SDL/SDL_syswm.h> @@ -43,6 +47,43 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo()  	OSystem_POSIX() {  } +OSystem_SDL_Maemo::~OSystem_SDL_Maemo() { +	delete _eventObserver; +#ifdef ENABLE_KEYMAPPER +	delete _keymapperDefaultBindings; +#endif +} + +#ifdef ENABLE_KEYMAPPER +static void registerDefaultKeyBindings(Common::KeymapperDefaultBindings *_keymapperDefaultBindings, Model _model) { +	_keymapperDefaultBindings->setDefaultBinding("gui", "REM", "HOME"); +	_keymapperDefaultBindings->setDefaultBinding("global", "REM", "HOME"); + +	if (_model.hasMenuKey && _model.hasHwKeyboard) { +		_keymapperDefaultBindings->setDefaultBinding("gui", "FUL", "FULLSCREEN"); +		_keymapperDefaultBindings->setDefaultBinding("global", "FUL", "FULLSCREEN"); +	} + +	if (_model.hasHwKeyboard) { +		_keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "C+ZOOMMINUS"); +		_keymapperDefaultBindings->setDefaultBinding("global", "VIR", "C+ZOOMMINUS"); +	} else { +		_keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "FULLSCREEN"); +		_keymapperDefaultBindings->setDefaultBinding("global", "VIR", "FULLSCREEN"); +	} + +	if (_model.hasMenuKey ) +		_keymapperDefaultBindings->setDefaultBinding("global", "MEN", "MENU"); +	else +		_keymapperDefaultBindings->setDefaultBinding("global", "MEN", "S+C+M"); + +	_keymapperDefaultBindings->setDefaultBinding("gui", "CLO", "ESCAPE"); + +	_keymapperDefaultBindings->setDefaultBinding("maemo", "RCL", "ZOOMPLUS"); +	_keymapperDefaultBindings->setDefaultBinding("maemo", "CLK", "ZOOMMINUS"); +} +#endif +  void OSystem_SDL_Maemo::initBackend() {  	// Create the events manager  	if (_eventSource == 0) @@ -51,12 +92,25 @@ void OSystem_SDL_Maemo::initBackend() {  	if (_graphicsManager == 0)  		_graphicsManager = new MaemoSdlGraphicsManager(_eventSource); +	if (_eventObserver == 0) +		_eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource); + +#ifdef ENABLE_KEYMAPPER +	if (_keymapperDefaultBindings == 0) +		_keymapperDefaultBindings = new Common::KeymapperDefaultBindings(); +#endif +  	ConfMan.set("vkeybdpath", DATA_PATH); -	_model = Model(detectModel()); +	_model = detectModel(); + +#ifdef ENABLE_KEYMAPPER +	registerDefaultKeyBindings(_keymapperDefaultBindings, _model); +#endif  	// Call parent implementation of this method  	OSystem_POSIX::initBackend(); +	initObserver();  }  void OSystem_SDL_Maemo::quit() { @@ -118,6 +172,41 @@ void OSystem_SDL_Maemo::setupIcon() {  	// http://bugzilla.libsdl.org/show_bug.cgi?id=586  } +#ifdef ENABLE_KEYMAPPER +Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() { +	return new Common::HardwareKeySet(Common::maemoKeys, Common::maemoModifiers); +} + +Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { +	using namespace Common; +	Keymap *globalMap = new Keymap("maemo"); + +	Action *act; + +	act = new Action(globalMap, "CLKM", _("Click Mode")); +	Event evt = Event(); +	evt.type = EVENT_CUSTOM_BACKEND; +	evt.customType = Maemo::kEventClickMode; +	act->addEvent(evt); + +	act = new Action(globalMap, "LCLK", _("Left Click")); +	act->addLeftClickEvent(); + +	act = new Action(globalMap, "MCLK", _("Middle Click")); +	act->addMiddleClickEvent(); + +	act = new Action(globalMap, "RCLK", _("Right Click")); +	act->addRightClickEvent(); + +	return globalMap; +} +#endif + +void OSystem_SDL_Maemo::initObserver() { +	assert(_eventManager); +	_eventManager->getEventDispatcher()->registerObserver(_eventObserver, 10, false); +} +  } //namespace Maemo  #endif diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 32b52470bc..4b84ae573a 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -29,25 +29,36 @@  #include "backends/platform/maemo/maemo-common.h"  namespace Maemo { +class MaemoSdlEventObserver;  class OSystem_SDL_Maemo : public OSystem_POSIX {  public:  	OSystem_SDL_Maemo(); +	~OSystem_SDL_Maemo();  	virtual void initBackend();  	virtual void quit();  	virtual void fatalError();  	virtual void setWindowCaption(const char *caption);  	virtual void setupIcon(); +#ifdef ENABLE_KEYMAPPER +	virtual Common::HardwareKeySet *getHardwareKeySet(); +	virtual Common::Keymap *getGlobalKeymap(); +	virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return _keymapperDefaultBindings; } +#endif  	Model getModel() { return _model; }  private:  	virtual void setXWindowName(const char *caption); +	void initObserver();  	const Model detectModel();  	Model _model; - +	MaemoSdlEventObserver *_eventObserver; +#ifdef ENABLE_KEYMAPPER +	Common::KeymapperDefaultBindings *_keymapperDefaultBindings; +#endif  };  } // namespace Maemo diff --git a/backends/platform/n64/osys_n64_utilities.cpp b/backends/platform/n64/osys_n64_utilities.cpp index 94d727e421..f007a1bd25 100644 --- a/backends/platform/n64/osys_n64_utilities.cpp +++ b/backends/platform/n64/osys_n64_utilities.cpp @@ -100,9 +100,9 @@ void refillAudioBuffers(void) {  	Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer();  	while (_requiredSoundSlots) { -		sndBuf = (byte*)getAIBuffer(); +		sndBuf = (byte *)getAIBuffer(); -		localmixer->mixCallback((byte*)sndBuf, osys->_audioBufferSize); +		localmixer->mixCallback((byte *)sndBuf, osys->_audioBufferSize);  		putAIBuffer(); diff --git a/backends/platform/openpandora/build/PXML.xml b/backends/platform/openpandora/build/PXML.xml deleted file mode 100755 index a87c49e2b8..0000000000 --- a/backends/platform/openpandora/build/PXML.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd"> -    <!-- This is the package, in our case ScummVM --> -    <package id="scummvm.djwillis.0001"> -        <author name="DJWillis" website="http://www.scummvm.org/"/> -        <!-- version type can be alpha, beta or release, set to release in branch --> -        <version major="1" minor="4" release="0" build="1" type="alpha"/> -        <!-- Both title and titles are needed --> -        <title lang="en_US">ScummVM</title> -        <titles> -            <title lang="en_US">ScummVM</title> -        </titles> -        <descriptions> -            <description lang="en_US"> -                ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! - -                ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. -            </description> -        </descriptions> -        <icon src="icon/scummvm.png"/> -    </package> - -    <!-- This is the application, the ScummVM binary --> -    <application id="scummvm.djwillis.0001" appdata="scummvm"> -        <exec command="./runscummvm.sh"/> -        <author name="DJWillis" website="http://www.scummvm.org/"/> -        <!-- version type can be alpha, beta or release, set to release in branch --> -        <version major="1" minor="4" release="0" build="1" type="alpha"/> -        <!-- Both title and titles are needed --> -        <title lang="en_US">ScummVM</title> -        <titles> -            <title lang="en_US">ScummVM</title> -        </titles> -        <descriptions> -            <description lang="en_US"> -                ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! - -                ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. -            </description> -        </descriptions> -        <licenses> -            <license name="GPLv2" url="http://www.gnu.org/licenses/gpl-2.0.html" sourcecodeurl="http://www.scummvm.org"/> -        </licenses> -        <icon src="icon/scummvm.png"/> -        <previewpics> -            <pic src="icon/preview-pic.png"/> -        </previewpics> -        <info name="ScummVM Documentation" type="text/html" src="docs/index.html"/> -        <categories> -            <category name="Game"> -                <subcategory name="AdventureGame"/> -            </category> -        </categories> -    </application> -</PXML> diff --git a/backends/platform/openpandora/build/PXML_schema.xsd b/backends/platform/openpandora/build/PXML_schema.xsd deleted file mode 100644 index 7c0d635016..0000000000 --- a/backends/platform/openpandora/build/PXML_schema.xsd +++ /dev/null @@ -1,341 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<xs:schema targetNamespace="http://openpandora.org/namespaces/PXML" xmlns="http://openpandora.org/namespaces/PXML" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> -	 -	 -	<!-- declare some simpleTypes for later usage --> -	 -	<!-- Specify params allows with the 'x11' entry in exec --> -	<xs:simpleType name="x11Param"> -		<xs:restriction base="xs:string"> -			<xs:enumeration value="req" /> -			<xs:enumeration value="stop" /> -			<xs:enumeration value="ignore" /> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- Specify the valid documentation formats in the <info> block --> -	<xs:simpleType name="docType"> -		<xs:restriction base="xs:string"> -			<xs:enumeration value="text/html" /> -			<xs:enumeration value="text/plain" /> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- Make sure that version numbers only consist of letters, numbers and + as well as - --> -	<xs:simpleType name="versionNumber"> -		<xs:restriction base="xs:string"> -			<xs:minLength value="1"/> -			<xs:pattern value="[a-zA-Z0-9+-]*" /> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- Specify what is valid as release type --> -	<xs:simpleType name="releaseType"> -		<xs:restriction base="xs:string"> -			<xs:enumeration value="alpha" /> -			<xs:enumeration value="beta" /> -			<xs:enumeration value="release" /> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- Specify what makes an email address "valid" --> -	<xs:simpleType name="emailAddress"> -		<xs:restriction base="xs:string"> -			<xs:pattern value="[^@]+@[^\.]+\..+"/> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- some restrictions regarding file names that are eg not allowed/possible when using sd cards formated as fat32 --> -	<xs:simpleType name="dumbPath"> -		<xs:restriction base="xs:normalizedString"> -			<xs:pattern value="[^?>:]+" /> -		</xs:restriction> -	</xs:simpleType> -	<xs:simpleType name="dumbFolderName"> -		<xs:restriction base="xs:normalizedString"> -			<xs:pattern value="[^?>:/]+" /> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- Specify lang codes --> -	<xs:simpleType name="isoLangcode"> -		<xs:restriction base="xs:string"> -			<xs:minLength value="2"/> -			<xs:pattern value="[a-zA-Z]{2,3}(_[a-zA-Z0-9]{2,3})*" /> -		</xs:restriction> -	</xs:simpleType> -	<xs:simpleType name="isoLangcode_en_US"> -		<xs:restriction base="xs:string"> -			<xs:enumeration value="en_US" /> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- Definition of all allowed categories following the FDO specs --> -	<xs:simpleType name="fdoCategory"> -		<xs:restriction base="xs:string"> -			<xs:pattern value="AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Settings|System|Utility"/> -		</xs:restriction> -	</xs:simpleType> -	<!-- Definition of all allowed subcategories following the FDO specs (should be based upon the given main categories, but would significantly increase complexity of the schema) --> -	<xs:simpleType name="fdoSubCategory"> -		<xs:restriction base="xs:string"> -			<xs:pattern value="Building|Debugger|IDE|GUIDesigner|Profiling|RevisionControl|Translation|Calendar|ContactManagement|Database|Dictionary|Chart|Email|Finance|FlowChart|PDA|ProjectManagement|Presentation|Spreadsheet|WordProcessor|2DGraphics|VectorGraphics|RasterGraphics|3DGraphics|Scanning|OCR|Photography|Publishing|Viewer|TextTools|DesktopSettings|HardwareSettings|Printing|PackageManager|Dialup|InstantMessaging|Chat|IRCClient|FileTransfer|HamRadio|News|P2P|RemoteAccess|Telephony|TelephonyTools|VideoConference|WebBrowser|WebDevelopment|Midi|Mixer|Sequencer|Tuner|TV|AudioVideoEditing|Player|Recorder|DiscBurning|ActionGame|AdventureGame|ArcadeGame|BoardGame|BlocksGame|CardGame|KidsGame|LogicGame|RolePlaying|Simulation|SportsGame|StrategyGame|Art|Construction|Music|Languages|Science|ArtificialIntelligence|Astronomy|Biology|Chemistry|ComputerScience|DataVisualization|Economy|Electricity|Geography|Geology|Geoscience|History|ImageProcessing|Literature|Math|NumericalAnalysis|MedicalSoftware|Physics|Robotics|Sports|ParallelComputing|Amusement|Archiving|Compression|Electronics|Emulator|Engineering|FileTools|FileManager|TerminalEmulator|Filesystem|Monitor|Security|Accessibility|Calculator|Clock|TextEditor|Documentation|Core|KDE|GNOME|GTK|Qt|Motif|Java|ConsoleOnly"/> -		</xs:restriction> -	</xs:simpleType> -	 -	<!-- Create some way to enforce entries to be nonempty --> -	<xs:simpleType name="nonempty_token"> -		<xs:restriction base="xs:token"> -			<xs:minLength value="1"/> -		</xs:restriction> -	</xs:simpleType> -		<xs:simpleType name="nonempty_string"> -		<xs:restriction base="xs:string"> -			<xs:minLength value="1"/> -		</xs:restriction> -	</xs:simpleType> -		<xs:simpleType name="nonempty_normalizedString"> -		<xs:restriction base="xs:string"> -			<xs:minLength value="1"/> -		</xs:restriction> -	</xs:simpleType> -	 -	 -	 -	<!-- declare some complexTypes for later usage --> -	 -	<!-- type used for file associations --> -	<xs:complexType name="association_data"> -		<xs:attribute name="name" use="required" type="nonempty_normalizedString" /> -		<xs:attribute name="filetype" use="required" type="nonempty_token" /> -		<xs:attribute name="exec" use="required" type="nonempty_token" /> -	</xs:complexType> -	 -	<!-- type used for author info --> -	<xs:complexType name="author_data"> -		<xs:attribute name="name" use="required" type="nonempty_normalizedString" /> -		<xs:attribute name="website" use="optional" type="xs:anyURI" /> -		<xs:attribute name="email" use="optional" type="emailAddress" /> -	</xs:complexType> -	 -	<!-- type used for version informations (full entry as well as os version) --> -	<xs:complexType name="app_version_info"> -		<xs:attribute name="major" use="required" type="versionNumber" /> -		<xs:attribute name="minor" use="required" type="versionNumber" /> -		<xs:attribute name="release" use="required" type="versionNumber" /> -		<xs:attribute name="build" use="required" type="versionNumber" /> -		<xs:attribute name="type" use="optional" type="releaseType" /> -	</xs:complexType> -	<xs:complexType name="os_version_info"> -		<xs:attribute name="major" use="required" type="versionNumber" /> -		<xs:attribute name="minor" use="required" type="versionNumber" /> -		<xs:attribute name="release" use="required" type="versionNumber" /> -		<xs:attribute name="build" use="required" type="versionNumber" /> -	</xs:complexType> -	 -	<!-- type used for exec entries --> -	<xs:complexType name="exec_params"> -		<xs:attribute name="command" use="required" type="nonempty_token" /> -		<xs:attribute name="arguments" use="optional" type="nonempty_token" /> -		<xs:attribute name="background" use="optional" type="xs:boolean" /> -		<xs:attribute name="startdir" use="optional" type="dumbPath" /> -		<xs:attribute name="standalone" use="optional" type="xs:boolean" /> -		<xs:attribute name="x11" use="optional" type="x11Param" /> -	</xs:complexType> -	 -	<!-- type used for tiles or descriptions, once in 'normal' version, once enforcing usage of en_US --> -	<xs:complexType name="title_or_description"> -		<xs:simpleContent> -			<xs:extension base="nonempty_string"> -				<xs:attribute name="lang" use="required" type="isoLangcode" /> -			</xs:extension> -		</xs:simpleContent> -	</xs:complexType> -	<xs:complexType name="title_or_description_enUS"> -		<xs:simpleContent> -			<xs:extension base="nonempty_string"> -				<xs:attribute name="lang" use="required" type="isoLangcode_en_US" /> -			</xs:extension> -		</xs:simpleContent> -	</xs:complexType> -	 -	<!-- type used for referencing images --> -	<xs:complexType name="image_entry"> -		<xs:attribute name="src" use="required" type="dumbPath" /> -	</xs:complexType> -	 -	<!-- type for referencing manuals/readme docs --> -	<xs:complexType name="information_entry"> -		<xs:attribute name="name" use="required" type="nonempty_normalizedString" /> -		<xs:attribute name="type" use="required" type="docType" /> -		<xs:attribute name="src" use="required" type="dumbPath" /> -	</xs:complexType> -	 -	<!-- type used for the license information --> -	<xs:complexType name="license_info"> -		<xs:attribute name="name" use="required" type="nonempty_normalizedString" /> -		<xs:attribute name="url" use="optional" type="xs:anyURI" /> -		<xs:attribute name="sourcecodeurl" use="optional" type="xs:anyURI" /> -	</xs:complexType> -	 -	 -	 -	<!-- Combine the symple and complex types into the "real" PXML specification --> -	 -	<xs:element name="PXML"> -		<xs:complexType> -			<xs:sequence> -				<!-- specify the <package> tag with info about the complete package, information providable: -					author -					version -					title(s) -					description(s) -					icon -					--> -				<xs:element name="package" minOccurs="1" maxOccurs="1"> -					<xs:complexType> -						<xs:all> -							<!--Author info--> -							<xs:element name="author" type="author_data" minOccurs="1" /> -							<!--App version info--> -							<xs:element name="version" type="app_version_info" minOccurs="1" /> -							<!--Title--> -							<xs:element name="titles" minOccurs="1"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> -										<xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Description--> -							<xs:element name="descriptions" minOccurs="0"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="title" type="title_or_description_enUS" minOccurs="0" maxOccurs="1" /> -										<xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Icon--> -							<xs:element name="icon" type="image_entry" minOccurs="0" /> -						</xs:all> -						<!--Package ID--> -						<xs:attribute name="id" use="required" type="dumbFolderName" /> -					</xs:complexType> -				</xs:element> -				<!-- specify the <application> tag with info about a single program -					executable call -					author -					version (of the application) -					osversion (min OS version supported) -					title(s) (allowing compatibility to <HF6, too!) -					description(s) (allowing compatibility to <HF6, too!) -					icon -					license -					preview pictures -					info/manual/readme entry -					categories -					associations to file types -					clockspeed -					--> -				<xs:element name="application" minOccurs="1" maxOccurs="unbounded"> -					<xs:complexType> -						<xs:all> -							<!--Execution params --> -							<xs:element name="exec" type="exec_params" minOccurs="1" /> -							<!--Author info--> -							<xs:element name="author" type="author_data" minOccurs="1" /> -							<!--App version info--> -							<xs:element name="version" type="app_version_info" minOccurs="1" /> -							<!--OS Version info--> -							<xs:element name="osversion" type="os_version_info" minOccurs="0" /> -							<!--Title--> -							<!-- via <titles> element, used for HF6+ --> -							<xs:element name="titles" minOccurs="1"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> -										<xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Title--> -							<!-- via <title> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 --> -							<xs:element name="title" type="title_or_description_enUS" minOccurs="0" /> -							<!--Description--> -							<!-- via <descriptions> element, used for HF6+ --> -							<xs:element name="descriptions" minOccurs="0"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="description" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> -										<xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Description--> -							<!-- via <description> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 --> -							<xs:element name="description" type="title_or_description_enUS" minOccurs="0" /> -							<!--Icon--> -							<xs:element name="icon" type="image_entry" minOccurs="0" /> -							<!--License--> -							<xs:element name="licenses" minOccurs="1"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="license" type="license_info" minOccurs="1" maxOccurs="unbounded" /> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Preview pics--> -							<xs:element name="previewpics" minOccurs="0"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="pic" type="image_entry" minOccurs="0" maxOccurs="unbounded" /> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Info (aka manual or readme entry)--> -							<xs:element name="info" type="information_entry" minOccurs="0" /> -							<!--Categories--> -							<xs:element name="categories" minOccurs="1"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="category" minOccurs="1" maxOccurs="unbounded"> -											<xs:complexType> -												<xs:sequence> -													<xs:element name="subcategory" minOccurs="0" maxOccurs="unbounded"> -														<xs:complexType> -															<xs:attribute name="name" type="fdoSubCategory" /> -														</xs:complexType> -													</xs:element> -												</xs:sequence> -												<xs:attribute name="name" use="required" type="fdoCategory" /> -											</xs:complexType> -										</xs:element> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Associations--> -							<xs:element name="associations" minOccurs="0"> -								<xs:complexType> -									<xs:sequence> -										<xs:element name="association" type="association_data" maxOccurs="unbounded" /> -									</xs:sequence> -								</xs:complexType> -							</xs:element> -							<!--Clockspeed--> -							<xs:element name="clockspeed" minOccurs="0"> -								<xs:complexType> -									<xs:attribute name="frequency" use="required" type="xs:positiveInteger" /> -								</xs:complexType> -							</xs:element> -						</xs:all> -						<!--AppID--> -						<xs:attribute name="id" use="required" type="dumbFolderName" /> -						<xs:attribute name="appdata" use="optional" type="dumbFolderName" /> -					</xs:complexType> -				</xs:element> -			</xs:sequence> -		</xs:complexType> -	</xs:element> -</xs:schema> diff --git a/backends/platform/openpandora/build/README-OPENPANDORA b/backends/platform/openpandora/build/README-OPENPANDORA deleted file mode 100755 index c8aabcbb7a..0000000000 --- a/backends/platform/openpandora/build/README-OPENPANDORA +++ /dev/null @@ -1,19 +0,0 @@ -ScummVM - OPENPANDORA SPECIFIC README ------------------------------------------------------------------------- -Please refer to the: - -ScummVM Forum: <http://forums.scummvm.org/> -WiKi: <http://wiki.scummvm.org/index.php/OpenPandora> - -for the most current information on the port and any updates to this -documentation. - -The wiki includes detailed instructions on how to use the port and  -control information. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -OpenPandora backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/README-PND.txt b/backends/platform/openpandora/build/README-PND.txt deleted file mode 100755 index 942c3a43e2..0000000000 --- a/backends/platform/openpandora/build/README-PND.txt +++ /dev/null @@ -1,38 +0,0 @@ -ScummVM - OPENPANDORA README - HOW TO INSTALL ------------------------------------------------------------------------- - -Please refer to the: - -ScummVM Forum: <http://forums.scummvm.org/> -WiKi: <http://wiki.scummvm.org/index.php/OpenPandora> - -for the most current information on the port and any updates to this -documentation. - ------------------------------------------------------------------------- -Installing: - -This archive contains ScummVM in a PND format ready to be copied to the -OpenPandora and used. - -To install just copy the .pnd file from this archive to your device. - -You will need to place the .pnd file in a suitable location on your SD -card. - -/pandora/desktop <- place here if you wish the icon to show on the -			desktop. Documentation will show in the menu. - -/pandora/menu <- place here if you wish the icon to show on the -			Xfce menu. Documentation will show in the menu. - -/pandora/apps <- place here if you wish the icon to show on the -			desktop and in the menu. Documentation will show -			in the menu. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -OpenPandora backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/icon/preview-pic.png b/backends/platform/openpandora/build/icon/preview-pic.png Binary files differdeleted file mode 100755 index 2f4a536d30..0000000000 --- a/backends/platform/openpandora/build/icon/preview-pic.png +++ /dev/null diff --git a/backends/platform/openpandora/build/icon/scummvm.png b/backends/platform/openpandora/build/icon/scummvm.png Binary files differdeleted file mode 100755 index 128e59efc4..0000000000 --- a/backends/platform/openpandora/build/icon/scummvm.png +++ /dev/null diff --git a/backends/platform/openpandora/build/index.html b/backends/platform/openpandora/build/index.html deleted file mode 100755 index 34d381d0f8..0000000000 --- a/backends/platform/openpandora/build/index.html +++ /dev/null @@ -1,26 +0,0 @@ -<html> - -<h3> -  <p>Welcome to the ScummVM!</p> -</h3> - -<h4> -  <p>ScummVM: OpenPandora Specific Documentation</p> -</h4> - -<A href="docs/README-OPENPANDORA">ScummVM OpenPandora README</a><br/> -<A href="http://scummvm.distant-earth.com/">ScummVM OpenPandora Website</a><br/> -<A href="http://wiki.scummvm.org/index.php/OpenPandora">ScummVM OpenPandora WiKi</a><br/> - -<h4> -  <p>ScummVM: General Documentation</p> -</h4> - -<A href="http://www.scummvm.org/">ScummVM website</a><br/> -<A href="docs/README">ScummVM README</a><br/> -<A href="docs/NEWS">ScummVM NEWS</a><br/> -<A href="docs/AUTHORS">ScummVM Authors</a><br/> -<A href="docs/COPYRIGHT">ScummVM Copyright</a><br/> -<A href="docs/COPYING">GPL Licence</a><br/> - -</html> diff --git a/backends/platform/openpandora/build/pnd_make.sh b/backends/platform/openpandora/build/pnd_make.sh deleted file mode 100755 index 0c03e8154d..0000000000 --- a/backends/platform/openpandora/build/pnd_make.sh +++ /dev/null @@ -1,321 +0,0 @@ -#!/bin/bash -# -# pnd_make.sh -# -# This script is meant to ease generation of a pnd file. Please consult the output -# when running --help for a list of available parameters and an explaination of -# those. -# -# Required tools when running the script: -# bash -# echo, cat, mv, rm -# mkisofs or mksquashfs (the latter when using the -c param!) -# xmllint (optional, only for validation of the PXML against the schema) - - -PXML_schema=$(dirname ${0})/PXML_schema.xsd -GENPXML_PATH=$(dirname ${0})/genpxml.sh - -# useful functions ... -black='\E[30m' -red='\E[31m' -green='\E[32m' -yellow='\E[33m' -blue='\E[34m' -magenta='\E[35m' -cyan='\E[36m' -white='\E[37m' - -check_for_tool() -{ -	which $1 &> /dev/null -	if [ "$?" -ne "0" ]; -	then -		cecho "ERROR: Could not find the program '$1'. Please make sure -that it is available in your PATH since it is required to complete your request." $red -		exit 1 -	fi -} - -cecho ()	# Color-echo. Argument $1 = message, Argument $2 = color -{ -	local default_msg="No message passed."   # Doesn't really need to be a local variable. -	message=${1:-$default_msg}               # Defaults to default message. -	color=${2:-$black}                       # Defaults to black, if not specified. -	echo -e "$color$message" -	tput sgr0                                # Reset to normal. -	return -}  - - -print_help() -{ -	cat << EOSTREAM -pnd_make.sh - A script to package "something" into a PND. - -Usage: -  $(basename ${0}) {--directory|-d} <folder> {--pndname|-p} <file> [{--compress-squashfs|-c}] -                   [{--genpxml} <file>] [{--icon|-i} <file>] [{--pxml|-x} <file>] -                   [{--schema|-s} <file>] [{--help|-h}] - - -Switches: -  --compress-squashfs / -c  Define whether or not the pnd should be compressed using -                            squashfs. If this parameter is selected, a compressed pnd -                            will be created. - -  --directory / -d          Sets the folder that is to be used for the resulting pnd -                            to <folder>. This option is mandatory for the script to -                            function correctly. - -  --genpxml                 Sets the script used for generating a PXML file (if none -                            is available already) to <file>. Please make sure to either -                            provide a full path or prefix a script in the current folder -                            with './' so that the script can actually be executed. If -                            this variable is not specified, $GENPXML_PATH -                            will be used. - -  --help / -h               Displays this help text. - -  --icon / -i               Sets the icon that will be appended in the pnd to <file>. - -  --pndname / -p            Sets the output filename of the resulting pnd to <file>. -                            This option is mandatory for the script to function -                            correctly. - -  --pxml / -x               Sets the PXML file that is to be used to <file>. If you -                            neither provide a PXML file or set this entry to 'guess', -                            an existing 'PXML.xml' in your selected '--directory' -                            will be used, or the script $GENPXML_PATH -                            will be called to try to generate a basic PXML file for you. - -  --schema / -s             Sets the schema file, that is to be used for validation, -                            to <file. If this is not defined, the script will try to -                            use the file '$PXML_schema'. If this fails, -                            a warning is issued. - -If you select the option to create a compressed squashfs, a version >=4.0 of squashfs -is required to be available in your PATH. -EOSTREAM -} - - -# Parse command line parameters -while [ "${1}" != "" ]; do -	if [ "${1}" = "--compress-squashfs" ] || [ "${1}" = "-c" ]; -	then -		SQUASH=1 -		shift 1 -	elif [ "${1}" = "--directory" ] || [ "${1}" = "-d" ]; -	then -		FOLDER=$2 -		shift 2 -	elif [ "${1}" = "--genpxml" ]; -	then -		GENPXML_PATH=$2 -		shift 2 -	elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ]; -	then -		print_help -		exit 0 -	elif [ "${1}" = "--icon" ] || [ "${1}" = "-i" ]; -	then -		ICON=$2 -		shift 2 -	elif [ "${1}" = "--pndname" ] || [ "${1}" = "-p" ]; -	then -		PNDNAME=$2 -		shift 2 -	elif [ "${1}" = "--pxml" ] || [ "${1}" = "-x" ]; -	then -		PXML=$2 -		shift 2 -	elif [ "${1}" = "--schema" ] || [ "${1}" = "-f" ] -	then -		PXML_schema=$2 -		shift 2 -	else -		cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red -		print_help -		exit 1 -	fi -done - - -# Generate a PXML if the param is set to Guess or it is empty. -if [ ! $PXML ] || [ $PXML = "guess" ] && [ $PNDNAME ] && [ $FOLDER ]; -then -	if [ -f $FOLDER/PXML.xml ]; # use the already existing PXML.xml file if there is one... -	then -		PXML=$FOLDER/PXML.xml -		PXML_ALREADY_EXISTING="true" -	else -		if [ -f $GENPXML_PATH ]; -		then -			$GENPXML_PATH --src $FOLDER --dest $FOLDER --author $USER -			if [ -f $FOLDER/PXML.xml ]; -			then -				PXML_GENERATED="true" -			else -				cecho "ERROR: Generating a PXML file using '$GENPXML_PATH' failed. -Please generate a PXML file manually." $red -				exit 1 -			fi -		else -			cecho "ERROR: Could not find '$GENPXML_PATH' for generating a PXML file." $red -			exit 1 -		fi -	fi -fi - - -# Probe if required variables were set -echo -e -cecho "Checking if all required variables were set." $green -if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; -then -	echo -e -	cecho "ERROR: Not all required options were set! Please see the --help information below." $red -	echo -e -	print_help -	exit 1 -else -	echo "PNDNAME set to '$PNDNAME'." -fi -# Check if the selected folder actually exists -if [ ! -d $FOLDER ]; -then -	echo -e -	cecho "ERROR: '$FOLDER' doesn't exist or is not a folder." $red -	exit 1 -else -	echo "FOLDER set to '$FOLDER'." -fi -# Check if the selected PXML file actually exists -if [ ! -f $PXML ]; -then -	echo -e -	cecho "ERROR: '$PXML' doesn't exist or is not a file." $red -	exit 1 -else -	if [ $PXML_ALREADY_EXISTING ]; -	then -		echo "You have not explicitly specified a PXML to use, but an existing file was -found. Will be using this one." -	elif [ $PXML_GENERATED ]; -	then -		echo "A PXML file was generated for you using '$GENPXML_PATH'. This file will -not be removed at the end of this script because you might want to review it, adjust -single entries and rerun the script to generate a pnd with a PXML file with all the -information you want to have listed." -	fi -	echo "PXML set to '$PXML'." -fi - -# Print the other variables: -if [ $ICON ]; -then -	if [ ! -f $ICON ] -	then -		cecho "WARNING: '$ICON' doesn't exist, will not append the selected icon to the pnd." $red -	else -		echo "ICON set to '$ICON'." -		USE_ICON="true" -	fi -fi -if [ $SQUASH ]; -then -	echo "Will use a squashfs for '$PNDNAME'." -fi - - -# Validate the PXML file (if xmllint is available) -# Errors and problems in this section will be shown but are not fatal. -echo -e -cecho "Trying to validate '$PXML' now. Will be using '$PXML_schema' to do so." $green -which xmllint &> /dev/null -if [ "$?" -ne "0" ]; -then -	VALIDATED=false -	cecho "WARNING: Could not find 'xmllint'. Validity check of '$PXML' is not possible!" $red -else -	if [ ! -f "$PXML_schema" ]; -	then -		VALIDATED=false -		cecho "WARNING: Could not find '$PXML_schema'. If you want to validate your -PXML file please make sure to provide a schema using the --schema option." $red -	else -		xmllint --noout --schema $PXML_schema $PXML -		if [ "$?" -ne "0" ]; then VALIDATED=false; else VALIDATED=true; fi -	fi -fi -# Print some message at the end about the validation in case the user missed the output above -if [ $VALIDATED = "false" ] -then -	cecho "WARNING: Could not successfully validate '$PXML'. Please check the output -above. This does not mean that your pnd will be broken. Either you are not following the strict -syntax required for validation or you don't have all files/programs required for validating." $red -else -	cecho "Your file '$PXML' was validated successfully. The resulting pnd should -work nicely with libpnd." $green -fi - - -# Make iso from folder -echo -e -cecho "Creating an iso file based on '$FOLDER'." $green -if [ $SQUASH ]; -then -	check_for_tool mksquashfs -	if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') -eq 0 ]; -	then -		cecho "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later" $red -		exit 1 -	fi -	mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery -else -	check_for_tool mkisofs -	mkisofs -o $PNDNAME.iso -R $FOLDER -fi - -# Check that the iso file was actually created before continuing -if [ ! -f $PNDNAME.iso ]; -then -	cecho "ERROR: The temporary file '$PNDNAME.iso' could not be created. -Please check the output above for any errors and retry after fixing them. Aborting." $red -	exit 1 -fi - - -# Append pxml to iso -echo -e -cecho "Appending '$PXML' to the created iso file." $green -cat $PNDNAME.iso $PXML > $PNDNAME -rm $PNDNAME.iso #cleanup - - -# Append icon if specified and available -if [ $USE_ICON ]; -then -	echo -e -	cecho "Appending the icon '$ICON' to the pnd." $green -	mv $PNDNAME $PNDNAME.tmp -	cat $PNDNAME.tmp $ICON > $PNDNAME # append icon -	rm $PNDNAME.tmp #cleanup -fi - - -# Final message -echo -e -if [ -f $PNDNAME ]; -then -	cecho "Successfully finished creating the pnd '$PNDNAME'." $green -else -	cecho "There seems to have been a problem and '$PNDNAME' was not created. Please check -the output above for any error messages. A possible cause for this is that there was -not enough space available." $red -	exit 1 -fi - - -#if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup diff --git a/backends/platform/openpandora/build/runscummvm.sh b/backends/platform/openpandora/build/runscummvm.sh deleted file mode 100755 index 9c9d8362cb..0000000000 --- a/backends/platform/openpandora/build/runscummvm.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Make sure any extra libs not in the firmware are pulled in. -LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib -export LD_LIBRARY_PATH - -# Ensure we have a folder to store save games on the SD card. -mkdir saves - -# make a runtime dir, just incase it creates anything in CWD -mkdir runtime -cd runtime - -../bin/scummvm --fullscreen  --gfx-mode=2x --config=../scummvm.config  --themepath=../data diff --git a/backends/platform/openpandora/op-bundle.mk b/backends/platform/openpandora/op-bundle.mk index 089430f43c..284a0497a8 100755 --- a/backends/platform/openpandora/op-bundle.mk +++ b/backends/platform/openpandora/op-bundle.mk @@ -14,15 +14,15 @@ op-bundle: $(EXECUTABLE)  	$(MKDIR) "$(bundle_name)/scummvm/icon"  	$(MKDIR) "$(bundle_name)/scummvm/lib" -	$(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ +	$(CP) $(srcdir)/dists/openpandora/runscummvm.sh $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/openpandora/PXML.xml $(bundle_name)/scummvm/data/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png  $(bundle_name)/scummvm/icon/ +	$(CP) $(srcdir)/dists/openpandora/icon/scummvm.png $(bundle_name)/scummvm/icon/ +	$(CP) $(srcdir)/dists/openpandora/icon/preview-pic.png  $(bundle_name)/scummvm/icon/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ +	$(CP) $(srcdir)/dists/openpandora/README-OPENPANDORA $(bundle_name)/scummvm/docs/ +	$(CP) $(srcdir)/dists/openpandora/index.html $(bundle_name)/scummvm/docs/  	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ @@ -50,15 +50,15 @@ op-pnd: $(EXECUTABLE)  	$(MKDIR) "$(bundle_name)/scummvm/icon"  	$(MKDIR) "$(bundle_name)/scummvm/lib" -	$(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ +	$(CP) $(srcdir)/dists/openpandora/runscummvm.sh $(bundle_name)/scummvm/ +	$(CP) $(srcdir)/dists/openpandora/PXML.xml $(bundle_name)/scummvm/data/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png  $(bundle_name)/scummvm/icon/ +	$(CP) $(srcdir)/dists/openpandora/icon/scummvm.png $(bundle_name)/scummvm/icon/ +	$(CP) $(srcdir)/dists/openpandora/icon/preview-pic.png  $(bundle_name)/scummvm/icon/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ -	$(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ +	$(CP) $(srcdir)/dists/openpandora/README-OPENPANDORA $(bundle_name)/scummvm/docs/ +	$(CP) $(srcdir)/dists/openpandora/index.html $(bundle_name)/scummvm/docs/  	$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ @@ -75,9 +75,10 @@ endif  	$(CP) $(libloc)/../arm-angstrom-linux-gnueabi/usr/lib/libFLAC.so.8.2.0 $(bundle_name)/scummvm/lib/libFLAC.so.8 -	$(srcdir)/backends/platform/openpandora/build/pnd_make.sh -p $(bundle_name).pnd -c -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png +	$(srcdir)/dists/openpandora/pnd_make.sh -p $(bundle_name).pnd -c -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png + +	$(CP) $(srcdir)/dists/openpandora/README-PND.txt $(bundle_name) -	$(CP) $(srcdir)/backends/platform/openpandora/build/README-PND.txt $(bundle_name)  	tar -cvjf $(bundle_name)-pnd.tar.bz2 $(bundle_name).pnd $(bundle_name)/README-PND.txt  	rm -R ./$(bundle_name) diff --git a/backends/platform/ps2/DmaPipe.cpp b/backends/platform/ps2/DmaPipe.cpp index c6f6ab72ac..a346a67566 100644 --- a/backends/platform/ps2/DmaPipe.cpp +++ b/backends/platform/ps2/DmaPipe.cpp @@ -48,7 +48,7 @@ private:  DmaPipe::DmaPipe(uint32 size) {  	size &= ~0x1F; -	_buf = (uint64*)memalign(64, size); +	_buf = (uint64 *)memalign(64, size);  	_curPipe = 0;      _pipes[0] = new SinglePipe(_buf, size >> 4);  	_pipes[1] = new SinglePipe(_buf + (size >> 4), size >> 4); @@ -260,7 +260,7 @@ void SinglePipe::init(void) {  	_buf[0] = 0x0000000070000000;  	_buf[1] = 0;  	_chainHead = _buf; -	_chainSize = (uint16*)_chainHead; +	_chainSize = (uint16 *)_chainHead;  	_bufPos = _buf + 2;  } @@ -272,7 +272,7 @@ void SinglePipe::appendChain(uint64 dmaTag) {  	_chainHead = _bufPos;  	_chainHead[0] = dmaTag;  	_chainHead[1] = 0; -	_chainSize = (uint16*)_chainHead; +	_chainSize = (uint16 *)_chainHead;  	_bufPos += 2;  } diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index b70e8b13fa..8df6198c38 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -130,9 +130,9 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {  	_height = height;  	_pitch = (width + 127) & ~127; -	_screenBuf = (uint8*)memalign(64, _width * _height); -	_overlayBuf = (uint16*)memalign(64, _width * _height * 2); -	_clut = (uint32*)memalign(64, 256 * 4); +	_screenBuf = (uint8 *)memalign(64, _width * _height); +	_overlayBuf = (uint16 *)memalign(64, _width * _height * 2); +	_clut = (uint32 *)memalign(64, 256 * 4);  	memset(_screenBuf, 0, _width * _height);  	memset(_clut, 0, 256 * sizeof(uint32)); @@ -291,11 +291,11 @@ void Gs2dScreen::quit(void) {  }  void Gs2dScreen::createAnimTextures(void) { -	uint8 *buf = (uint8*)memalign(64, 16 * 64); +	uint8 *buf = (uint8 *)memalign(64, 16 * 64);  	memset(buf, 0, 16 * 64);  	uint32 vramDest = _texPtrs[TEXT];  	for (int i = 0; i < 16; i++) { -		uint32 *destPos = (uint32*)buf; +		uint32 *destPos = (uint32 *)buf;  		for (int ch = 15; ch >= 0; ch--) {  			const uint32 *src = (const uint32*)(_binaryData + ((_binaryPattern[i] >> ch) & 1) * 4 * 14);  			for (int line = 0; line < 14; line++) @@ -331,8 +331,8 @@ void Gs2dScreen::newScreenSize(uint16 width, uint16 height) {  	// malloc new buffers  	free(_screenBuf);  	free(_overlayBuf); -	_screenBuf = (uint8*)memalign(64, _width * _height); -	_overlayBuf = (uint16*)memalign(64, _width * _height * 2); +	_screenBuf = (uint8 *)memalign(64, _width * _height); +	_overlayBuf = (uint16 *)memalign(64, _width * _height * 2);  	memset(_screenBuf, 0, _width * height);  	memset(_overlayBuf, 0, _width * height * 2);  	memset(_clut, 0, 256 * sizeof(uint32)); @@ -556,7 +556,7 @@ void Gs2dScreen::copyPrintfOverlay(const uint8 *buf) {  }  void Gs2dScreen::clearPrintfOverlay(void) { -	uint8 *tmpBuf = (uint8*)memalign(64, 320 * 200); +	uint8 *tmpBuf = (uint8 *)memalign(64, 320 * 200);  	memset(tmpBuf, 4, 320 * 200);  	_dmaPipe->uploadTex(_texPtrs[PRINTF], 3 * 128, 0, 0, GS_PSMT8H, tmpBuf, 320, 200);  	_dmaPipe->flush(); @@ -619,7 +619,7 @@ void Gs2dScreen::setMouseOverlay(const uint8 *buf, uint16 width, uint16 height,  		_mTraCol = transpCol;  		_clutChanged = true;  	} -	uint8 *bufCopy = (uint8*)memalign(64, M_SIZE * M_SIZE); // make a copy to align to 64 bytes +	uint8 *bufCopy = (uint8 *)memalign(64, M_SIZE * M_SIZE); // make a copy to align to 64 bytes  	memset(bufCopy, _mTraCol, M_SIZE * M_SIZE);  	for (int cnt = 0; cnt < height; cnt++)  		memcpy(bufCopy + cnt * M_SIZE, buf + cnt * width, width); diff --git a/backends/platform/ps2/fileio.cpp b/backends/platform/ps2/fileio.cpp index ef01f3a693..1ec16a3817 100644 --- a/backends/platform/ps2/fileio.cpp +++ b/backends/platform/ps2/fileio.cpp @@ -52,7 +52,7 @@ Ps2File::Ps2File() {  	_eof = false;  	_err = false; -	_cacheBuf = (uint8*)memalign(64, CACHE_SIZE * 2); +	_cacheBuf = (uint8 *)memalign(64, CACHE_SIZE * 2);  	_cacheOpRunning = 0;  	_filePos = _physFilePos = _cachePos = 0; @@ -362,7 +362,7 @@ uint32 Ps2File::read(void *dest, uint32 len) {  		_eof = true;  	} -	uint8 *destBuf = (uint8*)dest; +	uint8 *destBuf = (uint8 *)dest;  	if ((_filePos < _cachePos) || (_filePos + len > _cachePos + _bytesInCache))  		cacheReadSync(); // we have to read from CD, sync cache. @@ -413,7 +413,7 @@ uint32 Ps2File::read(void *dest, uint32 len) {  #ifdef __PS2_FILE_SEMA__  	SignalSema(_sema);  #endif -	return destBuf - (uint8*)dest; +	return destBuf - (uint8 *)dest;  }  uint32 Ps2File::write(const void *src, uint32 len) { @@ -518,7 +518,7 @@ FILE *ps2_fopen(const char *fname, const char *mode) {  }  int ps2_fclose(FILE *stream) { -	Ps2File *file = (Ps2File*)stream; +	Ps2File *file = (Ps2File *)stream;  	delete file; @@ -528,10 +528,10 @@ int ps2_fclose(FILE *stream) {  size_t ps2_fread(void *buf, size_t r, size_t n, FILE *stream) {  	assert(r != 0); -	return ((Ps2File*)stream)->read(buf, r * n) / r; +	return ((Ps2File *)stream)->read(buf, r * n) / r;  }  size_t ps2_fwrite(const void *buf, size_t r, size_t n, FILE *stream) {  	assert(r != 0); -	return ((Ps2File*)stream)->write(buf, r * n) / r; +	return ((Ps2File *)stream)->write(buf, r * n) / r;  } diff --git a/backends/platform/ps2/icon.cpp b/backends/platform/ps2/icon.cpp index 9852e6d40b..bda4843647 100644 --- a/backends/platform/ps2/icon.cpp +++ b/backends/platform/ps2/icon.cpp @@ -960,13 +960,13 @@ void PS2Icon::setup(mcIcon *icon) {  	memcpy(icon->head, "PS2D", 4);  	icon->nlOffset = strlen(_info) + 1;  	strcpy(title, _info); -	strcpy_sjis((short*)&(icon->title), title); +	strcpy_sjis((short *)&(icon->title), title);  	icon->trans = 0x10;  	memcpy(icon->bgCol, _bgcolor, sizeof(_bgcolor));  	memcpy(icon->lightDir, _lightdir, sizeof(_lightdir));  	memcpy(icon->lightCol, _lightcol, sizeof(_lightcol));  	memcpy(icon->lightAmbient, _ambient, sizeof(_ambient)); -	strcpy((char*)icon->view, "scummvm.icn"); -	strcpy((char*)icon->copy, "scummvm.icn"); -	strcpy((char*)icon->del, "scummvm.icn"); +	strcpy((char *)icon->view, "scummvm.icn"); +	strcpy((char *)icon->copy, "scummvm.icn"); +	strcpy((char *)icon->del, "scummvm.icn");  } diff --git a/backends/platform/ps2/ps2mutex.cpp b/backends/platform/ps2/ps2mutex.cpp index 5b30fa7862..ae63fe5724 100644 --- a/backends/platform/ps2/ps2mutex.cpp +++ b/backends/platform/ps2/ps2mutex.cpp @@ -57,7 +57,7 @@ OSystem::MutexRef OSystem_PS2::createMutex(void) {  void OSystem_PS2::lockMutex(MutexRef mutex) {  	WaitSema(_mutexSema); -	Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; +	Ps2Mutex *sysMutex = (Ps2Mutex *)mutex;  	int tid = GetThreadId();  	assert(tid != 0); @@ -75,7 +75,7 @@ void OSystem_PS2::lockMutex(MutexRef mutex) {  void OSystem_PS2::unlockMutex(MutexRef mutex) {  	WaitSema(_mutexSema); -	Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; +	Ps2Mutex *sysMutex = (Ps2Mutex *)mutex;  	int tid = GetThreadId();  	if (sysMutex->owner && sysMutex->count && (sysMutex->owner == tid)) @@ -90,7 +90,7 @@ void OSystem_PS2::unlockMutex(MutexRef mutex) {  void OSystem_PS2::deleteMutex(MutexRef mutex) {  	WaitSema(_mutexSema); -	Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; +	Ps2Mutex *sysMutex = (Ps2Mutex *)mutex;  	if (sysMutex->owner || sysMutex->count)  		printf("WARNING: Deleting LOCKED mutex!\n");  	DeleteSema(sysMutex->sema); diff --git a/backends/platform/ps2/ps2pad.cpp b/backends/platform/ps2/ps2pad.cpp index eeb9dfbd93..b6afc217e6 100644 --- a/backends/platform/ps2/ps2pad.cpp +++ b/backends/platform/ps2/ps2pad.cpp @@ -30,7 +30,7 @@  Ps2Pad::Ps2Pad(OSystem_PS2 *system) {  	_system = system; -	_padBuf = (uint8*)memalign(64, 256); +	_padBuf = (uint8 *)memalign(64, 256);  	_padStatus = STAT_NONE;  	padInit(0); // initialize library diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 481227dd02..d4e993da63 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -384,8 +384,8 @@ void OSystem_PS2::initTimer(void) {  	ee_thread_t timerThread, soundThread, thisThread;  	ReferThreadStatus(GetThreadId(), &thisThread); -	_timerStack = (uint8*)malloc(TIMER_STACK_SIZE); -	_soundStack = (uint8*)malloc(SOUND_STACK_SIZE); +	_timerStack = (uint8 *)malloc(TIMER_STACK_SIZE); +	_soundStack = (uint8 *)malloc(SOUND_STACK_SIZE);  	// give timer thread a higher priority than main thread  	timerThread.initial_priority = thisThread.current_priority - 1; @@ -435,7 +435,7 @@ void OSystem_PS2::timerThreadCallback(void) {  }  void OSystem_PS2::soundThreadCallback(void) { -	int16 *soundBufL = (int16*)memalign(64, SMP_PER_BLOCK * sizeof(int16) * 2); +	int16 *soundBufL = (int16 *)memalign(64, SMP_PER_BLOCK * sizeof(int16) * 2);  	int16 *soundBufR = soundBufL + SMP_PER_BLOCK;  	int bufferedSamples = 0; @@ -453,9 +453,9 @@ void OSystem_PS2::soundThreadCallback(void) {  		if (bufferedSamples <= 8 * SMP_PER_BLOCK) {  			// we have to produce more samples, call sound mixer  			// the scratchpad at 0x70000000 is used as temporary soundbuffer -			//_scummSoundProc(_scummSoundParam, (uint8*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); -			// Audio::Mixer::mixCallback(_scummMixer, (byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); -			_scummMixer->mixCallback((byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); +			//_scummSoundProc(_scummSoundParam, (uint8 *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); +			// Audio::Mixer::mixCallback(_scummMixer, (byte *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); +			_scummMixer->mixCallback((byte *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16));  			// demux data into 2 buffers, L and R  			 __asm__ ( @@ -635,7 +635,7 @@ void OSystem_PS2::clearOverlay(void) {  }  void OSystem_PS2::grabOverlay(OverlayColor *buf, int pitch) { -	_screen->grabOverlay((uint16*)buf, (uint16)pitch); +	_screen->grabOverlay((uint16 *)buf, (uint16)pitch);  }  void OSystem_PS2::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { @@ -738,12 +738,12 @@ void OSystem_PS2::msgPrintf(int millis, const char *format, ...) {          lnSta = lnEnd + 1;  	} -	uint8 *scrBuf = (uint8*)memalign(64, 320 * 200); +	uint8 *scrBuf = (uint8 *)memalign(64, 320 * 200);  	memset(scrBuf, 4, 320 * 200);  	uint8 *dstPos = scrBuf + ((200 - posY) >> 1) * 320 + (320 - maxWidth) / 2;  	for (int y = 0; y < posY; y++) { -		uint8 *srcPos = (uint8*)surf.getBasePtr((300 - maxWidth) / 2, y); +		uint8 *srcPos = (uint8 *)surf.getBasePtr((300 - maxWidth) / 2, y);  		for (int x = 0; x < maxWidth; x++)  			dstPos[x] = srcPos[x] + 5;  		dstPos += 320; diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index cdb130e2a0..10a732b1e3 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -210,14 +210,14 @@ void MasterGuRenderer::guProgramDisplayBufferSizes() {  	switch (GuRenderer::_displayManager->getOutputBitsPerPixel()) {  	case 16:  		sceGuDrawBuffer(GU_PSM_4444, (void *)0, PSP_BUFFER_WIDTH); -		sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)(PSP_FRAME_SIZE * sizeof(uint16)), PSP_BUFFER_WIDTH); -		sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * sizeof(uint16) * 2), PSP_BUFFER_WIDTH); +		sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void *)(PSP_FRAME_SIZE * sizeof(uint16)), PSP_BUFFER_WIDTH); +		sceGuDepthBuffer((void *)(PSP_FRAME_SIZE * sizeof(uint16) * 2), PSP_BUFFER_WIDTH);  		VramAllocator::instance().allocate(PSP_FRAME_SIZE * sizeof(uint16) * 2);  		break;  	case 32:  		sceGuDrawBuffer(GU_PSM_8888, (void *)0, PSP_BUFFER_WIDTH); -		sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)(PSP_FRAME_SIZE * sizeof(uint32)), PSP_BUFFER_WIDTH); -		sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * sizeof(uint32) * 2), PSP_BUFFER_WIDTH); +		sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void *)(PSP_FRAME_SIZE * sizeof(uint32)), PSP_BUFFER_WIDTH); +		sceGuDepthBuffer((void *)(PSP_FRAME_SIZE * sizeof(uint32) * 2), PSP_BUFFER_WIDTH);  		VramAllocator::instance().allocate(PSP_FRAME_SIZE * sizeof(uint32) * 2);  		break;  	} diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 9a33e357da..5fb4473ebd 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -28,159 +28,143 @@  using namespace Common; -struct Key { -	const char *hwId; -	KeyCode keycode; -	uint16 ascii; -	const char *desc; -	KeyType preferredAction; -	bool shiftable; -}; - -static const Key keys[] = { -	{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, -	{"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, -	{"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false}, -	{"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, false}, -	{"PAUSE", KEYCODE_PAUSE, 0, "Pause", kActionKeyType, false}, -	{"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false}, -	{"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false}, -	{"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false}, -	{"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false}, -	{"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, -	{"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false}, -	{"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false}, -	{"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false}, -	{"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false}, -	{"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false}, -	{"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, -	{"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, -	{"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false}, -	{"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, -	{"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false}, -	{"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false}, -	{"0", KEYCODE_0, '0', "0", kActionKeyType, false}, -	{"1", KEYCODE_1, '1', "1", kActionKeyType, false}, -	{"2", KEYCODE_2, '2', "2", kActionKeyType, false}, -	{"3", KEYCODE_3, '3', "3", kActionKeyType, false}, -	{"4", KEYCODE_4, '4', "4", kActionKeyType, false}, -	{"5", KEYCODE_5, '5', "5", kActionKeyType, false}, -	{"6", KEYCODE_6, '6', "6", kActionKeyType, false}, -	{"7", KEYCODE_7, '7', "7", kActionKeyType, false}, -	{"8", KEYCODE_8, '8', "8", kActionKeyType, false}, -	{"9", KEYCODE_9, '9', "9", kActionKeyType, false}, -	{"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false}, -	{"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false}, -	{"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false}, -	{"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false}, -	{"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false}, -	{"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false}, -	{"AT", KEYCODE_AT, '@', "@", kActionKeyType, false}, - -	{"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false}, -	{"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false}, -	{"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false}, -	{"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false}, -	{"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false}, -	{"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false}, -	{"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, -	{"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, -	{"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, -	{"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, -	{"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, -	{"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, -	{"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, -	{"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, -	{"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, -	{"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, -	{"k", KEYCODE_k, 'k', "k", kActionKeyType, true}, -	{"l", KEYCODE_l, 'l', "l", kActionKeyType, true}, -	{"m", KEYCODE_m, 'm', "m", kActionKeyType, true}, -	{"n", KEYCODE_n, 'n', "n", kActionKeyType, true}, -	{"o", KEYCODE_o, 'o', "o", kActionKeyType, true}, -	{"p", KEYCODE_p, 'p', "p", kActionKeyType, true}, -	{"q", KEYCODE_q, 'q', "q", kActionKeyType, true}, -	{"r", KEYCODE_r, 'r', "r", kActionKeyType, true}, -	{"s", KEYCODE_s, 's', "s", kActionKeyType, true}, -	{"t", KEYCODE_t, 't', "t", kActionKeyType, true}, -	{"u", KEYCODE_u, 'u', "u", kActionKeyType, true}, -	{"v", KEYCODE_v, 'v', "v", kActionKeyType, true}, -	{"w", KEYCODE_w, 'w', "w", kActionKeyType, true}, -	{"x", KEYCODE_x, 'x', "x", kActionKeyType, true}, -	{"y", KEYCODE_y, 'y', "y", kActionKeyType, true}, -	{"z", KEYCODE_z, 'z', "z", kActionKeyType, true}, -	{"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false}, +static const KeyTableEntry sdlKeys[] = { +	{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, +	{"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, +	{"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, +	{"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", false}, +	{"PAUSE", KEYCODE_PAUSE, 0, "Pause", false}, +	{"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, +	{"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, +	{"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, +	{"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, +	{"HASH", KEYCODE_HASH, '#', "#", false}, +	{"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, +	{"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, +	{"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, +	{"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, +	{"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, +	{"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, +	{"PLUS", KEYCODE_PLUS, '+', "+", false}, +	{"COMMA", KEYCODE_COMMA, ',', ",", false}, +	{"MINUS", KEYCODE_MINUS, '-', "-", false}, +	{"PERIOD", KEYCODE_PERIOD, '.', ".", false}, +	{"SLASH", KEYCODE_SLASH, '/', "/", false}, +	{"0", KEYCODE_0, '0', "0", false}, +	{"1", KEYCODE_1, '1', "1", false}, +	{"2", KEYCODE_2, '2', "2", false}, +	{"3", KEYCODE_3, '3', "3", false}, +	{"4", KEYCODE_4, '4', "4", false}, +	{"5", KEYCODE_5, '5', "5", false}, +	{"6", KEYCODE_6, '6', "6", false}, +	{"7", KEYCODE_7, '7', "7", false}, +	{"8", KEYCODE_8, '8', "8", false}, +	{"9", KEYCODE_9, '9', "9", false}, +	{"COLON", KEYCODE_COLON, ':', ":", false}, +	{"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, +	{"LESS", KEYCODE_LESS, '<', "<", false}, +	{"EQUALS", KEYCODE_EQUALS, '=', "=", false}, +	{"GREATER", KEYCODE_GREATER, '>', ">", false}, +	{"QUESTION", KEYCODE_QUESTION, '?', "?", false}, +	{"AT", KEYCODE_AT, '@', "@", false}, + +	{"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, +	{"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, +	{"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, +	{"CARET", KEYCODE_CARET, '^', "^", false}, +	{"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, +	{"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, +	{"a", KEYCODE_a, 'a', "a", true}, +	{"b", KEYCODE_b, 'b', "b", true}, +	{"c", KEYCODE_c, 'c', "c", true}, +	{"d", KEYCODE_d, 'd', "d", true}, +	{"e", KEYCODE_e, 'e', "e", true}, +	{"f", KEYCODE_f, 'f', "f", true}, +	{"g", KEYCODE_g, 'g', "g", true}, +	{"h", KEYCODE_h, 'h', "h", true}, +	{"i", KEYCODE_i, 'i', "i", true}, +	{"j", KEYCODE_j, 'j', "j", true}, +	{"k", KEYCODE_k, 'k', "k", true}, +	{"l", KEYCODE_l, 'l', "l", true}, +	{"m", KEYCODE_m, 'm', "m", true}, +	{"n", KEYCODE_n, 'n', "n", true}, +	{"o", KEYCODE_o, 'o', "o", true}, +	{"p", KEYCODE_p, 'p', "p", true}, +	{"q", KEYCODE_q, 'q', "q", true}, +	{"r", KEYCODE_r, 'r', "r", true}, +	{"s", KEYCODE_s, 's', "s", true}, +	{"t", KEYCODE_t, 't', "t", true}, +	{"u", KEYCODE_u, 'u', "u", true}, +	{"v", KEYCODE_v, 'v', "v", true}, +	{"w", KEYCODE_w, 'w', "w", true}, +	{"x", KEYCODE_x, 'x', "x", true}, +	{"y", KEYCODE_y, 'y', "y", true}, +	{"z", KEYCODE_z, 'z', "z", true}, +	{"DELETE", KEYCODE_DELETE, 0, "Del", false},  	// Numeric keypad -	{"KP0", KEYCODE_KP0, 0, "KP0", kActionKeyType, false}, -	{"KP1", KEYCODE_KP1, 0, "KP1", kActionKeyType, false}, -	{"KP2", KEYCODE_KP2, 0, "KP2", kActionKeyType, false}, -	{"KP3", KEYCODE_KP3, 0, "KP3", kActionKeyType, false}, -	{"KP4", KEYCODE_KP4, 0, "KP4", kActionKeyType, false}, -	{"KP5", KEYCODE_KP5, 0, "KP5", kActionKeyType, false}, -	{"KP6", KEYCODE_KP6, 0, "KP6", kActionKeyType, false}, -	{"KP7", KEYCODE_KP7, 0, "KP7", kActionKeyType, false}, -	{"KP8", KEYCODE_KP8, 0, "KP8", kActionKeyType, false}, -	{"KP9", KEYCODE_KP9, 0, "KP9", kActionKeyType, false}, -	{"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", kActionKeyType, false}, -	{"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", kActionKeyType, false}, -	{"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", kActionKeyType, false}, -	{"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", kActionKeyType, false}, -	{"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", kActionKeyType, false}, -	{"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", kActionKeyType, false}, -	{"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", kActionKeyType, false}, +	{"KP0", KEYCODE_KP0, 0, "KP0", false}, +	{"KP1", KEYCODE_KP1, 0, "KP1", false}, +	{"KP2", KEYCODE_KP2, 0, "KP2", false}, +	{"KP3", KEYCODE_KP3, 0, "KP3", false}, +	{"KP4", KEYCODE_KP4, 0, "KP4", false}, +	{"KP5", KEYCODE_KP5, 0, "KP5", false}, +	{"KP6", KEYCODE_KP6, 0, "KP6", false}, +	{"KP7", KEYCODE_KP7, 0, "KP7", false}, +	{"KP8", KEYCODE_KP8, 0, "KP8", false}, +	{"KP9", KEYCODE_KP9, 0, "KP9", false}, +	{"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", false}, +	{"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", false}, +	{"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", false}, +	{"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", false}, +	{"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", false}, +	{"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", false}, +	{"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", false},  	// Arrows + Home/End pad -	{"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, -	{"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, -	{"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, -	{"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, -	{"INSERT", KEYCODE_INSERT, 0, "Insert", kActionKeyType, false}, -	{"HOME", KEYCODE_HOME, 0, "Home", kActionKeyType, false}, -	{"END", KEYCODE_END, 0, "End", kActionKeyType, false}, -	{"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", kActionKeyType, false}, -	{"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", kActionKeyType, false}, +	{"UP", KEYCODE_UP, 0, "Up", false}, +	{"DOWN", KEYCODE_DOWN, 0, "Down", false}, +	{"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, +	{"LEFT", KEYCODE_LEFT, 0, "Left", false}, +	{"INSERT", KEYCODE_INSERT, 0, "Insert", false}, +	{"HOME", KEYCODE_HOME, 0, "Home", false}, +	{"END", KEYCODE_END, 0, "End", false}, +	{"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", false}, +	{"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", false},  	// Function keys -	{"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false}, -	{"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false}, -	{"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false}, -	{"F4", KEYCODE_F4, ASCII_F4, "F4", kActionKeyType, false}, -	{"F5", KEYCODE_F5, ASCII_F5, "F5", kActionKeyType, false}, -	{"F6", KEYCODE_F6, ASCII_F6, "F6", kActionKeyType, false}, -	{"F7", KEYCODE_F7, ASCII_F7, "F7", kActionKeyType, false}, -	{"F8", KEYCODE_F8, ASCII_F8, "F8", kActionKeyType, false}, -	{"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false}, -	{"F10", KEYCODE_F10, ASCII_F10, "F10", kActionKeyType, false}, -	{"F11", KEYCODE_F11, ASCII_F11, "F11", kActionKeyType, false}, -	{"F12", KEYCODE_F12, ASCII_F12, "F12", kActionKeyType, false}, -	{"F13", KEYCODE_F13, 0, "F13", kActionKeyType, false}, -	{"F14", KEYCODE_F14, 0, "F14", kActionKeyType, false}, -	{"F15", KEYCODE_F15, 0, "F15", kActionKeyType, false}, +	{"F1", KEYCODE_F1, ASCII_F1, "F1", false}, +	{"F2", KEYCODE_F2, ASCII_F2, "F2", false}, +	{"F3", KEYCODE_F3, ASCII_F3, "F3", false}, +	{"F4", KEYCODE_F4, ASCII_F4, "F4", false}, +	{"F5", KEYCODE_F5, ASCII_F5, "F5", false}, +	{"F6", KEYCODE_F6, ASCII_F6, "F6", false}, +	{"F7", KEYCODE_F7, ASCII_F7, "F7", false}, +	{"F8", KEYCODE_F8, ASCII_F8, "F8", false}, +	{"F9", KEYCODE_F9, ASCII_F9, "F9", false}, +	{"F10", KEYCODE_F10, ASCII_F10, "F10", false}, +	{"F11", KEYCODE_F11, ASCII_F11, "F11", false}, +	{"F12", KEYCODE_F12, ASCII_F12, "F12", false}, +	{"F13", KEYCODE_F13, 0, "F13", false}, +	{"F14", KEYCODE_F14, 0, "F14", false}, +	{"F15", KEYCODE_F15, 0, "F15", false},  	// Miscellaneous function keys -	{"HELP", KEYCODE_HELP, 0, "Help", kActionKeyType, false}, -	{"PRINT", KEYCODE_PRINT, 0, "Print", kActionKeyType, false}, -	{"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", kActionKeyType, false}, -	{"BREAK", KEYCODE_BREAK, 0, "Break", kActionKeyType, false}, -	{"MENU", KEYCODE_MENU, 0, "Menu", kActionKeyType, false}, +	{"HELP", KEYCODE_HELP, 0, "Help", false}, +	{"PRINT", KEYCODE_PRINT, 0, "Print", false}, +	{"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", false}, +	{"BREAK", KEYCODE_BREAK, 0, "Break", false}, +	{"MENU", KEYCODE_MENU, 0, "Menu", false},  		// Power Macintosh power key -	{"POWER", KEYCODE_POWER, 0, "Power", kActionKeyType, false}, +	{"POWER", KEYCODE_POWER, 0, "Power", false},  		// Some european keyboards -	{"EURO", KEYCODE_EURO, 0, "Euro", kActionKeyType, false}, +	{"EURO", KEYCODE_EURO, 0, "Euro", false},  		// Atari keyboard has Undo -	{"UNDO", KEYCODE_UNDO, 0, "Undo", kActionKeyType, false}, -	{0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} -}; - -struct Mod { -	byte flag; -	const char *id; -	const char *desc; -	bool shiftable; +	{"UNDO", KEYCODE_UNDO, 0, "Undo", false}, +	{0, KEYCODE_INVALID, 0, 0, false}  }; -static const Mod modifiers[] = { +static const ModifierTableEntry sdlModifiers[] = {  	{ 0, "", "", false },  	{ KBD_CTRL, "C+", "Ctrl+", false },  	{ KBD_ALT, "A+", "Alt+", false }, @@ -190,41 +174,8 @@ static const Mod modifiers[] = {  	{ KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true },  	{ 0, 0, 0, false }  }; -#endif -  Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { -#ifdef ENABLE_KEYMAPPER -	HardwareKeySet *keySet = new HardwareKeySet(); -	const Key *key; -	const Mod *mod; -	char fullKeyId[50]; -	char fullKeyDesc[100]; -	uint16 ascii; - -	for (mod = modifiers; mod->id; mod++) { -		for (key = keys; key->hwId; key++) { -			ascii = key->ascii; - -			if (mod->shiftable && key->shiftable) { -				snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); -				snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); -				ascii = toupper(key->ascii); -			} else if (mod->shiftable) { -				snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); -				snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); -			} else { -				snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); -				snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); -			} - -			keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction )); -		} -	} - -	return keySet; - -#else -	return 0; -#endif +	return new HardwareKeySet(sdlKeys, sdlModifiers);  } +#endif diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm index bb089a6b61..97c7edba3e 100755 --- a/backends/platform/sdl/macosx/appmenu_osx.mm +++ b/backends/platform/sdl/macosx/appmenu_osx.mm @@ -35,6 +35,11 @@  - (void)setAppleMenu:(NSMenu *)menu;  @end +NSString *constructNSStringFromCString(const char* rawCString, NSStringEncoding stringEncoding) { +        NSData *nsData = [NSData dataWithBytes:rawCString length:strlen(rawCString)]; +        return [[NSString alloc] initWithData:nsData encoding:stringEncoding]; +} +  void replaceApplicationMenuItems() {  	// Code mainly copied and adapted from SDLmain.m @@ -50,34 +55,47 @@ void replaceApplicationMenuItems() {  	// Create new application menu  	appleMenu = [[NSMenu alloc] initWithTitle:@""]; +	NSString *nsString = NULL; +  	// Get current encoding  #ifdef USE_TRANSLATION -	NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[NSString stringWithCString:(TransMan.getCurrentCharset()).c_str() encoding:NSASCIIStringEncoding])); +	nsString = constructNSStringFromCString((TransMan.getCurrentCharset()).c_str(), NSASCIIStringEncoding); +	NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)nsString)); +	[nsString release];  #else  	NSStringEncoding stringEncoding = NSASCIIStringEncoding;  #endif -	 +  	// Add "About ScummVM" menu item -	[appleMenu addItemWithTitle:[NSString stringWithCString:_("About ScummVM") encoding:stringEncoding] action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; +	nsString = constructNSStringFromCString(_("About ScummVM"), stringEncoding); +	[appleMenu addItemWithTitle:nsString action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; +	[nsString release];  	// Add separator  	[appleMenu addItem:[NSMenuItem separatorItem]];  	// Add "Hide ScummVM" menu item -	[appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide ScummVM") encoding:stringEncoding] action:@selector(hide:) keyEquivalent:@"h"]; +	nsString = constructNSStringFromCString(_("Hide ScummVM"), stringEncoding); +	[appleMenu addItemWithTitle:nsString action:@selector(hide:) keyEquivalent:@"h"]; +	[nsString release];  	// Add "Hide Others" menu item -	menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide Others") encoding:stringEncoding] action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; +	nsString = constructNSStringFromCString(_("Hide Others"), stringEncoding); +	menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:nsString action:@selector(hideOtherApplications:) keyEquivalent:@"h"];  	[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];  	// Add "Show All" menu item -	[appleMenu addItemWithTitle:[NSString stringWithCString:_("Show All") encoding:stringEncoding] action:@selector(unhideAllApplications:) keyEquivalent:@""]; +	nsString = constructNSStringFromCString(_("Show All"), stringEncoding); +	[appleMenu addItemWithTitle:nsString action:@selector(unhideAllApplications:) keyEquivalent:@""]; +	[nsString release];  	// Add separator  	[appleMenu addItem:[NSMenuItem separatorItem]];  	// Add "Quit ScummVM" menu item -	[appleMenu addItemWithTitle:[NSString stringWithCString:_("Quit ScummVM") encoding:stringEncoding] action:@selector(terminate:) keyEquivalent:@"q"]; +	nsString = constructNSStringFromCString(_("Quit ScummVM"), stringEncoding); +	[appleMenu addItemWithTitle:nsString action:@selector(terminate:) keyEquivalent:@"q"]; +	[nsString release];  	// Put application menu into the menubar  	menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; @@ -89,16 +107,22 @@ void replaceApplicationMenuItems() {  	// Create new "Window" menu -	windowMenu = [[NSMenu alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding]]; +	nsString = constructNSStringFromCString(_("Window"), stringEncoding); +	windowMenu = [[NSMenu alloc] initWithTitle:nsString]; +	[nsString release];  	// Add "Minimize" menu item -	menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Minimize") encoding:stringEncoding] action:@selector(performMiniaturize:) keyEquivalent:@"m"]; +	nsString = constructNSStringFromCString(_("Minimize"), stringEncoding); +	menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:@selector(performMiniaturize:) keyEquivalent:@"m"];  	[windowMenu addItem:menuItem]; +	[nsString release];  	// Put menu into the menubar -	menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding] action:nil keyEquivalent:@""]; +	nsString = constructNSStringFromCString(_("Window"), stringEncoding); +	menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:nil keyEquivalent:@""];  	[menuItem setSubmenu:windowMenu];  	[[NSApp mainMenu] addItem:menuItem]; +	[nsString release];  	// Tell the application object that this is now the window menu.  	[NSApp setWindowsMenu:windowMenu]; diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 05c779a4e0..7a8b1e7b70 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -175,7 +175,7 @@ bool OSystem_POSIX::displayLogFile() {  	} else if (pid == 0) {  		// Try xdg-open first -		execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char*)0); +		execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char *)0);  		// If we're here, that clearly failed. @@ -184,7 +184,7 @@ bool OSystem_POSIX::displayLogFile() {  		// Try xterm+less next -		execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char*)0); +		execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char *)0);  		// TODO: If less does not exist we could fall back to 'more'.  		// However, we'll have to use 'xterm -hold' for that to prevent the diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 22d79dbfe7..64e63b40a6 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -58,7 +58,9 @@ public:  	virtual void engineInit();  	virtual void engineDone();  #endif +#ifdef ENABLE_KEYMAPPER  	virtual Common::HardwareKeySet *getHardwareKeySet(); +#endif  	virtual void quit();  	virtual void fatalError(); diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 3e09aa2640..453d566c7b 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -38,6 +38,7 @@  #include <SDL_syswm.h> // For setting the icon  #include "backends/platform/sdl/win32/win32.h" +#include "backends/saves/windows/windows-saves.h"  #include "backends/fs/windows/windows-fs-factory.h"  #include "backends/taskbar/win32/win32-taskbar.h" @@ -74,6 +75,10 @@ void OSystem_Win32::initBackend() {  		FreeConsole();  	} +	// Create the savefile manager +	if (_savefileManager == 0) +		_savefileManager = new WindowsSaveFileManager(); +  	// Invoke parent implementation of this method  	OSystem_SDL::initBackend();  } diff --git a/backends/platform/webos/webos.cpp b/backends/platform/webos/webos.cpp index bfb19ed3bc..710a3f79be 100644 --- a/backends/platform/webos/webos.cpp +++ b/backends/platform/webos/webos.cpp @@ -51,20 +51,18 @@ void OSystem_SDL_WebOS::initBackend() {   *   * @return The hardware key set with added webOS specific keys.   */ -HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() {  #ifdef ENABLE_KEYMAPPER +HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() {  	// Get the original SDL hardware key set  	HardwareKeySet *keySet = OSystem_SDL::getHardwareKeySet();  	// Add WebOS specific keys  	keySet->addHardwareKey(new HardwareKey("FORWARD", -		KeyState((KeyCode) 229, 229, 0), "Forward", kActionKeyType)); +		KeyState((KeyCode) 229, 229, 0), "Forward"));  	// Return the modified hardware key set  	return keySet; -#else -	return 0; -#endif  } +#endif  #endif diff --git a/backends/platform/webos/webos.h b/backends/platform/webos/webos.h index 850aaf9ce2..71390a1d2c 100644 --- a/backends/platform/webos/webos.h +++ b/backends/platform/webos/webos.h @@ -31,7 +31,9 @@ public:  	OSystem_SDL_WebOS();  	virtual void initBackend(); +#ifdef ENABLE_KEYMAPPER  	virtual Common::HardwareKeySet *getHardwareKeySet(); +#endif  };  #endif diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 4e17827e5c..a57fcb9628 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -87,15 +87,15 @@ extern "C" void *__wrap_malloc(size_t size) {  		void *ptr = __real_malloc(size+4);  //		printf("malloc(%d) = %p\n", size, ptr);  		if (ptr != NULL) { -			*((HANDLE*)ptr) = 0; -			return 4+(char*)ptr; +			*((HANDLE *)ptr) = 0; +			return 4+(char *)ptr;  		}  		return NULL;  	}  	HANDLE H = CreateFileMapping((HANDLE)INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size+4, 0);  	void *ptr = MapViewOfFile(H, FILE_MAP_ALL_ACCESS, 0, 0, 0); -	*((HANDLE*)ptr) = H; -	return 4+(char*)ptr; +	*((HANDLE *)ptr) = H; +	return 4+(char *)ptr;  }  extern "C" void __wrap_free(void *ptr) { @@ -104,9 +104,9 @@ extern "C" void __wrap_free(void *ptr) {  	printf("free(%p)\n", ptr);  */  	if (ptr != NULL) { -		HANDLE H = *(HANDLE*)((char *)ptr-4); +		HANDLE H = *(HANDLE *)((char *)ptr-4);  		if (H == 0) { -			__real_free((char*)ptr-4); +			__real_free((char *)ptr-4);  			return;  		}  		UnmapViewOfFile((char *)ptr-4);  | 
