diff options
author | Filippos Karapetis | 2009-06-07 16:50:34 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-06-07 16:50:34 +0000 |
commit | 3b687a7a04b08ab2c88b85fc265397f895b6ea6e (patch) | |
tree | 20638268c1b2be6cd468927e36d427ca2f00984b | |
parent | 36cdd09223aeb0b1839635e55e42131fc6834b3e (diff) | |
download | scummvm-rg350-3b687a7a04b08ab2c88b85fc265397f895b6ea6e.tar.gz scummvm-rg350-3b687a7a04b08ab2c88b85fc265397f895b6ea6e.tar.bz2 scummvm-rg350-3b687a7a04b08ab2c88b85fc265397f895b6ea6e.zip |
Replaced KP_ALT, SKPV_OR_ALT and UKPV_OR_ALT
svn-id: r41340
-rw-r--r-- | engines/sci/engine/kernel.h | 5 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 60 | ||||
-rw-r--r-- | engines/sci/engine/kmath.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/kmenu.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 3 | ||||
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 10 |
9 files changed, 50 insertions, 52 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 0ec47e4ce7..27d9df059d 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -204,11 +204,6 @@ bool is_object(EngineState *s, reg_t obj); /* 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) diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 5c3e481710..5a6f586cb5 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -397,7 +397,7 @@ reg_t kMoveCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) { break; case K_GRAPH_DRAW_LINE: { - - gfx_color_t gfxcolor = graph_map_color(s, argv[5].toSint16(), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1)); + 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); 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 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) { break; case K_GRAPH_FILL_BOX_ANY: { - - gfx_color_t color = graph_map_color(s, argv[6].toSint16(), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1)); + 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); 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 @@ reg_t kTextSize(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 @@ static int collides_with(EngineState *s, Common::Rect area, reg_t other_obj, int 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 @@ void _k_view_list_free_backgrounds(EngineState *s, ViewObject *list, int list_nr 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 @@ reg_t kDrawCel(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 @@ static void animate_do_animation(EngineState *s, int funct_nr, int argc, reg_t * 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 @@ reg_t kAnimate(EngineState *s, int funct_nr, int argc, reg_t *argv) { #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 kShakeScreen(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 }; diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp index 1cdf84c3d0..e4c314c605 100644 --- a/engines/sci/engine/kmath.cpp +++ b/engines/sci/engine/kmath.cpp @@ -101,9 +101,11 @@ reg_t kGetAngle(EngineState *s, int funct_nr, int argc, reg_t *argv) { } 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 kSinDiv(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 kTimesTan(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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)"); diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp index 50553341c6..c65d201b90 100644 --- a/engines/sci/engine/kmenu.cpp +++ b/engines/sci/engine/kmenu.cpp @@ -66,8 +66,8 @@ reg_t kGetMenu(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 @@ static int _menu_go_down(Menubar *menubar, int menu_nr, int item_nr) { 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); diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 68b72ec26c..7954dc5783 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -127,7 +127,7 @@ reg_t kGetTime(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 : diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 361228bedb..20a7be3aea 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -223,8 +223,9 @@ reg_t kInitBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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; } diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index a1f6b07d64..c254875230 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -1672,7 +1672,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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; diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 108f9e79ae..2479696630 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -253,7 +253,7 @@ reg_t kDisposeClone(EngineState *s, int funct_nr, int argc, reg_t *argv) { // 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; diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 9abead3f8c..970be1b683 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -202,7 +202,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their 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 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) { 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) : |