[Scummvm-cvs-logs] SF.net SVN: scummvm:[41340] scummvm/trunk/engines/sci/engine

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Jun 7 18:50:34 CEST 2009


Revision: 41340
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41340&view=rev
Author:   thebluegr
Date:     2009-06-07 16:50:34 +0000 (Sun, 07 Jun 2009)

Log Message:
-----------
Replaced KP_ALT, SKPV_OR_ALT and UKPV_OR_ALT

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/kmath.cpp
    scummvm/trunk/engines/sci/engine/kmenu.cpp
    scummvm/trunk/engines/sci/engine/kmisc.cpp
    scummvm/trunk/engines/sci/engine/kmovement.cpp
    scummvm/trunk/engines/sci/engine/kpathing.cpp
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/ksound.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-06-07 16:50:34 UTC (rev 41340)
@@ -204,11 +204,6 @@
 
 /* Returns the parameter value or (alt) if not enough parameters were supplied */
 
-#define KP_ALT(x, alt) ((x < argc)? argv[x] : (alt))
-
-#define SKPV_OR_ALT(x,a) KP_ALT(x, make_reg(0, a)).toSint16()
-#define UKPV_OR_ALT(x,a) KP_ALT(x, make_reg(0, a)).toUint16()
-
 reg_t *kernel_dereference_reg_pointer(EngineState *s, reg_t pointer, int entries);
 byte *kernel_dereference_bulk_pointer(EngineState *s, reg_t pointer, int entries);
 #define kernel_dereference_char_pointer(state, pointer, entries) (char*)kernel_dereference_bulk_pointer(state, pointer, entries)

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -397,7 +397,7 @@
 reg_t kShow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	int old_map = s->pic_visible_map;
 
-	s->pic_visible_map = (gfx_map_mask_t) UKPV_OR_ALT(0, 1);
+	s->pic_visible_map = (argc > 0) ? (gfx_map_mask_t) argv[0].toUint16() : GFX_MASK_VISUAL;
 
 	switch (s->pic_visible_map) {
 
@@ -501,11 +501,12 @@
 		break;
 
 	case K_GRAPH_DRAW_LINE: {
+		int16 priority = (argc > 6) ? argv[6].toSint16() : -1;
+		int16 control = (argc > 7) ? argv[7].toSint16() : -1;
+		gfx_color_t gfxcolor = graph_map_color(s, argv[5].toSint16(), priority, control);
 
-		gfx_color_t gfxcolor = graph_map_color(s, argv[5].toSint16(), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1));
-
 		debugC(2, kDebugLevelGraphics, "draw_line((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
-		          argv[2].toSint16(), argv[1].toSint16(), argv[4].toSint16(), argv[3].toSint16(), argv[5].toSint16(), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1), gfxcolor.mask);
+		          argv[2].toSint16(), argv[1].toSint16(), argv[4].toSint16(), argv[3].toSint16(), argv[5].toSint16(), priority, control, gfxcolor.mask);
 
 		redraw_port = 1;
 
@@ -551,13 +552,14 @@
 		break;
 
 	case K_GRAPH_FILL_BOX_ANY: {
+		int16 priority = (argc > 7) ? argv[7].toSint16() : -1;
+		int16 control = (argc > 8) ? argv[8].toSint16() : -1;
+		gfx_color_t color = graph_map_color(s, argv[6].toSint16(), priority, control);
 
-		gfx_color_t color = graph_map_color(s, argv[6].toSint16(), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1));
-
 		color.mask = (byte)argv[5].toUint16();
 
 		debugC(2, kDebugLevelGraphics, "fill_box_any((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
-		          argv[2].toSint16(), argv[1].toSint16(), argv[4].toSint16(), argv[3].toSint16(), argv[6].toSint16(), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1), argv[5].toUint16());
+		          argv[2].toSint16(), argv[1].toSint16(), argv[4].toSint16(), argv[3].toSint16(), argv[6].toSint16(), priority, control, argv[5].toUint16());
 
 		// FIXME/TODO: this is not right, as some of the dialogs are drawn *behind* some widgets. But at least it works for now
 		//ADD_TO_CURRENT_PICTURE_PORT(gfxw_new_box(s->gfx_state, area, color, color, GFX_BOX_SHADE_FLAT));	// old code
@@ -620,7 +622,7 @@
 	int width, height;
 	char *text = argv[1].segment ? (char *) kernel_dereference_bulk_pointer(s, argv[1], 0) : NULL;
 	reg_t *dest = kernel_dereference_reg_pointer(s, argv[0], 4);
-	int maxwidth = KP_ALT(3, NULL_REG).toUint16();
+	int maxwidth = (argc > 3) ? argv[3].toUint16() : 0;
 	int font_nr = argv[2].toUint16();
 
 	if (maxwidth < 0)
@@ -771,7 +773,7 @@
 
 reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	reg_t obj = argv[0];
-	reg_t cliplist_ref = KP_ALT(1, NULL_REG);
+	reg_t cliplist_ref = (argc > 1) ? argv[1] : NULL_REG;
 	List *cliplist = NULL;
 	GfxPort *port = s->picture_port;
 	uint16 signal;
@@ -987,24 +989,19 @@
 
 reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	drawn_pic_t dp;
-	int add_to_pic = 1;
+	bool add_to_pic = (argc > 2) ? !argv[2].toSint16() : false;
 	gfx_color_t transparent = s->wm_port->_bgcolor;
 	int picFlags = DRAWPIC01_FLAG_FILL_NORMALLY;
 
+	if (s->_flags & GF_SCI0_OLDGFXFUNCS)
+		add_to_pic = (argc > 2) ? argv[2].toSint16() : false;
+
 	dp.nr = argv[0].toSint16();
-	dp.palette = SKPV_OR_ALT(3, 0);
+	dp.palette = (argc > 3) ? argv[3].toSint16() : 0;
 
 	if ((argc > 1) && (argv[1].toUint16() & K_DRAWPIC_FLAG_MIRRORED))
 		picFlags |= DRAWPIC1_FLAG_MIRRORED;
 
-	if (s->_flags & GF_SCI0_OLDGFXFUNCS) {
-		if (!SKPV_OR_ALT(2, 0))
-			add_to_pic = 0;
-	} else {
-		if (SKPV_OR_ALT(2, 1))
-			add_to_pic = 0;
-	}
-
 	gfxop_disable_dirty_frames(s->gfx_state);
 
 	if (NULL != s->old_screen) {
@@ -2403,7 +2400,7 @@
 	int cel = argv[2].toSint16();
 	int x = argv[3].toSint16();
 	int y = argv[4].toSint16();
-	int priority = SKPV_OR_ALT(5, -1);
+	int priority = (argc > 5) ? argv[5].toSint16() : -1;
 	GfxView *new_view;
 
 /*
@@ -2490,14 +2487,16 @@
 
 	flags = argv[5 + argextra].toSint16();
 
-	priority = SKPV_OR_ALT(6 + argextra, -1);
+	priority = (argc > 6 + argextra) ? argv[6 + argextra].toSint16() : -1;
 	bgcolor.mask = 0;
 
-	if (SKPV_OR_ALT(8 + argextra, 255) >= 0) {
+	int16 bgColor = (argc > 8 + argextra) ? argv[8 + argextra].toSint16() : 255;
+
+	if (bgColor >= 0) {
 		if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA)
-			bgcolor.visual = get_pic_color(s, SKPV_OR_ALT(8 + argextra, 15));
+			bgcolor.visual = get_pic_color(s, MIN<int>(bgColor, 15));
 		else
-			bgcolor.visual = get_pic_color(s, SKPV_OR_ALT(8 + argextra, 255));
+			bgcolor.visual = get_pic_color(s, bgColor);
 		bgcolor.mask = GFX_MASK_VISUAL;
 	} else {
 		bgcolor.visual = PaletteEntry(0,0,0);
@@ -2509,7 +2508,8 @@
 	bgcolor.control = -1;
 	debugC(2, kDebugLevelGraphics, "New window with params %d, %d, %d, %d\n", argv[0].toSint16(), argv[1].toSint16(), argv[2].toSint16(), argv[3].toSint16());
 
-	fgcolor.visual = get_pic_color(s, SKPV_OR_ALT(7 + argextra, 0));
+	int16 visualColor = (argc > 7 + argextra) ? argv[7 + argextra].toSint16() : 0;
+	fgcolor.visual = get_pic_color(s, visualColor);
 	fgcolor.mask = GFX_MASK_VISUAL;
 	fgcolor.control = -1;
 	fgcolor.priority = -1;
@@ -2962,8 +2962,8 @@
 
 reg_t kAnimate(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	// Animations are supposed to take a maximum of animation_delay milliseconds.
-	reg_t cast_list_ref = KP_ALT(0, NULL_REG);
-	int cycle = (KP_ALT(1, NULL_REG)).offset;
+	reg_t cast_list_ref = (argc > 0) ? argv[0] : NULL_REG;
+	int cycle = (argc > 1) ? argv[1].toUint16() : 0;
 	List *cast_list = NULL;
 	int open_animation = 0;
 
@@ -3071,8 +3071,8 @@
 #define SHAKE_RIGHT 2
 
 reg_t kShakeScreen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
-	int shakes = SKPV_OR_ALT(0, 1);
-	int directions = SKPV_OR_ALT(1, 1);
+	int shakes = (argc > 0) ? argv[0].toSint16() : 1;
+	int directions = (argc > 1) ? argv[1].toSint16() : 1;
 	gfx_pixmap_t *screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 0, 320, 200));
 	int i;
 
@@ -3121,7 +3121,7 @@
 reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	int argpt;
 	reg_t textp = argv[0];
-	int index = UKPV_OR_ALT(1, 0);
+	int index = (argc > 1) ? argv[1].toUint16() : 0;
 	int temp;
 	bool save_under = false;
 	gfx_color_t transparent = { PaletteEntry(), 0, -1, -1, 0 };

Modified: scummvm/trunk/engines/sci/engine/kmath.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmath.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kmath.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -101,9 +101,11 @@
 }
 
 reg_t kGetDistance(EngineState *s, int funct_nr, int argc, reg_t *argv) {
-	int xrel = (int)(((float) argv[1].toSint16() - SKPV_OR_ALT(3, 0)) / cos(SKPV_OR_ALT(5, 0) * PI / 180.0)); // This works because cos(0)==1
-	int yrel = argv[0].toSint16() - SKPV_OR_ALT(2, 0);
-
+	int xdiff = (argc > 3) ? argv[3].toSint16() : 0;
+	int ydiff = (argc > 2) ? argv[2].toSint16() : 0;
+	int angle = (argc > 5) ? argv[5].toSint16() : 0;
+	int xrel = (int)(((float) argv[1].toSint16() - xdiff) / cos(angle * PI / 180.0)); // This works because cos(0)==1
+	int yrel = argv[0].toSint16() - ydiff;
 	return make_reg(0, (int16)sqrt((float) xrel*xrel + yrel*yrel));
 }
 
@@ -147,7 +149,7 @@
 
 reg_t kTimesTan(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	int param = argv[0].toSint16();
-	int scale = SKPV_OR_ALT(1, 1);
+	int scale = (argc > 1) ? argv[1].toSint16() : 1;
 
 	param -= 90;
 	if ((param % 90) == 0) {
@@ -159,7 +161,7 @@
 
 reg_t kTimesCot(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	int param = argv[0].toSint16();
-	int scale = SKPV_OR_ALT(1, 1);
+	int scale = (argc > 1) ? argv[1].toSint16() : 1;
 
 	if ((param % 90) == 0) {
 		warning("Attempted tan(pi/2)");

Modified: scummvm/trunk/engines/sci/engine/kmenu.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmenu.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kmenu.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -66,8 +66,8 @@
 
 reg_t kDrawStatus(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	reg_t text = argv[0];
-	int fgcolor = SKPV_OR_ALT(1, s->status_bar_foreground);
-	int bgcolor = SKPV_OR_ALT(2, s->status_bar_background);
+	int fgcolor = (argc > 1) ? argv[1].toSint16() : s->status_bar_foreground;
+	int bgcolor = (argc > 2) ? argv[2].toSint16() : s->status_bar_background;
 
 	s->titlebar_port->_color.visual = get_pic_color(s, fgcolor);
 	s->titlebar_port->_color.mask = GFX_MASK_VISUAL;
@@ -125,7 +125,7 @@
 
 reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	reg_t event = argv[0];
-	/*int pause_sound = UKPV_OR_ALT(1, 1);*/ /* FIXME: Do this eventually */
+	/*int pause_sound = (argc > 1) ? argv[1].toUint16() : 1;*/ /* FIXME: Do this eventually */
 	bool claimed = false;
 	int type = GET_SEL32V(event, type);
 	int message = GET_SEL32V(event, message);

Modified: scummvm/trunk/engines/sci/engine/kmisc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -127,7 +127,7 @@
 		return make_reg(0, retval);
 	}
 
-	int mode = argc > 0 ? UKPV_OR_ALT(0, 0) : 0;
+	int mode = (argc > 0) ? argv[0].toUint16() : 0;
 
 	switch (mode) {
 	case _K_NEW_GETTIME_TICKS :

Modified: scummvm/trunk/engines/sci/engine/kmovement.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmovement.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kmovement.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -223,8 +223,9 @@
 
 	int deltax = GET_SEL32SV(mover, x) - GET_SEL32SV(client, x);
 	int deltay = GET_SEL32SV(mover, y) - GET_SEL32SV(client, y);
+	int step_factor = (argc < 1) ? argv[1].toUint16() : 1;
 
-	initialize_bresen(s, argc, argv, mover, KP_ALT(1, make_reg(0, 1)).toUint16(), deltax, deltay);
+	initialize_bresen(s, argc, argv, mover, step_factor, deltax, deltay);
 
 	return s->r_acc;
 }

Modified: scummvm/trunk/engines/sci/engine/kpathing.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -1672,7 +1672,7 @@
 		Common::Point end = Common::Point(argv[2].toSint16(), argv[3].toSint16());
 		reg_t poly_list = argv[4];
 		//int poly_list_size = argv[5].toUint16();
-		int opt = UKPV_OR_ALT(6, 1);
+		int opt = (argc > 6) ? argv[6].toUint16() : 1;
 		reg_t output;
 		PathfindingState *p;
 

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -253,7 +253,7 @@
 // Returns script dispatch address index in the supplied script
 reg_t kScriptID(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	int script = argv[0].toUint16();
-	int index = KP_ALT(1, NULL_REG).toUint16();
+	int index = (argc > 1) ? argv[1].toUint16() : 0;
 
 	SegmentId scriptid = script_get_segment(s, script, SCRIPT_GET_LOAD);
 	Script *scr;

Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp	2009-06-07 16:44:57 UTC (rev 41339)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp	2009-06-07 16:50:34 UTC (rev 41340)
@@ -202,7 +202,7 @@
 
 
 reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
-	reg_t obj = KP_ALT(1, NULL_REG);
+	reg_t obj = (argc > 1) ? argv[1] : NULL_REG;
 	uint16 command = argv[0].toUint16();
 	song_handle_t handle = FROBNICATE_HANDLE(obj);
 	int number = obj.segment ?
@@ -335,7 +335,7 @@
 	case _K_SCI0_SOUND_VOLUME: {
 		/* range from 0x0 to 0xf */
 		/* parameter optional. If present, set.*/
-		int vol = SKPV_OR_ALT(1, -1);
+		int vol = (argc > 1) ? argv[1].toSint16() : -1;
 
 		if (vol != -1)
 			s->_sound.sfx_set_volume(vol << 0xf);
@@ -382,7 +382,7 @@
 
 reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	uint16 command = argv[0].toUint16();
-	reg_t obj = KP_ALT(1, NULL_REG);
+	reg_t obj = (argc > 1) ? argv[1] : NULL_REG;
 	song_handle_t handle = FROBNICATE_HANDLE(obj);
 	int number = obj.segment ?
 	             GET_SEL32V(obj, number) :
@@ -456,7 +456,7 @@
 
 	switch (command) {
 	case _K_SCI01_SOUND_MASTER_VOLME : {
-		int vol = SKPV_OR_ALT(1, -1);
+		int vol = (argc > 1) ? argv[1].toSint16() : -1;
 
 		if (vol != -1)
 			s->_sound.sfx_set_volume(vol << 0xf);
@@ -672,7 +672,7 @@
 
 reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	uint16 command = argv[0].toUint16();
-	reg_t obj = KP_ALT(1, NULL_REG);
+	reg_t obj = (argc > 1) ? argv[1] : NULL_REG;
 	song_handle_t handle = FROBNICATE_HANDLE(obj);
 	int number = obj.segment ?
 	             GET_SEL32V(obj, number) :


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list