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
2009-02-21 15:40:14 +00:00
# include "common/system.h"
2009-05-21 22:03:23 +00:00
# include "common/events.h"
2009-07-03 14:18:20 +00:00
# include "graphics/cursorman.h"
2009-08-30 19:47:47 +00:00
# include "graphics/video/avi_player.h"
# 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-02-27 02:23:40 +00:00
# include "sci/engine/state.h"
2009-03-07 19:23:47 +00:00
# include "sci/engine/kernel.h"
2009-03-25 12:52:03 +00:00
# include "sci/gfx/gfx_gui.h"
2009-02-21 19:33:01 +00:00
# include "sci/gfx/gfx_widgets.h"
2009-04-24 10:46:20 +00:00
# include "sci/gfx/gfx_state_internal.h" // required for GfxContainer, GfxPort, GfxVisual
2009-05-21 22:03:23 +00:00
# include "sci/gfx/seq_decoder.h"
2009-10-04 22:43:30 +00:00
# include "sci/gui/gui.h"
2009-10-07 21:29:47 +00:00
# include "sci/gui/gui_cursor.h"
2009-02-15 06:10:59 +00:00
2009-02-21 10:23:36 +00:00
namespace Sci {
2009-02-15 06:10:59 +00:00
# undef DEBUG_LSRECT
2009-02-26 02:21:55 +00:00
// This is the real width of a text with a specified width of 0
# define MAX_TEXT_WIDTH_MAGIC_VALUE 192
2009-02-19 20:50:55 +00:00
// Graph subfunctions
2009-04-24 10:43:42 +00:00
enum {
K_GRAPH_GET_COLORS_NR = 2 ,
2009-10-12 07:11:22 +00:00
// 3 - SET PALETTE VIA RESOURCE
2009-04-24 10:43:42 +00:00
K_GRAPH_DRAW_LINE = 4 ,
2009-10-12 07:11:22 +00:00
// 5 - NOP
// 6 - DRAW PATTERN
2009-04-24 10:43:42 +00:00
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 ,
K_GRAPH_ADJUST_PRIORITY = 14
} ;
2009-02-15 06:10:59 +00:00
# define ADD_TO_CURRENT_PORT(widget) \
2009-02-22 13:11:43 +00:00
{ if ( s - > port ) \
2009-05-30 14:30:39 +00:00
s - > port - > add ( ( GfxContainer * ) s - > port , widget ) ; \
2009-02-22 13:11:43 +00:00
else \
2009-05-30 14:30:39 +00:00
s - > picture_port - > add ( ( GfxContainer * ) s - > visual , widget ) ; }
2009-02-15 06:10:59 +00:00
# define ADD_TO_CURRENT_PICTURE_PORT(widget) \
2009-02-22 13:11:43 +00:00
{ if ( s - > port ) \
2009-05-30 14:30:39 +00:00
s - > port - > add ( ( GfxContainer * ) s - > port , widget ) ; \
2009-02-22 13:11:43 +00:00
else \
2009-05-30 14:30:39 +00:00
s - > picture_port - > add ( ( GfxContainer * ) s - > picture_port , widget ) ; }
2009-02-15 06:10:59 +00:00
# define ADD_TO_WINDOW_PORT(widget) \
2009-05-30 14:30:39 +00:00
s - > wm_port - > add ( ( GfxContainer * ) s - > wm_port , widget ) ;
2009-02-15 06:10:59 +00:00
# define FULL_REDRAW()\
2009-02-22 13:11:43 +00:00
if ( s - > visual ) \
2009-04-24 14:22:14 +00:00
s - > visual - > draw ( gfxw_point_zero ) ; \
2009-02-22 13:11:43 +00:00
gfxop_update ( s - > gfx_state ) ;
2009-02-15 06:10:59 +00:00
2009-04-21 21:37:03 +00:00
#if 0
// Used for debugging
2009-02-15 06:10:59 +00:00
# define FULL_INSPECTION()\
2009-02-22 13:11:43 +00:00
if ( s - > visual ) \
2009-04-24 10:48:25 +00:00
s - > visual - > print ( s - > visual , 0 ) ;
2009-04-21 21:37:03 +00:00
# endif
2009-02-15 06:10:59 +00:00
2009-02-19 20:50:55 +00:00
static inline int sign_extend_byte ( int value ) {
2009-02-15 06:10:59 +00:00
if ( value & 0x80 )
return value - 256 ;
else
return value ;
}
2009-10-03 20:49:18 +00:00
// was static
void assert_primary_widget_lists ( EngineState * s ) {
2009-02-15 06:10:59 +00:00
if ( ! s - > dyn_views ) {
2009-04-24 10:45:09 +00:00
rect_t bounds = s - > picture_port - > _bounds ;
2009-02-15 06:10:59 +00:00
s - > dyn_views = gfxw_new_list ( bounds , GFXW_LIST_SORTED ) ;
2009-04-24 10:45:09 +00:00
s - > dyn_views - > _flags | = GFXW_FLAG_IMMUNE_TO_SNAPSHOTS ;
2009-02-15 06:10:59 +00:00
ADD_TO_CURRENT_PICTURE_PORT ( s - > dyn_views ) ;
}
if ( ! s - > drop_views ) {
2009-04-24 10:45:09 +00:00
rect_t bounds = s - > picture_port - > _bounds ;
2009-02-15 06:10:59 +00:00
s - > drop_views = gfxw_new_list ( bounds , GFXW_LIST_SORTED ) ;
2009-04-24 10:45:09 +00:00
s - > drop_views - > _flags | = GFXW_FLAG_IMMUNE_TO_SNAPSHOTS ;
2009-02-15 06:10:59 +00:00
ADD_TO_CURRENT_PICTURE_PORT ( s - > drop_views ) ;
}
}
2009-10-03 20:49:18 +00:00
// static
void reparentize_primary_widget_lists ( EngineState * s , GfxPort * newport ) {
2009-02-15 06:10:59 +00:00
if ( ! newport )
newport = s - > picture_port ;
if ( s - > dyn_views ) {
2009-04-24 10:48:25 +00:00
gfxw_remove_widget_from_container ( s - > dyn_views - > _parent , s - > dyn_views ) ;
2009-02-15 06:10:59 +00:00
2009-05-30 14:30:39 +00:00
newport - > add ( ( GfxContainer * ) newport , s - > dyn_views ) ;
2009-02-15 06:10:59 +00:00
}
}
2009-02-21 10:47:56 +00:00
int _find_view_priority ( EngineState * s , int y ) {
2009-02-19 20:50:55 +00:00
/*if (s->version <= SCI_VERSION_LTU_PRIORITY_OB1)
+ + y ; */
2009-02-15 06:10:59 +00:00
2009-02-19 20:50:55 +00:00
if ( s - > pic_priority_table ) { // SCI01 priority table set?
2009-02-15 06:10:59 +00:00
int j ;
for ( j = 0 ; j < 15 ; j + + )
if ( y < s - > pic_priority_table [ j + 1 ] )
return j ;
2009-02-19 20:50:55 +00:00
return 14 ; // Maximum
2009-02-15 22:28:12 +00:00
} else {
2009-10-08 14:37:55 +00:00
if ( ! s - > usesOldGfxFunctions ( ) )
2009-02-15 06:10:59 +00:00
return SCI0_VIEW_PRIORITY_14_ZONES ( y ) ;
else
2009-02-19 20:50:55 +00:00
return SCI0_VIEW_PRIORITY ( y ) = = 15 ? 14 : SCI0_VIEW_PRIORITY ( y ) ;
2009-02-15 06:10:59 +00:00
}
}
2009-02-21 10:47:56 +00:00
int _find_priority_band ( EngineState * s , int nr ) {
2009-10-08 14:37:55 +00:00
if ( ! s - > usesOldGfxFunctions ( ) & & ( nr < 0 | | nr > 14 ) ) {
2009-02-15 06:10:59 +00:00
if ( nr = = 15 )
return 0xffff ;
else {
2009-02-20 20:11:12 +00:00
warning ( " Attempt to get priority band %d " , nr ) ;
2009-02-15 06:10:59 +00:00
}
return 0 ;
}
2009-10-08 14:37:55 +00:00
if ( s - > usesOldGfxFunctions ( ) & & ( nr < 0 | | nr > 15 ) ) {
2009-02-20 20:11:12 +00:00
warning ( " Attempt to get priority band %d " , nr ) ;
2009-02-15 06:10:59 +00:00
return 0 ;
}
2009-02-19 20:50:55 +00:00
if ( s - > pic_priority_table ) // SCI01 priority table set?
2009-02-15 06:10:59 +00:00
return s - > pic_priority_table [ nr ] ;
else {
int retval ;
2009-10-08 14:37:55 +00:00
if ( ! s - > usesOldGfxFunctions ( ) )
2009-02-15 06:10:59 +00:00
retval = SCI0_PRIORITY_BAND_FIRST_14_ZONES ( nr ) ;
else
retval = SCI0_PRIORITY_BAND_FIRST ( nr ) ;
2009-02-19 20:50:55 +00:00
/* if (s->version <= SCI_VERSION_LTU_PRIORITY_OB1)
- - retval ; */
2009-02-15 06:10:59 +00:00
return retval ;
}
}
2009-02-21 10:47:56 +00:00
reg_t graph_save_box ( EngineState * s , rect_t area ) {
2009-10-04 18:38:18 +00:00
reg_t handle = kalloc ( s - > _segMan , " graph_save_box() " , sizeof ( gfxw_snapshot_t * ) ) ;
gfxw_snapshot_t * * ptr = ( gfxw_snapshot_t * * ) kmem ( s - > _segMan , handle ) ;
2009-02-15 06:10:59 +00:00
2009-05-18 12:34:25 +00:00
// FIXME: gfxw_make_snapshot returns a pointer. Now why do we store a
// pointer to real memory inside the SCI heap?
// If we save and the load again, this cannot work in general.
// This seems like bad design. Either the snapshot data itself should be
// stored in the heap, or a unique persistent id.
2009-02-15 06:10:59 +00:00
* ptr = gfxw_make_snapshot ( s - > visual , area ) ;
return handle ;
}
2009-02-21 10:47:56 +00:00
void graph_restore_box ( EngineState * s , reg_t handle ) {
2009-02-15 06:10:59 +00:00
gfxw_snapshot_t * * ptr ;
2009-04-24 10:45:09 +00:00
int port_nr = s - > port - > _ID ;
2009-02-15 06:10:59 +00:00
if ( ! handle . segment ) {
2009-02-20 20:11:12 +00:00
warning ( " Attempt to restore box with zero handle " ) ;
2009-02-15 06:10:59 +00:00
return ;
}
2009-10-04 18:38:18 +00:00
ptr = ( gfxw_snapshot_t * * ) kmem ( s - > _segMan , handle ) ;
2009-02-15 06:10:59 +00:00
if ( ! ptr ) {
2009-05-21 17:18:46 +00:00
warning ( " Attempt to restore invalid handle %04x:%04x " , PRINT_REG ( handle ) ) ;
2009-02-15 06:10:59 +00:00
return ;
}
2009-04-24 10:48:25 +00:00
while ( port_nr > 2 & & ! ( s - > port - > _flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS ) & & ( gfxw_widget_matches_snapshot ( * ptr , s - > port ) ) ) {
2009-02-19 20:50:55 +00:00
// This shouldn't ever happen, actually, since windows (ports w/ ID > 2) should all be immune
2009-06-02 14:16:59 +00:00
GfxPort * newport = s - > visual - > getPort ( port_nr ) ;
2009-05-18 11:53:04 +00:00
error ( " Port %d is not immune against snapshots " , s - > port - > _ID ) ;
2009-02-15 06:10:59 +00:00
port_nr - - ;
if ( newport )
s - > port = newport ;
}
2009-04-24 10:48:25 +00:00
if ( s - > dyn_views & & gfxw_widget_matches_snapshot ( * ptr , s - > dyn_views - > _parent ) ) {
2009-04-24 10:46:20 +00:00
GfxContainer * parent = s - > dyn_views - > _parent ;
2009-02-15 06:10:59 +00:00
do {
2009-04-24 10:45:09 +00:00
parent = parent - > _parent ;
2009-04-24 10:48:25 +00:00
} while ( parent & & ( gfxw_widget_matches_snapshot ( * ptr , parent ) ) ) ;
2009-02-15 06:10:59 +00:00
if ( ! parent ) {
2009-05-18 11:53:04 +00:00
error ( " Attempted widget mass destruction by a snapshot " ) ;
2009-02-15 06:10:59 +00:00
}
2009-04-24 10:46:20 +00:00
reparentize_primary_widget_lists ( s , ( GfxPort * ) parent ) ;
2009-02-15 06:10:59 +00:00
}
if ( ! ptr ) {
2009-05-21 17:18:46 +00:00
error ( " Attempt to restore invalid snaphot with handle %04x:%04x " , PRINT_REG ( handle ) ) ;
2009-02-15 06:10:59 +00:00
return ;
}
gfxw_restore_snapshot ( s - > visual , * ptr ) ;
free ( * ptr ) ;
* ptr = NULL ;
2009-10-04 18:38:18 +00:00
kfree ( s - > _segMan , handle ) ;
2009-02-15 06:10:59 +00:00
}
2009-03-08 20:17:01 +00:00
PaletteEntry get_pic_color ( EngineState * s , int color ) {
2009-09-02 12:02:37 +00:00
if ( ! s - > resMan - > isVGA ( ) )
2009-03-08 20:17:01 +00:00
return s - > ega_colors [ color ] . visual ;
2009-02-15 06:10:59 +00:00
2009-03-29 01:56:03 +00:00
if ( color = = - 1 | | color = = 255 ) // -1 occurs in Eco Quest 1. Not sure if this is the best approach, but it seems to work
2009-03-08 20:17:01 +00:00
return PaletteEntry ( 255 , 255 , 255 ) ;
2009-03-23 08:43:53 +00:00
else if ( color < s - > gfx_state - > gfxResMan - > getColorCount ( ) )
return s - > gfx_state - > gfxResMan - > getColor ( color ) ;
2009-02-15 22:28:12 +00:00
else {
2009-05-27 17:13:42 +00:00
// Happens in the beginning of EcoQuest 2, when the dialog box of the customs officer shows up
warning ( " Color index %d out of bounds for pic %d (%d max) " , color , s - > gfx_state - > pic_nr , s - > gfx_state - > gfxResMan - > getColorCount ( ) ) ;
2009-05-20 17:53:31 +00:00
return PaletteEntry ( 0 , 0 , 0 ) ;
2009-02-15 22:28:12 +00:00
}
2009-02-15 06:10:59 +00:00
}
2009-10-09 17:34:52 +00:00
void _k_redraw_box ( EngineState * s , int x1 , int y1 , int x2 , int y2 ) {
warning ( " _k_redraw_box(): Unimplemented " ) ;
#if 0
int i ;
ViewObject * list = s - > dyn_views ;
printf ( " Reanimating views \n " , s - > dyn_views_nr ) ;
for ( i = 0 ; i < s - > dyn_views_nr ; i + + ) {
* ( list [ i ] . underBitsp ) = graph_save_box ( s , list [ i ] . nsLeft , list [ i ] . nsTop , list [ i ] . nsRight - list [ i ] . nsLeft ,
list [ i ] . nsBottom - list [ i ] . nsTop , SCI_MAP_VISUAL | SCI_MAP_PRIORITY ) ;
draw_view0 ( s - > pic , s - > ports [ 0 ] , list [ i ] . nsLeft , list [ i ] . nsTop , list [ i ] . priority , list [ i ] . loop ,
list [ i ] . cel , 0 , list [ i ] . view ) ;
}
graph_update_box ( s , x1 , y1 , x2 - x1 , y2 - y1 ) ;
for ( i = 0 ; i < s - > dyn_views_nr ; i + + ) {
graph_restore_box ( s , * ( list [ i ] . underBitsp ) ) ;
list [ i ] . underBits = 0 ;
}
# endif
}
void _k_dirloop ( reg_t obj , uint16 angle , EngineState * s , int argc , reg_t * argv ) {
SegManager * segMan = s - > _segMan ;
int view = GET_SEL32V ( obj , view ) ;
int signal = GET_SEL32V ( obj , signal ) ;
int loop ;
int maxloops ;
bool oldScriptHeader = ( getSciVersion ( ) = = SCI_VERSION_0_EARLY ) ;
if ( signal & _K_VIEW_SIG_FLAG_DOESNT_TURN )
return ;
angle % = 360 ;
if ( ! oldScriptHeader ) {
if ( angle < 45 )
loop = 3 ;
else if ( angle < 136 )
loop = 0 ;
else if ( angle < 225 )
loop = 2 ;
else if ( angle < 316 )
loop = 1 ;
else
loop = 3 ;
} else {
if ( angle > = 330 | | angle < = 30 )
loop = 3 ;
else if ( angle < = 150 )
loop = 0 ;
else if ( angle < = 210 )
loop = 2 ;
else if ( angle < 330 )
loop = 1 ;
else loop = 0xffff ;
}
maxloops = gfxop_lookup_view_get_loops ( s - > gfx_state , view ) ;
if ( ( loop > 1 ) & & ( maxloops < 4 ) )
return ;
PUT_SEL32V ( obj , loop , loop ) ;
}
Common : : Rect set_base ( EngineState * s , reg_t object ) {
SegManager * segMan = s - > _segMan ;
int x , y , original_y , z , ystep , xsize , ysize ;
int xbase , ybase , xend , yend ;
int view , loop , cel ;
int oldloop , oldcel ;
int xmod = 0 , ymod = 0 ;
Common : : Rect retval ;
x = ( int16 ) GET_SEL32V ( object , x ) ;
original_y = y = ( int16 ) GET_SEL32V ( object , y ) ;
if ( s - > _kernel - > _selectorCache . z > - 1 )
z = ( int16 ) GET_SEL32V ( object , z ) ;
else
z = 0 ;
y - = z ; // Subtract z offset
ystep = ( int16 ) GET_SEL32V ( object , yStep ) ;
view = ( int16 ) GET_SEL32V ( object , view ) ;
oldloop = loop = sign_extend_byte ( GET_SEL32V ( object , loop ) ) ;
oldcel = cel = sign_extend_byte ( GET_SEL32V ( object , cel ) ) ;
Common : : Point offset = Common : : Point ( 0 , 0 ) ;
if ( loop ! = oldloop ) {
loop = 0 ;
PUT_SEL32V ( object , loop , 0 ) ;
debugC ( 2 , kDebugLevelGraphics , " Resetting loop for %04x:%04x! \n " , PRINT_REG ( object ) ) ;
}
if ( cel ! = oldcel ) {
cel = 0 ;
PUT_SEL32V ( object , cel , 0 ) ;
}
gfxop_get_cel_parameters ( s - > gfx_state , view , loop , cel , & xsize , & ysize , & offset ) ;
xmod = offset . x ;
ymod = offset . y ;
xbase = x - xmod - ( xsize > > 1 ) ;
xend = xbase + xsize ;
yend = y /* - ymod */ + 1 ;
ybase = yend - ystep ;
debugC ( 2 , kDebugLevelBaseSetter , " (%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d) \n " ,
x , y , xmod , ymod , xsize , ysize , xbase , ybase , xend , yend ) ;
retval . left = xbase ;
retval . top = ybase ;
retval . right = xend ;
retval . bottom = yend ;
return retval ;
}
static Common : : Rect nsrect_clip ( EngineState * s , int y , Common : : Rect retval , int priority ) {
int pri_top ;
if ( priority = = - 1 )
priority = _find_view_priority ( s , y ) ;
pri_top = _find_priority_band ( s , priority ) + 1 ;
// +1: Don't know why, but this seems to be happening
if ( retval . top < pri_top )
retval . top = pri_top ;
if ( retval . bottom < retval . top )
retval . top = retval . bottom - 1 ;
return retval ;
}
static Common : : Rect calculate_nsrect ( EngineState * s , int x , int y , int view , int loop , int cel ) {
int xbase , ybase , xend , yend , xsize , ysize ;
int xmod = 0 , ymod = 0 ;
Common : : Rect retval ( 0 , 0 , 0 , 0 ) ;
Common : : Point offset = Common : : Point ( 0 , 0 ) ;
gfxop_get_cel_parameters ( s - > gfx_state , view , loop , cel , & xsize , & ysize , & offset ) ;
xmod = offset . x ;
ymod = offset . y ;
xbase = x - xmod - ( xsize > > 1 ) ;
xend = xbase + xsize ;
yend = y - ymod + 1 ; // +1: magic modifier
ybase = yend - ysize ;
retval . left = xbase ;
retval . top = ybase ;
retval . right = xend ;
retval . bottom = yend ;
return retval ;
}
Common : : Rect get_nsrect ( EngineState * s , reg_t object , byte clip ) {
SegManager * segMan = s - > _segMan ;
int x , y , z ;
int view , loop , cel ;
Common : : Rect retval ;
x = ( int16 ) GET_SEL32V ( object , x ) ;
y = ( int16 ) GET_SEL32V ( object , y ) ;
if ( s - > _kernel - > _selectorCache . z > - 1 )
z = ( int16 ) GET_SEL32V ( object , z ) ;
else
z = 0 ;
y - = z ; // Subtract z offset
view = ( int16 ) GET_SEL32V ( object , view ) ;
loop = sign_extend_byte ( ( int16 ) GET_SEL32V ( object , loop ) ) ;
cel = sign_extend_byte ( ( int16 ) GET_SEL32V ( object , cel ) ) ;
retval = calculate_nsrect ( s , x , y , view , loop , cel ) ;
if ( clip ) {
int priority = ( int16 ) GET_SEL32V ( object , priority ) ;
return nsrect_clip ( s , y , retval , priority ) ;
}
return retval ;
}
// ======================================================================================================
- 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 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > setCursorPos ( 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 ;
}
2009-10-07 21:29:47 +00:00
s - > _gui - > setCursorShape ( 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-10-07 14:53:15 +00:00
if ( argv [ 0 ] . isNull ( ) )
2009-10-07 21:29:47 +00:00
s - > _gui - > hideCursor ( ) ;
2009-10-07 14:53:15 +00:00
else
2009-10-07 21:29:47 +00:00
s - > _gui - > showCursor ( ) ;
2009-05-29 08:25:42 +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 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > setCursorPos ( 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 ) ;
2009-10-07 21:29:47 +00:00
s - > _cursor - > setMoveZone ( 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 :
2009-10-13 17:09:32 +00:00
s - > _gui - > setCursorView ( 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 ) {
2009-08-30 01:37:52 +00:00
switch ( s - > detectSetCursorType ( ) ) {
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 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > moveCursor ( 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 kShow ( EngineState * s , int argc , reg_t * argv ) {
2009-02-15 06:10:59 +00:00
int old_map = s - > pic_visible_map ;
2009-06-07 16:50:34 +00:00
s - > pic_visible_map = ( argc > 0 ) ? ( gfx_map_mask_t ) argv [ 0 ] . toUint16 ( ) : GFX_MASK_VISUAL ;
2009-02-15 06:10:59 +00:00
switch ( s - > pic_visible_map ) {
case GFX_MASK_VISUAL :
case GFX_MASK_PRIORITY :
case GFX_MASK_CONTROL :
gfxop_set_visible_map ( s - > gfx_state , s - > pic_visible_map ) ;
if ( old_map ! = s - > pic_visible_map ) {
2009-02-19 20:50:55 +00:00
if ( s - > pic_visible_map = = GFX_MASK_VISUAL ) // Full widget redraw
2009-04-24 14:22:14 +00:00
s - > visual - > draw ( Common : : Point ( 0 , 0 ) ) ;
2009-02-15 06:10:59 +00:00
gfxop_update ( s - > gfx_state ) ;
2009-07-06 10:39:22 +00:00
debugC ( 2 , kDebugLevelGraphics , " Switching visible map to %x \n " , s - > pic_visible_map ) ;
2009-02-15 06:10:59 +00:00
}
break ;
default :
2009-02-20 20:11:12 +00:00
warning ( " Show(%x) selects unknown map " , s - > pic_visible_map ) ;
2009-02-15 06:10:59 +00:00
}
s - > pic_not_valid = 2 ;
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
2009-10-12 07:30:55 +00:00
return make_reg ( 0 , s - > _gui - > picNotValid ( newPicNotValid ) ) ;
2009-02-15 06:10:59 +00:00
}
2009-10-12 12:38:58 +00:00
void kGraphCreateRect ( int16 x , int16 y , int16 x1 , int16 y1 , Common : : Rect * destRect ) {
if ( x > x1 ) SWAP ( x , x1 ) ;
if ( y > y1 ) SWAP ( y , y1 ) ;
* destRect = Common : : Rect ( x , y , x1 , y1 ) ;
}
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-03 20:49:18 +00:00
uint16 flags ;
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 :
2009-09-02 12:02:37 +00:00
return make_reg ( 0 , ! s - > resMan - > isVGA ( ) ? 0x10 : 0x100 ) ;
2009-02-15 06:10:59 +00:00
break ;
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
2009-10-07 21:29:47 +00:00
s - > _gui - > graphDrawLine ( 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 :
2009-10-12 12:38:58 +00:00
kGraphCreateRect ( x , y , x1 , y1 , & rect ) ;
2009-10-03 20:49:18 +00:00
flags = ( argc > 5 ) ? argv [ 5 ] . toUint16 ( ) : 0 ;
2009-10-07 21:29:47 +00:00
return s - > _gui - > graphSaveBox ( rect , flags ) ;
2009-02-15 06:10:59 +00:00
case K_GRAPH_RESTORE_BOX :
2009-10-07 21:29:47 +00:00
s - > _gui - > graphRestoreBox ( argv [ 1 ] ) ;
2009-02-15 06:10:59 +00:00
break ;
case K_GRAPH_FILL_BOX_BACKGROUND :
2009-10-12 12:38:58 +00:00
kGraphCreateRect ( x , y , x1 , y1 , & rect ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > graphFillBoxBackground ( rect ) ;
2009-02-15 06:10:59 +00:00
break ;
case K_GRAPH_FILL_BOX_FOREGROUND :
2009-10-12 12:38:58 +00:00
kGraphCreateRect ( x , y , x1 , y1 , & rect ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > graphFillBoxForeground ( 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
2009-10-05 13:33:26 +00:00
rect = Common : : Rect ( x , y , x1 , y1 ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > graphFillBox ( rect , colorMask , color , priority , control ) ;
2009-10-03 20:49:18 +00:00
break ;
2009-02-15 06:10:59 +00:00
2009-10-12 12:42:50 +00:00
case K_GRAPH_UPDATE_BOX :
2009-10-12 12:38:58 +00:00
kGraphCreateRect ( x , y , x1 , y1 , & rect ) ;
2009-10-12 07:11:22 +00:00
s - > _gui - > graphUpdateBox ( rect ) ;
break ;
2009-02-15 06:10:59 +00:00
2009-10-12 12:42:50 +00:00
case K_GRAPH_REDRAW_BOX :
2009-10-12 12:38:58 +00:00
kGraphCreateRect ( x , y , x1 , y1 , & rect ) ;
2009-10-12 11:36:42 +00:00
s - > _gui - > graphRedrawBox ( rect ) ;
break ;
2009-02-15 06:10:59 +00:00
case K_GRAPH_ADJUST_PRIORITY :
2009-06-07 15:53:30 +00:00
debugC ( 2 , kDebugLevelGraphics , " adjust_priority(%d, %d) \n " , argv [ 1 ] . toSint16 ( ) , argv [ 2 ] . toSint16 ( ) ) ;
s - > priority_first = argv [ 1 ] . toSint16 ( ) - 10 ;
s - > priority_last = argv [ 2 ] . toSint16 ( ) - 10 ;
2009-02-15 06:10:59 +00:00
break ;
default :
2009-10-12 12:42:50 +00:00
error ( " Unsupported kGraph() operation %04x " , argv [ 0 ] . toSint16 ( ) ) ;
2009-02-15 06:10:59 +00:00
}
gfxop_update ( s - > gfx_state ) ;
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 ) ;
2009-05-30 15:40:49 +00:00
debugC ( 2 , kDebugLevelStrings , " GetTextSize: Empty string \n " ) ;
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 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > textSize ( s - > strSplit ( text . c_str ( ) , sep ) . c_str ( ) , font_nr , maxwidth , & textWidth , & textHeight ) ;
2009-10-03 20:49:18 +00:00
debugC ( 2 , kDebugLevelStrings , " GetTextSize '%s' -> %dx%d \n " , text . c_str ( ) , textWidth , textHeight ) ;
2009-02-15 06:10:59 +00:00
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-10-03 20:49:18 +00:00
#if 0
uint32 time ;
2009-02-15 06:10:59 +00:00
2009-02-21 15:40:14 +00:00
time = g_system - > getMillis ( ) ;
2009-02-21 23:16:03 +00:00
s - > r_acc = make_reg ( 0 , ( ( long ) time - ( long ) s - > last_wait_time ) * 60 / 1000 ) ;
2009-02-21 15:40:14 +00:00
s - > last_wait_time = time ;
2009-02-15 06:10:59 +00:00
2009-06-04 11:28:05 +00:00
sleep_time * = g_debug_sleeptime_factor ;
2009-08-31 14:24:35 +00:00
gfxop_sleep ( s - > gfx_state , sleep_time * 1000 / 60 ) ;
2009-02-15 06:10:59 +00:00
2009-08-11 20:18:15 +00:00
// Reset speed throttler: Game is playing along nicely anyway
if ( sleep_time > 0 )
s - > speedThrottler - > reset ( ) ;
2009-10-03 20:49:18 +00:00
# endif
// FIXME: we should not be asking from the GUI to wait. The kernel sounds
// like a better place
2009-10-07 21:29:47 +00:00
s - > _gui - > 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 ) ) {
return make_reg ( 0 , s - > _gui - > coordinateToPriority ( y ) ) ;
} else {
int16 priority = argv [ 1 ] . toSint16 ( ) ;
return make_reg ( 0 , s - > _gui - > priorityToCoordinate ( 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 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
2009-10-09 13:15:37 +00:00
return make_reg ( 0 , s - > _gui - > priorityToCoordinate ( 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 ;
}
2009-03-18 16:43:12 +00:00
static Common : : Rect nsrect_clip ( EngineState * s , int y , Common : : Rect retval , int 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 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 ;
2009-02-15 06:10:59 +00:00
2009-10-09 16:51:10 +00:00
if ( s - > _gui - > canBeHere ( curObject , listReference ) )
return make_reg ( 0 , 1 ) ;
return NULL_REG ;
}
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 ) {
reg_t result = kCanBeHere ( s , argc , argv ) ;
2009-09-17 13:22:00 +00:00
result . offset = ! result . offset ;
return 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 kIsItSkip ( EngineState * s , int argc , reg_t * argv ) {
2009-06-07 15:53:30 +00:00
int view = argv [ 0 ] . toSint16 ( ) ;
int loop = argv [ 1 ] . toSint16 ( ) ;
int cel = argv [ 2 ] . toSint16 ( ) ;
int y = argv [ 3 ] . toUint16 ( ) ;
int x = argv [ 4 ] . toUint16 ( ) ;
2009-02-15 06:10:59 +00:00
gfxr_view_t * res = NULL ;
gfx_pixmap_t * pxm = NULL ;
2009-03-22 23:11:43 +00:00
res = s - > gfx_state - > gfxResMan - > getView ( view , & loop , & cel , 0 ) ;
2009-03-17 23:30:57 +00:00
if ( ! res ) {
2009-06-08 11:42:13 +00:00
warning ( " [GFX] Attempt to get cel parameters for invalid view %d " , view ) ;
2009-09-30 23:00:03 +00:00
return SIGNAL_REG ;
2009-02-15 06:10:59 +00:00
}
pxm = res - > loops [ loop ] . cels [ cel ] ;
2009-03-16 00:07:12 +00:00
if ( x > pxm - > index_width )
x = pxm - > index_width - 1 ;
if ( y > pxm - > index_height )
y = pxm - > index_height - 1 ;
2009-02-15 06:10:59 +00:00
2009-03-16 00:07:12 +00:00
return make_reg ( 0 , pxm - > index_data [ y * pxm - > index_width + x ] = = pxm - > color_key ) ;
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-06-07 15:53:30 +00:00
int view = argv [ 0 ] . toSint16 ( ) ;
int loop = argv [ 1 ] . toSint16 ( ) ;
2009-10-12 15:13:15 +00:00
int cel = ( argc > = 3 ) ? argv [ 2 ] . toSint16 ( ) : 0 ;
2009-02-15 06:10:59 +00:00
int height , width ;
2009-02-17 19:15:37 +00:00
Common : : Point offset ;
2009-02-15 06:10:59 +00:00
2009-10-12 15:13:15 +00:00
if ( argc > 3 )
2009-10-12 13:10:25 +00:00
error ( " celHigh called with more than 3 parameters " ) ;
2009-02-15 06:10:59 +00:00
2009-09-04 15:04:13 +00:00
gfxop_get_cel_parameters ( s - > gfx_state , view , loop , cel , & width , & height , & offset ) ;
return make_reg ( 0 , height ) ;
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-06-07 15:53:30 +00:00
int view = argv [ 0 ] . toSint16 ( ) ;
int loop = argv [ 1 ] . toSint16 ( ) ;
2009-10-12 15:13:15 +00:00
int cel = ( argc > = 3 ) ? argv [ 2 ] . toSint16 ( ) : 0 ;
2009-02-15 06:10:59 +00:00
int height , width ;
2009-02-17 19:15:37 +00:00
Common : : Point offset ;
2009-02-15 06:10:59 +00:00
2009-10-12 15:13:15 +00:00
if ( argc > 3 )
2009-10-12 13:10:25 +00:00
error ( " celWide called with more than 3 parameters " ) ;
2009-02-15 06:10:59 +00:00
2009-09-04 15:04:13 +00:00
gfxop_get_cel_parameters ( s - > gfx_state , view , loop , cel , & width , & height , & offset ) ;
return make_reg ( 0 , width ) ;
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-04 18:38:18 +00:00
SegManager * segMan = s - > _segMan ;
2009-02-15 06:10:59 +00:00
reg_t obj = argv [ 0 ] ;
int view = GET_SEL32V ( obj , view ) ;
int loops_nr = gfxop_lookup_view_get_loops ( s - > gfx_state , view ) ;
if ( loops_nr < 0 ) {
2009-05-18 11:53:04 +00:00
error ( " view.%d (0x%x) not found " , view , view ) ;
2009-02-15 06:10:59 +00:00
return NULL_REG ;
}
2009-05-30 15:40:49 +00:00
debugC ( 2 , kDebugLevelGraphics , " NumLoops(view.%d) = %d \n " , view , loops_nr ) ;
2009-02-15 06:10:59 +00:00
return make_reg ( 0 , loops_nr ) ;
}
- 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-04 18:38:18 +00:00
SegManager * segMan = s - > _segMan ;
2009-02-15 06:10:59 +00:00
reg_t obj = argv [ 0 ] ;
int loop = GET_SEL32V ( obj , loop ) ;
int view = GET_SEL32V ( obj , view ) ;
int cel = 0xffff ;
2009-09-04 15:04:13 +00:00
gfxop_check_cel ( s - > gfx_state , view , & loop , & cel ) ;
2009-02-15 06:10:59 +00:00
2009-05-30 15:40:49 +00:00
debugC ( 2 , kDebugLevelGraphics , " NumCels(view.%d, %d) = %d \n " , view , loop , cel + 1 ) ;
2009-02-15 06:10:59 +00:00
return make_reg ( 0 , cel + 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
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 ) ) {
screenMask = GFX_MASK_CONTROL ;
} 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
}
2009-10-07 21:29:47 +00:00
return make_reg ( 0 , s - > _gui - > onControl ( screenMask , rect ) ) ;
2009-02-15 06:10:59 +00:00
}
2009-02-28 11:12:59 +00:00
void _k_view_list_free_backgrounds ( EngineState * s , ViewObject * list , int list_nr ) ;
2009-02-15 06:10:59 +00:00
2009-05-17 13:37:54 +00:00
# define K_DRAWPIC_FLAG_MIRRORED (1 << 14)
- 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-07 20:58:33 +00:00
int16 flags = 0 ;
int16 animationNr = - 1 ;
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 ) {
flags = argv [ 1 ] . toSint16 ( ) ;
animationNr = flags & 0xFF ;
if ( flags & K_DRAWPIC_FLAG_MIRRORED )
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 ;
2009-10-08 14:37:55 +00:00
if ( ! s - > usesOldGfxFunctions ( ) )
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
2009-10-07 21:29:47 +00:00
s - > _gui - > drawPicture ( pictureId , animationNr , 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 ] ;
2009-10-10 10:48:46 +00:00
if ( lookup_selector ( s - > _segMan , object , s - > _kernel - > _selectorCache . brLeft , NULL , NULL ) = = kSelectorVariable ) {
// Note: there was a check here for a very old version of SCI, which supposedly needed
// to subtract 1 from absrect.top. The original check was for version 0.000.256, which
// does not exist (earliest one was KQ4 SCI, version 0.000.274). This code is left here
// for reference only
#if 0
if ( getSciVersion ( ) < = SCI_VERSION_0 )
- - absrect . top ; // Compensate for early SCI OB1 'bug'
# endif
Common : : Rect absrect = set_base ( s , object ) ;
SegManager * segMan = s - > _segMan ;
PUT_SEL32V ( object , brLeft , absrect . left ) ;
PUT_SEL32V ( object , brRight , absrect . right ) ;
PUT_SEL32V ( object , brTop , absrect . top ) ;
PUT_SEL32V ( object , brBottom , absrect . bottom ) ;
}
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
2009-02-19 20:50:55 +00:00
} // kBaseSetter
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 ) {
2009-10-07 21:29:47 +00:00
s - > _gui - > setNowSeen ( argv [ 0 ] ) ;
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 ) {
2009-10-03 20:49:18 +00:00
// warning("kPalette %d", argv[0].toUint16());
2009-06-07 15:53:30 +00:00
switch ( argv [ 0 ] . toUint16 ( ) ) {
2009-03-29 15:08:50 +00:00
case 1 :
2009-10-03 20:49:18 +00:00
if ( argc = = 3 ) {
int resourceNo = argv [ 1 ] . toUint16 ( ) ;
int flags = argv [ 2 ] . toUint16 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > paletteSet ( resourceNo , flags ) ;
2009-10-03 20:49:18 +00:00
}
2009-03-29 15:08:50 +00:00
break ;
case 2 :
2009-05-16 14:24:12 +00:00
debug ( 5 , " STUB: kPalette() effect 2, set flag to colors " ) ;
2009-03-29 15:08:50 +00:00
break ;
case 3 :
2009-05-16 14:24:12 +00:00
debug ( 5 , " STUB: kPalette() effect 3, clear flag to colors " ) ;
2009-03-29 15:08:50 +00:00
break ;
2009-10-04 19:49:47 +00:00
case 4 : { // Set palette intensity
if ( argc > = 4 ) {
int fromColor = CLIP < int > ( 1 , 255 , argv [ 1 ] . toUint16 ( ) ) ;
int toColor = CLIP < int > ( 1 , 255 , argv [ 2 ] . toUint16 ( ) ) ;
int intensity = argv [ 3 ] . toUint16 ( ) ;
bool setPalette = ( argc < 5 ) ? true : ( argv [ 5 ] . isNull ( ) ) ? true : false ;
2009-10-07 21:29:47 +00:00
s - > _gui - > paletteSetIntensity ( fromColor , toColor , intensity , setPalette ) ;
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-06-07 15:53:30 +00:00
int r = argv [ 1 ] . toUint16 ( ) ;
int g = argv [ 2 ] . toUint16 ( ) ;
int b = argv [ 3 ] . toUint16 ( ) ;
2009-02-15 06:10:59 +00:00
2009-10-07 21:29:47 +00:00
return make_reg ( 0 , s - > _gui - > paletteFind ( r , g , b ) ) ;
2009-02-15 06:10:59 +00:00
}
2009-03-29 15:08:50 +00:00
case 6 :
2009-10-03 20:49:18 +00:00
if ( argc = = 4 ) {
int fromColor = argv [ 1 ] . toUint16 ( ) ;
int toColor = argv [ 2 ] . toUint16 ( ) ;
int speed = argv [ 3 ] . toSint16 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > paletteAnimate ( fromColor , toColor , speed ) ;
2009-10-03 20:49:18 +00:00
}
2009-02-15 06:10:59 +00:00
break ;
2009-03-29 15:08:50 +00:00
case 7 :
2009-05-16 14:24:12 +00:00
debug ( 5 , " STUB: kPalette() effect 7, save palette to heap " ) ;
2009-03-29 15:08:50 +00:00
break ;
case 8 :
2009-05-16 14:24:12 +00:00
debug ( 5 , " STUB: kPalette() effect 8, set stored palette " ) ;
2009-03-29 15:08:50 +00:00
break ;
default :
2009-06-07 15:53:30 +00:00
warning ( " kPalette(): Unimplemented subfunction: %d " , 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-11 12:15:17 +00:00
// Control types and flags
enum {
K_CONTROL_BUTTON = 1 ,
K_CONTROL_TEXT = 2 ,
2009-10-11 14:28:20 +00:00
K_CONTROL_TEXTEDIT = 3 ,
2009-10-11 12:15:17 +00:00
K_CONTROL_ICON = 4 ,
2009-10-11 14:28:20 +00:00
K_CONTROL_LIST = 6 ,
K_CONTROL_LIST_ALIAS = 7 ,
2009-10-11 12:15:17 +00:00
K_CONTROL_BOX = 10
} ;
2009-09-13 00:08:17 +00:00
static void disableCertainButtons ( SegManager * segMan , Common : : String gameName , reg_t obj ) {
2009-02-15 22:28:12 +00:00
reg_t text_pos = GET_SEL32 ( obj , text ) ;
2009-09-27 01:50:26 +00:00
Common : : String text ;
if ( ! text_pos . isNull ( ) )
text = segMan - > getString ( text_pos ) ;
2009-02-15 06:10:59 +00:00
int type = GET_SEL32V ( obj , type ) ;
int state = GET_SEL32V ( obj , state ) ;
2009-04-09 08:49:42 +00:00
/*
* WORKAROUND : The function is a " prevent the user from doing something
* nasty " type of thing, and goes back to the ugly way in which savegame
* deletion is implemented in SCI ( and even worse in SQ4 / Floppy , for
* which the workaround is intended ) . The result is basically that you
* can ' t implement savegame deletion for SQ4 / Floppy unless you duplicate
* the exact naming scheme of savefiles ( i . e . savefiles must be named
* SQ4SG . < number > ) and the exact file format of the savegame index
* ( SQ4SG . DIR ) . From the earlier discussions on file I / O handling -
* before as well as after the merge - I gather that this is not an
2009-05-20 17:53:31 +00:00
* option .
*
2009-04-09 08:49:42 +00:00
* SQ4 / Floppy is special , being the first game to implement savegame
* deletion at all . For later games , we manage to implement deletion by
* using gross hacks in kDeviceInfo ( ) ( essentially repurposing a few
* subfunctions ) . I decided at the time that SQ4 / Floppy was not worth the
* effort ( see above ) , and to simply disable the delete functionality for
* that game - bringing the save / load dialog on a par with SCI0 .
*/
2009-09-13 00:08:17 +00:00
// NOTE: This _only_ works with the English version
2009-09-27 01:50:26 +00:00
if ( type = = K_CONTROL_BUTTON & & ( gameName = = " sq4 " ) & &
getSciVersion ( ) < SCI_VERSION_1_1 & & text = = " Delete " ) {
2009-09-13 00:08:17 +00:00
PUT_SEL32V ( obj , state , ( state | kControlStateDisabled ) & ~ kControlStateEnabled ) ;
}
// Disable the "Change Directory" button, as we don't allow the game engine to
// change the directory where saved games are placed
// NOTE: This _only_ works with the English version
2009-09-27 01:50:26 +00:00
if ( type = = K_CONTROL_BUTTON & & text = = " Change \r \n Directory " ) {
2009-03-25 12:07:10 +00:00
PUT_SEL32V ( obj , state , ( state | kControlStateDisabled ) & ~ kControlStateEnabled ) ;
2009-02-19 20:50:55 +00:00
}
2009-02-15 06:10:59 +00:00
}
2009-10-11 14:28:20 +00:00
void _k_GenericDrawControl ( EngineState * s , reg_t controlObject , bool hilite ) {
SegManager * segMan = s - > _segMan ;
int16 type = GET_SEL32V ( controlObject , type ) ;
2009-10-11 15:41:52 +00:00
int16 style = GET_SEL32V ( controlObject , state ) ;
2009-10-11 14:28:20 +00:00
int16 x = GET_SEL32V ( controlObject , nsLeft ) ;
int16 y = GET_SEL32V ( controlObject , nsTop ) ;
GuiResourceId fontId = GET_SEL32V ( controlObject , font ) ;
reg_t textReference = GET_SEL32 ( controlObject , text ) ;
Common : : String text ;
Common : : Rect rect ;
int16 mode , maxChars , cursorPos , upperPos , listCount , i ;
int16 upperOffset , cursorOffset ;
GuiResourceId viewId ;
GuiViewLoopNo loopNo ;
GuiViewCelNo celNo ;
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
rect = Common : : Rect ( x , y , ( int16 ) GET_SEL32V ( controlObject , nsRight ) , ( int16 ) GET_SEL32V ( controlObject , nsBottom ) ) ;
if ( ! textReference . isNull ( ) )
text = segMan - > getString ( textReference ) ;
switch ( type ) {
case K_CONTROL_BUTTON :
debugC ( 2 , kDebugLevelGraphics , " drawing button %04x:%04x to %d,%d \n " , PRINT_REG ( controlObject ) , x , y ) ;
2009-10-11 15:41:52 +00:00
s - > _gui - > drawControlButton ( rect , controlObject , s - > strSplit ( text . c_str ( ) , NULL ) . c_str ( ) , fontId , style , hilite ) ;
2009-10-11 14:28:20 +00:00
return ;
case K_CONTROL_TEXT :
mode = GET_SEL32V ( controlObject , mode ) ;
debugC ( 2 , kDebugLevelGraphics , " drawing text %04x:%04x ('%s') to %d,%d, mode=%d \n " , PRINT_REG ( controlObject ) , text . c_str ( ) , x , y , mode ) ;
2009-10-11 15:41:52 +00:00
s - > _gui - > drawControlText ( rect , controlObject , s - > strSplit ( text . c_str ( ) , NULL ) . c_str ( ) , fontId , mode , style , hilite ) ;
2009-10-11 14:28:20 +00:00
return ;
case K_CONTROL_TEXTEDIT :
mode = GET_SEL32V ( controlObject , mode ) ;
maxChars = GET_SEL32V ( controlObject , max ) ;
cursorPos = GET_SEL32V ( controlObject , cursor ) ;
debugC ( 2 , kDebugLevelGraphics , " drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d \n " , PRINT_REG ( controlObject ) , PRINT_REG ( textReference ) , text . c_str ( ) , x , y ) ;
2009-10-11 15:41:52 +00:00
s - > _gui - > drawControlTextEdit ( rect , controlObject , s - > strSplit ( text . c_str ( ) , NULL ) . c_str ( ) , fontId , mode , style , cursorPos , maxChars , hilite ) ;
2009-10-11 14:28:20 +00:00
return ;
case K_CONTROL_ICON :
viewId = GET_SEL32V ( controlObject , view ) ;
loopNo = sign_extend_byte ( GET_SEL32V ( controlObject , loop ) ) ;
celNo = sign_extend_byte ( GET_SEL32V ( controlObject , cel ) ) ;
debugC ( 2 , kDebugLevelGraphics , " drawing icon control %04x:%04x to %d,%d \n " , PRINT_REG ( controlObject ) , x , y - 1 ) ;
2009-10-11 15:41:52 +00:00
s - > _gui - > drawControlIcon ( rect , controlObject , viewId , loopNo , celNo , style , hilite ) ;
2009-10-11 14:28:20 +00:00
return ;
case K_CONTROL_LIST :
case K_CONTROL_LIST_ALIAS :
2009-10-11 15:41:52 +00:00
if ( type = = K_CONTROL_LIST_ALIAS )
isAlias = true ;
2009-10-11 14:28:20 +00:00
maxChars = GET_SEL32V ( controlObject , x ) ; // max chars per entry
// NOTE: most types of pointer dereferencing don't like odd offsets
if ( maxChars & 1 ) {
warning ( " List control with odd maxChars %d. This is not yet implemented for all types of segments " , maxChars ) ;
}
cursorOffset = GET_SEL32V ( controlObject , cursor ) ;
if ( s - > _kernel - > _selectorCache . topString ! = - 1 ) {
// Games from early SCI1 onwards use topString
upperOffset = GET_SEL32V ( controlObject , topString ) ;
} else {
// Earlier games use lsTop
upperOffset = GET_SEL32V ( controlObject , lsTop ) ;
}
// 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 ;
}
}
debugC ( 2 , kDebugLevelGraphics , " drawing list control %04x:%04x to %d,%d, diff %d \n " , PRINT_REG ( controlObject ) , x , y , SCI_MAX_SAVENAME_LENGTH ) ;
2009-10-11 15:41:52 +00:00
s - > _gui - > drawControlList ( rect , controlObject , maxChars , listCount , listEntries , fontId , style , upperPos , cursorPos , isAlias , hilite ) ;
2009-10-11 14:28:20 +00:00
free ( listEntries ) ;
delete [ ] listStrings ;
return ;
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-02-15 06:10:59 +00:00
2009-10-11 14:28:20 +00:00
disableCertainButtons ( s - > _segMan , s - > _gameName , controlObject ) ;
_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
2009-10-11 12:15:17 +00:00
if ( ! controlObject . isNull ( ) )
s - > _gui - > editControl ( controlObject , eventObject ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
2009-02-21 10:47:56 +00:00
void _k_view_list_mark_free ( EngineState * s , reg_t off ) {
2009-02-15 06:10:59 +00:00
if ( s - > dyn_views ) {
2009-04-24 14:20:31 +00:00
GfxDynView * w = ( GfxDynView * ) s - > dyn_views - > _contents ;
2009-02-15 06:10:59 +00:00
while ( w ) {
2009-04-24 10:45:09 +00:00
if ( w - > _ID = = off . segment
& & w - > _subID = = off . offset ) {
2009-06-06 11:38:20 +00:00
w - > under_bitsp . obj = NULL_REG ;
2009-02-15 06:10:59 +00:00
}
2009-04-24 14:20:31 +00:00
w = ( GfxDynView * ) w - > _next ;
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 kAddToPic ( EngineState * s , int argc , reg_t * argv ) {
2009-10-05 07:10:01 +00:00
GuiResourceId viewId ;
GuiViewLoopNo loopNo ;
GuiViewCelNo 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 ) {
case 0 :
break ;
case 1 :
2009-10-07 21:29:47 +00:00
s - > _gui - > addToPicList ( 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 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > addToPicView ( 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 ) {
2009-10-07 21:29:47 +00:00
return s - > _gui - > getPort ( ) ;
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 ) {
2009-10-03 20:49:18 +00:00
uint16 portPtr ;
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 :
2009-10-03 20:49:18 +00:00
portPtr = argv [ 0 ] . toSint16 ( ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > setPort ( portPtr ) ;
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 ;
s - > _gui - > setPortPic ( 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 ( ) ;
GuiViewLoopNo loopNo = argv [ 1 ] . toSint16 ( ) ;
GuiViewCelNo celNo = argv [ 2 ] . toSint16 ( ) ;
2009-06-07 15:53:30 +00:00
int x = argv [ 3 ] . toSint16 ( ) ;
int y = argv [ 4 ] . toSint16 ( ) ;
2009-10-03 20:49:18 +00:00
int priority = ( argc > 5 ) ? argv [ 5 ] . toUint16 ( ) : - 1 ;
int paletteNo = ( argc > 6 ) ? argv [ 6 ] . toSint16 ( ) : 0 ;
2009-02-15 06:10:59 +00:00
2009-10-07 21:29:47 +00:00
s - > _gui - > drawCel ( viewId , loopNo , celNo , x , y , priority , paletteNo ) ;
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 ) {
2009-10-03 20:49:18 +00:00
int goner_nr = argv [ 0 ] . toSint16 ( ) ;
int arg2 = ( argc ! = 2 | | argv [ 2 ] . toUint16 ( ) = = 0 ? 0 : 1 ) ;
2009-02-19 20:50:55 +00:00
2009-10-07 21:29:47 +00:00
s - > _gui - > disposeWindow ( goner_nr , arg2 ) ;
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 ;
2009-05-25 13:25:31 +00:00
int argextra = argc = = 13 ? 4 : 0 ; // Triggers in PQ3 and SCI1.1 games
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;
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 ] ) ;
2009-09-27 01:50:26 +00:00
title = s - > strSplit ( title . c_str ( ) , NULL ) ;
}
2009-02-15 06:10:59 +00:00
2009-10-07 21:29:47 +00:00
return s - > _gui - > newWindow ( 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-10-09 19:41:39 +00:00
// Take care of incoming events (kAnimate is called semi-regularly)
process_sound_events ( s ) ;
2009-10-07 21:29:47 +00:00
s - > _gui - > animate ( castListReference , cycle , 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 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
2009-10-11 08:52:23 +00:00
s - > _gui - > shakeScreen ( 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 + + ;
2009-02-15 06:10:59 +00:00
text = kernel_lookup_text ( s , textp , index ) ;
}
2009-10-07 21:29:47 +00:00
s - > _gui - > display ( s - > strSplit ( text . c_str ( ) ) . c_str ( ) , argc , argv ) ;
2009-02-15 06:10:59 +00:00
return s - > r_acc ;
}
2009-02-21 10:23:36 +00:00
2009-09-02 11:33:25 +00:00
static reg_t kShowMovie_Windows ( EngineState * s , int argc , reg_t * argv ) {
2009-10-04 18:38:18 +00:00
Common : : String filename = s - > _segMan - > getString ( argv [ 1 ] ) ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
Graphics : : AVIPlayer * player = new Graphics : : AVIPlayer ( g_system ) ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
if ( ! player - > open ( filename ) ) {
2009-09-27 01:50:26 +00:00
warning ( " Failed to open movie file %s " , filename . c_str ( ) ) ;
2009-08-30 19:47:47 +00:00
return s - > r_acc ;
}
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
uint32 startTime = g_system - > getMillis ( ) ;
bool play = true ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
while ( play & & player - > getCurFrame ( ) < player - > getFrameCount ( ) ) {
uint32 elapsed = g_system - > getMillis ( ) - startTime ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
if ( elapsed > = player - > getCurFrame ( ) * 1000 / player - > getFrameRate ( ) ) {
Graphics : : Surface * surface = player - > getNextFrame ( ) ;
Palette * palette = NULL ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
if ( player - > dirtyPalette ( ) ) {
byte * rawPalette = player - > getPalette ( ) ;
2009-09-09 08:19:16 +00:00
Palette * colors = new Palette ( 256 ) ;
byte r , g , b ;
2009-08-30 19:47:47 +00:00
for ( uint16 i = 0 ; i < 256 ; i + + ) {
2009-09-09 08:19:16 +00:00
r = rawPalette [ i * 4 ] ;
g = rawPalette [ i * 4 + 1 ] ;
b = rawPalette [ i * 4 + 2 ] ;
colors - > setColor ( i , r , g , b ) ;
2009-08-30 19:47:47 +00:00
}
palette - > forceInto ( s - > gfx_state - > driver - > getMode ( ) - > palette ) ;
}
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
if ( surface ) {
// Allocate a pixmap
gfx_pixmap_t * pixmap = gfx_new_pixmap ( surface - > w , surface - > h , 0 , 0 , 0 ) ;
assert ( pixmap ) ;
gfx_pixmap_alloc_index_data ( pixmap ) ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
// Copy data from the surface
memcpy ( pixmap - > index_data , surface - > pixels , surface - > w * surface - > h ) ;
pixmap - > xoffset = ( g_system - > getWidth ( ) - surface - > w ) / 2 ;
pixmap - > yoffset = ( g_system - > getHeight ( ) - surface - > h ) / 2 ;
pixmap - > palette = palette ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
// Copy the frame to the screen
2009-09-04 09:44:06 +00:00
gfx_xlate_pixmap ( pixmap , s - > gfx_state - > driver - > getMode ( ) ) ;
2009-08-31 14:24:35 +00:00
gfxop_draw_pixmap ( s - > gfx_state , pixmap , gfx_rect ( 0 , 0 , 320 , 200 ) , Common : : Point ( pixmap - > xoffset , pixmap - > yoffset ) ) ;
2009-08-30 19:47:47 +00:00
gfxop_update_box ( s - > gfx_state , gfx_rect ( 0 , 0 , 320 , 200 ) ) ;
gfx_free_pixmap ( pixmap ) ;
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
// Surface is freed when the codec in the video is deleted
}
}
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
Common : : Event event ;
while ( g_system - > getEventManager ( ) - > pollEvent ( event ) ) {
switch ( event . type ) {
case Common : : EVENT_QUIT :
play = false ;
quit_vm ( ) ;
break ;
default :
break ;
}
}
2009-10-07 21:25:31 +00:00
2009-08-30 19:47:47 +00:00
g_system - > delayMillis ( 10 ) ;
}
delete player ;
return s - > r_acc ;
}
2009-09-02 11:33:25 +00:00
static reg_t kShowMovie_DOS ( EngineState * s , int argc , reg_t * argv ) {
2009-10-04 18:38:18 +00:00
Common : : String filename = s - > _segMan - > getString ( argv [ 0 ] ) ;
2009-08-25 00:18:11 +00:00
int delay = argv [ 1 ] . toUint16 ( ) ; // Time between frames in ticks
2009-05-25 11:14:42 +00:00
int frameNr = 0 ;
2009-05-21 22:03:23 +00:00
SeqDecoder seq ;
2009-05-26 00:03:41 +00:00
if ( ! seq . loadFile ( filename ) & & ! seq . loadFile ( Common : : String ( " SEQ/ " ) + filename ) ) {
2009-09-27 01:50:26 +00:00
warning ( " Failed to open movie file %s " , filename . c_str ( ) ) ;
2009-05-21 22:03:23 +00:00
return s - > r_acc ;
}
bool play = true ;
while ( play ) {
2009-08-25 00:18:11 +00:00
uint32 startTime = g_system - > getMillis ( ) ;
2009-05-21 22:03:23 +00:00
gfx_pixmap_t * pixmap = seq . getFrame ( play ) ;
2009-05-25 11:14:42 +00:00
if ( frameNr + + = = 0 )
2009-06-06 10:21:48 +00:00
pixmap - > palette - > forceInto ( s - > gfx_state - > driver - > getMode ( ) - > palette ) ;
2009-05-25 11:14:42 +00:00
2009-09-04 09:44:06 +00:00
gfx_xlate_pixmap ( pixmap , s - > gfx_state - > driver - > getMode ( ) ) ;
2009-08-31 14:24:35 +00:00
gfxop_draw_pixmap ( s - > gfx_state , pixmap , gfx_rect ( 0 , 0 , 320 , 200 ) , Common : : Point ( pixmap - > xoffset , pixmap - > yoffset ) ) ;
2009-05-21 22:03:23 +00:00
gfxop_update_box ( s - > gfx_state , gfx_rect ( 0 , 0 , 320 , 200 ) ) ;
gfx_free_pixmap ( pixmap ) ;
// Wait before showing the next frame
2009-08-25 00:18:11 +00:00
while ( play & & ( g_system - > getMillis ( ) < startTime + ( delay * 1000 / 60 ) ) ) {
2009-05-21 22:03:23 +00:00
// FIXME: we should probably make a function that handles quitting in these kinds of situations
Common : : Event curEvent ;
Common : : EventManager * eventMan = g_system - > getEventManager ( ) ;
// Process quit events
while ( eventMan - > pollEvent ( curEvent ) ) {
if ( curEvent . type = = Common : : EVENT_QUIT ) {
play = false ;
quit_vm ( ) ;
}
}
g_system - > delayMillis ( 10 ) ;
}
}
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 kShowMovie ( EngineState * s , int argc , reg_t * argv ) {
2009-08-30 19:47:47 +00:00
// KQ6 Windows calls this with one argument. It doesn't seem
// to have a purpose...
if ( argc = = 1 )
return NULL_REG ;
// The Windows and DOS versions use different video format as well
// as a different argument set.
if ( argv [ 0 ] . toUint16 ( ) = = 0 )
2009-09-02 11:33:25 +00:00
return kShowMovie_Windows ( s , argc , argv ) ;
2009-08-30 19:47:47 +00:00
2009-09-02 11:33:25 +00:00
return kShowMovie_DOS ( s , argc , argv ) ;
2009-08-30 19:47:47 +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-06-07 15:53:30 +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 ) {
2009-10-07 21:29:47 +00:00
s - > _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 ) {
2009-10-07 21:29:47 +00:00
s - > _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