2009-02-17 15:02:16 +00:00
/* 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 .
*
*/
2009-02-15 06:10:59 +00:00
2010-07-21 21:37:30 +00:00
# include "common/system.h"
2010-05-26 03:43:21 +00:00
# include "engines/util.h"
2009-07-03 14:18:20 +00:00
# include "graphics/cursorman.h"
2009-08-30 19:47:47 +00:00
# include "graphics/surface.h"
2012-01-13 22:46:22 +02:00
# include "graphics/palette.h" // temporary, for the fadeIn()/fadeOut() functions below
2009-02-21 15:40:14 +00:00
2010-08-02 12:39:01 +00:00
# include "gui/message.h"
2009-05-13 16:52:41 +00:00
# include "sci/sci.h"
2009-06-04 11:28:05 +00:00
# include "sci/debug.h" // for g_debug_sleeptime_factor
2010-11-20 19:52:31 +00:00
# include "sci/event.h"
2009-05-15 14:07:45 +00:00
# include "sci/resource.h"
2010-02-13 17:44:58 +00:00
# include "sci/engine/features.h"
2009-02-27 02:23:40 +00:00
# include "sci/engine/state.h"
2010-01-29 11:03:54 +00:00
# include "sci/engine/selector.h"
2009-03-07 19:23:47 +00:00
# include "sci/engine/kernel.h"
2010-01-05 01:37:57 +00:00
# include "sci/graphics/animate.h"
2010-01-31 17:14:58 +00:00
# include "sci/graphics/cache.h"
2010-02-05 20:44:03 +00:00
# include "sci/graphics/compare.h"
2011-10-26 01:48:20 +03:00
# include "sci/graphics/controls16.h"
2010-01-05 01:37:57 +00:00
# include "sci/graphics/cursor.h"
2010-01-31 16:21:11 +00:00
# include "sci/graphics/palette.h"
2010-02-04 19:22:40 +00:00
# include "sci/graphics/paint16.h"
2010-07-24 16:47:12 +00:00
# include "sci/graphics/picture.h"
2010-01-31 22:20:55 +00:00
# include "sci/graphics/ports.h"
2010-01-05 01:37:57 +00:00
# include "sci/graphics/screen.h"
2010-06-15 13:01:07 +00:00
# include "sci/graphics/text16.h"
2010-01-05 01:37:57 +00:00
# include "sci/graphics/view.h"
2010-06-17 07:26:06 +00:00
# ifdef ENABLE_SCI32
2011-10-28 22:19:52 +03:00
# include "sci/graphics/controls32.h"
2011-10-14 14:05:34 +03:00
# include "sci/graphics/font.h" // TODO: remove once kBitmap is moved in a separate class
2011-09-03 14:50:58 +03:00
# include "sci/graphics/text32.h"
2010-07-21 21:18:21 +00:00
# include "sci/graphics/frameout.h"
2010-06-17 07:26:06 +00:00
# endif
2009-02-15 06:10:59 +00:00
2009-02-21 10:23:36 +00:00
namespace Sci {
2011-03-02 08:24:31 +02:00
static int16 adjustGraphColor ( int16 color ) {
// WORKAROUND: SCI1 EGA and Amiga games can set invalid colors (above 0 - 15).
// Colors above 15 are all white in SCI1 EGA games, which is why this was never
// observed. We clip them all to (0, 15) instead, as colors above 15 are used
// for the undithering algorithm in EGA games - bug #3048908.
if ( getSciVersion ( ) > = SCI_VERSION_1_EARLY & & g_sci - > getResMan ( ) - > getViewType ( ) = = kViewEga )
return color & 0x0F ; // 0 - 15
else
return color ;
}
2010-08-17 20:33:22 +00:00
void showScummVMDialog ( const Common : : String & message ) {
GUI : : MessageDialog dialog ( message , " OK " ) ;
dialog . runModal ( ) ;
}
2010-09-03 22:15:08 +00:00
void kDirLoopWorker ( reg_t object , uint16 angle , EngineState * s , int argc , reg_t * argv ) {
2010-05-29 23:37:15 +00:00
GuiResourceId viewId = readSelectorValue ( s - > _segMan , object , SELECTOR ( view ) ) ;
uint16 signal = readSelectorValue ( s - > _segMan , object , SELECTOR ( signal ) ) ;
2009-10-09 17:34:52 +00:00
2009-10-21 19:19:03 +00:00
if ( signal & kSignalDoesntTurn )
2009-10-09 17:34:52 +00:00
return ;
2010-09-03 22:15:08 +00:00
int16 useLoop = - 1 ;
if ( getSciVersion ( ) > SCI_VERSION_0_EARLY ) {
if ( ( angle > 315 ) | | ( angle < 45 ) ) {
useLoop = 3 ;
} else if ( ( angle > 135 ) & & ( angle < 225 ) ) {
useLoop = 2 ;
}
2009-10-09 17:34:52 +00:00
} else {
2010-09-03 22:15:08 +00:00
// SCI0EARLY
if ( ( angle > 330 ) | | ( angle < 30 ) ) {
useLoop = 3 ;
} else if ( ( angle > 150 ) & & ( angle < 210 ) ) {
useLoop = 2 ;
}
}
if ( useLoop = = - 1 ) {
if ( angle > = 180 ) {
useLoop = 1 ;
} else {
useLoop = 0 ;
}
} else {
int16 loopCount = g_sci - > _gfxCache - > kernelViewGetLoopCount ( viewId ) ;
if ( loopCount < 4 )
return ;
2009-10-09 17:34:52 +00:00
}
2010-09-03 22:15:08 +00:00
writeSelectorValue ( s - > _segMan , object , SELECTOR ( loop ) , useLoop ) ;
2009-10-09 17:34:52 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
static reg_t kSetCursorSci0 ( EngineState * s , int argc , reg_t * argv ) {
2009-10-07 12:47:53 +00:00
Common : : Point pos ;
2009-10-07 14:53:15 +00:00
GuiResourceId cursorId = argv [ 0 ] . toSint16 ( ) ;
2009-08-30 01:37:52 +00:00
// Set pointer position, if requested
2009-10-07 12:47:53 +00:00
if ( argc > = 4 ) {
pos . y = argv [ 3 ] . toSint16 ( ) ;
pos . x = argv [ 2 ] . toSint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelSetPos ( pos ) ;
2009-10-07 12:47:53 +00:00
}
2009-10-07 14:53:15 +00:00
if ( ( argc > = 2 ) & & ( argv [ 1 ] . toSint16 ( ) = = 0 ) ) {
cursorId = - 1 ;
}
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelSetShape ( cursorId ) ;
2009-08-30 01:37:52 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
static reg_t kSetCursorSci11 ( EngineState * s , int argc , reg_t * argv ) {
2009-10-07 12:47:53 +00:00
Common : : Point pos ;
2009-08-30 01:37:52 +00:00
Common : : Point * hotspot = NULL ;
2009-08-25 08:38:14 +00:00
2009-02-15 22:28:12 +00:00
switch ( argc ) {
2009-08-30 01:37:52 +00:00
case 1 :
2009-11-30 19:34:45 +00:00
switch ( argv [ 0 ] . toSint16 ( ) ) {
case 0 :
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelHide ( ) ;
2009-11-30 19:34:45 +00:00
break ;
case - 1 :
2010-10-03 22:41:35 +00:00
g_sci - > _gfxCursor - > kernelClearZoomZone ( ) ;
2009-11-30 19:34:45 +00:00
break ;
case - 2 :
2010-07-23 10:58:06 +00:00
g_sci - > _gfxCursor - > kernelResetMoveZone ( ) ;
2009-11-30 19:34:45 +00:00
break ;
default :
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelShow ( ) ;
2009-11-30 19:34:45 +00:00
break ;
}
2010-02-06 05:29:08 +00:00
break ;
2009-08-30 01:37:52 +00:00
case 2 :
2009-10-07 12:47:53 +00:00
pos . y = argv [ 1 ] . toSint16 ( ) ;
pos . x = argv [ 0 ] . toSint16 ( ) ;
2011-06-20 00:59:48 +02:00
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelSetPos ( pos ) ;
2009-05-29 08:25:42 +00:00
break ;
2009-08-30 01:38:14 +00:00
case 4 : {
2010-07-22 21:40:10 +00:00
int16 top , left , bottom , right ;
if ( getSciVersion ( ) > = SCI_VERSION_2 ) {
top = argv [ 1 ] . toSint16 ( ) ;
left = argv [ 0 ] . toSint16 ( ) ;
2010-07-22 22:13:25 +00:00
bottom = argv [ 3 ] . toSint16 ( ) ;
right = argv [ 2 ] . toSint16 ( ) ;
2010-07-22 21:40:10 +00:00
} else {
top = argv [ 0 ] . toSint16 ( ) ;
left = argv [ 1 ] . toSint16 ( ) ;
2010-07-22 22:13:25 +00:00
bottom = argv [ 2 ] . toSint16 ( ) ;
2010-07-22 21:40:10 +00:00
right = argv [ 3 ] . toSint16 ( ) ;
}
2010-07-22 22:13:25 +00:00
// bottom/right needs to be included into our movezone, because we compare it like any regular Common::Rect
bottom + + ;
right + + ;
2010-06-05 18:15:41 +00:00
2009-08-30 01:38:14 +00:00
if ( ( right > = left ) & & ( bottom > = top ) ) {
2009-10-07 11:35:12 +00:00
Common : : Rect rect = Common : : Rect ( left , top , right , bottom ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelSetMoveZone ( rect ) ;
2009-08-30 01:38:14 +00:00
} else {
warning ( " kSetCursor: Ignoring invalid mouse zone (%i, %i)-(%i, %i) " , left , top , right , bottom ) ;
}
break ;
}
2010-07-30 15:26:30 +00:00
case 9 : // case for kq5cd, we are getting calling with 4 additional 900d parameters
2009-08-30 01:37:52 +00:00
case 5 :
hotspot = new Common : : Point ( argv [ 3 ] . toSint16 ( ) , argv [ 4 ] . toSint16 ( ) ) ;
// Fallthrough
case 3 :
2010-05-18 04:17:58 +00:00
if ( g_sci - > getPlatform ( ) = = Common : : kPlatformMacintosh )
g_sci - > _gfxCursor - > kernelSetMacCursor ( argv [ 0 ] . toUint16 ( ) , argv [ 1 ] . toUint16 ( ) , argv [ 2 ] . toUint16 ( ) , hotspot ) ;
else
g_sci - > _gfxCursor - > kernelSetView ( argv [ 0 ] . toUint16 ( ) , argv [ 1 ] . toUint16 ( ) , argv [ 2 ] . toUint16 ( ) , hotspot ) ;
2009-02-15 06:10:59 +00:00
break ;
2010-07-30 08:21:54 +00:00
case 10 :
// Freddy pharkas, when using the whiskey glass to read the prescription (bug #3034973)
2011-06-20 00:59:48 +02:00
g_sci - > _gfxCursor - > kernelSetZoomZone ( argv [ 0 ] . toUint16 ( ) ,
2010-10-03 22:41:35 +00:00
Common : : Rect ( argv [ 1 ] . toUint16 ( ) , argv [ 2 ] . toUint16 ( ) , argv [ 3 ] . toUint16 ( ) , argv [ 4 ] . toUint16 ( ) ) ,
argv [ 5 ] . toUint16 ( ) , argv [ 6 ] . toUint16 ( ) , argv [ 7 ] . toUint16 ( ) ,
argv [ 8 ] . toUint16 ( ) , argv [ 9 ] . toUint16 ( ) ) ;
2010-07-30 08:21:54 +00:00
break ;
2009-02-15 06:10:59 +00:00
default :
2010-06-17 23:53:30 +00:00
error ( " kSetCursor: Unhandled case: %d arguments given " , argc ) ;
2009-02-15 06:10:59 +00:00
break ;
}
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kSetCursor ( EngineState * s , int argc , reg_t * argv ) {
2010-02-13 17:44:58 +00:00
switch ( g_sci - > _features - > detectSetCursorType ( ) ) {
2009-08-30 01:37:52 +00:00
case SCI_VERSION_0_EARLY :
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
return kSetCursorSci0 ( s , argc , argv ) ;
2009-08-30 01:37:52 +00:00
case SCI_VERSION_1_1 :
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
return kSetCursorSci11 ( s , argc , argv ) ;
2009-08-30 01:37:52 +00:00
default :
2010-06-17 23:53:30 +00:00
error ( " Unknown SetCursor type " ) ;
2009-08-30 01:37:52 +00:00
return NULL_REG ;
}
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kMoveCursor ( EngineState * s , int argc , reg_t * argv ) {
2011-01-12 23:30:59 +00:00
g_sci - > _gfxCursor - > kernelSetPos ( Common : : Point ( argv [ 0 ] . toSint16 ( ) , argv [ 1 ] . toSint16 ( ) ) ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kPicNotValid ( EngineState * s , int argc , reg_t * argv ) {
2009-10-12 07:30:55 +00:00
int16 newPicNotValid = ( argc > 0 ) ? argv [ 0 ] . toUint16 ( ) : - 1 ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
return make_reg ( 0 , g_sci - > _gfxScreen - > kernelPicNotValid ( newPicNotValid ) ) ;
2009-02-15 06:10:59 +00:00
}
2010-07-10 18:21:09 +00:00
static Common : : Rect getGraphRect ( reg_t * argv ) {
int16 x = argv [ 1 ] . toSint16 ( ) ;
int16 y = argv [ 0 ] . toSint16 ( ) ;
int16 x1 = argv [ 3 ] . toSint16 ( ) ;
int16 y1 = argv [ 2 ] . toSint16 ( ) ;
2009-10-12 12:38:58 +00:00
if ( x > x1 ) SWAP ( x , x1 ) ;
if ( y > y1 ) SWAP ( y , y1 ) ;
2010-01-11 16:28:46 +00:00
return Common : : Rect ( x , y , x1 , y1 ) ;
2009-10-12 12:38:58 +00:00
}
2010-07-10 18:21:09 +00:00
static Common : : Point getGraphPoint ( reg_t * argv ) {
int16 x = argv [ 1 ] . toSint16 ( ) ;
int16 y = argv [ 0 ] . toSint16 ( ) ;
return Common : : Point ( x , y ) ;
}
2009-10-28 18:59:11 +00:00
2009-10-03 20:49:18 +00:00
reg_t kGraph ( EngineState * s , int argc , reg_t * argv ) {
2010-07-10 18:21:09 +00:00
if ( ! s )
return make_reg ( 0 , getSciVersion ( ) ) ;
error ( " not supposed to call this " ) ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphGetColorCount ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
return make_reg ( 0 , g_sci - > _gfxPalette - > getTotalColorCount ( ) ) ;
2010-07-10 18:21:09 +00:00
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphDrawLine ( EngineState * s , int argc , reg_t * argv ) {
2011-03-02 08:24:31 +02:00
int16 color = adjustGraphColor ( argv [ 4 ] . toSint16 ( ) ) ;
2010-07-10 18:21:09 +00:00
int16 priority = ( argc > 5 ) ? argv [ 5 ] . toSint16 ( ) : - 1 ;
int16 control = ( argc > 6 ) ? argv [ 6 ] . toSint16 ( ) : - 1 ;
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
g_sci - > _gfxPaint16 - > kernelGraphDrawLine ( getGraphPoint ( argv ) , getGraphPoint ( argv + 2 ) , color , priority , control ) ;
return s - > r_acc ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphSaveBox ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect rect = getGraphRect ( argv ) ;
2010-07-26 15:40:12 +00:00
uint16 screenMask = argv [ 4 ] . toUint16 ( ) & GFX_SCREEN_MASK_ALL ;
2010-07-10 18:21:09 +00:00
return g_sci - > _gfxPaint16 - > kernelGraphSaveBox ( rect , screenMask ) ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphRestoreBox ( EngineState * s , int argc , reg_t * argv ) {
// This may be called with a memoryhandle from SAVE_BOX or SAVE_UPSCALEDHIRES_BOX
g_sci - > _gfxPaint16 - > kernelGraphRestoreBox ( argv [ 0 ] ) ;
return s - > r_acc ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphFillBoxBackground ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect rect = getGraphRect ( argv ) ;
g_sci - > _gfxPaint16 - > kernelGraphFillBoxBackground ( rect ) ;
return s - > r_acc ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphFillBoxForeground ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect rect = getGraphRect ( argv ) ;
g_sci - > _gfxPaint16 - > kernelGraphFillBoxForeground ( rect ) ;
return s - > r_acc ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphFillBoxAny ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect rect = getGraphRect ( argv ) ;
int16 colorMask = argv [ 4 ] . toUint16 ( ) ;
2011-03-02 08:24:31 +02:00
int16 color = adjustGraphColor ( argv [ 5 ] . toSint16 ( ) ) ;
2010-08-11 18:19:58 +00:00
int16 priority = argv [ 6 ] . toSint16 ( ) ; // yes, we may read from stack sometimes here
int16 control = argv [ 7 ] . toSint16 ( ) ; // sierra did the same
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
g_sci - > _gfxPaint16 - > kernelGraphFillBox ( rect , colorMask , color , priority , control ) ;
return s - > r_acc ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphUpdateBox ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect rect = getGraphRect ( argv ) ;
// argv[4] is the map (1 for visual, etc.)
// argc == 6 on upscaled hires
bool hiresMode = ( argc > 5 ) ? true : false ;
g_sci - > _gfxPaint16 - > kernelGraphUpdateBox ( rect , hiresMode ) ;
return s - > r_acc ;
}
2009-10-30 22:55:35 +00:00
2010-07-10 18:21:09 +00:00
reg_t kGraphRedrawBox ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect rect = getGraphRect ( argv ) ;
g_sci - > _gfxPaint16 - > kernelGraphRedrawBox ( rect ) ;
return s - > r_acc ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 18:21:09 +00:00
// Seems to be only implemented for SCI0/SCI01 games
reg_t kGraphAdjustPriority ( EngineState * s , int argc , reg_t * argv ) {
g_sci - > _gfxPorts - > kernelGraphAdjustPriority ( argv [ 0 ] . toUint16 ( ) , argv [ 1 ] . toUint16 ( ) ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
2010-07-10 18:21:09 +00:00
reg_t kGraphSaveUpscaledHiresBox ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect rect = getGraphRect ( argv ) ;
return g_sci - > _gfxPaint16 - > kernelGraphSaveUpscaledHiresBox ( rect ) ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kTextSize ( EngineState * s , int argc , reg_t * argv ) {
2009-10-03 20:49:18 +00:00
int16 textWidth , textHeight ;
2009-10-04 18:38:18 +00:00
Common : : String text = s - > _segMan - > getString ( argv [ 1 ] ) ;
reg_t * dest = s - > _segMan - > derefRegPtr ( argv [ 0 ] , 4 ) ;
2009-06-07 16:50:34 +00:00
int maxwidth = ( argc > 3 ) ? argv [ 3 ] . toUint16 ( ) : 0 ;
2009-06-07 15:53:30 +00:00
int font_nr = argv [ 2 ] . toUint16 ( ) ;
2009-02-15 06:10:59 +00:00
2010-10-15 14:33:57 +00:00
if ( ! dest ) {
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelStrings , " GetTextSize: Empty destination " ) ;
2010-10-15 14:33:57 +00:00
return s - > r_acc ;
}
2009-09-27 01:50:26 +00:00
Common : : String sep_str ;
2009-10-03 20:49:18 +00:00
const char * sep = NULL ;
2009-09-27 01:50:26 +00:00
if ( ( argc > 4 ) & & ( argv [ 4 ] . segment ) ) {
2009-10-04 18:38:18 +00:00
sep_str = s - > _segMan - > getString ( argv [ 4 ] ) ;
2009-09-27 01:50:26 +00:00
sep = sep_str . c_str ( ) ;
}
2009-06-24 19:12:45 +00:00
2009-02-15 06:10:59 +00:00
dest [ 0 ] = dest [ 1 ] = NULL_REG ;
2010-10-15 14:33:57 +00:00
if ( text . empty ( ) ) { // Empty text
dest [ 2 ] = dest [ 3 ] = make_reg ( 0 , 0 ) ;
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelStrings , " GetTextSize: Empty string " ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
2009-10-03 20:49:18 +00:00
textWidth = dest [ 3 ] . toUint16 ( ) ; textHeight = dest [ 2 ] . toUint16 ( ) ;
2010-06-24 11:54:33 +00:00
2010-01-29 22:02:28 +00:00
# ifdef ENABLE_SCI32
2011-10-08 17:16:58 +03:00
if ( g_sci - > _gfxText32 )
g_sci - > _gfxText32 - > kernelTextSize ( g_sci - > strSplit ( text . c_str ( ) , sep ) . c_str ( ) , font_nr , maxwidth , & textWidth , & textHeight ) ;
else
2010-01-29 22:02:28 +00:00
# endif
2010-06-15 13:01:07 +00:00
g_sci - > _gfxText16 - > kernelTextSize ( g_sci - > strSplit ( text . c_str ( ) , sep ) . c_str ( ) , font_nr , maxwidth , & textWidth , & textHeight ) ;
2011-05-29 21:12:37 +03:00
// One of the game texts in LB2 German contains loads of spaces in
// its end. We trim the text here, otherwise the graphics code will
// attempt to draw a very large window (larger than the screen) to
// show the text, and crash.
// Fixes bug #3306417.
if ( textWidth > = g_sci - > _gfxScreen - > getDisplayWidth ( ) | |
textHeight > = g_sci - > _gfxScreen - > getDisplayHeight ( ) ) {
// TODO: Is this needed for SCI32 as well?
if ( g_sci - > _gfxText16 ) {
warning ( " kTextSize: string would be too big to fit on screen. Trimming it " ) ;
text . trim ( ) ;
// Copy over the trimmed string...
s - > _segMan - > strcpy ( argv [ 1 ] , text . c_str ( ) ) ;
// ...and recalculate bounding box dimensions
g_sci - > _gfxText16 - > kernelTextSize ( g_sci - > strSplit ( text . c_str ( ) , sep ) . c_str ( ) , font_nr , maxwidth , & textWidth , & textHeight ) ;
}
}
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelStrings , " GetTextSize '%s' -> %dx%d " , text . c_str ( ) , textWidth , textHeight ) ;
2011-10-08 19:11:14 +03:00
if ( getSciVersion ( ) < = SCI_VERSION_1_1 ) {
dest [ 2 ] = make_reg ( 0 , textHeight ) ;
dest [ 3 ] = make_reg ( 0 , textWidth ) ;
} else {
dest [ 2 ] = make_reg ( 0 , textWidth ) ;
dest [ 3 ] = make_reg ( 0 , textHeight ) ;
}
2011-05-29 21:12:37 +03:00
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kWait ( EngineState * s , int argc , reg_t * argv ) {
2009-06-07 15:53:30 +00:00
int sleep_time = argv [ 0 ] . toUint16 ( ) ;
2009-02-15 06:10:59 +00:00
2010-02-23 22:44:46 +00:00
s - > wait ( sleep_time ) ;
2009-08-11 20:18:15 +00:00
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kCoordPri ( EngineState * s , int argc , reg_t * argv ) {
2009-10-09 13:15:37 +00:00
int16 y = argv [ 0 ] . toSint16 ( ) ;
2009-02-15 06:10:59 +00:00
2009-10-11 14:58:58 +00:00
if ( ( argc < 2 ) | | ( y ! = 1 ) ) {
2010-02-13 17:43:31 +00:00
return make_reg ( 0 , g_sci - > _gfxPorts - > kernelCoordinateToPriority ( y ) ) ;
2009-10-11 14:58:58 +00:00
} else {
int16 priority = argv [ 1 ] . toSint16 ( ) ;
2010-02-13 17:43:31 +00:00
return make_reg ( 0 , g_sci - > _gfxPorts - > kernelPriorityToCoordinate ( priority ) ) ;
2009-10-11 14:58:58 +00:00
}
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kPriCoord ( EngineState * s , int argc , reg_t * argv ) {
2009-10-09 13:15:37 +00:00
int16 priority = argv [ 0 ] . toSint16 ( ) ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
return make_reg ( 0 , g_sci - > _gfxPorts - > kernelPriorityToCoordinate ( priority ) ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kDirLoop ( EngineState * s , int argc , reg_t * argv ) {
2010-09-03 22:15:08 +00:00
kDirLoopWorker ( argv [ 0 ] , argv [ 1 ] . toUint16 ( ) , s , argc , argv ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kCanBeHere ( EngineState * s , int argc , reg_t * argv ) {
2009-10-09 16:51:10 +00:00
reg_t curObject = argv [ 0 ] ;
reg_t listReference = ( argc > 1 ) ? argv [ 1 ] : NULL_REG ;
2010-02-05 20:44:03 +00:00
2010-07-15 19:23:18 +00:00
reg_t canBeHere = g_sci - > _gfxCompare - > kernelCanBeHere ( curObject , listReference ) ;
return make_reg ( 0 , canBeHere . isNull ( ) ? 1 : 0 ) ;
2009-10-09 16:51:10 +00:00
}
2009-02-15 06:10:59 +00:00
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kCantBeHere ( EngineState * s , int argc , reg_t * argv ) {
2009-10-14 09:36:39 +00:00
reg_t curObject = argv [ 0 ] ;
reg_t listReference = ( argc > 1 ) ? argv [ 1 ] : NULL_REG ;
2011-06-20 00:59:48 +02:00
2010-07-15 19:23:18 +00:00
reg_t canBeHere = g_sci - > _gfxCompare - > kernelCanBeHere ( curObject , listReference ) ;
2010-07-15 19:39:43 +00:00
return canBeHere ;
2009-09-17 13:22:00 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kIsItSkip ( EngineState * s , int argc , reg_t * argv ) {
2009-10-28 18:59:11 +00:00
GuiResourceId viewId = argv [ 0 ] . toSint16 ( ) ;
int16 loopNo = argv [ 1 ] . toSint16 ( ) ;
int16 celNo = argv [ 2 ] . toSint16 ( ) ;
2009-10-28 19:10:39 +00:00
Common : : Point position ( argv [ 4 ] . toUint16 ( ) , argv [ 3 ] . toUint16 ( ) ) ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
bool result = g_sci - > _gfxCompare - > kernelIsItSkip ( viewId , loopNo , celNo , position ) ;
2009-10-28 13:43:09 +00:00
return make_reg ( 0 , result ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kCelHigh ( EngineState * s , int argc , reg_t * argv ) {
2009-10-28 18:59:11 +00:00
GuiResourceId viewId = argv [ 0 ] . toSint16 ( ) ;
2009-12-24 13:50:50 +00:00
if ( viewId = = - 1 ) // Happens in SCI32
return NULL_REG ;
2009-10-28 18:59:11 +00:00
int16 loopNo = argv [ 1 ] . toSint16 ( ) ;
int16 celNo = ( argc > = 3 ) ? argv [ 2 ] . toSint16 ( ) : 0 ;
2010-01-29 21:30:46 +00:00
int16 celHeight ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
celHeight = g_sci - > _gfxCache - > kernelViewGetCelHeight ( viewId , loopNo , celNo ) ;
2010-01-29 22:02:28 +00:00
2010-01-29 21:30:46 +00:00
return make_reg ( 0 , celHeight ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kCelWide ( EngineState * s , int argc , reg_t * argv ) {
2009-10-28 18:59:11 +00:00
GuiResourceId viewId = argv [ 0 ] . toSint16 ( ) ;
2009-12-24 13:50:50 +00:00
if ( viewId = = - 1 ) // Happens in SCI32
return NULL_REG ;
2009-10-28 18:59:11 +00:00
int16 loopNo = argv [ 1 ] . toSint16 ( ) ;
int16 celNo = ( argc > = 3 ) ? argv [ 2 ] . toSint16 ( ) : 0 ;
2010-01-29 21:30:46 +00:00
int16 celWidth ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
celWidth = g_sci - > _gfxCache - > kernelViewGetCelWidth ( viewId , loopNo , celNo ) ;
2010-01-29 22:02:28 +00:00
2010-01-29 21:30:46 +00:00
return make_reg ( 0 , celWidth ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kNumLoops ( EngineState * s , int argc , reg_t * argv ) {
2009-10-28 18:59:11 +00:00
reg_t object = argv [ 0 ] ;
2010-05-29 23:37:15 +00:00
GuiResourceId viewId = readSelectorValue ( s - > _segMan , object , SELECTOR ( view ) ) ;
2010-01-29 21:30:46 +00:00
int16 loopCount ;
2010-02-13 17:43:31 +00:00
loopCount = g_sci - > _gfxCache - > kernelViewGetLoopCount ( viewId ) ;
2009-02-15 06:10:59 +00:00
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelGraphics , " NumLoops(view.%d) = %d " , viewId , loopCount ) ;
2009-02-15 06:10:59 +00:00
2009-10-25 22:33:08 +00:00
return make_reg ( 0 , loopCount ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kNumCels ( EngineState * s , int argc , reg_t * argv ) {
2009-10-28 18:59:11 +00:00
reg_t object = argv [ 0 ] ;
2010-05-29 23:37:15 +00:00
GuiResourceId viewId = readSelectorValue ( s - > _segMan , object , SELECTOR ( view ) ) ;
int16 loopNo = readSelectorValue ( s - > _segMan , object , SELECTOR ( loop ) ) ;
2010-01-29 21:30:46 +00:00
int16 celCount ;
2010-02-13 17:43:31 +00:00
celCount = g_sci - > _gfxCache - > kernelViewGetCelCount ( viewId , loopNo ) ;
2009-02-15 06:10:59 +00:00
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelGraphics , " NumCels(view.%d, %d) = %d " , viewId , loopNo , celCount ) ;
2009-02-15 06:10:59 +00:00
2009-10-25 22:33:08 +00:00
return make_reg ( 0 , celCount ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kOnControl ( EngineState * s , int argc , reg_t * argv ) {
2009-10-04 10:47:10 +00:00
Common : : Rect rect ;
byte screenMask ;
int argBase = 0 ;
2009-02-15 06:10:59 +00:00
2009-10-04 10:47:10 +00:00
if ( ( argc = = 2 ) | | ( argc = = 4 ) ) {
2010-05-15 08:57:13 +00:00
screenMask = GFX_SCREEN_MASK_CONTROL ;
2009-10-04 10:47:10 +00:00
} else {
screenMask = argv [ 0 ] . toUint16 ( ) ;
argBase = 1 ;
2009-02-15 06:10:59 +00:00
}
2009-10-04 10:47:10 +00:00
rect . left = argv [ argBase ] . toSint16 ( ) ;
rect . top = argv [ argBase + 1 ] . toSint16 ( ) ;
2009-02-15 06:10:59 +00:00
if ( argc > 3 ) {
2009-10-07 11:35:12 +00:00
rect . right = argv [ argBase + 2 ] . toSint16 ( ) ;
rect . bottom = argv [ argBase + 3 ] . toSint16 ( ) ;
2009-10-04 10:47:10 +00:00
} else {
rect . right = rect . left + 1 ;
rect . bottom = rect . top + 1 ;
2009-02-15 06:10:59 +00:00
}
2010-02-13 17:43:31 +00:00
uint16 result = g_sci - > _gfxCompare - > kernelOnControl ( screenMask , rect ) ;
2009-10-29 14:16:20 +00:00
return make_reg ( 0 , result ) ;
2009-02-15 06:10:59 +00:00
}
2009-10-28 18:59:11 +00:00
# define K_DRAWPIC_FLAGS_MIRRORED (1 << 14)
2009-10-14 18:09:54 +00:00
# define K_DRAWPIC_FLAGS_ANIMATIONBLACKOUT (1 << 15)
2009-05-17 13:37:54 +00:00
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kDrawPic ( EngineState * s , int argc , reg_t * argv ) {
2009-10-05 07:10:01 +00:00
GuiResourceId pictureId = argv [ 0 ] . toUint16 ( ) ;
2009-10-14 11:28:50 +00:00
uint16 flags = 0 ;
2009-10-07 20:58:33 +00:00
int16 animationNr = - 1 ;
2009-10-14 18:09:54 +00:00
bool animationBlackoutFlag = false ;
2009-10-07 20:58:33 +00:00
bool mirroredFlag = false ;
bool addToFlag = false ;
2009-10-07 18:09:06 +00:00
int16 EGApaletteNo = 0 ; // default needs to be 0
2009-10-03 20:49:18 +00:00
2009-10-07 20:58:33 +00:00
if ( argc > = 2 ) {
2009-10-14 11:28:50 +00:00
flags = argv [ 1 ] . toUint16 ( ) ;
2009-10-14 18:09:54 +00:00
if ( flags & K_DRAWPIC_FLAGS_ANIMATIONBLACKOUT )
animationBlackoutFlag = true ;
2009-10-07 20:58:33 +00:00
animationNr = flags & 0xFF ;
2009-10-14 18:09:54 +00:00
if ( flags & K_DRAWPIC_FLAGS_MIRRORED )
2009-10-07 20:58:33 +00:00
mirroredFlag = true ;
}
2009-10-03 20:49:18 +00:00
if ( argc > = 3 ) {
2009-10-07 20:58:33 +00:00
if ( ! argv [ 2 ] . isNull ( ) )
addToFlag = true ;
2010-02-13 17:44:58 +00:00
if ( ! g_sci - > _features - > usesOldGfxFunctions ( ) )
2009-10-08 14:37:55 +00:00
addToFlag = ! addToFlag ;
2009-02-15 06:10:59 +00:00
}
2009-10-03 20:49:18 +00:00
if ( argc > = 4 )
EGApaletteNo = argv [ 3 ] . toUint16 ( ) ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelDrawPicture ( pictureId , animationNr , animationBlackoutFlag , mirroredFlag , addToFlag , EGApaletteNo ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kBaseSetter ( EngineState * s , int argc , reg_t * argv ) {
2009-02-15 06:10:59 +00:00
reg_t object = argv [ 0 ] ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCompare - > kernelBaseSetter ( object ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
2009-10-28 19:19:35 +00:00
}
2009-02-15 06:10:59 +00:00
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kSetNowSeen ( EngineState * s , int argc , reg_t * argv ) {
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCompare - > kernelSetNowSeen ( argv [ 0 ] ) ;
2010-01-29 22:02:28 +00:00
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
2009-02-26 02:21:55 +00:00
}
2009-02-15 06:10:59 +00:00
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kPalette ( EngineState * s , int argc , reg_t * argv ) {
2010-07-10 12:19:32 +00:00
if ( ! s )
return make_reg ( 0 , getSciVersion ( ) ) ;
error ( " not supposed to call this " ) ;
}
2010-01-29 21:30:46 +00:00
2010-07-10 12:19:32 +00:00
reg_t kPaletteSetFromResource ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
GuiResourceId resourceId = argv [ 0 ] . toUint16 ( ) ;
bool force = false ;
if ( argc = = 2 )
force = argv [ 1 ] . toUint16 ( ) = = 2 ? true : false ;
2011-03-05 18:39:17 +02:00
// Non-VGA games don't use palette resources.
// This has been changed to 64 colors because Longbow Amiga does have
// one palette (palette 999).
if ( g_sci - > _gfxPalette - > getTotalColorCount ( ) < 64 )
2011-03-04 21:56:14 +02:00
return s - > r_acc ;
g_sci - > _gfxPalette - > kernelSetFromResource ( resourceId , force ) ;
2010-07-10 12:19:32 +00:00
return s - > r_acc ;
}
reg_t kPaletteSetFlag ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
uint16 fromColor = CLIP < uint16 > ( argv [ 0 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 toColor = CLIP < uint16 > ( argv [ 1 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 flags = argv [ 2 ] . toUint16 ( ) ;
g_sci - > _gfxPalette - > kernelSetFlag ( fromColor , toColor , flags ) ;
2010-07-10 12:19:32 +00:00
return s - > r_acc ;
}
reg_t kPaletteUnsetFlag ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
uint16 fromColor = CLIP < uint16 > ( argv [ 0 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 toColor = CLIP < uint16 > ( argv [ 1 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 flags = argv [ 2 ] . toUint16 ( ) ;
g_sci - > _gfxPalette - > kernelUnsetFlag ( fromColor , toColor , flags ) ;
2010-07-10 12:19:32 +00:00
return s - > r_acc ;
}
reg_t kPaletteSetIntensity ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
uint16 fromColor = CLIP < uint16 > ( argv [ 0 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 toColor = CLIP < uint16 > ( argv [ 1 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 intensity = argv [ 2 ] . toUint16 ( ) ;
bool setPalette = ( argc < 4 ) ? true : ( argv [ 3 ] . isNull ( ) ) ? true : false ;
2010-07-10 12:19:32 +00:00
2011-03-04 21:56:14 +02:00
// Palette intensity in non-VGA SCI1 games has been removed
if ( g_sci - > _gfxPalette - > getTotalColorCount ( ) < 256 )
return s - > r_acc ;
g_sci - > _gfxPalette - > kernelSetIntensity ( fromColor , toColor , intensity , setPalette ) ;
2010-07-10 12:19:32 +00:00
return s - > r_acc ;
}
2009-02-15 06:10:59 +00:00
2010-07-10 12:19:32 +00:00
reg_t kPaletteFindColor ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
uint16 r = argv [ 0 ] . toUint16 ( ) ;
uint16 g = argv [ 1 ] . toUint16 ( ) ;
uint16 b = argv [ 2 ] . toUint16 ( ) ;
return make_reg ( 0 , g_sci - > _gfxPalette - > kernelFindColor ( r , g , b ) ) ;
2010-07-10 12:19:32 +00:00
}
reg_t kPaletteAnimate ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
int16 argNr ;
bool paletteChanged = false ;
// Palette animation in non-VGA SCI1 games has been removed
if ( g_sci - > _gfxPalette - > getTotalColorCount ( ) < 256 )
return s - > r_acc ;
for ( argNr = 0 ; argNr < argc ; argNr + = 3 ) {
uint16 fromColor = argv [ argNr ] . toUint16 ( ) ;
uint16 toColor = argv [ argNr + 1 ] . toUint16 ( ) ;
int16 speed = argv [ argNr + 2 ] . toSint16 ( ) ;
if ( g_sci - > _gfxPalette - > kernelAnimate ( fromColor , toColor , speed ) )
paletteChanged = true ;
2009-10-20 16:11:31 +00:00
}
2011-03-04 21:56:14 +02:00
if ( paletteChanged )
g_sci - > _gfxPalette - > kernelAnimateSet ( ) ;
2010-07-10 12:19:32 +00:00
return s - > r_acc ;
}
reg_t kPaletteSave ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
return g_sci - > _gfxPalette - > kernelSave ( ) ;
2010-07-10 12:19:32 +00:00
}
2009-02-19 20:50:55 +00:00
2010-07-10 12:19:32 +00:00
reg_t kPaletteRestore ( EngineState * s , int argc , reg_t * argv ) {
2011-03-04 21:56:14 +02:00
g_sci - > _gfxPalette - > kernelRestore ( argv [ 0 ] ) ;
2010-07-27 17:51:44 +00:00
return argv [ 0 ] ;
2009-02-15 06:10:59 +00:00
}
2009-10-15 06:37:05 +00:00
reg_t kPalVary ( EngineState * s , int argc , reg_t * argv ) {
2010-07-10 10:20:23 +00:00
if ( ! s )
return make_reg ( 0 , getSciVersion ( ) ) ;
error ( " not supposed to call this " ) ;
}
2009-10-20 19:56:37 +00:00
2010-07-10 10:20:23 +00:00
reg_t kPalVaryInit ( EngineState * s , int argc , reg_t * argv ) {
GuiResourceId paletteId = argv [ 0 ] . toUint16 ( ) ;
uint16 ticks = argv [ 1 ] . toUint16 ( ) ;
uint16 stepStop = argc > = 3 ? argv [ 2 ] . toUint16 ( ) : 64 ;
uint16 direction = argc > = 4 ? argv [ 3 ] . toUint16 ( ) : 1 ;
if ( g_sci - > _gfxPalette - > kernelPalVaryInit ( paletteId , ticks , stepStop , direction ) )
return SIGNAL_REG ;
return NULL_REG ;
}
2010-06-20 18:20:05 +00:00
2010-07-10 10:20:23 +00:00
reg_t kPalVaryReverse ( EngineState * s , int argc , reg_t * argv ) {
int16 ticks = argc > = 1 ? argv [ 0 ] . toUint16 ( ) : - 1 ;
int16 stepStop = argc > = 2 ? argv [ 1 ] . toUint16 ( ) : 0 ;
int16 direction = argc > = 3 ? argv [ 2 ] . toSint16 ( ) : - 1 ;
2010-06-20 18:20:05 +00:00
2010-07-10 10:20:23 +00:00
return make_reg ( 0 , g_sci - > _gfxPalette - > kernelPalVaryReverse ( ticks , stepStop , direction ) ) ;
}
reg_t kPalVaryGetCurrentStep ( EngineState * s , int argc , reg_t * argv ) {
return make_reg ( 0 , g_sci - > _gfxPalette - > kernelPalVaryGetCurrentStep ( ) ) ;
}
reg_t kPalVaryDeinit ( EngineState * s , int argc , reg_t * argv ) {
g_sci - > _gfxPalette - > kernelPalVaryDeinit ( ) ;
return NULL_REG ;
}
reg_t kPalVaryChangeTarget ( EngineState * s , int argc , reg_t * argv ) {
2010-07-10 12:19:32 +00:00
GuiResourceId paletteId = argv [ 0 ] . toUint16 ( ) ;
2010-07-10 10:20:23 +00:00
int16 currentStep = g_sci - > _gfxPalette - > kernelPalVaryChangeTarget ( paletteId ) ;
return make_reg ( 0 , currentStep ) ;
}
reg_t kPalVaryChangeTicks ( EngineState * s , int argc , reg_t * argv ) {
2010-07-10 12:19:32 +00:00
uint16 ticks = argv [ 0 ] . toUint16 ( ) ;
2010-07-10 10:20:23 +00:00
g_sci - > _gfxPalette - > kernelPalVaryChangeTicks ( ticks ) ;
return NULL_REG ;
}
reg_t kPalVaryPauseResume ( EngineState * s , int argc , reg_t * argv ) {
2010-07-10 12:19:32 +00:00
bool pauseState = ! argv [ 0 ] . isNull ( ) ;
2010-07-10 10:20:23 +00:00
g_sci - > _gfxPalette - > kernelPalVaryPause ( pauseState ) ;
return NULL_REG ;
}
reg_t kPalVaryUnknown ( EngineState * s , int argc , reg_t * argv ) {
// Unknown (seems to be SCI32 exclusive)
2009-10-15 06:37:05 +00:00
return NULL_REG ;
}
2009-10-20 16:11:31 +00:00
reg_t kAssertPalette ( EngineState * s , int argc , reg_t * argv ) {
2010-07-10 12:19:32 +00:00
GuiResourceId paletteId = argv [ 0 ] . toUint16 ( ) ;
2009-10-31 17:54:28 +00:00
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > kernelAssertPalette ( paletteId ) ;
2009-10-20 16:11:31 +00:00
return s - > r_acc ;
}
2009-10-30 22:55:35 +00:00
// Used to show hires character portraits in the Windows CD version of KQ6
reg_t kPortrait ( EngineState * s , int argc , reg_t * argv ) {
uint16 operation = argv [ 0 ] . toUint16 ( ) ;
switch ( operation ) {
2009-10-31 19:48:28 +00:00
case 0 : { // load
2009-10-31 15:25:47 +00:00
if ( argc = = 2 ) {
Common : : String resourceName = s - > _segMan - > getString ( argv [ 1 ] ) ;
2010-06-15 12:01:49 +00:00
s - > r_acc = g_sci - > _gfxPaint16 - > kernelPortraitLoad ( resourceName ) ;
2009-10-31 15:25:47 +00:00
} else {
2010-06-17 23:53:30 +00:00
error ( " kPortrait(loadResource) called with unsupported argc %d " , argc ) ;
2009-10-31 15:25:47 +00:00
}
break ;
}
2009-10-31 19:48:28 +00:00
case 1 : { // show
2009-10-31 15:25:47 +00:00
if ( argc = = 10 ) {
Common : : String resourceName = s - > _segMan - > getString ( argv [ 1 ] ) ;
2009-10-31 19:48:28 +00:00
Common : : Point position = Common : : Point ( argv [ 2 ] . toUint16 ( ) , argv [ 3 ] . toUint16 ( ) ) ;
2010-01-10 11:33:10 +00:00
uint resourceNum = argv [ 4 ] . toUint16 ( ) ;
2009-10-31 15:25:47 +00:00
uint noun = argv [ 5 ] . toUint16 ( ) & 0xff ;
uint verb = argv [ 6 ] . toUint16 ( ) & 0xff ;
uint cond = argv [ 7 ] . toUint16 ( ) & 0xff ;
2009-10-31 19:55:49 +00:00
uint seq = argv [ 8 ] . toUint16 ( ) & 0xff ;
2009-10-31 15:25:47 +00:00
// argv[9] is usually 0??!!
2009-10-31 17:54:28 +00:00
2010-06-15 12:01:49 +00:00
g_sci - > _gfxPaint16 - > kernelPortraitShow ( resourceName , position , resourceNum , noun , verb , cond , seq ) ;
2009-10-31 19:48:28 +00:00
return SIGNAL_REG ;
2009-10-31 15:25:47 +00:00
} else {
2010-06-17 23:53:30 +00:00
error ( " kPortrait(show) called with unsupported argc %d " , argc ) ;
2009-10-31 15:25:47 +00:00
}
break ;
}
2009-10-31 19:48:28 +00:00
case 2 : { // unload
2009-10-31 15:25:47 +00:00
if ( argc = = 2 ) {
2009-10-31 19:55:49 +00:00
uint16 portraitId = argv [ 1 ] . toUint16 ( ) ;
2010-06-15 12:01:49 +00:00
g_sci - > _gfxPaint16 - > kernelPortraitUnload ( portraitId ) ;
2009-10-31 15:25:47 +00:00
} else {
2010-06-17 23:53:30 +00:00
error ( " kPortrait(unload) called with unsupported argc %d " , argc ) ;
2009-10-31 15:25:47 +00:00
}
break ;
}
2009-10-30 23:44:12 +00:00
default :
2010-06-17 23:53:30 +00:00
error ( " kPortrait(%d), not implemented (argc = %d) " , operation , argc ) ;
2009-10-30 22:55:35 +00:00
}
2009-10-31 17:54:28 +00:00
return s - > r_acc ;
2009-10-30 22:55:35 +00:00
}
2010-08-02 17:13:09 +00:00
// Original top-left must stay on kControl rects, we adjust accordingly because
// sierra sci actually wont draw rects that are upside down (example: jones,
// when challenging jones - one button is a duplicate and also has lower-right
// which is 0, 0)
2010-01-23 11:00:24 +00:00
Common : : Rect kControlCreateRect ( int16 x , int16 y , int16 x1 , int16 y1 ) {
if ( x > x1 ) x1 = x ;
if ( y > y1 ) y1 = y ;
return Common : : Rect ( x , y , x1 , y1 ) ;
}
2009-10-11 14:28:20 +00:00
void _k_GenericDrawControl ( EngineState * s , reg_t controlObject , bool hilite ) {
2010-05-29 23:37:15 +00:00
int16 type = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( type ) ) ;
int16 style = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( state ) ) ;
int16 x = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( nsLeft ) ) ;
int16 y = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( nsTop ) ) ;
GuiResourceId fontId = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( font ) ) ;
reg_t textReference = readSelector ( s - > _segMan , controlObject , SELECTOR ( text ) ) ;
2009-10-11 14:28:20 +00:00
Common : : String text ;
Common : : Rect rect ;
2010-01-05 01:37:57 +00:00
TextAlignment alignment ;
2009-10-11 14:28:20 +00:00
int16 mode , maxChars , cursorPos , upperPos , listCount , i ;
int16 upperOffset , cursorOffset ;
GuiResourceId viewId ;
2010-01-06 17:25:54 +00:00
int16 loopNo ;
int16 celNo ;
2010-01-22 22:34:14 +00:00
int16 priority ;
2009-10-11 14:28:20 +00:00
reg_t listSeeker ;
Common : : String * listStrings = NULL ;
const char * * listEntries = NULL ;
2009-10-11 15:41:52 +00:00
bool isAlias = false ;
2009-10-11 14:28:20 +00:00
2010-02-05 22:55:18 +00:00
rect = kControlCreateRect ( x , y ,
2010-05-29 23:37:15 +00:00
readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( nsRight ) ) ,
readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( nsBottom ) ) ) ;
2009-10-14 10:11:03 +00:00
2009-10-11 14:28:20 +00:00
if ( ! textReference . isNull ( ) )
2009-11-03 14:24:47 +00:00
text = s - > _segMan - > getString ( textReference ) ;
2009-10-11 14:28:20 +00:00
switch ( type ) {
2009-10-13 18:49:10 +00:00
case SCI_CONTROLS_TYPE_BUTTON :
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelGraphics , " drawing button %04x:%04x to %d,%d " , PRINT_REG ( controlObject ) , x , y ) ;
2011-10-26 01:48:20 +03:00
g_sci - > _gfxControls16 - > kernelDrawButton ( rect , controlObject , g_sci - > strSplit ( text . c_str ( ) , NULL ) . c_str ( ) , fontId , style , hilite ) ;
2009-10-11 14:28:20 +00:00
return ;
2009-10-13 18:49:10 +00:00
case SCI_CONTROLS_TYPE_TEXT :
2010-05-29 23:37:15 +00:00
alignment = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( mode ) ) ;
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelGraphics , " drawing text %04x:%04x ('%s') to %d,%d, mode=%d " , PRINT_REG ( controlObject ) , text . c_str ( ) , x , y , alignment ) ;
2011-10-26 01:48:20 +03:00
g_sci - > _gfxControls16 - > kernelDrawText ( rect , controlObject , g_sci - > strSplit ( text . c_str ( ) ) . c_str ( ) , fontId , alignment , style , hilite ) ;
2010-09-09 10:52:17 +00:00
s - > r_acc = g_sci - > _gfxText16 - > allocAndFillReferenceRectArray ( ) ;
2009-10-11 14:28:20 +00:00
return ;
2009-10-13 18:49:10 +00:00
case SCI_CONTROLS_TYPE_TEXTEDIT :
2010-05-29 23:37:15 +00:00
mode = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( mode ) ) ;
maxChars = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( max ) ) ;
cursorPos = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( cursor ) ) ;
2010-07-12 11:09:29 +00:00
if ( cursorPos > ( int ) text . size ( ) ) {
2010-07-11 16:55:08 +00:00
// if cursor is outside of text, adjust accordingly
cursorPos = text . size ( ) ;
writeSelectorValue ( s - > _segMan , controlObject , SELECTOR ( cursor ) , cursorPos ) ;
}
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelGraphics , " drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d " , PRINT_REG ( controlObject ) , PRINT_REG ( textReference ) , text . c_str ( ) , x , y ) ;
2011-10-26 01:48:20 +03:00
g_sci - > _gfxControls16 - > kernelDrawTextEdit ( rect , controlObject , g_sci - > strSplit ( text . c_str ( ) , NULL ) . c_str ( ) , fontId , mode , style , cursorPos , maxChars , hilite ) ;
2009-10-11 14:28:20 +00:00
return ;
2009-10-13 18:49:10 +00:00
case SCI_CONTROLS_TYPE_ICON :
2010-05-29 23:37:15 +00:00
viewId = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( view ) ) ;
2009-10-13 20:25:51 +00:00
{
2010-05-29 23:37:15 +00:00
int l = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( loop ) ) ;
2009-10-13 20:25:51 +00:00
loopNo = ( l & 0x80 ) ? l - 256 : l ;
2010-05-29 23:37:15 +00:00
int c = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( cel ) ) ;
2009-10-13 20:25:51 +00:00
celNo = ( c & 0x80 ) ? c - 256 : c ;
2010-06-25 09:57:37 +00:00
// Check if the control object specifies a priority selector (like in Jones)
if ( lookupSelector ( s - > _segMan , controlObject , SELECTOR ( priority ) , NULL , NULL ) = = kSelectorVariable )
2010-05-29 23:37:15 +00:00
priority = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( priority ) ) ;
2010-01-22 22:34:14 +00:00
else
priority = - 1 ;
2009-10-13 20:25:51 +00:00
}
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelGraphics , " drawing icon control %04x:%04x to %d,%d " , PRINT_REG ( controlObject ) , x , y - 1 ) ;
2011-10-26 01:48:20 +03:00
g_sci - > _gfxControls16 - > kernelDrawIcon ( rect , controlObject , viewId , loopNo , celNo , priority , style , hilite ) ;
2009-10-11 14:28:20 +00:00
return ;
2009-10-13 18:49:10 +00:00
case SCI_CONTROLS_TYPE_LIST :
case SCI_CONTROLS_TYPE_LIST_ALIAS :
if ( type = = SCI_CONTROLS_TYPE_LIST_ALIAS )
2009-10-11 15:41:52 +00:00
isAlias = true ;
2010-05-29 23:37:15 +00:00
maxChars = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( x ) ) ; // max chars per entry
cursorOffset = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( cursor ) ) ;
2010-06-10 09:18:57 +00:00
if ( SELECTOR ( topString ) ! = - 1 ) {
2009-10-11 14:28:20 +00:00
// Games from early SCI1 onwards use topString
2010-05-29 23:37:15 +00:00
upperOffset = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( topString ) ) ;
2009-10-11 14:28:20 +00:00
} else {
2010-01-24 18:57:23 +00:00
// Earlier games use lsTop or brTop
2010-06-10 09:18:57 +00:00
if ( lookupSelector ( s - > _segMan , controlObject , SELECTOR ( brTop ) , NULL , NULL ) = = kSelectorVariable )
2010-05-29 23:37:15 +00:00
upperOffset = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( brTop ) ) ;
2010-01-24 18:57:23 +00:00
else
2010-05-29 23:37:15 +00:00
upperOffset = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( lsTop ) ) ;
2009-10-11 14:28:20 +00:00
}
// Count string entries in NULL terminated string list
listCount = 0 ; listSeeker = textReference ;
while ( s - > _segMan - > strlen ( listSeeker ) > 0 ) {
listCount + + ;
listSeeker . offset + = maxChars ;
}
// TODO: This is rather convoluted... It would be a lot cleaner
// if sciw_new_list_control would take a list of Common::String
cursorPos = 0 ; upperPos = 0 ;
if ( listCount ) {
// We create a pointer-list to the different strings, we also find out whats upper and cursor position
listSeeker = textReference ;
listEntries = ( const char * * ) malloc ( sizeof ( char * ) * listCount ) ;
listStrings = new Common : : String [ listCount ] ;
for ( i = 0 ; i < listCount ; i + + ) {
listStrings [ i ] = s - > _segMan - > getString ( listSeeker ) ;
listEntries [ i ] = listStrings [ i ] . c_str ( ) ;
if ( listSeeker . offset = = upperOffset )
upperPos = i ;
if ( listSeeker . offset = = cursorOffset )
cursorPos = i ;
listSeeker . offset + = maxChars ;
}
}
2011-01-01 12:48:12 +00:00
debugC ( kDebugLevelGraphics , " drawing list control %04x:%04x to %d,%d, diff %d " , PRINT_REG ( controlObject ) , x , y , SCI_MAX_SAVENAME_LENGTH ) ;
2011-10-26 01:48:20 +03:00
g_sci - > _gfxControls16 - > kernelDrawList ( rect , controlObject , maxChars , listCount , listEntries , fontId , style , upperPos , cursorPos , isAlias , hilite ) ;
2009-10-11 14:28:20 +00:00
free ( listEntries ) ;
delete [ ] listStrings ;
return ;
2009-10-13 19:08:40 +00:00
case SCI_CONTROLS_TYPE_DUMMY :
// Actually this here does nothing at all, its required by at least QfG1/EGA that we accept this type
2009-10-13 17:50:27 +00:00
return ;
2009-10-11 14:28:20 +00:00
default :
error ( " unsupported control type %d " , type ) ;
}
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kDrawControl ( EngineState * s , int argc , reg_t * argv ) {
2009-10-11 14:28:20 +00:00
reg_t controlObject = argv [ 0 ] ;
2009-10-29 19:32:27 +00:00
Common : : String objName = s - > _segMan - > getObjectName ( controlObject ) ;
2010-09-08 20:11:11 +00:00
// Most of the time, we won't return anything to the caller
// but |r| textcodes will trigger creation of rects in memory and will then set s->r_acc
s - > r_acc = NULL_REG ;
2009-10-29 19:32:27 +00:00
// Disable the "Change Directory" button, as we don't allow the game engine to
// change the directory where saved games are placed
2010-08-02 12:39:01 +00:00
// "changeDirItem" is used in the import windows of QFG2&3
if ( ( objName = = " changeDirI " ) | | ( objName = = " changeDirItem " ) ) {
2010-05-29 23:37:15 +00:00
int state = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( state ) ) ;
writeSelectorValue ( s - > _segMan , controlObject , SELECTOR ( state ) , ( state | SCI_CONTROLS_STYLE_DISABLED ) & ~ SCI_CONTROLS_STYLE_ENABLED ) ;
2009-10-29 19:32:27 +00:00
}
2010-07-11 16:55:08 +00:00
if ( objName = = " DEdit " ) {
reg_t textReference = readSelector ( s - > _segMan , controlObject , SELECTOR ( text ) ) ;
if ( ! textReference . isNull ( ) ) {
Common : : String text = s - > _segMan - > getString ( textReference ) ;
2010-07-13 20:28:17 +00:00
if ( ( text = = " a:hq1_hero.sav " ) | | ( text = = " a:glory1.sav " ) | | ( text = = " a:glory2.sav " ) | | ( text = = " a:glory3.sav " ) ) {
// Remove "a:" from hero quest / quest for glory export default filenames
2010-07-11 16:55:08 +00:00
text . deleteChar ( 0 ) ;
text . deleteChar ( 0 ) ;
s - > _segMan - > strcpy ( textReference , text . c_str ( ) ) ;
}
}
}
2010-08-02 12:39:01 +00:00
if ( objName = = " savedHeros " ) {
// Import of QfG character files dialog is shown
// display additional popup information before letting user use it
2010-08-02 21:57:17 +00:00
reg_t changeDirButton = s - > _segMan - > findObjectByName ( " changeDirItem " ) ;
if ( ! changeDirButton . isNull ( ) ) {
// check if checkDirButton is still enabled, in that case we are called the first time during that room
if ( ! ( readSelectorValue ( s - > _segMan , changeDirButton , SELECTOR ( state ) ) & SCI_CONTROLS_STYLE_DISABLED ) ) {
2010-08-17 20:33:22 +00:00
showScummVMDialog ( " Characters saved inside ScummVM are shown "
2010-08-02 21:57:17 +00:00
" automatically. Character files saved in the original "
" interpreter need to be put inside ScummVM's saved games "
" directory and a prefix needs to be added depending on which "
" game it was saved in: 'qfg1-' for Quest for Glory 1, 'qfg2-' "
2010-08-17 20:33:22 +00:00
" for Quest for Glory 2. Example: 'qfg2-thief.sav'. " ) ;
2010-08-02 21:57:17 +00:00
}
}
2010-08-29 15:13:25 +00:00
s - > _chosenQfGImportItem = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( mark ) ) ;
2010-08-02 12:39:01 +00:00
}
2009-02-15 06:10:59 +00:00
2009-10-11 14:28:20 +00:00
_k_GenericDrawControl ( s , controlObject , false ) ;
2010-09-08 20:11:11 +00:00
return s - > r_acc ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kHiliteControl ( EngineState * s , int argc , reg_t * argv ) {
2009-10-11 14:28:20 +00:00
reg_t controlObject = argv [ 0 ] ;
2009-02-19 20:50:55 +00:00
2009-10-11 14:28:20 +00:00
_k_GenericDrawControl ( s , controlObject , true ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kEditControl ( EngineState * s , int argc , reg_t * argv ) {
2009-10-11 12:15:17 +00:00
reg_t controlObject = argv [ 0 ] ;
reg_t eventObject = argv [ 1 ] ;
2009-02-15 06:10:59 +00:00
2010-01-31 22:20:55 +00:00
if ( ! controlObject . isNull ( ) ) {
2010-05-29 23:37:15 +00:00
int16 controlType = readSelectorValue ( s - > _segMan , controlObject , SELECTOR ( type ) ) ;
2010-01-31 22:20:55 +00:00
switch ( controlType ) {
case SCI_CONTROLS_TYPE_TEXTEDIT :
// Only process textedit controls in here
2011-10-26 01:48:20 +03:00
g_sci - > _gfxControls16 - > kernelTexteditChange ( controlObject , eventObject ) ;
break ;
default :
break ;
2010-01-31 22:20:55 +00:00
}
}
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kAddToPic ( EngineState * s , int argc , reg_t * argv ) {
2009-10-05 07:10:01 +00:00
GuiResourceId viewId ;
2010-01-06 17:25:54 +00:00
int16 loopNo ;
int16 celNo ;
2009-10-04 14:59:51 +00:00
int16 leftPos , topPos , priority , control ;
2009-02-15 06:10:59 +00:00
2009-10-04 14:59:51 +00:00
switch ( argc ) {
2009-10-25 18:43:23 +00:00
// Is this ever really gets called with 0 parameters, we need to set _picNotValid!!
//case 0:
// break;
2009-10-04 14:59:51 +00:00
case 1 :
2009-10-23 20:41:59 +00:00
if ( argv [ 0 ] . isNull ( ) )
return s - > r_acc ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxAnimate - > kernelAddToPicList ( argv [ 0 ] , argc , argv ) ;
2009-10-04 14:59:51 +00:00
break ;
case 7 :
viewId = argv [ 0 ] . toUint16 ( ) ;
2009-10-04 16:35:02 +00:00
loopNo = argv [ 1 ] . toSint16 ( ) ;
2009-10-05 07:10:01 +00:00
celNo = argv [ 2 ] . toSint16 ( ) ;
2009-10-04 14:59:51 +00:00
leftPos = argv [ 3 ] . toSint16 ( ) ;
topPos = argv [ 4 ] . toSint16 ( ) ;
2009-06-07 15:53:30 +00:00
priority = argv [ 5 ] . toSint16 ( ) ;
control = argv [ 6 ] . toSint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxAnimate - > kernelAddToPicView ( viewId , loopNo , celNo , leftPos , topPos , priority , control ) ;
2009-10-04 14:59:51 +00:00
break ;
default :
2009-10-07 21:25:31 +00:00
error ( " kAddToPic with unsupported parameter count %d " , argc ) ;
2009-02-15 06:10:59 +00:00
}
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kGetPort ( EngineState * s , int argc , reg_t * argv ) {
2010-02-13 17:43:31 +00:00
return g_sci - > _gfxPorts - > kernelGetActive ( ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kSetPort ( EngineState * s , int argc , reg_t * argv ) {
2010-01-31 12:35:15 +00:00
uint16 portId ;
2009-10-03 20:49:18 +00:00
Common : : Rect picRect ;
int16 picTop , picLeft ;
2009-10-13 16:18:17 +00:00
bool initPriorityBandsFlag = false ;
2009-10-07 21:25:31 +00:00
2009-02-15 22:28:12 +00:00
switch ( argc ) {
2009-10-11 18:42:52 +00:00
case 1 :
2010-01-31 12:35:15 +00:00
portId = argv [ 0 ] . toSint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPorts - > kernelSetActive ( portId ) ;
2009-10-03 20:49:18 +00:00
break ;
2009-02-15 06:10:59 +00:00
2009-10-13 16:18:17 +00:00
case 7 :
initPriorityBandsFlag = true ;
2009-10-11 18:42:52 +00:00
case 6 :
2009-10-03 20:49:18 +00:00
picRect . top = argv [ 0 ] . toSint16 ( ) ;
picRect . left = argv [ 1 ] . toSint16 ( ) ;
2009-10-07 11:35:12 +00:00
picRect . bottom = argv [ 2 ] . toSint16 ( ) ;
picRect . right = argv [ 3 ] . toSint16 ( ) ;
2010-07-17 19:52:19 +00:00
picTop = argv [ 4 ] . toSint16 ( ) ;
picLeft = argv [ 5 ] . toSint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPorts - > kernelSetPicWindow ( picRect , picTop , picLeft , initPriorityBandsFlag ) ;
2009-02-15 06:10:59 +00:00
break ;
2009-10-03 20:49:18 +00:00
2009-10-11 18:42:52 +00:00
default :
2009-05-31 10:02:16 +00:00
error ( " SetPort was called with %d parameters " , argc ) ;
2009-02-15 06:10:59 +00:00
break ;
}
return NULL_REG ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kDrawCel ( EngineState * s , int argc , reg_t * argv ) {
2009-10-05 07:10:01 +00:00
GuiResourceId viewId = argv [ 0 ] . toSint16 ( ) ;
2010-01-06 17:25:54 +00:00
int16 loopNo = argv [ 1 ] . toSint16 ( ) ;
int16 celNo = argv [ 2 ] . toSint16 ( ) ;
2009-10-31 15:25:47 +00:00
uint16 x = argv [ 3 ] . toUint16 ( ) ;
uint16 y = argv [ 4 ] . toUint16 ( ) ;
2010-01-19 17:45:14 +00:00
int16 priority = ( argc > 5 ) ? argv [ 5 ] . toSint16 ( ) : - 1 ;
2009-10-31 15:25:47 +00:00
uint16 paletteNo = ( argc > 6 ) ? argv [ 6 ] . toUint16 ( ) : 0 ;
2010-07-26 19:25:56 +00:00
bool hiresMode = false ;
reg_t upscaledHiresHandle = NULL_REG ;
uint16 scaleX = 128 ;
uint16 scaleY = 128 ;
if ( argc > 7 ) {
// this is either kq6 hires or scaling
if ( paletteNo > 0 ) {
// it's scaling
scaleX = argv [ 6 ] . toUint16 ( ) ;
scaleY = argv [ 7 ] . toUint16 ( ) ;
paletteNo = 0 ;
} else {
// KQ6 hires
hiresMode = true ;
upscaledHiresHandle = argv [ 7 ] ;
}
}
2009-02-15 06:10:59 +00:00
2010-07-26 19:25:56 +00:00
g_sci - > _gfxPaint16 - > kernelDrawCel ( viewId , loopNo , celNo , x , y , priority , paletteNo , scaleX , scaleY , hiresMode , upscaledHiresHandle ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kDisposeWindow ( EngineState * s , int argc , reg_t * argv ) {
2010-01-31 12:35:15 +00:00
int windowId = argv [ 0 ] . toSint16 ( ) ;
2010-01-14 20:56:46 +00:00
bool reanimate = false ;
2010-01-17 13:07:50 +00:00
if ( ( argc ! = 2 ) | | ( argv [ 1 ] . isNull ( ) ) )
2010-01-14 20:56:46 +00:00
reanimate = true ;
2009-02-19 20:50:55 +00:00
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPorts - > kernelDisposeWindow ( windowId , reanimate ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kNewWindow ( EngineState * s , int argc , reg_t * argv ) {
2009-10-07 11:35:12 +00:00
Common : : Rect rect1 ( argv [ 1 ] . toSint16 ( ) , argv [ 0 ] . toSint16 ( ) , argv [ 3 ] . toSint16 ( ) , argv [ 2 ] . toSint16 ( ) ) ;
2009-10-03 20:49:18 +00:00
Common : : Rect rect2 ;
2010-01-15 15:37:40 +00:00
int argextra = argc > = 13 ? 4 : 0 ; // Triggers in PQ3 and SCI1.1 games, argc 13 for DOS argc 15 for mac
2009-10-03 20:49:18 +00:00
int style = argv [ 5 + argextra ] . toSint16 ( ) ;
int priority = ( argc > 6 + argextra ) ? argv [ 6 + argextra ] . toSint16 ( ) : - 1 ;
2011-03-02 08:24:31 +02:00
int colorPen = adjustGraphColor ( ( argc > 7 + argextra ) ? argv [ 7 + argextra ] . toSint16 ( ) : 0 ) ;
int colorBack = adjustGraphColor ( ( argc > 8 + argextra ) ? argv [ 8 + argextra ] . toSint16 ( ) : 255 ) ;
2010-08-22 23:55:29 +00:00
2011-03-13 19:34:23 +02:00
if ( argc > = 13 )
2009-10-07 11:35:12 +00:00
rect2 = Common : : Rect ( argv [ 5 ] . toSint16 ( ) , argv [ 4 ] . toSint16 ( ) , argv [ 7 ] . toSint16 ( ) , argv [ 6 ] . toSint16 ( ) ) ;
2009-06-07 16:50:34 +00:00
2009-09-27 01:50:26 +00:00
Common : : String title ;
if ( argv [ 4 + argextra ] . segment ) {
2009-10-04 18:38:18 +00:00
title = s - > _segMan - > getString ( argv [ 4 + argextra ] ) ;
2010-02-13 17:46:44 +00:00
title = g_sci - > strSplit ( title . c_str ( ) , NULL ) ;
2009-09-27 01:50:26 +00:00
}
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
return g_sci - > _gfxPorts - > kernelNewWindow ( rect1 , rect2 , style , priority , colorPen , colorBack , title . c_str ( ) ) ;
2009-02-15 06:10:59 +00:00
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kAnimate ( EngineState * s , int argc , reg_t * argv ) {
2009-10-04 14:59:51 +00:00
reg_t castListReference = ( argc > 0 ) ? argv [ 0 ] : NULL_REG ;
bool cycle = ( argc > 1 ) ? ( ( argv [ 1 ] . toUint16 ( ) ) ? true : false ) : false ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
g_sci - > _gfxAnimate - > kernelAnimate ( castListReference , cycle , argc , argv ) ;
2009-10-14 21:45:16 +00:00
2010-11-20 19:52:31 +00:00
// WORKAROUND: At the end of Ecoquest 1, during the credits, the game
// doesn't call kGetEvent(), so no events are processed (e.g. window
// focusing, window moving etc). We poll events for that scene, to
// keep ScummVM responsive. Fixes ScummVM "freezing" during the credits,
// bug #3101846
if ( g_sci - > getGameId ( ) = = GID_ECOQUEST & & s - > currentRoomNumber ( ) = = 680 )
g_sci - > getEventManager ( ) - > getSciEvent ( SCI_EVENT_PEEK ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kShakeScreen ( EngineState * s , int argc , reg_t * argv ) {
2009-10-11 08:52:23 +00:00
int16 shakeCount = ( argc > 0 ) ? argv [ 0 ] . toUint16 ( ) : 1 ;
int16 directions = ( argc > 1 ) ? argv [ 1 ] . toUint16 ( ) : 1 ;
2009-02-15 06:10:59 +00:00
2010-08-01 17:54:48 +00:00
g_sci - > _gfxScreen - > kernelShakeScreen ( shakeCount , directions ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
reg_t kDisplay ( EngineState * s , int argc , reg_t * argv ) {
2009-02-15 06:10:59 +00:00
reg_t textp = argv [ 0 ] ;
2009-06-07 16:50:34 +00:00
int index = ( argc > 1 ) ? argv [ 1 ] . toUint16 ( ) : 0 ;
2009-02-15 06:10:59 +00:00
2009-10-03 20:49:18 +00:00
Common : : String text ;
2009-02-15 06:10:59 +00:00
if ( textp . segment ) {
2009-10-03 20:49:18 +00:00
argc - - ; argv + + ;
2009-10-04 18:38:18 +00:00
text = s - > _segMan - > getString ( textp ) ;
2009-02-15 06:10:59 +00:00
} else {
2009-10-03 20:49:18 +00:00
argc - - ; argc - - ; argv + + ; argv + + ;
2010-05-18 12:16:48 +00:00
text = g_sci - > getKernel ( ) - > lookupText ( textp , index ) ;
2009-02-15 06:10:59 +00:00
}
2010-02-13 17:46:44 +00:00
return g_sci - > _gfxPaint16 - > kernelDisplay ( g_sci - > strSplit ( text . c_str ( ) ) . c_str ( ) , argc , argv ) ;
2009-02-15 06:10:59 +00:00
}
2009-02-21 10:23:36 +00:00
2010-07-21 21:18:21 +00:00
reg_t kSetVideoMode ( EngineState * s , int argc , reg_t * argv ) {
// This call is used for KQ6's intro. It has one parameter, which is 1 when
// the intro begins, and 0 when it ends. It is suspected that this is
// actually a flag to enable video planar memory access, as the video
// decoder in KQ6 is specifically written for the planar memory model.
// Planar memory mode access was used for VGA "Mode X" (320x240 resolution,
// although the intro in KQ6 is 320x200).
// Refer to http://en.wikipedia.org/wiki/Mode_X
//warning("STUB: SetVideoMode %d", argv[0].toUint16());
return s - > r_acc ;
}
// New calls for SCI11. Using those is only needed when using text-codes so that
// one is able to change font and/or color multiple times during kDisplay and
// kDrawControl
reg_t kTextFonts ( EngineState * s , int argc , reg_t * argv ) {
g_sci - > _gfxText16 - > kernelTextFonts ( argc , argv ) ;
return s - > r_acc ;
}
reg_t kTextColors ( EngineState * s , int argc , reg_t * argv ) {
g_sci - > _gfxText16 - > kernelTextColors ( argc , argv ) ;
return s - > r_acc ;
}
2010-08-22 16:30:33 +00:00
/**
* Debug command , used by the SCI builtin debugger
*/
reg_t kShow ( EngineState * s , int argc , reg_t * argv ) {
uint16 map = argv [ 0 ] . toUint16 ( ) ;
switch ( map ) {
case 1 : // Visual, substituted by display for us
g_sci - > _gfxScreen - > debugShowMap ( 3 ) ;
break ;
case 2 : // Priority
g_sci - > _gfxScreen - > debugShowMap ( 1 ) ;
break ;
case 3 : // Control
case 4 : // Control
g_sci - > _gfxScreen - > debugShowMap ( 2 ) ;
break ;
default :
warning ( " Map %d is not available " , map ) ;
}
return s - > r_acc ;
}
2010-09-15 15:21:59 +00:00
reg_t kRemapColors ( EngineState * s , int argc , reg_t * argv ) {
uint16 operation = argv [ 0 ] . toUint16 ( ) ;
switch ( operation ) {
2011-02-22 19:11:35 +02:00
case 0 : { // Set remapping to base. 0 turns remapping off.
int16 base = ( argc > = 2 ) ? argv [ 1 ] . toSint16 ( ) : 0 ;
2012-01-13 22:46:22 +02:00
if ( base ! = 0 ) // 0 is the default behavior when changing rooms in GK1, thus silencing the warning
warning ( " kRemapColors: Set remapping to base %d " , base ) ;
2010-09-15 15:21:59 +00:00
}
break ;
case 1 : { // unknown
// The demo of QFG4 calls this with 1+3 parameters, thus there are differences here
//int16 unk1 = argv[1].toSint16();
//int16 unk2 = argv[2].toSint16();
//int16 unk3 = argv[3].toSint16();
//uint16 unk4 = argv[4].toUint16();
//uint16 unk5 = (argc >= 6) ? argv[5].toUint16() : 0;
2011-02-22 19:11:35 +02:00
kStub ( s , argc , argv ) ;
2010-09-15 15:21:59 +00:00
}
break ;
case 2 : { // remap by percent
2011-02-24 21:26:00 +02:00
// This adjusts the alpha value of a specific color, and it operates on
// an RGBA palette. Since we're operating on an RGB palette, we just
// modify the color intensity instead
// TODO: From what I understand, palette remapping should be placed
// separately, so that it can be reset by case 0 above. Thus, we
// should adjust the functionality of the Palette class accordingly.
int16 color = argv [ 1 ] . toSint16 ( ) ;
if ( color > = 10 )
color - = 10 ;
2011-02-22 19:11:35 +02:00
uint16 percent = argv [ 2 ] . toUint16 ( ) ; // 0 - 100
2011-02-24 21:26:00 +02:00
if ( argc > = 4 )
warning ( " RemapByPercent called with 4 parameters, unknown parameter is %d " , argv [ 3 ] . toUint16 ( ) ) ;
g_sci - > _gfxPalette - > kernelSetIntensity ( color , 255 , percent , false ) ;
2010-09-15 15:21:59 +00:00
}
break ;
case 3 : { // remap to gray
2011-02-22 19:11:35 +02:00
// NOTE: This adjusts the alpha value of a specific color, and it operates on
// an RGBA palette
int16 color = argv [ 1 ] . toSint16 ( ) ; // this is subtracted from a maximum color value, and can be offset by 10
int16 percent = argv [ 2 ] . toSint16 ( ) ; // 0 - 100
uint16 unk3 = ( argc > = 4 ) ? argv [ 3 ] . toUint16 ( ) : 0 ;
warning ( " kRemapColors: RemapToGray color %d by %d percent (unk3 = %d) " , color , percent , unk3 ) ;
2010-09-15 15:21:59 +00:00
}
break ;
case 4 : { // unknown
//int16 unk1 = argv[1].toSint16();
//uint16 unk2 = argv[2].toUint16();
//uint16 unk3 = argv[3].toUint16();
//uint16 unk4 = (argc >= 5) ? argv[4].toUint16() : 0;
2011-02-22 19:11:35 +02:00
kStub ( s , argc , argv ) ;
2010-09-15 15:21:59 +00:00
}
break ;
case 5 : { // increment color
//int16 unk1 = argv[1].toSint16();
//uint16 unk2 = argv[2].toUint16();
2011-02-22 19:11:35 +02:00
kStub ( s , argc , argv ) ;
2010-09-15 15:21:59 +00:00
}
break ;
default :
break ;
}
return s - > r_acc ;
}
2010-01-29 22:02:28 +00:00
# ifdef ENABLE_SCI32
2010-07-21 21:18:21 +00:00
reg_t kIsHiRes ( EngineState * s , int argc , reg_t * argv ) {
// Returns 0 if the screen width or height is less than 640 or 400,
// respectively.
if ( g_system - > getWidth ( ) < 640 | | g_system - > getHeight ( ) < 400 )
return make_reg ( 0 , 0 ) ;
return make_reg ( 0 , 1 ) ;
}
2010-07-25 13:11:28 +00:00
// SCI32 variant, can't work like sci16 variants
reg_t kCantBeHere32 ( EngineState * s , int argc , reg_t * argv ) {
2010-11-11 23:48:01 +00:00
// TODO
2010-07-25 13:11:28 +00:00
// reg_t curObject = argv[0];
// reg_t listReference = (argc > 1) ? argv[1] : NULL_REG;
2011-06-20 00:59:48 +02:00
2010-07-25 13:11:28 +00:00
return NULL_REG ;
}
2010-07-21 21:18:21 +00:00
reg_t kAddScreenItem ( EngineState * s , int argc , reg_t * argv ) {
2011-10-12 02:43:08 +03:00
if ( g_sci - > _gfxFrameout - > findScreenItem ( argv [ 0 ] ) = = NULL )
g_sci - > _gfxFrameout - > kernelAddScreenItem ( argv [ 0 ] ) ;
else
g_sci - > _gfxFrameout - > kernelUpdateScreenItem ( argv [ 0 ] ) ;
2010-09-19 14:50:28 +00:00
return s - > r_acc ;
2010-07-21 21:18:21 +00:00
}
reg_t kUpdateScreenItem ( EngineState * s , int argc , reg_t * argv ) {
2010-09-19 14:50:28 +00:00
g_sci - > _gfxFrameout - > kernelUpdateScreenItem ( argv [ 0 ] ) ;
return s - > r_acc ;
2010-07-21 21:18:21 +00:00
}
reg_t kDeleteScreenItem ( EngineState * s , int argc , reg_t * argv ) {
2010-09-19 14:50:28 +00:00
g_sci - > _gfxFrameout - > kernelDeleteScreenItem ( argv [ 0 ] ) ;
return s - > r_acc ;
2010-07-21 21:18:21 +00:00
}
reg_t kAddPlane ( EngineState * s , int argc , reg_t * argv ) {
2010-09-19 14:50:28 +00:00
g_sci - > _gfxFrameout - > kernelAddPlane ( argv [ 0 ] ) ;
return s - > r_acc ;
2010-07-21 21:18:21 +00:00
}
reg_t kDeletePlane ( EngineState * s , int argc , reg_t * argv ) {
2010-09-19 14:50:28 +00:00
g_sci - > _gfxFrameout - > kernelDeletePlane ( argv [ 0 ] ) ;
return s - > r_acc ;
2010-07-21 21:18:21 +00:00
}
reg_t kUpdatePlane ( EngineState * s , int argc , reg_t * argv ) {
2010-09-19 14:50:28 +00:00
g_sci - > _gfxFrameout - > kernelUpdatePlane ( argv [ 0 ] ) ;
2010-07-21 21:18:21 +00:00
return s - > r_acc ;
}
2010-07-25 20:41:23 +00:00
reg_t kAddPicAt ( EngineState * s , int argc , reg_t * argv ) {
reg_t planeObj = argv [ 0 ] ;
GuiResourceId pictureId = argv [ 1 ] . toUint16 ( ) ;
2011-09-23 18:53:52 +03:00
int16 pictureX = argv [ 2 ] . toSint16 ( ) ;
int16 pictureY = argv [ 3 ] . toSint16 ( ) ;
2010-07-25 20:41:23 +00:00
2011-09-23 18:53:52 +03:00
g_sci - > _gfxFrameout - > kernelAddPicAt ( planeObj , pictureId , pictureX , pictureY ) ;
2010-07-25 20:41:23 +00:00
return s - > r_acc ;
}
2010-07-21 21:18:21 +00:00
reg_t kGetHighPlanePri ( EngineState * s , int argc , reg_t * argv ) {
return make_reg ( 0 , g_sci - > _gfxFrameout - > kernelGetHighPlanePri ( ) ) ;
}
reg_t kFrameOut ( EngineState * s , int argc , reg_t * argv ) {
g_sci - > _gfxFrameout - > kernelFrameout ( ) ;
return NULL_REG ;
}
2011-10-19 19:52:21 +03:00
reg_t kObjectIntersect ( EngineState * s , int argc , reg_t * argv ) {
Common : : Rect objRect1 = g_sci - > _gfxCompare - > getNSRect ( argv [ 0 ] ) ;
Common : : Rect objRect2 = g_sci - > _gfxCompare - > getNSRect ( argv [ 1 ] ) ;
return make_reg ( 0 , objRect1 . intersects ( objRect2 ) ) ;
}
2010-09-09 20:07:53 +00:00
// Tests if the coordinate is on the passed object
reg_t kIsOnMe ( EngineState * s , int argc , reg_t * argv ) {
2010-07-21 21:18:21 +00:00
uint16 x = argv [ 0 ] . toUint16 ( ) ;
uint16 y = argv [ 1 ] . toUint16 ( ) ;
reg_t targetObject = argv [ 2 ] ;
2010-07-24 19:38:13 +00:00
uint16 illegalBits = argv [ 3 ] . offset ;
2011-10-19 20:27:43 +03:00
Common : : Rect nsRect = g_sci - > _gfxCompare - > getNSRect ( targetObject , true ) ;
2010-07-21 21:18:21 +00:00
2010-07-24 19:38:13 +00:00
// we assume that x, y are local coordinates
2011-10-19 20:27:43 +03:00
bool contained = nsRect . contains ( x , y ) ;
2010-07-24 19:38:13 +00:00
if ( contained & & illegalBits ) {
// If illegalbits are set, we check the color of the pixel that got clicked on
// for now, we return false if the pixel is transparent
// although illegalBits may get differently set, don't know yet how this really works out
uint16 viewId = readSelectorValue ( s - > _segMan , targetObject , SELECTOR ( view ) ) ;
int16 loopNo = readSelectorValue ( s - > _segMan , targetObject , SELECTOR ( loop ) ) ;
int16 celNo = readSelectorValue ( s - > _segMan , targetObject , SELECTOR ( cel ) ) ;
if ( g_sci - > _gfxCompare - > kernelIsItSkip ( viewId , loopNo , celNo , Common : : Point ( x - nsRect . left , y - nsRect . top ) ) )
contained = false ;
}
return make_reg ( 0 , contained ) ;
2010-07-21 21:18:21 +00:00
}
reg_t kCreateTextBitmap ( EngineState * s , int argc , reg_t * argv ) {
switch ( argv [ 0 ] . toUint16 ( ) ) {
case 0 : {
if ( argc ! = 4 ) {
warning ( " kCreateTextBitmap(0): expected 4 arguments, got %i " , argc ) ;
return NULL_REG ;
}
2011-09-03 14:50:58 +03:00
reg_t object = argv [ 3 ] ;
Common : : String text = s - > _segMan - > getString ( readSelector ( s - > _segMan , object , SELECTOR ( text ) ) ) ;
debugC ( kDebugLevelStrings , " kCreateTextBitmap case 0 (%04x:%04x, %04x:%04x, %04x:%04x) " ,
PRINT_REG ( argv [ 1 ] ) , PRINT_REG ( argv [ 2 ] ) , PRINT_REG ( argv [ 3 ] ) ) ;
debugC ( kDebugLevelStrings , " %s " , text . c_str ( ) ) ;
2011-10-09 19:13:16 +03:00
uint16 maxWidth = argv [ 1 ] . toUint16 ( ) ; // nsRight - nsLeft + 1
uint16 maxHeight = argv [ 2 ] . toUint16 ( ) ; // nsBottom - nsTop + 1
2011-10-09 19:56:17 +03:00
return g_sci - > _gfxText32 - > createTextBitmap ( object , maxWidth , maxHeight ) ;
2011-01-09 13:27:00 +00:00
}
case 1 : {
if ( argc ! = 2 ) {
2011-10-09 19:13:16 +03:00
warning ( " kCreateTextBitmap(1): expected 2 arguments, got %i " , argc ) ;
2011-01-09 13:27:00 +00:00
return NULL_REG ;
}
2011-09-03 14:50:58 +03:00
reg_t object = argv [ 1 ] ;
Common : : String text = s - > _segMan - > getString ( readSelector ( s - > _segMan , object , SELECTOR ( text ) ) ) ;
debugC ( kDebugLevelStrings , " kCreateTextBitmap case 1 (%04x:%04x) " , PRINT_REG ( argv [ 1 ] ) ) ;
debugC ( kDebugLevelStrings , " %s " , text . c_str ( ) ) ;
2011-10-09 19:56:17 +03:00
return g_sci - > _gfxText32 - > createTextBitmap ( object ) ;
2010-07-21 21:18:21 +00:00
}
default :
warning ( " CreateTextBitmap(%d) " , argv [ 0 ] . toUint16 ( ) ) ;
2011-10-09 19:56:17 +03:00
return NULL_REG ;
2010-07-21 21:18:21 +00:00
}
}
2011-10-11 01:24:28 +03:00
reg_t kDisposeTextBitmap ( EngineState * s , int argc , reg_t * argv ) {
g_sci - > _gfxText32 - > disposeTextBitmap ( argv [ 0 ] ) ;
return s - > r_acc ;
}
2010-09-09 11:40:46 +00:00
reg_t kGetWindowsOption ( EngineState * s , int argc , reg_t * argv ) {
uint16 windowsOption = argv [ 0 ] . toUint16 ( ) ;
switch ( windowsOption ) {
case 0 :
// Title bar on/off in Phantasmagoria, we return 0 (off)
return NULL_REG ;
default :
warning ( " GetWindowsOption: Unknown option %d " , windowsOption ) ;
return NULL_REG ;
}
}
2010-09-09 15:09:26 +00:00
reg_t kWinHelp ( EngineState * s , int argc , reg_t * argv ) {
2010-09-09 18:34:27 +00:00
switch ( argv [ 0 ] . toUint16 ( ) ) {
case 1 :
// Load a help file
// Maybe in the future we can implement this, but for now this message should suffice
showScummVMDialog ( " Please use an external viewer to open the game's help file: " + s - > _segMan - > getString ( argv [ 1 ] ) ) ;
break ;
case 2 :
// Looks like some init function
break ;
default :
warning ( " Unknown kWinHelp subop %d " , argv [ 0 ] . toUint16 ( ) ) ;
}
2010-09-09 15:09:26 +00:00
return s - > r_acc ;
}
2012-01-13 22:46:22 +02:00
// Taken from the SCI16 GfxTransitions class
static void fadeOut ( ) {
byte oldPalette [ 3 * 256 ] , workPalette [ 3 * 256 ] ;
int16 stepNr , colorNr ;
// Sierra did not fade in/out color 255 for sci1.1, but they used it in
// several pictures (e.g. qfg3 demo/intro), so the fading looked weird
2012-01-14 00:21:55 +02:00
int16 tillColorNr = getSciVersion ( ) > = SCI_VERSION_1_1 ? 255 : 254 ;
2012-01-13 22:46:22 +02:00
g_system - > getPaletteManager ( ) - > grabPalette ( oldPalette , 0 , 256 ) ;
for ( stepNr = 100 ; stepNr > = 0 ; stepNr - = 10 ) {
2012-01-14 00:21:55 +02:00
for ( colorNr = 1 ; colorNr < = tillColorNr ; colorNr + + ) {
2012-01-13 22:46:22 +02:00
if ( g_sci - > _gfxPalette - > colorIsFromMacClut ( colorNr ) ) {
workPalette [ colorNr * 3 + 0 ] = oldPalette [ colorNr * 3 ] ;
workPalette [ colorNr * 3 + 1 ] = oldPalette [ colorNr * 3 + 1 ] ;
workPalette [ colorNr * 3 + 2 ] = oldPalette [ colorNr * 3 + 2 ] ;
} else {
workPalette [ colorNr * 3 + 0 ] = oldPalette [ colorNr * 3 ] * stepNr / 100 ;
workPalette [ colorNr * 3 + 1 ] = oldPalette [ colorNr * 3 + 1 ] * stepNr / 100 ;
workPalette [ colorNr * 3 + 2 ] = oldPalette [ colorNr * 3 + 2 ] * stepNr / 100 ;
}
}
2012-01-14 00:21:55 +02:00
g_system - > getPaletteManager ( ) - > setPalette ( workPalette + 3 , 1 , tillColorNr ) ;
2012-01-13 22:46:22 +02:00
g_sci - > getEngineState ( ) - > wait ( 2 ) ;
}
}
// Taken from the SCI16 GfxTransitions class
static void fadeIn ( ) {
int16 stepNr ;
// Sierra did not fade in/out color 255 for sci1.1, but they used it in
// several pictures (e.g. qfg3 demo/intro), so the fading looked weird
2012-01-14 00:21:55 +02:00
int16 tillColorNr = getSciVersion ( ) > = SCI_VERSION_1_1 ? 255 : 254 ;
2012-01-13 22:46:22 +02:00
for ( stepNr = 0 ; stepNr < = 100 ; stepNr + = 10 ) {
2012-01-14 00:21:55 +02:00
g_sci - > _gfxPalette - > kernelSetIntensity ( 1 , tillColorNr + 1 , stepNr , true ) ;
2012-01-13 22:46:22 +02:00
g_sci - > getEngineState ( ) - > wait ( 2 ) ;
}
}
2010-09-17 15:19:18 +00:00
/**
2011-10-19 19:54:13 +03:00
* Used for scene transitions , replacing ( but reusing parts of ) the old
* transition code .
2010-09-17 15:19:18 +00:00
*/
reg_t kSetShowStyle ( EngineState * s , int argc , reg_t * argv ) {
2011-01-09 13:27:00 +00:00
// Can be called with 7 or 8 parameters
2011-10-19 19:54:13 +03:00
// The style defines which transition to perform. Related to the transition
// tables inside graphics/transitions.cpp
2010-09-17 15:19:18 +00:00
uint16 showStyle = argv [ 0 ] . toUint16 ( ) ; // 0 - 15
2011-10-19 19:54:13 +03:00
reg_t planeObj = argv [ 1 ] ; // the affected plane
2012-01-13 22:46:22 +02:00
uint16 seconds = argv [ 2 ] . toUint16 ( ) ; // seconds that the transition lasts
uint16 backColor = argv [ 3 ] . toUint16 ( ) ; // target back color(?). When fading out, it's 0x0000. When fading in, it's 0xffff
int16 priority = argv [ 4 ] . toSint16 ( ) ; // always 0xc8 (200) when fading in/out
uint16 animate = argv [ 5 ] . toUint16 ( ) ; // boolean, animate or not while the transition lasts
uint16 refFrame = argv [ 6 ] . toUint16 ( ) ; // refFrame, always 0 when fading in/out
int16 divisions ;
2011-10-19 23:51:13 +03:00
// If the game has the pFadeArray selector, another parameter is used here,
// before the optional last parameter
2012-01-13 22:46:22 +02:00
bool hasFadeArray = g_sci - > getKernel ( ) - > findSelector ( " pFadeArray " ) > 0 ;
2011-10-19 23:51:13 +03:00
if ( hasFadeArray ) {
// argv[7]
2012-01-13 22:46:22 +02:00
divisions = ( argc > = 9 ) ? argv [ 8 ] . toSint16 ( ) : - 1 ; // divisions (transition steps?)
2011-10-19 23:51:13 +03:00
} else {
2012-01-13 22:46:22 +02:00
divisions = ( argc > = 8 ) ? argv [ 7 ] . toSint16 ( ) : - 1 ; // divisions (transition steps?)
}
2010-09-17 15:19:18 +00:00
if ( showStyle > 15 ) {
warning ( " kSetShowStyle: Illegal style %d for plane %04x:%04x " , showStyle , PRINT_REG ( planeObj ) ) ;
return s - > r_acc ;
}
2012-01-13 22:46:22 +02:00
// TODO: Proper implementation. This is a very basic version. I'm not even
// sure if the rest of the styles will work with this mechanism.
// Check if the passed parameters are the ones we expect
if ( showStyle = = 13 | | showStyle = = 14 ) { // fade out / fade in
if ( seconds ! = 1 )
warning ( " kSetShowStyle(fade): seconds isn't 1, it's %d " , seconds ) ;
if ( backColor ! = 0 & & backColor ! = 0xFFFF )
warning ( " kSetShowStyle(fade): backColor isn't 0 or 0xFFFF, it's %d " , backColor ) ;
if ( priority ! = 200 )
warning ( " kSetShowStyle(fade): priority isn't 200, it's %d " , priority ) ;
if ( animate ! = 0 )
warning ( " kSetShowStyle(fade): animate isn't 0, it's %d " , animate ) ;
if ( refFrame ! = 0 )
warning ( " kSetShowStyle(fade): refFrame isn't 0, it's %d " , refFrame ) ;
if ( divisions > = 0 & & divisions ! = 20 )
warning ( " kSetShowStyle(fade): divisions isn't 20, it's %d " , divisions ) ;
}
2010-11-08 16:09:59 +00:00
// TODO: Check if the plane is in the list of planes to draw
2012-01-13 22:46:22 +02:00
switch ( showStyle ) {
//case 0: // no transition, perhaps? (like in the previous SCI versions)
case 13 : // fade out
// TODO: Temporary implementation, which ignores all additional parameters
fadeOut ( ) ;
break ;
case 14 : // fade in
// TODO: Temporary implementation, which ignores all additional parameters
g_sci - > _gfxFrameout - > kernelFrameout ( ) ; // draw new scene before fading in
fadeIn ( ) ;
break ;
default :
// TODO: This is all a stub/skeleton, thus we're invoking kStub() for now
kStub ( s , argc , argv ) ;
break ;
}
2011-10-19 19:54:13 +03:00
2010-09-17 15:19:18 +00:00
return s - > r_acc ;
}
2011-01-08 10:23:27 +00:00
reg_t kCelInfo ( EngineState * s , int argc , reg_t * argv ) {
2011-10-08 20:43:54 -07:00
// Used by Shivers 1, room 23601 to determine what blocks on the red door puzzle board
// are occupied by pieces already
2011-01-08 10:23:27 +00:00
2011-10-19 19:54:13 +03:00
switch ( argv [ 0 ] . toUint16 ( ) ) { // subops 0 - 4
// 0 - return the view
// 1 - return the loop
// 2, 3 - nop
2011-10-08 20:43:54 -07:00
case 4 : {
GuiResourceId viewId = argv [ 1 ] . toSint16 ( ) ;
int16 loopNo = argv [ 2 ] . toSint16 ( ) ;
int16 celNo = argv [ 3 ] . toSint16 ( ) ;
int16 x = argv [ 4 ] . toUint16 ( ) ;
int16 y = argv [ 5 ] . toUint16 ( ) ;
byte color = g_sci - > _gfxCache - > kernelViewGetColorAtCoordinate ( viewId , loopNo , celNo , x , y ) ;
return make_reg ( 0 , color ) ;
}
default : {
kStub ( s , argc , argv ) ;
return s - > r_acc ;
}
}
2011-01-08 10:23:27 +00:00
}
2011-01-08 12:28:47 +00:00
reg_t kScrollWindow ( EngineState * s , int argc , reg_t * argv ) {
// Used by Phantasmagoria 1 and SQ6. In SQ6, it is used for the messages
// shown in the scroll window at the bottom of the screen.
// TODO: This is all a stub/skeleton, thus we're invoking kStub() for now
kStub ( s , argc , argv ) ;
switch ( argv [ 0 ] . toUint16 ( ) ) {
case 0 : // Init
// 2 parameters
// argv[1] points to the scroll object (e.g. textScroller in SQ6)
// argv[2] is an integer (e.g. 0x32)
break ;
case 1 : // Show message
// 5 or 6 parameters
// Seems to be called with 5 parameters when the narrator speaks, and
// with 6 when Roger speaks
// argv[1] unknown (usually 0)
// argv[2] the text to show
// argv[3] a small integer (e.g. 0x32)
// argv[4] a small integer (e.g. 0x54)
// argv[5] optional, unknown (usually 0)
warning ( " kScrollWindow: '%s' " , s - > _segMan - > getString ( argv [ 2 ] ) . c_str ( ) ) ;
break ;
case 2 : // Clear
// 2 parameters
// TODO
break ;
case 3 : // Page up
// 2 parameters
// TODO
break ;
case 4 : // Page down
// 2 parameters
// TODO
break ;
case 5 : // Up arrow
// 2 parameters
// TODO
break ;
case 6 : // Down arrow
// 2 parameters
// TODO
break ;
case 7 : // Home
// 2 parameters
// TODO
break ;
case 8 : // End
// 2 parameters
// TODO
break ;
case 9 : // Resize
// 3 parameters
// TODO
break ;
case 10 : // Where
// 3 parameters
// TODO
break ;
case 11 : // Go
// 4 parameters
// TODO
break ;
case 12 : // Insert
// 7 parameters
// TODO
break ;
case 13 : // Delete
// 3 parameters
// TODO
break ;
case 14 : // Modify
// 7 or 8 parameters
// TODO
break ;
case 15 : // Hide
// 2 parameters
// TODO
break ;
case 16 : // Show
// 2 parameters
// TODO
break ;
case 17 : // Destroy
// 2 parameters
// TODO
break ;
case 18 : // Text
// 2 parameters
// TODO
break ;
case 19 : // Reconstruct
// 3 parameters
// TODO
break ;
default :
error ( " kScrollWindow: unknown subop %d " , argv [ 0 ] . toUint16 ( ) ) ;
break ;
}
return s - > r_acc ;
}
2011-02-03 15:51:51 +00:00
reg_t kSetFontRes ( EngineState * s , int argc , reg_t * argv ) {
2011-02-03 18:07:47 +00:00
// TODO: This defines the resolution that the fonts are supposed to be displayed
// in. Currently, this is only used for showing high-res fonts in GK1 Mac, but
2011-06-20 00:59:48 +02:00
// should be extended to handle other font resolutions such as those
2011-02-03 15:51:51 +00:00
int xResolution = argv [ 0 ] . toUint16 ( ) ;
//int yResolution = argv[1].toUint16();
g_sci - > _gfxScreen - > setFontIsUpscaled ( xResolution = = 640 & &
g_sci - > _gfxScreen - > getUpscaledHires ( ) ! = GFX_SCREEN_UPSCALED_DISABLED ) ;
return s - > r_acc ;
}
2011-02-03 18:07:47 +00:00
reg_t kFont ( EngineState * s , int argc , reg_t * argv ) {
// Handle font settings for SCI2.1
switch ( argv [ 0 ] . toUint16 ( ) ) {
case 1 :
// Set font resolution
return kSetFontRes ( s , argc - 1 , argv + 1 ) ;
default :
warning ( " kFont: unknown subop %d " , argv [ 0 ] . toUint16 ( ) ) ;
}
return s - > r_acc ;
}
2011-10-14 14:05:34 +03:00
// TODO: Eventually, all of the kBitmap operations should be put
// in a separate class
# define BITMAP_HEADER_SIZE 46
2011-10-07 02:46:44 +03:00
reg_t kBitmap ( EngineState * s , int argc , reg_t * argv ) {
// Used for bitmap operations in SCI2.1 and SCI3.
// This is the SCI2.1 version, the functionality seems to have changed in SCI3.
switch ( argv [ 0 ] . toUint16 ( ) ) {
case 0 : // init bitmap surface
{
// 6 params, called e.g. from TextView::init() in Torin's Passage,
// script 64890 and TransView::init() in script 64884
uint16 width = argv [ 1 ] . toUint16 ( ) ;
uint16 height = argv [ 2 ] . toUint16 ( ) ;
2011-10-14 20:28:39 +03:00
//uint16 skip = argv[3].toUint16();
2011-10-14 14:05:34 +03:00
uint16 back = argv [ 4 ] . toUint16 ( ) ; // usually equals skip
2011-10-14 20:28:39 +03:00
//uint16 width2 = (argc >= 6) ? argv[5].toUint16() : 0;
//uint16 height2 = (argc >= 7) ? argv[6].toUint16() : 0;
//uint16 transparentFlag = (argc >= 8) ? argv[7].toUint16() : 0;
2011-10-13 14:01:19 +03:00
// TODO: skip, width2, height2, transparentFlag
2011-10-14 14:05:34 +03:00
// (used for transparent bitmaps)
int entrySize = width * height + BITMAP_HEADER_SIZE ;
reg_t memoryId = s - > _segMan - > allocateHunkEntry ( " Bitmap() " , entrySize ) ;
2011-10-13 14:01:19 +03:00
byte * memoryPtr = s - > _segMan - > getHunkPointer ( memoryId ) ;
2011-10-14 14:05:34 +03:00
memset ( memoryPtr , 0 , BITMAP_HEADER_SIZE ) ; // zero out the bitmap header
memset ( memoryPtr + BITMAP_HEADER_SIZE , back , width * height ) ;
// Save totalWidth, totalHeight
// TODO: Save the whole bitmap header, like SSCI does
2011-10-28 22:54:02 +03:00
WRITE_LE_UINT16 ( memoryPtr , width ) ;
WRITE_LE_UINT16 ( memoryPtr + 2 , height ) ;
2011-10-13 14:01:19 +03:00
return memoryId ;
2011-10-07 02:46:44 +03:00
}
break ;
2011-10-11 02:03:40 +03:00
case 1 : // dispose text bitmap surface
return kDisposeTextBitmap ( s , argc - 1 , argv + 1 ) ;
2011-10-07 02:46:44 +03:00
case 2 : // dispose bitmap surface, with extra param
// 2 params, called e.g. from MenuItem::dispose in Torin's Passage,
// script 64893
warning ( " kBitmap(2), unk1 %d, bitmap ptr %04x:%04x " , argv [ 1 ] . toUint16 ( ) , PRINT_REG ( argv [ 2 ] ) ) ;
break ;
case 3 : // tiled surface
{
// 6 params, called e.g. from TiledBitmap::resize() in Torin's Passage,
// script 64869
2011-10-13 14:01:19 +03:00
reg_t hunkId = argv [ 1 ] ; // obtained from kBitmap(0)
2011-10-07 02:46:44 +03:00
// The tiled view seems to always have 2 loops.
// These loops need to have 1 cel in loop 0 and 8 cels in loop 1.
2011-10-13 14:01:19 +03:00
uint16 viewNum = argv [ 2 ] . toUint16 ( ) ; // vTiles selector
2011-10-07 02:46:44 +03:00
uint16 loop = argv [ 3 ] . toUint16 ( ) ;
uint16 cel = argv [ 4 ] . toUint16 ( ) ;
uint16 x = argv [ 5 ] . toUint16 ( ) ;
uint16 y = argv [ 6 ] . toUint16 ( ) ;
2011-10-13 14:01:19 +03:00
2011-10-14 14:05:34 +03:00
byte * memoryPtr = s - > _segMan - > getHunkPointer ( hunkId ) ;
// Get totalWidth, totalHeight
2011-10-28 22:54:02 +03:00
uint16 totalWidth = READ_LE_UINT16 ( memoryPtr ) ;
uint16 totalHeight = READ_LE_UINT16 ( memoryPtr + 2 ) ;
2011-10-14 14:05:34 +03:00
byte * bitmap = memoryPtr + BITMAP_HEADER_SIZE ;
2011-10-13 14:01:19 +03:00
GfxView * view = g_sci - > _gfxCache - > getView ( viewNum ) ;
2011-10-14 14:05:34 +03:00
uint16 tileWidth = view - > getWidth ( loop , cel ) ;
uint16 tileHeight = view - > getHeight ( loop , cel ) ;
const byte * tileBitmap = view - > getBitmap ( loop , cel ) ;
uint16 width = MIN < uint16 > ( totalWidth - x , tileWidth ) ;
uint16 height = MIN < uint16 > ( totalHeight - y , tileHeight ) ;
for ( uint16 curY = 0 ; curY < height ; curY + + ) {
for ( uint16 curX = 0 ; curX < width ; curX + + ) {
bitmap [ ( curY + y ) * totalWidth + ( curX + x ) ] = tileBitmap [ curY * tileWidth + curX ] ;
2011-10-13 14:01:19 +03:00
}
}
2011-10-07 02:46:44 +03:00
}
break ;
2011-10-14 14:05:34 +03:00
case 4 : // add text to bitmap
2011-10-07 02:46:44 +03:00
{
// 13 params, called e.g. from TextButton::createBitmap() in Torin's Passage,
// script 64894
2011-10-14 14:05:34 +03:00
reg_t hunkId = argv [ 1 ] ; // obtained from kBitmap(0)
2011-10-07 02:46:44 +03:00
Common : : String text = s - > _segMan - > getString ( argv [ 2 ] ) ;
2011-10-14 14:05:34 +03:00
uint16 textX = argv [ 3 ] . toUint16 ( ) ;
uint16 textY = argv [ 4 ] . toUint16 ( ) ;
//reg_t unk5 = argv[5];
//reg_t unk6 = argv[6];
//reg_t unk7 = argv[7]; // skip?
//reg_t unk8 = argv[8]; // back?
//reg_t unk9 = argv[9];
uint16 fontId = argv [ 10 ] . toUint16 ( ) ;
//uint16 mode = argv[11].toUint16();
2011-10-07 02:46:44 +03:00
uint16 dimmed = argv [ 12 ] . toUint16 ( ) ;
2011-10-14 14:05:34 +03:00
//warning("kBitmap(4): bitmap ptr %04x:%04x, font %d, mode %d, dimmed %d - text: \"%s\"",
// PRINT_REG(bitmapPtr), font, mode, dimmed, text.c_str());
uint16 foreColor = 255 ; // TODO
byte * memoryPtr = s - > _segMan - > getHunkPointer ( hunkId ) ;
// Get totalWidth, totalHeight
2011-10-28 22:54:02 +03:00
uint16 totalWidth = READ_LE_UINT16 ( memoryPtr ) ;
uint16 totalHeight = READ_LE_UINT16 ( memoryPtr + 2 ) ;
2011-10-14 14:05:34 +03:00
byte * bitmap = memoryPtr + BITMAP_HEADER_SIZE ;
GfxFont * font = g_sci - > _gfxCache - > getFont ( fontId ) ;
int16 charCount = 0 ;
uint16 curX = textX , curY = textY ;
const char * txt = text . c_str ( ) ;
while ( * txt ) {
charCount = g_sci - > _gfxText32 - > GetLongest ( txt , totalWidth , font ) ;
if ( charCount = = 0 )
break ;
for ( int i = 0 ; i < charCount ; i + + ) {
unsigned char curChar = txt [ i ] ;
font - > drawToBuffer ( curChar , curY , curX , foreColor , dimmed , bitmap , totalWidth , totalHeight ) ;
curX + = font - > getCharWidth ( curChar ) ;
}
curX = textX ;
curY + = font - > getHeight ( ) ;
txt + = charCount ;
while ( * txt = = ' ' )
txt + + ; // skip over breaking spaces
}
2011-10-07 02:46:44 +03:00
}
break ;
2011-10-13 14:01:19 +03:00
case 5 : // fill with color
2011-10-07 02:46:44 +03:00
{
// 6 params, called e.g. from TextView::init() and TextView::draw()
// in Torin's Passage, script 64890
2011-10-13 14:01:19 +03:00
reg_t hunkId = argv [ 1 ] ; // obtained from kBitmap(0)
uint16 x = argv [ 2 ] . toUint16 ( ) ;
uint16 y = argv [ 3 ] . toUint16 ( ) ;
2011-10-14 14:05:34 +03:00
uint16 fillWidth = argv [ 4 ] . toUint16 ( ) ; // width - 1
uint16 fillHeight = argv [ 5 ] . toUint16 ( ) ; // height - 1
2011-10-07 02:46:44 +03:00
uint16 back = argv [ 6 ] . toUint16 ( ) ;
2011-10-13 14:01:19 +03:00
2011-10-14 14:05:34 +03:00
byte * memoryPtr = s - > _segMan - > getHunkPointer ( hunkId ) ;
// Get totalWidth, totalHeight
2011-10-28 22:54:02 +03:00
uint16 totalWidth = READ_LE_UINT16 ( memoryPtr ) ;
uint16 totalHeight = READ_LE_UINT16 ( memoryPtr + 2 ) ;
2011-10-14 14:05:34 +03:00
uint16 width = MIN < uint16 > ( totalWidth - x , fillWidth ) ;
uint16 height = MIN < uint16 > ( totalHeight - y , fillHeight ) ;
byte * bitmap = memoryPtr + BITMAP_HEADER_SIZE ;
for ( uint16 curY = 0 ; curY < height ; curY + + ) {
for ( uint16 curX = 0 ; curX < width ; curX + + ) {
bitmap [ ( curY + y ) * totalWidth + ( curX + x ) ] = back ;
2011-10-13 14:01:19 +03:00
}
}
2011-10-07 02:46:44 +03:00
}
break ;
default :
kStub ( s , argc , argv ) ;
break ;
}
return s - > r_acc ;
}
2011-10-28 22:19:52 +03:00
// Used for edit boxes in save/load dialogs. It's a rewritten version of kEditControl,
// but it handles events on its own, using an internal loop, instead of using SCI
// scripts for event management like kEditControl does. Called by script 64914,
// DEdit::hilite().
reg_t kEditText ( EngineState * s , int argc , reg_t * argv ) {
reg_t controlObject = argv [ 0 ] ;
if ( ! controlObject . isNull ( ) ) {
g_sci - > _gfxControls32 - > kernelTexteditChange ( controlObject ) ;
}
return s - > r_acc ;
}
2010-01-29 22:02:28 +00:00
# endif
2010-01-28 19:57:14 +00:00
2009-02-21 10:23:36 +00:00
} // End of namespace Sci