diff options
Diffstat (limited to 'backends/PalmOS/Src')
| -rwxr-xr-x | backends/PalmOS/Src/be_os5.cpp | 119 | ||||
| -rwxr-xr-x | backends/PalmOS/Src/be_os5.h | 79 | ||||
| -rwxr-xr-x | backends/PalmOS/Src/os5_event.cpp | 69 | ||||
| -rwxr-xr-x | backends/PalmOS/Src/os5_gfx.cpp | 255 | ||||
| -rwxr-xr-x | backends/PalmOS/Src/os5_mouse.cpp | 121 | ||||
| -rwxr-xr-x | backends/PalmOS/Src/os5_overlay.cpp | 65 | ||||
| -rwxr-xr-x | backends/PalmOS/Src/os5_renderer.cpp | 155 | ||||
| -rwxr-xr-x | backends/PalmOS/Src/os5_sound.cpp | 114 | 
8 files changed, 753 insertions, 224 deletions
diff --git a/backends/PalmOS/Src/be_os5.cpp b/backends/PalmOS/Src/be_os5.cpp index 1b93990438..7396c44755 100755 --- a/backends/PalmOS/Src/be_os5.cpp +++ b/backends/PalmOS/Src/be_os5.cpp @@ -1,7 +1,7 @@  /* ScummVM - Scumm Interpreter   * Copyright (C) 2001  Ludvig Strigeus   * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2005 Chris Apers - PalmOS Backend + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -22,66 +22,24 @@   */  #include "be_os5.h" -#include "oscalls.h" -#include "palmdefs.h"  #ifndef __TWKEYS_H__  #include <PalmNavigator.h>  #include <HsKeyCommon.h>  #endif -static TimerExType _timerEx; -  OSystem_PalmOS5::OSystem_PalmOS5() : OSystem_PalmBase() {  	_sound.active = false; -	_timerEx.timerID = 0; -	_timerEx.timer = &_timer; - -#ifdef PALMOS_ARM -	// CHECK : is this ok for OS5 too ? -	if (HALHRTimerTicksPerSecond(&_timerEx.ticks)) -		_timerEx.ticks = SysTicksPerSecond(); -#endif -} - -#ifdef PALMOS_ARM - -static SYSTEM_CALLBACK void timer_handler(void *userDataP) { -	CALLBACK_PROLOGUE -	TimerExPtr _timerEx = (TimerExPtr)userDataP; -	TimerPtr _timer = _timerEx->timer; -	_timer->duration = _timer->callback(_timer->duration); -	KALTimerSet(_timerEx->timerID, (_timer->duration * _timerEx->ticks / 1000)); -	CALLBACK_EPILOGUE -} - -void OSystem_PalmOS5::setTimerCallback(TimerProc callback, int timer) { -	if (_timer.active && _timerEx.timerID) -		KALTimerDelete(_timerEx.timerID); - -	if (callback != NULL) { -		Err e; -		CALLBACK_INIT(_timerEx); -		_timer.duration = timer; -		_timer.callback = callback; - -		// create the timer -		e = KALTimerCreate(&_timerEx.timerID, appFileCreator, &::timer_handler, &_timerEx); -		if (!e) { -			e = KALTimerSet(_timerEx.timerID, (timer * _timerEx.ticks / 1000)); -			if (e) KALTimerDelete(_timerEx.timerID); -		} -		_timer.active = (!e); - -	} else { -		_timer.active = false; -	} +	_setPalette = false; -	if (!_timer.active) -		_timerEx.timerID = 0; -} +	_workScreenH = NULL; +	_overlayH = NULL; +	_isSwitchable = false; +	_wasRotated = false; -#endif +	MemSet(&_soundEx, sizeof(SoundExType), 0); +	_soundEx.sound = &_sound; +}  void OSystem_PalmOS5::int_initBackend() {  	if (OPTIONS_TST(kOpt5WayNavigatorV1)) { @@ -93,8 +51,8 @@ void OSystem_PalmOS5::int_initBackend() {  		_keyMouse.hasMore	= true;  	} else if (OPTIONS_TST(kOpt5WayNavigatorV2)) { -		_keyMouse.bitUp		= keyBitRockerUp; -		_keyMouse.bitDown	= keyBitRockerDown; +		_keyMouse.bitUp		= keyBitRockerUp|keyBitPageUp; +		_keyMouse.bitDown	= keyBitRockerDown|keyBitPageDown;  		_keyMouse.bitLeft	= keyBitRockerLeft;  		_keyMouse.bitRight	= keyBitRockerRight;  		_keyMouse.bitButLeft= keyBitRockerCenter; @@ -102,12 +60,51 @@ void OSystem_PalmOS5::int_initBackend() {  	}  } -void OSystem_PalmOS5::int_quit() { -#ifdef PALMOS_ARM -	if (_timerEx.timerID) -		KALTimerDelete(_timerEx.timerID); -#endif -	clearSoundCallback(); -	unload_gfx_mode(); -	exit(0); +void OSystem_PalmOS5::setWindowCaption(const char *caption) { +	Err e; +	Char buf[64]; +	Coord w, y, h = FntLineHeight() + 2; +	const Char *loading = "Loading, please wait\0"; + +	// allocate bitmap +	BitmapTypeV3 *bmp2P; +	BitmapType *bmp1P = BmpCreate(320, (h * 3), 8, NULL, &e); +	WinHandle tmpH = WinCreateBitmapWindow(bmp1P, &e); + +	WinSetDrawWindow(tmpH); +	WinSetBackColor(0); +	WinSetTextColor(255); +	WinEraseWindow(); + +	// loading message +	FntSetFont(boldFont); +	w = FntCharsWidth(loading, StrLen(loading)); +	w = (320 - w) / 2; +	WinDrawChars(loading, StrLen(loading), w, 0 + h); + +	// caption +	FntSetFont(stdFont); +	w = FntCharsWidth(caption, StrLen(caption)); +	w = (320 - w) / 2; +	WinDrawChars(caption, StrLen(caption), w, 0); + +	// memory size +	StrPrintF(buf, "memory : %ld KB", gVars->startupMemory); +	w = FntCharsWidth(buf, StrLen(buf)); +	w = (320 - w) / 2; +	WinDrawChars(buf, StrLen(buf), w, h * 2); + +	// set the bitmap as v3 +	bmp2P = BmpCreateBitmapV3(bmp1P, kDensityDouble, BmpGetBits(bmp1P), NULL); +	y = (80 - (h / 4) - 5); + +	// draw it +	WinSetDrawWindow(WinGetDisplayWindow()); +	WinEraseWindow(); +	WinDrawBitmap((BitmapPtr)bmp2P, 0, y); + +	// free +	WinDeleteWindow(tmpH, 0); +	BmpDelete((BitmapPtr)bmp2P); +	BmpDelete(bmp1P);  } diff --git a/backends/PalmOS/Src/be_os5.h b/backends/PalmOS/Src/be_os5.h index f5dca61fe1..6d44648eba 100755 --- a/backends/PalmOS/Src/be_os5.h +++ b/backends/PalmOS/Src/be_os5.h @@ -1,7 +1,7 @@  /* ScummVM - Scumm Interpreter   * Copyright (C) 2001  Ludvig Strigeus   * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2005 Chris Apers - PalmOS Backend + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -68,30 +68,46 @@  #	define CALLBACK_INIT(regs)  #endif +// TODO : change / remove this +#define gfxMakeDisplayRGB_BigEndian(_r,_g,_b) \ +  ( (((_g) & 0xFC) << 11) | (((_b) & 0xF8) << 5) | ((_r) & 0xF8) | (((_g) & 0xFF) >> 5) ) + +#define gfxMakeDisplayRGB_LittleEndian(_r,_g,_b) \ +  ( (((_r) & 0xF8) << 8) | (((_g) & 0xFC) << 3) | (((_b) & 0xF8) >> 3) ) + +#if CPU_TYPE == CPU_68K +#define gfxMakeDisplayRGB(_r,_g,_b) gfxMakeDisplayRGB_BigEndian(_r,_g,_b) +#else +#define gfxMakeDisplayRGB(_r,_g,_b) gfxMakeDisplayRGB_LittleEndian(_r,_g,_b) +#endif +  typedef struct { +	// for real thread version only  	UInt32 __reg1;  	UInt32 __reg2; -	void *proc; -	void *param; +	// no real thread version +	Boolean set; +	UInt32	size; +	void *dataP; +	// default sound stuff  	SndStreamRef handle; -	Boolean	active; -} SoundDataType; -extern SoundDataType _sound; - -typedef struct { -	UInt32 __r9; -	UInt32 __r10; -	TimerPtr timer; -	UInt32 timerID; -	UInt32 ticks; -} TimerExType, *TimerExPtr; +	SoundPtr sound; +} SoundExType, *SoundExPtr; +extern SoundExType _soundEx;  class OSystem_PalmOS5 : public OSystem_PalmBase {  private: -	byte *_overlayP; -	WinHandle _overlayH; +	typedef void (OSystem_PalmOS5::*RendererProc)(RectangleType &r, PointType &p); +	RendererProc _render; + +	OverlayColor *_overlayP; +	WinHandle _overlayH, _workScreenH; +	int16 _nativePal[256]; +	int16 *_workScreenP; +	 +	Boolean _isSwitchable, _wasRotated;  	virtual void int_initBackend();  	virtual void int_updateScreen(); @@ -99,18 +115,26 @@ private:  	virtual void unload_gfx_mode();  	virtual void load_gfx_mode(); +	virtual void hotswap_gfx_mode(int mode);  	void draw_mouse();  	void undraw_mouse();  	virtual void get_coordinates(EventPtr ev, Coord &x, Coord &y);  	virtual bool check_event(Event &event, EventPtr ev); +	virtual void extras_palette(uint8 index, uint8 r, uint8 g, uint8 b); -#ifdef PALMOS_ARM -	void timer_handler() {}; -#endif +	void render_landscape(RectangleType &r, PointType &p); +	void render_portrait(RectangleType &r, PointType &p); +	void render_1x(RectangleType &r, PointType &p); +	WinHandle alloc_screen(Coord w, Coord h); +	virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0); + +	virtual SndStreamVariableBufferCallback sound_callback(); +	virtual void sound_handler();  protected:  	UInt16 _sysOldCoord, _sysOldOrientation; +	Boolean _stretched;  public:  	OSystem_PalmOS5(); @@ -119,25 +143,20 @@ public:  	void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);  	void clearScreen(); -	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale); +	void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale); -	virtual void showOverlay(); -	virtual void hideOverlay(); +	void showOverlay(); +	void hideOverlay();  	virtual void clearOverlay();  	virtual void grabOverlay(OverlayColor *buf, int pitch);  	virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);  	virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);  	virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); -#ifdef PALMOS_ARM -	void setTimerCallback(TimerProc callback, int interval); -#endif - -	bool setSoundCallback(SoundProc proc, void *param); +	virtual bool setSoundCallback(SoundProc proc, void *param);  	void clearSoundCallback(); -	 -	void int_quit(); -	void setWindowCaption(const char *caption) {}; + +	void setWindowCaption(const char *caption);  }; diff --git a/backends/PalmOS/Src/os5_event.cpp b/backends/PalmOS/Src/os5_event.cpp index fe8540effa..4691092b15 100755 --- a/backends/PalmOS/Src/os5_event.cpp +++ b/backends/PalmOS/Src/os5_event.cpp @@ -1,7 +1,7 @@  /* ScummVM - Scumm Interpreter   * Copyright (C) 2001  Ludvig Strigeus   * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2005 Chris Apers - PalmOS Backend + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -29,4 +29,71 @@ void OSystem_PalmOS5::get_coordinates(EventPtr ev, Coord &x, Coord &y) {  	x = (ev->screenX - _screenOffset.x);  	y = (ev->screenY - _screenOffset.y); +	 +	if (_stretched) { +		if (OPTIONS_TST(kOptModeLandscape)) { +			x = (x * 2 / 3); +			y = (y * 2 / 3); +		} else { +			y =       ((ev->screenX - _screenOffset.y) * 2) / 3; +			x = 320 - ((ev->screenY - _screenOffset.x) * 2) / 3 - 1;	 +		} +	} +} + +bool OSystem_PalmOS5::check_event(Event &event, EventPtr ev) { +	if (ev->eType == keyDownEvent) { +		switch (ev->data.keyDown.chr) { +		case vchrHard4: +			_lastKey = kKeyNone; +			event.type = EVENT_RBUTTONDOWN; +			event.mouse.x = _mouseCurState.x; +			event.mouse.y = _mouseCurState.y; +			return true; + +		// trun off +		case vchrAutoOff: +		case vchrPowerOff: +			// pause the sound thread if any +			if (_sound.active) +				SndStreamPause(_soundEx.handle, true); +			break; +		 +		case vchrLateWakeup: +			// resume the sound thread if any +			if (_sound.active) +				SndStreamPause(_soundEx.handle, false); +			break; +		} +		 +		if (_keyMouse.hasMore) { +			switch (ev->data.keyDown.chr) { +			// hot swap gfx +			case vchrHard1: +				if (OPTIONS_TST(kOptCollapsible)) +					hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); +				return false; // not a key + +			// ESC key +			case vchrHard2: +				_lastKey = kKeyNone; +				event.type = EVENT_KEYDOWN; +				event.kbd.keycode = 27; +				event.kbd.ascii = 27; +				event.kbd.flags = 0; +				return true; +			 +			// F5 = menu +			case vchrHard3: +				_lastKey = kKeyNone; +				event.type = EVENT_KEYDOWN; +				event.kbd.keycode = 319; +				event.kbd.ascii = 319; +				event.kbd.flags = 0; +				return true; +			} +		} +	} + +	return false;  } diff --git a/backends/PalmOS/Src/os5_gfx.cpp b/backends/PalmOS/Src/os5_gfx.cpp index 1833821213..c7dc244558 100755 --- a/backends/PalmOS/Src/os5_gfx.cpp +++ b/backends/PalmOS/Src/os5_gfx.cpp @@ -1,7 +1,7 @@  /* ScummVM - Scumm Interpreter   * Copyright (C) 2001  Ludvig Strigeus   * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2005 Chris Apers - PalmOS Backend + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -22,37 +22,168 @@   */  #include "be_os5.h" +#include <PenInputMgr.h> +#include <palmOneResources.h>  #ifdef PALMOS_ARM -#include "pace.h" -#include "oscalls.h" +#include <System/WIP.h> +#include <Libraries/AIA/palmOneStatusBarMgrARM.h>  #endif +#include "oscalls.h" +  void OSystem_PalmOS5::int_initSize(uint w, uint h, int overlayScale) {  } -void OSystem_PalmOS5::load_gfx_mode() { +WinHandle OSystem_PalmOS5::alloc_screen(Coord w, Coord h) {  	Err e; +	WinHandle winH; +	UInt16 old = WinSetCoordinateSystem(kCoordinatesNative); +	winH = WinCreateOffscreenWindow(w, h, nativeFormat, &e); +	WinSetCoordinateSystem(old); +	return winH; +} + +void OSystem_PalmOS5::load_gfx_mode() { +	Err e; +  	if (_gfxLoaded)  		return;  	_gfxLoaded = true; -	_sysOldCoord = WinSetCoordinateSystem(kCoordinatesNative); -#ifdef PALMOS_68K -	// init mouse (must be here, after WinSetCoordinateSystem) -	_mouseBackupH = WinCreateOffscreenWindow(MAX_MOUSE_W, MAX_MOUSE_H, nativeFormat, &e); -	_mouseBackupP = (byte *)(BmpGetBits(WinGetBitmap(_mouseBackupH))); +	_mouseBackupP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H * 2); // *2 if 16bit +	_mouseDataP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H); +	_offScreenP	= (byte *)malloc(_screenWidth * _screenHeight); + +	UInt32 depth = 16; +	WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL); +	clearScreen(); -	_offScreenH	= WinCreateOffscreenWindow(_screenWidth, _screenHeight, nativeFormat, &e); +	gVars->indicator.on = RGBToColor(0,255,0); +	gVars->indicator.off = RGBToColor(0,0,0); + +	_overlayH =  alloc_screen(_screenWidth, _screenHeight);  	_screenH = WinGetDisplayWindow(); -	_offScreenP	= (byte *)(BmpGetBits(WinGetBitmap(_offScreenH))); + +	_overlayP = (OverlayColor *)(BmpGetBits(WinGetBitmap(_overlayH)));  	_screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH))); + +	MemSet(_offScreenP, _screenWidth * _screenHeight, 0); +	MemSet(_nativePal, sizeof(_nativePal), 0); +	MemSet(_currentPalette, sizeof(_currentPalette), 0); + +	_isSwitchable = (_screenWidth == 320 && _screenHeight == 200 && OPTIONS_TST(kOptCollapsible)); +	if (_screenWidth > 320 || _screenHeight > 200 || !_isSwitchable) +		_mode = GFX_NORMAL; + +	hotswap_gfx_mode(_mode); +} + +void OSystem_PalmOS5::hotswap_gfx_mode(int mode) { +	Err e; +	UInt32 device; +	Boolean isT3; + +	if (_mode != GFX_NORMAL && !_isSwitchable) +		return; + +	if (_workScreenH) +		WinDeleteWindow(_workScreenH, false); +	_workScreenH = NULL; + +	isT3 = false; +#ifdef PALMOS_ARM +	if (!FtrGet(sysFileCSystem, sysFtrNumOEMDeviceID, &device)) +		isT3 = (device == kPalmOneDeviceIDTungstenT3); +#endif + +	// prevent bad DIA redraw (Stat part) +	if (mode  == GFX_NORMAL) {		 +		// only if this API is available +		if (_stretched && OPTIONS_TST(kOptCollapsible)) { +#ifdef PALMOS_ARM +			if (isT3) { +				//AiaSetInputAreaState(aiaInputAreaShow); +				StatShow_68k(); +				PINSetInputAreaState_68k(pinInputAreaOpen); +			} else  #endif +			{ +				StatShow(); +				PINSetInputAreaState(pinInputAreaOpen); +			} +		} + +		_redawOSD = true; +		_stretched = false; +		OPTIONS_RST(kOptDisableOnScrDisp); +		_screenDest.w = _screenWidth; +		_screenDest.h = _screenHeight; + +		if (_wasRotated) { +			// restore controls rotation +			SWAP(_keyMouse.bitLeft, _keyMouse.bitRight); +			SWAP(_keyMouse.bitRight, _keyMouse.bitDown); +			SWAP(_keyMouse.bitLeft, _keyMouse.bitUp); +			_wasRotated = false; +		} -	_screenOffset.x = (gVars->screenWidth - _screenWidth) / 2; -	_screenOffset.y = (gVars->screenHeight - _screenHeight)  / 2; +		_workScreenH = alloc_screen(_screenWidth, _screenHeight); +		_workScreenP = (int16 *)(BmpGetBits(WinGetBitmap(_workScreenH))); +		MemSet(_workScreenP, _screenWidth * _screenHeight * 2, 0); + +		_screenOffset.x = (gVars->screenWidth - _screenWidth) / 2; +		_screenOffset.y = (gVars->screenHeight - _screenHeight)  / 2; +		 +		_render = &OSystem_PalmOS5::render_1x; + +	} else { +#ifdef PALMOS_ARM +		// T3 DIA library is 68k base, there is no possible native call +		if (isT3) { +			//AiaSetInputAreaState(aiaInputAreaFullScreen); +			PINSetInputAreaState_68k(pinInputAreaClosed); +			StatHide_68k(); +		} else +#endif +		{ +			PINSetInputAreaState(pinInputAreaClosed); +			StatHide(); +		} + +		_redawOSD = false; +		_stretched = true; +		OPTIONS_SET(kOptDisableOnScrDisp); + +		if (OPTIONS_TST(kOptModeLandscape)) { +			_screenDest.w = 480; +			_screenDest.h = 300; +			_workScreenH = alloc_screen(480, 300); +			_render = &OSystem_PalmOS5::render_landscape; + +		} else { +			_screenDest.w = 300; +			_screenDest.h = 480; +			_workScreenH = alloc_screen(300, 480); +			_render = &OSystem_PalmOS5::render_portrait; +			// This mode need a controls rotation +			SWAP(_keyMouse.bitLeft, _keyMouse.bitUp); +			SWAP(_keyMouse.bitRight, _keyMouse.bitDown); +			SWAP(_keyMouse.bitLeft, _keyMouse.bitRight); +			_wasRotated = true; +		} + +		_workScreenP = (int16 *)(BmpGetBits(WinGetBitmap(_workScreenH))); +		MemSet(_workScreenP, 480 * 300 * 2, 0); + +		_screenOffset.x = 0; +		_screenOffset.y = 10; +	} + +	_mode = mode; +	clearScreen();  }  void OSystem_PalmOS5::unload_gfx_mode() { @@ -60,8 +191,23 @@ void OSystem_PalmOS5::unload_gfx_mode() {  		return;	  	_gfxLoaded = false; -	if (_mouseBackupH) -		WinDeleteWindow(_mouseBackupH, false); +	MemPtrFree(_mouseBackupP); +	MemPtrFree(_mouseDataP); +	free(_offScreenP); + +	if (_workScreenH) +		WinDeleteWindow(_workScreenH, false); +	if (_overlayH) +		WinDeleteWindow(_overlayH, false); +		 +	_workScreenH = NULL; +	_overlayH = NULL; + +	UInt32 depth = 8; +	WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL); +	clearScreen(); + +	WinSetCoordinateSystem(_sysOldCoord);  }  void OSystem_PalmOS5::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { @@ -87,23 +233,10 @@ void OSystem_PalmOS5::copyRectToScreen(const byte *buf, int pitch, int x, int y,  	if (w <= 0 || h <= 0)  		return; -#ifdef PALMOS_68K -	BitmapTypeV1 nfo = { -		w, h, pitch, -		{0,0,0,0,0,0,0,0,0}, -		8, BitmapVersionOne, 0 -	}; -	 -	BitmapTypeV3 *v3 = BmpCreateBitmapV3((BitmapType*)&nfo, kDensityDouble, (void *)buf, 0); - -	WinSetDrawWindow(_offScreenH); -	WinDrawBitmap((BitmapPtr)v3, x, y); -	BmpDelete((BitmapPtr)v3); -#else  	byte *dst = _offScreenP + y * _screenWidth + x;  	if (w == pitch && w == _screenWidth) { -		MemMove(dst, buf, w*h); +		MemMove(dst, buf, w * h);  	} else {  		do {  			MemMove(dst, buf, w); @@ -111,15 +244,19 @@ void OSystem_PalmOS5::copyRectToScreen(const byte *buf, int pitch, int x, int y,  			buf += pitch;  		} while (--h);  	} -#endif  }  void OSystem_PalmOS5::int_updateScreen() { -#ifdef PALMOS_68K  	RectangleType r; -	RctSetRectangle(&r, 0, 0, _screenWidth, _screenHeight - _current_shake_pos); -	WinCopyRectangle(_offScreenH, _screenH, &r, _screenOffset.x, _screenOffset.y + _current_shake_pos, winPaint); -#endif +	PointType p; + +	draw_mouse(); +	((this)->*(_render))(r, p); + +	_sysOldCoord = WinSetCoordinateSystem(kCoordinatesNative); +	WinCopyRectangle(_workScreenH, _screenH, &r, p.x, p.y, winPaint); +	WinSetCoordinateSystem(_sysOldCoord); +	undraw_mouse();  }  void OSystem_PalmOS5::clearScreen() { @@ -128,3 +265,53 @@ void OSystem_PalmOS5::clearScreen() {  	WinSetBackColorRGB(&rgb, 0);  	WinEraseWindow();  } + +void OSystem_PalmOS5::extras_palette(uint8 index, uint8 r, uint8 g, uint8 b) { +	_nativePal[index] = gfxMakeDisplayRGB( r, g, b); +} + +void OSystem_PalmOS5::draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color) { +	if (_mode != GFX_NORMAL) +		return; +//	MemHandle hTemp = DmGetResource(bitmapRsc, id); +	MemHandle hTemp = DmGetResource('abmp', id + 100); + +	if (hTemp) { +		RGBColorType oldRGB; +		static const RGBColorType pal[4] = { +			{0,0,255,0}, +			{0,255,255,0}, +			{0,255,0,0}, +			{0,0,0,0} +		}; + +		BitmapType *bmTemp; +		bmTemp	= (BitmapType *)MemHandleLock(hTemp); + +		Coord w, h; +		BmpGetDimensions(bmTemp, &w, &h, 0); + +		PointType dst = { _screenOffset.x + x, _screenOffset.y + y }; +		RectangleType c, r = { dst.x, dst.y, w, h }; + +		UInt16 old = WinSetCoordinateSystem(kCoordinatesNative); +		WinSetDrawWindow(_screenH); +		WinGetClip(&c); +		WinResetClip(); + +		if (show) { +			WinSetForeColorRGB(&pal[3], &oldRGB); +			WinSetBackColorRGB(&pal[color], &oldRGB); +			WinDrawBitmap(bmTemp, dst.x, dst.y); +		} else { +			WinSetBackColorRGB(&pal[3], &oldRGB); +			WinFillRectangle(&r, 0); +		} + +		WinSetClip(&c); +		WinSetCoordinateSystem(old); + +		MemPtrUnlock(bmTemp); +		DmReleaseResource(hTemp); +	} +} diff --git a/backends/PalmOS/Src/os5_mouse.cpp b/backends/PalmOS/Src/os5_mouse.cpp index 4b0f2c8ac5..41e7b0ceb0 100755 --- a/backends/PalmOS/Src/os5_mouse.cpp +++ b/backends/PalmOS/Src/os5_mouse.cpp @@ -1,7 +1,7 @@  /* ScummVM - Scumm Interpreter   * Copyright (C) 2001  Ludvig Strigeus   * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2005 Chris Apers - PalmOS Backend + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -35,38 +35,22 @@ void OSystem_PalmOS5::setMouseCursor(const byte *buf, uint w, uint h, int hotspo  	_mouseKeyColor = keycolor; -#ifdef PALMOS_68K -	// free old cursor if any -	if (_mouseDataH) -		WinDeleteWindow(_mouseDataH, false); - -	// allocate new cursor -	Err e; -	_mouseDataH = WinCreateOffscreenWindow(w, h, nativeFormat, &e); -	_mouseDataP = (byte *)BmpGetBits(WinGetBitmap(_mouseDataH)); - -	// set bitmap transparency -	BmpSetTransparentValue(WinGetBitmap(_mouseDataH), _mouseKeyColor); -  	// copy new cursor -	BitmapTypeV1 nfo = { -		w, h, w, -		{0,0,0,0,0,0,0,0,0}, -		8, BitmapVersionOne, 0 -	}; - -	BitmapTypeV3 *v3 = BmpCreateBitmapV3((BitmapType*)&nfo, kDensityDouble, (void *)buf, 0); - -	WinSetDrawWindow(_mouseDataH); -	WinDrawBitmap((BitmapPtr)v3, 0, 0); -	BmpDelete((BitmapPtr)v3); -#endif +	byte *dst = _mouseDataP; +	while (h--) { +		memcpy(dst, buf, w); +		dst += MAX_MOUSE_W; +		buf += w; +	}  }  void OSystem_PalmOS5::draw_mouse() {  	if (_mouseDrawn || !_mouseVisible)  		return; -	_mouseDrawn = true; + +	byte *src = _mouseDataP;		// Image representing the mouse +	byte color; +	int width;  	_mouseCurState.y = _mouseCurState.y >= _screenHeight ? _screenHeight - 1 : _mouseCurState.y; @@ -81,10 +65,12 @@ void OSystem_PalmOS5::draw_mouse() {  	// clip the mouse rect  	if (x < 0) {  		w += x; +		src -= x;  		x = 0;  	}  	if (y < 0) {  		h += y; +		src -= y * MAX_MOUSE_W;  		y = 0;  	}  	if (w > _screenWidth - x) @@ -103,31 +89,86 @@ void OSystem_PalmOS5::draw_mouse() {  	_mouseOldState.w = w;  	_mouseOldState.h = h; -#ifdef PALMOS_68K +	// Quick check to see if anything has to be drawn at all +	if (w <= 0 || h <= 0) +		return; + +	// Store the bounding box so that undraw mouse can restore the area the +	// mouse currently covers to its original content. +	_mouseOldState.x = x; +	_mouseOldState.y = y; +	_mouseOldState.w = w; +	_mouseOldState.h = h; +  	// Backup the covered area draw the mouse cursor  	if (_overlayVisible) { +		int16 *bak = (int16 *)_mouseBackupP;			// Surface used to backup the area obscured by the mouse +		int16 *dst = _overlayP + y * _screenWidth + x; +		 +		do { +			width = w; +			do { +				*bak++ = *dst; +				color = *src++; +				if (color != _mouseKeyColor)	// transparent, don't draw +					*dst = _nativePal[color]; +				dst++; +			} while (--width); + +			src += MAX_MOUSE_W - w; +			bak += MAX_MOUSE_W - w; +			dst += _screenWidth - w; +		} while (--h); +  	} else { -		// backup... -		RectangleType r = {x, y, w, h}; -		WinCopyRectangle(_offScreenH, _mouseBackupH, &r, 0, 0, winPaint); -		// ...and draw -		WinSetDrawWindow(_offScreenH); -		WinDrawBitmap(WinGetBitmap(_mouseDataH), draw_x, draw_y); +		byte *bak = _mouseBackupP;						// Surface used to backup the area obscured by the mouse +		byte *dst =_offScreenP + y * _screenWidth + x;	// Surface we are drawing into + +		do { +			width = w; +			do { +				*bak++ = *dst; +				color = *src++; +				if (color != _mouseKeyColor)	// transparent, don't draw +					*dst = color; +				dst++; +			} while (--width); + +			src += MAX_MOUSE_W - w; +			bak += MAX_MOUSE_W - w; +			dst += _screenWidth - w; +		} while (--h);  	} -#endif + +	_mouseDrawn = true;  }  void OSystem_PalmOS5::undraw_mouse() {  	if (!_mouseDrawn)  		return; -	_mouseDrawn = false; -#ifdef PALMOS_68K +	int h = _mouseOldState.h;  	// No need to do clipping here, since draw_mouse() did that already  	if (_overlayVisible) { +		int16 *bak = (int16 *)_mouseBackupP; +		int16 *dst = _overlayP + _mouseOldState.y * _screenWidth + _mouseOldState.x; + +		do { +			memcpy(dst, bak, _mouseOldState.w * 2); +			bak += MAX_MOUSE_W; +			dst += _screenWidth; +		} while (--h); +  	} else { -		RectangleType r = {0, 0, _mouseOldState.w, _mouseOldState.h}; -		WinCopyRectangle(_mouseBackupH, _offScreenH, &r, _mouseOldState.x, _mouseOldState.y, winPaint); +		byte *dst, *bak = _mouseBackupP; +		dst = _offScreenP + _mouseOldState.y * _screenWidth + _mouseOldState.x; +		 +		do { +			memcpy(dst, bak, _mouseOldState.w); +			bak += MAX_MOUSE_W; +			dst += _screenWidth; +		} while (--h);  	} -#endif + +	_mouseDrawn = false;  } diff --git a/backends/PalmOS/Src/os5_overlay.cpp b/backends/PalmOS/Src/os5_overlay.cpp index 5ca43be60c..1c5c29f4f6 100755 --- a/backends/PalmOS/Src/os5_overlay.cpp +++ b/backends/PalmOS/Src/os5_overlay.cpp @@ -1,7 +1,7 @@  /* ScummVM - Scumm Interpreter   * Copyright (C) 2001  Ludvig Strigeus   * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2005 Chris Apers - PalmOS Backend + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -23,15 +23,64 @@  #include "be_os5.h" -OverlayColor OSystem_PalmOS5::RGBToColor(uint8 r, uint8 g, uint8 b) { -	RGBColorType rgb = {0, r, g, b}; -	OverlayColor color = WinRGBToIndex(&rgb); +void OSystem_PalmOS5::showOverlay() { +	// hide fight indicator +	draw_osd(kDrawFight, _screenDest.w - 34, _screenDest.h + 2, false); + +	undraw_mouse(); +	_overlayVisible = true; +	clearOverlay();	 +} + +void OSystem_PalmOS5::hideOverlay() { +	undraw_mouse(); +	_overlayVisible = false; +	_redawOSD = true; +} + +void OSystem_PalmOS5::clearOverlay() { +	if (!_overlayVisible) +		return; + +	byte *src = _offScreenP; +	int16 *dst =  _overlayP; +	int cnt = _screenWidth * _screenHeight; +	do { +		*dst++ = _nativePal[*src++]; +	} while (--cnt); +} + +void OSystem_PalmOS5::grabOverlay(OverlayColor *buf, int pitch) { +	OverlayColor *src = _overlayP; +	int h = _screenHeight; +	do { +		memcpy(buf, src, _screenWidth * 2); +		src += _screenWidth; +		buf += pitch; +	} while (--h); +} + +void OSystem_PalmOS5::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +	if (w == 0 || h == 0) +		return; -	return color; +	OverlayColor *dst = _overlayP + x + y * _screenWidth; +	do { +		memcpy(dst, buf, w * 2); +		dst += _screenWidth; +		buf += pitch; +	} while (--h); +} + +OverlayColor OSystem_PalmOS5::RGBToColor(uint8 r, uint8 g, uint8 b) { +	return gfxMakeDisplayRGB(r, g, b);  }  void OSystem_PalmOS5::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { -	r = _currentPalette[color].r; -	g = _currentPalette[color].g; -	b = _currentPalette[color].b; +#ifdef PALMOS_68K +	color = SWAP_BYTES_16(color); +#endif +	r = ((color >> 8) & 0xF8); +	g = ((color >> 3) & 0xFC); +	b = ((color << 3) & 0xF8);  } diff --git a/backends/PalmOS/Src/os5_renderer.cpp b/backends/PalmOS/Src/os5_renderer.cpp new file mode 100755 index 0000000000..4bf42d439c --- /dev/null +++ b/backends/PalmOS/Src/os5_renderer.cpp @@ -0,0 +1,155 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001  Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Header$ + * + */ + +#include "be_os5.h" + +void OSystem_PalmOS5::render_1x(RectangleType &r, PointType &p) { +	Coord o = 0; + +	if (_overlayVisible) { +		int16 *src = _overlayP; +		int16 *dst =  _workScreenP; +		MemMove(dst, src, _screenWidth * _screenHeight * 2); + +	} else { +		byte *src = _offScreenP; +		int16 *dst =  _workScreenP; +		int cnt = _screenWidth * _screenHeight; +		o = _current_shake_pos; + +		do { +			*dst++ = _nativePal[*src++]; +		} while (--cnt); +	} + +	p.x = _screenOffset.x; +	p.y = _screenOffset.y + o; +	RctSetRectangle(&r, 0, 0, _screenWidth, _screenHeight - o); +} + +void OSystem_PalmOS5::render_landscape(RectangleType &r, PointType &p) { +	Coord x, y, o = 0; +	int16 *dst =  _workScreenP; + +	if (_overlayVisible) { +		int16 *src = _overlayP; + +		for (y = 0; y < 100; y++) { +			// draw 2 lines +			for (x = 0; x < 320; x++) { +				*dst++ = *src++; +				*dst++ = *src; +				*dst++ = *src++; +			} +			// copy the second to the next line +			MemMove(dst, dst - 480, 480 * 2); +			dst += 480; +		} + +	} else { +		byte *src = _offScreenP; +		o = _current_shake_pos; + +		for (y = 0; y < 100; y++) { +			// draw 2 lines +			for (x = 0; x < 320; x++) { +				*dst++ = _nativePal[*src++]; +				*dst++ = _nativePal[*src]; +				*dst++ = _nativePal[*src++]; +			} +			// copy the second to the next line +			MemMove(dst, dst - 480, 480 * 2); +			dst += 480; +		} +	} + +	p.x = _screenOffset.x; +	p.y = _screenOffset.y + o; +	RctSetRectangle(&r, 0, 0, 480, 300 - o); +} + +void OSystem_PalmOS5::render_portrait(RectangleType &r, PointType &p) { +	Coord x, y, o = 0; +	int16 *dst =  _workScreenP; + +	if (_overlayVisible) { +		int16 *src = _overlayP + 320 - 1; +		int16 *src2 = src; + +		for (x = 0; x < 160; x++) { +			for (y = 0; y < 100; y++) { +				*dst++ = *src; +				src += 320; +				*dst++ = *src; +				*dst++ = *src; +				src += 320; +			} +			src = --src2; + +			for (y = 0; y < 100; y++) { +				*dst++ = *src; +				src += 320; +				*dst++ = *src; +				*dst++ = *src; +				src += 320; +			} +			src = --src2; + +			MemMove(dst, dst - 300, 300 * 2);	// 300 = 200 x 1.5 +			dst += 300; +		} + +	} else { +		byte *src = _offScreenP + 320 - 1; +		byte *src2 = src; +		o = _current_shake_pos; + +		for (x = 0; x < 160; x++) { +			for (y = 0; y < 100; y++) { +				*dst++ = _nativePal[*src]; +				src += 320; +				*dst++ = _nativePal[*src]; +				*dst++ = _nativePal[*src]; +				src += 320; +			} +			src = --src2; + +			for (y = 0; y < 100; y++) { +				*dst++ = _nativePal[*src]; +				src += 320; +				*dst++ = _nativePal[*src]; +				*dst++ = _nativePal[*src]; +				src += 320; +			} +			src = --src2; + +			MemMove(dst, dst - 300, 300 * 2);	// 300 = 200 x 1.5 +			dst += 300; +		} +	} + +	p.y = _screenOffset.x; +	p.x = _screenOffset.y + o; +	RctSetRectangle(&r, 0, 0, 300 - o, 480); +} + diff --git a/backends/PalmOS/Src/os5_sound.cpp b/backends/PalmOS/Src/os5_sound.cpp index 3ffa8e84c6..7d5e4ceaa7 100755 --- a/backends/PalmOS/Src/os5_sound.cpp +++ b/backends/PalmOS/Src/os5_sound.cpp @@ -1,7 +1,7 @@  /* ScummVM - Scumm Interpreter   * Copyright (C) 2001  Ludvig Strigeus   * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2005 Chris Apers - PalmOS Backend + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -22,41 +22,44 @@   */  #include "be_os5.h" +#include "backends/intern.h"  #include "common/config-manager.h" -#ifdef PALMOS_68K -static void initRegs(void *addr) { -	asm ( -		move.l	addr, a0 -		move.l	a4, 0(a0) -		move.l	a5, 4(a0) -	); -} +SoundExType _soundEx;  static Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP) { -	asm ( -//		movem.l a4-a5, -(sp) -		move.l UserDataP, a0 -		move.l 0(a0), a4 -		move.l 4(a0), a5 -	); - -	SoundDataType *_sound = (SoundDataType *)UserDataP; -	((OSystem::SoundProc)_sound->proc)(_sound->param, (byte *)bufferP, *bufferSizeP); - -//	asm ( movem.l (sp)+, a4-a5 ); +	SoundExType *_soundEx = (SoundExType *)UserDataP; +	SoundType *_sound = _soundEx->sound; +	 +	if (_soundEx->set && _soundEx->size) { +		MemMove(bufferP, _soundEx->dataP, _soundEx->size); +		*bufferSizeP = _soundEx->size; +		_soundEx->set = false; + +	} else { +		_soundEx->size = *bufferSizeP; +		MemSet(bufferP, 128, 0); +		*bufferSizeP = 128; +	} +	  	return errNone;  } -#else +void OSystem_PalmOS5::sound_handler() { +	if (_sound.active) { +		if (_soundEx.size && !_soundEx.set) { +			if (!_soundEx.dataP) +				_soundEx.dataP = MemPtrNew(_soundEx.size); -static SYSTEM_CALLBACK Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP) { -	SoundDataType *_sound = (SoundDataType *)UserDataP; -	((OSystem::SoundProc)_sound->proc)(_sound->param, (byte *)bufferP, *bufferSizeP); -	return errNone; +			((SoundProc)_sound.proc)(_sound.param, (byte *)_soundEx.dataP, _soundEx.size); +			_soundEx.set = true; +		} +	}// TODO : no Sound API case  } -#endif +SndStreamVariableBufferCallback OSystem_PalmOS5::sound_callback() { +	return sndCallback; +}  bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {  	Err e; @@ -68,47 +71,54 @@ bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {  			ConfMan.set("FM_high_quality", (gVars->fmQuality == FM_QUALITY_HI));  		} +#if defined (COMPILE_OS5) +		CALLBACK_INIT(_soundEx); +#endif  		_sound.proc = proc;  		_sound.param = param; -		_sound.active = true;		// always true when we call this function, false when sound is off -		_sound.handle = NULL; +		_sound.active = true;	// always true when we call this function, false when sound is off + +		_soundEx.handle = 0; +		_soundEx.size = 0;		// set by the callback +		_soundEx.set = false; +		_soundEx.dataP = NULL;	// set by the handler  		if (ConfMan.hasKey("output_rate"))  			_samplesPerSec = ConfMan.getInt("output_rate");  		else -#ifdef PALMOS_ARM -			_samplesPerSec = 44100;	// default value -#else -			_samplesPerSec = 8000;	// default value -#endif +			_samplesPerSec = SAMPLES_PER_SEC;  		// try to create sound stream -		if (1 || OPTIONS_TST(kOptPalmSoundAPI)) { -#ifdef PALMOS_68K -			initRegs(&_sound); -#endif +		if (OPTIONS_TST(kOptPalmSoundAPI)) {  			e = SndStreamCreateExtended( -						&_sound.handle, +						&_soundEx.handle,  						sndOutput,  						sndFormatPCM,  						_samplesPerSec, -#ifdef PALMOS_ARM -						sndInt16Little, -#else +#ifdef PALMOS_68K  						sndInt16Big, +#else +						sndInt16Little,  #endif  						sndStereo, -						(SndStreamVariableBufferCallback)sndCallback, -						&_sound, +						sound_callback(), +						&_soundEx,  						8192  #ifdef PALMOS_68K  						,false +#elif defined (COMPILE_OS5) +						,true  #endif  						); -			e = e ? e : SndStreamStart(_sound.handle); -			e = e ? e :	SndStreamSetVolume(_sound.handle, (32767L / 16) * gVars->palmVolume / 100); +			e = e ? e : SndStreamStart(_soundEx.handle); +			e = e ? e :	SndStreamSetVolume(_soundEx.handle, 1024L * gVars->palmVolume / 100);  			success = (e == errNone); + +		// no Sound API +		} else { +			_soundEx.size = 512; +			_soundEx.dataP = MemPtrNew(_soundEx.size);  		}  	}  	// if not true some scenes (indy3 256,...) may freeze (ESC to skip) @@ -117,12 +127,16 @@ bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {  void OSystem_PalmOS5::clearSoundCallback() {  	if (_sound.active) { -		if (1 || OPTIONS_TST(kOptPalmSoundAPI)) { -			SndStreamStop(_sound.handle); -			SndStreamDelete(_sound.handle); +		if (OPTIONS_TST(kOptPalmSoundAPI)) { +			SndStreamStop(_soundEx.handle); +			SndStreamDelete(_soundEx.handle);  		} + +		if (_soundEx.dataP) +			free(_soundEx.dataP);  	} -	 +  	_sound.active = false; -	_sound.handle = NULL; +	_soundEx.handle = NULL; +	_soundEx.dataP = NULL;  }  | 
