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 .
*
* $ URL $
* $ Id $
*
*/
2009-02-15 06:10:59 +00:00
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-10-16 18:05:56 +00:00
# include "graphics/video/avi_decoder.h"
2010-05-26 03:43:21 +00:00
# include "graphics/video/qt_decoder.h"
2009-08-30 19:47:47 +00:00
# include "graphics/surface.h"
2009-02-21 15:40:14 +00:00
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
2009-05-15 14:07:45 +00:00
# include "sci/resource.h"
2009-12-30 10:09:48 +00:00
# include "sci/video/seq_decoder.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:22:16 +00:00
# include "sci/graphics/gui.h"
2010-01-29 21:30:46 +00:00
# include "sci/graphics/gui32.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"
2010-01-31 22:20:55 +00:00
# include "sci/graphics/controls.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-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"
# include "sci/graphics/view.h"
2009-02-15 06:10:59 +00:00
2009-02-21 10:23:36 +00:00
namespace Sci {
2009-10-28 18:59:11 +00:00
void _k_dirloop ( 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-28 18:59:11 +00:00
int16 loopNo ;
int16 maxLoops ;
2009-10-09 17:34:52 +00:00
bool oldScriptHeader = ( getSciVersion ( ) = = SCI_VERSION_0_EARLY ) ;
2009-10-21 19:19:03 +00:00
if ( signal & kSignalDoesntTurn )
2009-10-09 17:34:52 +00:00
return ;
angle % = 360 ;
if ( ! oldScriptHeader ) {
if ( angle < 45 )
2009-10-28 18:59:11 +00:00
loopNo = 3 ;
2009-10-09 17:34:52 +00:00
else if ( angle < 136 )
2009-10-28 18:59:11 +00:00
loopNo = 0 ;
2009-10-09 17:34:52 +00:00
else if ( angle < 225 )
2009-10-28 18:59:11 +00:00
loopNo = 2 ;
2009-10-09 17:34:52 +00:00
else if ( angle < 316 )
2009-10-28 18:59:11 +00:00
loopNo = 1 ;
2009-10-09 17:34:52 +00:00
else
2009-10-28 18:59:11 +00:00
loopNo = 3 ;
2009-10-09 17:34:52 +00:00
} else {
if ( angle > = 330 | | angle < = 30 )
2009-10-28 18:59:11 +00:00
loopNo = 3 ;
2009-10-09 17:34:52 +00:00
else if ( angle < = 150 )
2009-10-28 18:59:11 +00:00
loopNo = 0 ;
2009-10-09 17:34:52 +00:00
else if ( angle < = 210 )
2009-10-28 18:59:11 +00:00
loopNo = 2 ;
2009-10-09 17:34:52 +00:00
else if ( angle < 330 )
2009-10-28 18:59:11 +00:00
loopNo = 1 ;
else loopNo = - 1 ;
2009-10-09 17:34:52 +00:00
}
2010-02-13 17:43:31 +00:00
maxLoops = g_sci - > _gfxCache - > kernelViewGetLoopCount ( viewId ) ;
2010-01-29 22:02:28 +00:00
2009-10-09 17:34:52 +00:00
2009-10-28 18:59:11 +00:00
if ( ( loopNo > 1 ) & & ( maxLoops < 4 ) )
2009-10-09 17:34:52 +00:00
return ;
2010-05-29 23:37:15 +00:00
writeSelectorValue ( s - > _segMan , object , SELECTOR ( loop ) , loopNo ) ;
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 :
// TODO: Special case at least in kq6, check disassembly
break ;
case - 2 :
// TODO: Special case at least in kq6, check disassembly
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 ( ) ;
2010-01-29 22:02:28 +00: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 : {
int16 top = argv [ 0 ] . toSint16 ( ) ;
int16 left = argv [ 1 ] . toSint16 ( ) ;
int16 bottom = argv [ 2 ] . toSint16 ( ) ;
int16 right = argv [ 3 ] . toSint16 ( ) ;
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 ;
}
2009-08-30 01:37:52 +00:00
case 5 :
case 9 :
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 ;
default :
2009-08-30 01:37:52 +00:00
warning ( " 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 :
warning ( " Unknown SetCursor type " ) ;
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 ) {
2009-10-07 12:47:53 +00:00
Common : : Point pos ;
if ( argc = = 2 ) {
pos . y = argv [ 1 ] . toSint16 ( ) ;
pos . x = argv [ 0 ] . toSint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelSetPos ( pos ) ;
2009-10-07 12:47:53 +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 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-01-11 16:28:46 +00:00
Common : : Rect kGraphCreateRect ( int16 x , int16 y , int16 x1 , int16 y1 ) {
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
}
2009-10-28 18:59:11 +00:00
// Graph subfunctions
enum {
K_GRAPH_GET_COLORS_NR = 2 ,
// 3 - SET PALETTE VIA RESOURCE
K_GRAPH_DRAW_LINE = 4 ,
// 5 - NOP
// 6 - DRAW PATTERN
K_GRAPH_SAVE_BOX = 7 ,
K_GRAPH_RESTORE_BOX = 8 ,
K_GRAPH_FILL_BOX_BACKGROUND = 9 ,
K_GRAPH_FILL_BOX_FOREGROUND = 10 ,
K_GRAPH_FILL_BOX_ANY = 11 ,
K_GRAPH_UPDATE_BOX = 12 ,
K_GRAPH_REDRAW_BOX = 13 ,
2009-10-30 22:55:35 +00:00
K_GRAPH_ADJUST_PRIORITY = 14 ,
2009-10-31 15:25:47 +00:00
K_GRAPH_SAVE_UPSCALEDHIRES_BOX = 15 // KQ6CD Windows version
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 ) {
2009-10-12 12:38:58 +00:00
int16 x = 0 , y = 0 , x1 = 0 , y1 = 0 ;
2009-10-31 15:25:47 +00:00
uint16 screenMask ;
2009-10-03 20:49:18 +00:00
int16 priority , control , color , colorMask ;
Common : : Rect rect ;
2009-10-05 13:33:26 +00:00
if ( argc > = 5 ) {
x = argv [ 2 ] . toSint16 ( ) ;
y = argv [ 1 ] . toSint16 ( ) ;
x1 = argv [ 4 ] . toSint16 ( ) ;
y1 = argv [ 3 ] . toSint16 ( ) ;
2009-02-15 06:10:59 +00:00
}
2009-06-07 15:53:30 +00:00
switch ( argv [ 0 ] . toSint16 ( ) ) {
2009-02-15 06:10:59 +00:00
case K_GRAPH_GET_COLORS_NR :
2010-02-13 17:44:19 +00:00
if ( g_sci - > getResMan ( ) - > isAmiga32color ( ) )
2010-01-25 20:44:13 +00:00
return make_reg ( 0 , 32 ) ;
2010-02-13 17:44:19 +00:00
return make_reg ( 0 , ! g_sci - > getResMan ( ) - > isVGA ( ) ? 16 : 256 ) ;
2009-02-15 06:10:59 +00:00
2009-10-03 20:49:18 +00:00
case K_GRAPH_DRAW_LINE :
priority = ( argc > 6 ) ? argv [ 6 ] . toSint16 ( ) : - 1 ;
control = ( argc > 7 ) ? argv [ 7 ] . toSint16 ( ) : - 1 ;
color = argv [ 5 ] . toSint16 ( ) ;
2009-02-15 06:10:59 +00:00
2010-01-19 17:45:14 +00:00
// TODO: Find out why we get >15 for color in EGA
2010-02-13 17:44:19 +00:00
if ( ! g_sci - > getResMan ( ) - > isVGA ( ) & & ! g_sci - > getResMan ( ) - > isAmiga32color ( ) )
2010-01-19 17:45:14 +00:00
color & = 0x0F ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelGraphDrawLine ( Common : : Point ( x , y ) , Common : : Point ( x1 , y1 ) , color , priority , control ) ;
2009-10-03 20:49:18 +00:00
break ;
2009-02-15 06:10:59 +00:00
case K_GRAPH_SAVE_BOX :
2010-01-11 16:28:46 +00:00
rect = kGraphCreateRect ( x , y , x1 , y1 ) ;
2009-10-31 15:25:47 +00:00
screenMask = ( argc > 5 ) ? argv [ 5 ] . toUint16 ( ) : 0 ;
2010-02-13 17:43:31 +00:00
return g_sci - > _gfxPaint16 - > kernelGraphSaveBox ( rect , screenMask ) ;
2009-02-15 06:10:59 +00:00
case K_GRAPH_RESTORE_BOX :
2009-10-31 15:25:47 +00:00
// This may be called with a memoryhandle from SAVE_BOX or SAVE_UPSCALEDHIRES_BOX
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelGraphRestoreBox ( argv [ 1 ] ) ;
2009-02-15 06:10:59 +00:00
break ;
case K_GRAPH_FILL_BOX_BACKGROUND :
2010-01-11 16:28:46 +00:00
rect = kGraphCreateRect ( x , y , x1 , y1 ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelGraphFillBoxBackground ( rect ) ;
2009-02-15 06:10:59 +00:00
break ;
case K_GRAPH_FILL_BOX_FOREGROUND :
2010-01-11 16:28:46 +00:00
rect = kGraphCreateRect ( x , y , x1 , y1 ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelGraphFillBoxForeground ( rect ) ;
2009-02-15 06:10:59 +00:00
break ;
2009-10-03 20:49:18 +00:00
case K_GRAPH_FILL_BOX_ANY :
priority = ( argc > 7 ) ? argv [ 7 ] . toSint16 ( ) : - 1 ;
control = ( argc > 8 ) ? argv [ 8 ] . toSint16 ( ) : - 1 ;
color = argv [ 6 ] . toSint16 ( ) ;
colorMask = argv [ 5 ] . toUint16 ( ) ;
2009-02-15 06:10:59 +00:00
2010-01-11 16:28:46 +00:00
rect = kGraphCreateRect ( x , y , x1 , y1 ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelGraphFillBox ( rect , colorMask , color , priority , control ) ;
2009-10-03 20:49:18 +00:00
break ;
2009-02-15 06:10:59 +00:00
2010-01-10 09:42:55 +00:00
case K_GRAPH_UPDATE_BOX : {
2010-01-11 16:28:46 +00:00
rect = kGraphCreateRect ( x , y , x1 , y1 ) ;
2010-01-10 09:42:55 +00:00
bool hiresMode = ( argc > 6 ) ? true : false ;
2010-01-07 15:50:58 +00:00
// argc == 7 on upscaled hires
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelGraphUpdateBox ( rect , hiresMode ) ;
2009-10-12 07:11:22 +00:00
break ;
2010-01-10 09:42:55 +00:00
}
2009-02-15 06:10:59 +00:00
2009-10-12 12:42:50 +00:00
case K_GRAPH_REDRAW_BOX :
2010-01-11 16:28:46 +00:00
rect = kGraphCreateRect ( x , y , x1 , y1 ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelGraphRedrawBox ( rect ) ;
2009-10-12 11:36:42 +00:00
break ;
2009-02-15 06:10:59 +00:00
case K_GRAPH_ADJUST_PRIORITY :
2009-11-04 12:54:27 +00:00
// Seems to be only implemented for SCI0/SCI01 games
2010-01-30 11:59:05 +00:00
debugC ( 2 , kDebugLevelGraphics , " adjust_priority(%d, %d) " , argv [ 1 ] . toUint16 ( ) , argv [ 2 ] . toUint16 ( ) ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPorts - > kernelGraphAdjustPriority ( argv [ 1 ] . toUint16 ( ) , argv [ 2 ] . toUint16 ( ) ) ;
2009-02-15 06:10:59 +00:00
break ;
2009-10-31 15:25:47 +00:00
case K_GRAPH_SAVE_UPSCALEDHIRES_BOX :
2010-01-11 16:28:46 +00:00
rect = kGraphCreateRect ( x , y , x1 , y1 ) ;
2010-02-13 17:43:31 +00:00
return g_sci - > _gfxPaint16 - > kernelGraphSaveUpscaledHiresBox ( rect ) ;
2009-10-30 22:55:35 +00:00
2009-02-15 06:10:59 +00:00
default :
2009-12-21 14:32:54 +00:00
warning ( " Unsupported kGraph() operation %04x " , argv [ 0 ] . 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 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
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 ;
2009-09-27 01:50:26 +00:00
if ( text . empty ( ) | | ! dest ) { // Empty text
2009-02-15 06:10:59 +00:00
dest [ 2 ] = dest [ 3 ] = make_reg ( 0 , 0 ) ;
2010-01-30 11:59:05 +00:00
debugC ( 2 , 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-01-29 22:02:28 +00:00
# ifdef ENABLE_SCI32
2010-02-13 17:43:31 +00:00
if ( g_sci - > _gui32 )
2010-02-13 17:46:44 +00:00
g_sci - > _gui32 - > textSize ( g_sci - > strSplit ( text . c_str ( ) , sep ) . c_str ( ) , font_nr , maxwidth , & textWidth , & textHeight ) ;
2010-01-29 22:02:28 +00:00
else
# endif
2010-02-13 17:46:44 +00:00
g_sci - > _gui - > textSize ( g_sci - > strSplit ( text . c_str ( ) , sep ) . c_str ( ) , font_nr , maxwidth , & textWidth , & textHeight ) ;
2010-01-29 22:02:28 +00:00
2010-01-30 11:59:05 +00:00
debugC ( 2 , kDebugLevelStrings , " GetTextSize '%s' -> %dx%d " , text . c_str ( ) , textWidth , textHeight ) ;
2009-10-03 20:49:18 +00:00
dest [ 2 ] = make_reg ( 0 , textHeight ) ;
dest [ 3 ] = make_reg ( 0 , textWidth ) ;
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 ) {
2009-09-02 11:33:25 +00:00
_k_dirloop ( 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-02-13 17:43:31 +00:00
bool canBeHere = g_sci - > _gfxCompare - > kernelCanBeHere ( curObject , listReference ) ;
2009-10-14 09:36:39 +00:00
return make_reg ( 0 , canBeHere ) ;
2009-10-09 16:51:10 +00:00
}
2009-02-15 06:10:59 +00:00
2009-10-09 17:34:52 +00:00
// kCantBeHere does the same thing as kCanBeHere, except that it returns the opposite result.
- 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 ;
2010-01-29 22:02:28 +00:00
2010-02-13 17:43:31 +00:00
bool canBeHere = g_sci - > _gfxCompare - > kernelCanBeHere ( curObject , listReference ) ;
2009-10-14 09:36:39 +00:00
return make_reg ( 0 , ! 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
2010-01-30 11:59:05 +00:00
debugC ( 2 , 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
2010-01-30 11:59:05 +00:00
debugC ( 2 , 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
2009-10-28 23:32:28 +00:00
// WORKAROUND for a problem in LSL1VGA. This allows the casino door to be opened,
// till the actual problem is found
2010-05-23 10:28:03 +00:00
if ( ! strcmp ( g_sci - > getGameID ( ) , " lsl1sci " ) & & s - > currentRoomNumber ( ) = = 300 ) {
2010-05-29 23:37:15 +00:00
int top = readSelectorValue ( s - > _segMan , object , SELECTOR ( brTop ) ) ;
writeSelectorValue ( s - > _segMan , object , SELECTOR ( brTop ) , top + 2 ) ;
2009-11-04 14:17:14 +00:00
}
2009-10-28 23:32:28 +00:00
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-01-31 16:21:11 +00:00
// we are called on EGA/amiga games as well, this doesnt make sense.
// doing this would actually break the system EGA/amiga palette
2010-02-13 17:44:19 +00:00
if ( ! g_sci - > getResMan ( ) - > isVGA ( ) )
2010-01-29 21:30:46 +00:00
return s - > r_acc ;
2009-06-07 15:53:30 +00:00
switch ( argv [ 0 ] . toUint16 ( ) ) {
2009-10-20 16:11:31 +00:00
case 1 : // Set resource palette
2009-10-03 20:49:18 +00:00
if ( argc = = 3 ) {
2009-10-20 16:11:31 +00:00
GuiResourceId resourceId = argv [ 1 ] . toUint16 ( ) ;
2010-01-26 22:45:52 +00:00
bool force = argv [ 2 ] . toUint16 ( ) = = 2 ? true : false ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > kernelSetFromResource ( resourceId , force ) ;
2010-02-06 21:22:05 +00:00
} else {
warning ( " kPalette(1) called with %d parameters " , argc ) ;
2009-10-03 20:49:18 +00:00
}
2009-03-29 15:08:50 +00:00
break ;
2009-10-20 18:45:46 +00:00
case 2 : { // Set palette-flag(s)
uint16 fromColor = CLIP < uint16 > ( argv [ 1 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 toColor = CLIP < uint16 > ( argv [ 2 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 flags = argv [ 3 ] . toUint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > kernelSetFlag ( fromColor , toColor , flags ) ;
2009-03-29 15:08:50 +00:00
break ;
2009-10-20 18:45:46 +00:00
}
case 3 : { // Remove palette-flag(s)
uint16 fromColor = CLIP < uint16 > ( argv [ 1 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 toColor = CLIP < uint16 > ( argv [ 2 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 flags = argv [ 3 ] . toUint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > kernelUnsetFlag ( fromColor , toColor , flags ) ;
2009-03-29 15:08:50 +00:00
break ;
2009-10-20 18:45:46 +00:00
}
2009-10-04 19:49:47 +00:00
case 4 : { // Set palette intensity
2009-10-20 16:11:31 +00:00
switch ( argc ) {
case 4 :
case 5 : {
2009-10-20 18:45:46 +00:00
uint16 fromColor = CLIP < uint16 > ( argv [ 1 ] . toUint16 ( ) , 1 , 255 ) ;
uint16 toColor = CLIP < uint16 > ( argv [ 2 ] . toUint16 ( ) , 1 , 255 ) ;
2009-10-20 16:11:31 +00:00
uint16 intensity = argv [ 3 ] . toUint16 ( ) ;
2009-10-14 19:39:07 +00:00
bool setPalette = ( argc < 5 ) ? true : ( argv [ 4 ] . isNull ( ) ) ? true : false ;
2009-10-04 19:49:47 +00:00
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > kernelSetIntensity ( fromColor , toColor , intensity , setPalette ) ;
2009-10-20 16:11:31 +00:00
break ;
}
default :
warning ( " kPalette(4) called with %d parameters " , argc ) ;
2009-04-01 20:32:45 +00:00
}
2009-03-29 15:08:50 +00:00
break ;
2009-10-04 19:49:47 +00:00
}
case 5 : { // Find closest color
2009-10-20 16:11:31 +00:00
uint16 r = argv [ 1 ] . toUint16 ( ) ;
uint16 g = argv [ 2 ] . toUint16 ( ) ;
uint16 b = argv [ 3 ] . toUint16 ( ) ;
2009-02-15 06:10:59 +00:00
2010-02-13 17:43:31 +00:00
return make_reg ( 0 , g_sci - > _gfxPalette - > kernelFindColor ( r , g , b ) ) ;
2009-02-15 06:10:59 +00:00
}
2009-10-20 16:11:31 +00:00
case 6 : { // Animate
2009-10-20 18:45:46 +00:00
int16 argNr ;
2010-01-04 16:44:58 +00:00
bool paletteChanged = false ;
2009-10-20 18:45:46 +00:00
for ( argNr = 1 ; argNr < argc ; argNr + = 3 ) {
uint16 fromColor = argv [ argNr ] . toUint16 ( ) ;
uint16 toColor = argv [ argNr + 1 ] . toUint16 ( ) ;
int16 speed = argv [ argNr + 2 ] . toSint16 ( ) ;
2010-02-13 17:43:31 +00:00
if ( g_sci - > _gfxPalette - > kernelAnimate ( fromColor , toColor , speed ) )
2010-01-04 16:44:58 +00:00
paletteChanged = true ;
2009-10-03 20:49:18 +00:00
}
2010-01-04 16:44:58 +00:00
if ( paletteChanged )
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > kernelAnimateSet ( ) ;
2009-02-15 06:10:59 +00:00
break ;
2009-10-20 16:11:31 +00:00
}
case 7 : { // Save palette to heap
warning ( " kPalette(7), save palette to heap STUB " ) ;
2009-03-29 15:08:50 +00:00
break ;
2009-10-20 16:11:31 +00:00
}
case 8 : { // Restore palette from heap
warning ( " kPalette(8), set stored palette STUB " ) ;
2009-03-29 15:08:50 +00:00
break ;
2009-10-20 16:11:31 +00:00
}
2009-03-29 15:08:50 +00:00
default :
2009-10-20 16:11:31 +00:00
warning ( " kPalette(%d), not implemented " , argv [ 0 ] . toUint16 ( ) ) ;
2009-02-15 06:10:59 +00:00
}
2009-02-19 20:50:55 +00:00
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
2009-10-15 06:37:05 +00:00
// This here is needed to make Pharkas work
reg_t kPalVary ( EngineState * s , int argc , reg_t * argv ) {
2009-10-20 19:56:37 +00:00
uint16 operation = argv [ 0 ] . toUint16 ( ) ;
2010-02-13 17:43:31 +00:00
if ( ! g_sci - > _gui )
2010-01-29 21:30:46 +00:00
return s - > r_acc ;
2009-10-20 19:56:37 +00:00
switch ( operation ) {
case 0 : { // Init
GuiResourceId paletteId ;
uint16 time ;
if ( argc = = 3 ) {
paletteId = argv [ 1 ] . toUint16 ( ) ;
time = argv [ 2 ] . toUint16 ( ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > startPalVary ( paletteId , time ) ;
2010-02-06 21:22:05 +00:00
warning ( " kPalVary(init) called with paletteId = %d, time = %d " , paletteId , time ) ;
2009-10-20 19:56:37 +00:00
} else {
warning ( " kPalVary(init) called with unsupported argc %d " , argc ) ;
}
break ;
}
2010-02-06 21:22:05 +00:00
case 1 : { // Unknown
2010-02-06 21:38:58 +00:00
warning ( " kPalVary(1) called with parameter %d (argc %d) " , argv [ 1 ] . toUint16 ( ) , argc ) ;
2010-02-06 21:22:05 +00:00
break ;
}
2009-10-20 19:56:37 +00:00
case 3 : { // DeInit
if ( argc = = 1 ) {
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > stopPalVary ( ) ;
2010-02-06 21:22:05 +00:00
warning ( " kPalVary(deinit) " ) ;
2009-10-20 19:56:37 +00:00
} else {
warning ( " kPalVary(deinit) called with unsupported argc %d " , argc ) ;
}
break ;
}
2010-02-06 21:38:58 +00:00
case 4 : { // Unknown
warning ( " kPalVary(4) called with parameter %d (argc %d) " , argv [ 1 ] . toUint16 ( ) , argc ) ;
break ;
}
2009-10-20 20:57:08 +00:00
case 6 : { // Pause
bool pauseState ;
if ( argc = = 2 ) {
pauseState = argv [ 1 ] . isNull ( ) ? false : true ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPalette - > togglePalVary ( pauseState ) ;
2010-02-06 21:22:05 +00:00
warning ( " kPalVary(pause) called with state = %d " , pauseState ) ;
2009-10-20 20:57:08 +00:00
} else {
warning ( " kPalVary(pause) called with unsupported argc %d " , argc ) ;
}
break ;
}
2009-10-20 19:56:37 +00:00
default :
warning ( " kPalVary(%d), not implemented (argc = %d) " , operation , argc ) ;
}
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-02-07 12:00:06 +00:00
GuiResourceId paletteId = argv [ 1 ] . 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-02-13 17:43:31 +00:00
s - > r_acc = g_sci - > _gui - > portraitLoad ( resourceName ) ;
2009-10-31 15:25:47 +00:00
} else {
warning ( " kPortrait(loadResource) called with unsupported argc %d " , argc ) ;
}
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-02-13 17:43:31 +00:00
g_sci - > _gui - > portraitShow ( 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 {
warning ( " kPortrait(show) called with unsupported argc %d " , argc ) ;
}
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-02-13 17:43:31 +00:00
g_sci - > _gui - > portraitUnload ( portraitId ) ;
2009-10-31 15:25:47 +00:00
} else {
warning ( " kPortrait(unload) called with unsupported argc %d " , argc ) ;
}
break ;
}
2009-10-30 23:44:12 +00:00
default :
warning ( " 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-01-23 11:00:24 +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)
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 :
2010-01-30 11:59:05 +00:00
debugC ( 2 , kDebugLevelGraphics , " drawing button %04x:%04x to %d,%d " , PRINT_REG ( controlObject ) , x , y ) ;
2010-02-13 17:46:44 +00:00
g_sci - > _gfxControls - > 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 ) ) ;
2010-01-30 11:59:05 +00:00
debugC ( 2 , kDebugLevelGraphics , " drawing text %04x:%04x ('%s') to %d,%d, mode=%d " , PRINT_REG ( controlObject ) , text . c_str ( ) , x , y , alignment ) ;
2010-02-13 17:46:44 +00:00
g_sci - > _gfxControls - > kernelDrawText ( rect , controlObject , g_sci - > strSplit ( text . c_str ( ) ) . c_str ( ) , fontId , alignment , style , hilite ) ;
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-01-30 11:59:05 +00:00
debugC ( 2 , kDebugLevelGraphics , " drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d " , PRINT_REG ( controlObject ) , PRINT_REG ( textReference ) , text . c_str ( ) , x , y ) ;
2010-02-13 17:46:44 +00:00
g_sci - > _gfxControls - > 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-01-22 22:34:14 +00:00
// Game-specific: *ONLY* the jones EGA/VGA sierra interpreter contain code using priority selector
// ALL other games use a hardcoded -1 (madness!)
// We are detecting jones/talkie as "jones" as well, but the sierra interpreter of talkie doesnt have this
// "hack". Hopefully it wont cause regressions (the code causes regressions if used against kq5/floppy)
2010-05-23 10:28:03 +00:00
if ( ! strcmp ( g_sci - > getGameID ( ) , " jones " ) )
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
}
2010-01-30 11:59:05 +00:00
debugC ( 2 , kDebugLevelGraphics , " drawing icon control %04x:%04x to %d,%d " , PRINT_REG ( controlObject ) , x , y - 1 ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxControls - > 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-02-13 17:45:40 +00:00
if ( g_sci - > getKernel ( ) - > _selectorCache . 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-05-29 23:37:15 +00:00
if ( lookupSelector ( s - > _segMan , controlObject , g_sci - > getKernel ( ) - > _selectorCache . brTop , NULL , NULL ) = = kSelectorVariable )
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 ;
}
}
2010-01-30 11:59:05 +00:00
debugC ( 2 , kDebugLevelGraphics , " drawing list control %04x:%04x to %d,%d, diff %d " , PRINT_REG ( controlObject ) , x , y , SCI_MAX_SAVENAME_LENGTH ) ;
2010-02-13 17:43:31 +00:00
g_sci - > _gfxControls - > 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 ) ;
// Disable the "Change Directory" button, as we don't allow the game engine to
// change the directory where saved games are placed
if ( objName = = " changeDirI " ) {
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
}
2009-02-15 06:10:59 +00:00
2009-10-11 14:28:20 +00:00
_k_GenericDrawControl ( s , controlObject , false ) ;
2009-02-15 06:10:59 +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 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
2010-02-13 17:43:31 +00:00
g_sci - > _gfxControls - > kernelTexteditChange ( controlObject , eventObject ) ;
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 4 :
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 ( ) ;
2009-10-13 16:18:17 +00:00
picTop = ( argc > = 6 ) ? argv [ 4 ] . toSint16 ( ) : 0 ;
picLeft = ( argc > = 6 ) ? argv [ 5 ] . toSint16 ( ) : 0 ;
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-01-10 08:55:19 +00:00
bool hiresMode = ( argc > 7 ) ? true : false ;
2010-01-07 20:29:48 +00:00
reg_t upscaledHiresHandle = ( argc > 7 ) ? argv [ 7 ] : NULL_REG ;
2009-02-15 06:10:59 +00:00
2010-05-23 10:28:03 +00:00
if ( ! strcmp ( g_sci - > getGameID ( ) , " freddypharkas " ) | | ! strcmp ( g_sci - > getGameID ( ) , " freddypharkas-demo " ) ) {
2010-01-20 19:45:42 +00:00
// WORKAROUND
// Script 24 contains code that draws the game menu on screen. It uses a temp variable for setting priority that
// is not set. in Sierra sci this happens to be 8250h. In our sci temporary variables are initialized thus we would
// get 0 here resulting in broken menus.
2010-01-27 19:28:13 +00:00
if ( ( viewId = = 995 ) & & ( loopNo = = 0 ) & & ( celNo = = 0 ) & & ( priority = = 0 ) ) // game menu
2010-01-20 17:56:00 +00:00
priority = 15 ;
2010-01-27 19:28:13 +00:00
if ( ( viewId = = 992 ) & & ( loopNo = = 0 ) & & ( celNo = = 0 ) & & ( priority = = 0 ) ) // quit game
2010-01-20 17:56:00 +00:00
priority = 15 ;
}
2010-05-23 10:28:03 +00:00
if ( ! strcmp ( g_sci - > getGameID ( ) , " laurabow2 " ) ) {
2010-01-27 21:33:51 +00:00
// WORKAROUND
// see the one above
if ( ( viewId = = 995 ) & & ( priority = = 0 ) )
priority = 15 ;
}
2010-02-13 17:43:31 +00:00
g_sci - > _gfxPaint16 - > kernelDrawCel ( viewId , loopNo , celNo , x , y , priority , paletteNo , 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 ;
int colorPen = ( argc > 7 + argextra ) ? argv [ 7 + argextra ] . toSint16 ( ) : 0 ;
int colorBack = ( argc > 8 + argextra ) ? argv [ 8 + argextra ] . toSint16 ( ) : 255 ;
2009-02-15 06:10:59 +00:00
2009-10-03 20:49:18 +00:00
// const char *title = argv[4 + argextra].segment ? kernel_dereference_char_pointer(s, argv[4 + argextra], 0) : NULL;
2010-01-15 15:37:40 +00: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-10-03 20:49:18 +00:00
}
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
2009-12-19 16:19:53 +00:00
# ifdef USE_OLD_MUSIC_FUNCTIONS
2010-01-01 15:35:27 +00:00
// Take care of incoming events (kAnimate is called semi-regularly)
2009-10-09 19:41:39 +00:00
process_sound_events ( s ) ;
2009-12-19 16:19:53 +00:00
# endif
2010-02-13 17:43:31 +00:00
g_sci - > _gfxAnimate - > kernelAnimate ( castListReference , cycle , argc , argv ) ;
2009-10-14 21:45:16 +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 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-02-13 17:43:31 +00:00
g_sci - > _gfxPaint - > 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
- 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 kShowMovie ( EngineState * s , int argc , reg_t * argv ) {
2010-01-27 16:54:58 +00:00
// Hide the cursor if it's showing and then show it again if it was
// previously visible.
2010-05-26 03:43:21 +00:00
bool reshowCursor = g_sci - > _gfxCursor - > isVisible ( ) ;
2010-02-05 14:48:51 +00:00
if ( reshowCursor )
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelHide ( ) ;
2010-05-26 03:43:21 +00:00
uint16 screenWidth = g_system - > getWidth ( ) ;
uint16 screenHeight = g_system - > getHeight ( ) ;
2010-05-18 14:17:24 +00:00
Graphics : : VideoDecoder * videoDecoder = 0 ;
2010-01-11 09:28:00 +00:00
2010-02-05 19:41:06 +00:00
if ( argv [ 0 ] . segment ! = 0 ) {
2010-05-18 14:17:24 +00:00
Common : : String filename = s - > _segMan - > getString ( argv [ 0 ] ) ;
2010-05-18 04:17:58 +00:00
if ( g_sci - > getPlatform ( ) = = Common : : kPlatformMacintosh ) {
// Mac QuickTime
// The only argument is the string for the video
2010-05-26 03:43:21 +00:00
// HACK: Switch to 16bpp graphics for Cinepak.
initGraphics ( screenWidth , screenHeight , screenWidth > 320 , NULL ) ;
if ( g_system - > getScreenFormat ( ) . bytesPerPixel = = 1 ) {
warning ( " This video requires >8bpp color to be displayed, but could not switch to RGB color mode. " ) ;
return NULL_REG ;
}
videoDecoder = new Graphics : : QuickTimeDecoder ( ) ;
if ( ! videoDecoder - > loadFile ( filename ) )
error ( " Could not open '%s' " , filename . c_str ( ) ) ;
2010-01-06 18:59:39 +00:00
} else {
2010-05-18 04:17:58 +00:00
// DOS SEQ
// SEQ's are called with no subops, just the string and delay
SeqDecoder * seqDecoder = new SeqDecoder ( ) ;
2010-05-18 14:17:24 +00:00
seqDecoder - > setFrameDelay ( argv [ 1 ] . toUint16 ( ) ) ; // Time between frames in ticks
videoDecoder = seqDecoder ;
if ( ! videoDecoder - > loadFile ( filename ) ) {
2010-05-18 04:17:58 +00:00
warning ( " Failed to open movie file %s " , filename . c_str ( ) ) ;
2010-05-18 14:17:24 +00:00
delete videoDecoder ;
videoDecoder = 0 ;
2010-05-18 04:17:58 +00:00
}
2010-01-06 18:59:39 +00:00
}
2010-02-05 19:41:06 +00:00
} else {
2010-05-26 03:43:21 +00:00
// Windows AVI
2010-01-30 03:57:58 +00:00
// TODO: This appears to be some sort of subop. case 0 contains the string
// for the video, so we'll just play it from there for now.
2010-02-05 19:41:06 +00:00
# ifdef ENABLE_SCI32
if ( getSciVersion ( ) > = SCI_VERSION_2_1 ) {
// SCI2.1 always has argv[0] as 1, the rest of the arguments seem to
// follow SCI1.1/2.
if ( argv [ 0 ] . toUint16 ( ) ! = 1 )
error ( " SCI2.1 kShowMovie argv[0] not 1 " ) ;
argv + + ;
argc - - ;
}
# endif
switch ( argv [ 0 ] . toUint16 ( ) ) {
2010-01-30 03:57:58 +00:00
case 0 : {
2010-02-05 19:41:06 +00:00
Common : : String filename = s - > _segMan - > getString ( argv [ 1 ] ) ;
2010-05-18 14:17:24 +00:00
videoDecoder = new Graphics : : AviDecoder ( g_system - > getMixer ( ) ) ;
if ( ! videoDecoder - > loadFile ( filename . c_str ( ) ) ) {
2010-01-30 03:57:58 +00:00
warning ( " Failed to open movie file %s " , filename . c_str ( ) ) ;
2010-05-18 14:17:24 +00:00
delete videoDecoder ;
videoDecoder = 0 ;
2010-01-30 03:57:58 +00:00
}
break ;
}
default :
2010-02-05 19:41:06 +00:00
warning ( " Unhandled SCI kShowMovie subop %d " , argv [ 1 ] . toUint16 ( ) ) ;
2010-01-30 03:57:58 +00:00
}
2009-10-16 18:05:56 +00:00
}
2010-05-18 14:17:24 +00:00
if ( videoDecoder ) {
2010-05-26 03:43:21 +00:00
uint16 x = ( screenWidth - videoDecoder - > getWidth ( ) ) / 2 ;
uint16 y = ( screenHeight - videoDecoder - > getHeight ( ) ) / 2 ;
2010-05-18 14:17:24 +00:00
2010-05-26 03:43:21 +00:00
while ( ! g_engine - > shouldQuit ( ) & & ! videoDecoder - > endOfVideo ( ) ) {
2010-05-18 14:17:24 +00:00
if ( videoDecoder - > needsUpdate ( ) ) {
Graphics : : Surface * frame = videoDecoder - > decodeNextFrame ( ) ;
if ( frame ) {
g_system - > copyRectToScreen ( ( byte * ) frame - > pixels , frame - > pitch , x , y , frame - > w , frame - > h ) ;
if ( videoDecoder - > hasDirtyPalette ( ) )
videoDecoder - > setSystemPalette ( ) ;
g_system - > updateScreen ( ) ;
}
}
Common : : Event event ;
while ( g_system - > getEventManager ( ) - > pollEvent ( event ) )
;
g_system - > delayMillis ( 10 ) ;
}
2010-05-26 03:43:21 +00:00
// HACK: Switch back to 8bpp if we played a QuickTime video.
// We also won't be copying the screen to the SCI screen...
if ( g_system - > getScreenFormat ( ) . bytesPerPixel ! = 1 )
initGraphics ( screenWidth , screenHeight , screenWidth > 320 ) ;
else
g_sci - > _gfxScreen - > kernelSyncWithFramebuffer ( ) ;
2010-05-18 14:17:24 +00:00
delete videoDecoder ;
}
2010-01-06 18:59:39 +00:00
2010-02-05 14:48:51 +00:00
if ( reshowCursor )
2010-02-13 17:43:31 +00:00
g_sci - > _gfxCursor - > kernelShow ( ) ;
2010-01-11 09:28:00 +00:00
2009-10-16 18:05:56 +00:00
return s - > r_acc ;
2009-08-30 19:47:47 +00:00
}
2010-01-29 22:02:28 +00:00
# ifdef ENABLE_SCI32
2010-01-28 19:57:14 +00:00
reg_t kRobot ( EngineState * s , int argc , reg_t * argv ) {
int16 subop = argv [ 0 ] . toUint16 ( ) ;
switch ( subop ) {
case 0 : { // init
int id = argv [ 1 ] . toUint16 ( ) ;
reg_t obj = argv [ 2 ] ;
int16 flag = argv [ 3 ] . toSint16 ( ) ;
int16 x = argv [ 4 ] . toUint16 ( ) ;
int16 y = argv [ 5 ] . toUint16 ( ) ;
warning ( " kRobot(init), id %d, obj %04x:%04x, flag %d, x=%d, y=%d " , id , PRINT_REG ( obj ) , flag , x , y ) ;
}
break ;
case 4 : { // start
int id = argv [ 1 ] . toUint16 ( ) ;
warning ( " kRobot(start), id %d " , id ) ;
}
break ;
case 8 : // sync
//warning("kRobot(sync), obj %04x:%04x", PRINT_REG(argv[1]));
break ;
default :
warning ( " kRobot(%d) " , subop ) ;
break ;
}
return s - > r_acc ;
}
2010-01-29 22:02:28 +00:00
# endif
2010-01-28 19:57:14 +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 kSetVideoMode ( EngineState * s , int argc , reg_t * argv ) {
2009-05-23 13:26:45 +00:00
// 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
2009-10-28 18:59:11 +00:00
//warning("STUB: SetVideoMode %d", argv[0].toUint16());
2009-05-23 13:26:45 +00:00
return s - > r_acc ;
}
2009-10-03 20:49:18 +00:00
// 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 ) {
2010-02-13 17:43:31 +00:00
g_sci - > _gui - > textFonts ( argc , argv ) ;
2009-10-03 20:49:18 +00:00
return s - > r_acc ;
}
reg_t kTextColors ( EngineState * s , int argc , reg_t * argv ) {
2010-02-13 17:43:31 +00:00
g_sci - > _gui - > textColors ( argc , argv ) ;
2009-10-03 20:49:18 +00:00
return s - > r_acc ;
}
2009-02-21 10:23:36 +00:00
} // End of namespace Sci