From 65f92d652588c27284ef0258327f760197c8a30a Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Thu, 19 Feb 2009 20:50:55 +0000 Subject: formating svn-id: r38564 --- engines/sci/engine/kgraphics.cpp | 1076 ++++++++++++++------------------------ 1 file changed, 393 insertions(+), 683 deletions(-) (limited to 'engines') diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 5feec224e9..d7842b260d 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -31,7 +31,7 @@ #undef DEBUG_LSRECT -/* Graph subfunctions */ +// Graph subfunctions #define K_GRAPH_GET_COLORS_NR 2 #define K_GRAPH_DRAW_LINE 4 #define K_GRAPH_SAVE_BOX 7 @@ -43,7 +43,7 @@ #define K_GRAPH_REDRAW_BOX 13 #define K_GRAPH_ADJUST_PRIORITY 14 -/* Control types and flags */ +// Control types and flags #define K_CONTROL_BUTTON 1 #define K_CONTROL_TEXT 2 #define K_CONTROL_EDIT 3 @@ -90,33 +90,29 @@ if (val == GFX_ERROR) \ SCIkwarn(SCIkWARNING, "GFX subsystem returned error on \"" #x "\"!\n"); \ else {\ - SCIkwarn(SCIkERROR, "GFX subsystem fatal error condition on \"" #x "\"!\n"); \ + SCIkwarn(SCIkERROR, "GFX subsystem fatal error condition on \"" #x "\"!\n"); \ vm_handle_fatal_error(s, __LINE__, __FILE__); \ - } \ - }\ + } \ + }\ } #define ASSERT(x) { \ - int val = !!(x); \ - if (!val) { \ - SCIkwarn(SCIkERROR, "Fatal error condition on \"" #x "\"!\n"); \ - BREAKPOINT(); \ - vm_handle_fatal_error(s, __LINE__, __FILE__); \ - } \ + int val = !!(x); \ + if (!val) { \ + SCIkwarn(SCIkERROR, "Fatal error condition on \"" #x "\"!\n"); \ + BREAKPOINT(); \ + vm_handle_fatal_error(s, __LINE__, __FILE__); \ + } \ } - -static inline int -sign_extend_byte(int value) { +static inline int sign_extend_byte(int value) { if (value & 0x80) return value - 256; else return value; } - -static void -assert_primary_widget_lists(state_t *s) { +static void assert_primary_widget_lists(state_t *s) { if (!s->dyn_views) { rect_t bounds = s->picture_port->bounds; @@ -134,8 +130,7 @@ assert_primary_widget_lists(state_t *s) { } } -static void -reparentize_primary_widget_lists(state_t *s, gfxw_port_t *newport) { +static void reparentize_primary_widget_lists(state_t *s, gfxw_port_t *newport) { if (!newport) newport = s->picture_port; @@ -146,28 +141,25 @@ reparentize_primary_widget_lists(state_t *s, gfxw_port_t *newport) { } } -int -_find_view_priority(state_t *s, int y) { - /* if (s->version <= SCI_VERSION_LTU_PRIORITY_OB1) - ++y; */ +int _find_view_priority(state_t *s, int y) { + /*if (s->version <= SCI_VERSION_LTU_PRIORITY_OB1) + ++y; */ - if (s->pic_priority_table) { /* SCI01 priority table set? */ + if (s->pic_priority_table) { // SCI01 priority table set? int j; for (j = 0; j < 15; j++) if (y < s->pic_priority_table[j+1]) return j; - return 14; /* Maximum */ + return 14; // Maximum } else { if (s->version >= SCI_VERSION_FTU_PRIORITY_14_ZONES) return SCI0_VIEW_PRIORITY_14_ZONES(y); else - return SCI0_VIEW_PRIORITY(y) == 15 ? 14 : - SCI0_VIEW_PRIORITY(y); + return SCI0_VIEW_PRIORITY(y) == 15 ? 14 : SCI0_VIEW_PRIORITY(y); } } -int -_find_priority_band(state_t *s, int nr) { +int _find_priority_band(state_t *s, int nr) { if (s->version >= SCI_VERSION_FTU_PRIORITY_14_ZONES && (nr < 0 || nr > 14)) { if (nr == 15) return 0xffff; @@ -182,7 +174,7 @@ _find_priority_band(state_t *s, int nr) { return 0; } - if (s->pic_priority_table) /* SCI01 priority table set? */ + if (s->pic_priority_table) // SCI01 priority table set? return s->pic_priority_table[nr]; else { int retval; @@ -192,14 +184,13 @@ _find_priority_band(state_t *s, int nr) { else retval = SCI0_PRIORITY_BAND_FIRST(nr); - /* if (s->version <= SCI_VERSION_LTU_PRIORITY_OB1) - --retval; */ +/* if (s->version <= SCI_VERSION_LTU_PRIORITY_OB1) + --retval; */ return retval; } } -reg_t -graph_save_box(state_t *s, rect_t area) { +reg_t graph_save_box(state_t *s, rect_t area) { reg_t handle = kalloc(s, "graph_save_box()", sizeof(gfxw_snapshot_t *)); gfxw_snapshot_t **ptr = (gfxw_snapshot_t **) kmem(s, handle); @@ -208,9 +199,7 @@ graph_save_box(state_t *s, rect_t area) { return handle; } - -void -graph_restore_box(state_t *s, reg_t handle) { +void graph_restore_box(state_t *s, reg_t handle) { gfxw_snapshot_t **ptr; int port_nr = s->port->ID; @@ -226,9 +215,8 @@ graph_restore_box(state_t *s, reg_t handle) { return; } - while (port_nr > 2 && !(s->port->flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) - && (gfxw_widget_matches_snapshot(*ptr, GFXW(s->port)))) { - /* This shouldn't ever happen, actually, since windows (ports w/ ID > 2) should all be immune */ + while (port_nr > 2 && !(s->port->flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) && (gfxw_widget_matches_snapshot(*ptr, GFXW(s->port)))) { + // This shouldn't ever happen, actually, since windows (ports w/ ID > 2) should all be immune gfxw_port_t *newport = gfxw_find_port(s->visual, port_nr); SCIkwarn(SCIkERROR, "Port %d is not immune against snapshots!\n", s->port->ID); port_nr--; @@ -274,8 +262,7 @@ graph_restore_box(state_t *s, reg_t handle) { static gfx_pixmap_color_t white = {GFX_COLOR_INDEX_UNMAPPED, 255, 255, 255}; -gfx_pixmap_color_t * -get_pic_color(state_t *s, int color) { +gfx_pixmap_color_t *get_pic_color(state_t *s, int color) { if (s->resmgr->sci_version < SCI_VERSION_01_VGA) return &(s->ega_colors[color].visual); @@ -284,15 +271,13 @@ get_pic_color(state_t *s, int color) { else if (color < KERNEL_COLORS_NR) return &(KERNEL_COLOR_PALETTE[color]); else { - SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", - color, s->gfx_state->pic_nr, KERNEL_COLORS_NR); + SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, KERNEL_COLORS_NR); BREAKPOINT(); - return NULL; /* Well, rather, not return. But gcc gets scared here. */ + return NULL; } } -static gfx_color_t -graph_map_color(state_t *s, int color, int priority, int control) { +static gfx_color_t graph_map_color(state_t *s, int color, int priority, int control) { gfx_color_t retval; if (s->resmgr->sci_version < SCI_VERSION_01_VGA) { @@ -304,20 +289,13 @@ graph_map_color(state_t *s, int color, int priority, int control) { retval.alpha = 0; retval.priority = priority; retval.control = control; - retval.mask = - GFX_MASK_VISUAL | - ((priority >= 0) ? GFX_MASK_PRIORITY : 0) | - ((control >= 0) ? GFX_MASK_CONTROL : 0); + retval.mask = GFX_MASK_VISUAL | ((priority >= 0) ? GFX_MASK_PRIORITY : 0) | ((control >= 0) ? GFX_MASK_CONTROL : 0); }; return retval; } -/* --- */ - - -reg_t -kSetCursor_SCI11(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kSetCursor_SCI11(state_t *s, int funct_nr, int argc, reg_t *argv) { switch (argc) { case 1 : if (UKPV(0) == 0) { @@ -360,8 +338,7 @@ kSetCursor_SCI11(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } -reg_t -kSetCursor(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kSetCursor(state_t *s, int funct_nr, int argc, reg_t *argv) { if (s->version >= SCI_VERSION(1, 001, 000) || has_kernel_function(s, "MoveCursor")) { return kSetCursor_SCI11(s, funct_nr, argc, argv); @@ -372,32 +349,28 @@ kSetCursor(state_t *s, int funct_nr, int argc, reg_t *argv) { } else s->mouse_pointer_view = GFXOP_NO_POINTER; - s->mouse_pointer_loop = s->mouse_pointer_cel = 0; /* Not used with cursor-format pointers */ + s->mouse_pointer_loop = s->mouse_pointer_cel = 0; // Not used with cursor-format pointers GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state, s->mouse_pointer_view)); if (argc > 2) { - Common::Point newpos = Common::Point(SKPV(2) + s->port->bounds.x, - SKPV(3) + s->port->bounds.y); - + Common::Point newpos = Common::Point(SKPV(2) + s->port->bounds.x, SKPV(3) + s->port->bounds.y); GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newpos)); } return s->r_acc; - } extern int oldx, oldy; -reg_t -kMoveCursor(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kMoveCursor(state_t *s, int funct_nr, int argc, reg_t *argv) { Common::Point newpos; static Common::Point oldpos(0, 0); newpos = s->gfx_state->pointer_pos; if (argc == 1) { - /* Case ignored on IBM PC */ + // Case ignored on IBM PC } else { newpos.x = SKPV(0) + s->port->zone.x; newpos.y = SKPV(1) + s->port->zone.y; @@ -418,14 +391,12 @@ kMoveCursor(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } -static inline void -_ascertain_port_contents(gfxw_port_t *port) { +static inline void _ascertain_port_contents(gfxw_port_t *port) { if (!port->contents) port->contents = (gfxw_widget_t *) gfxw_new_list(port->bounds, 0); } -reg_t -kShow(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kShow(state_t *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); @@ -438,7 +409,7 @@ kShow(state_t *s, int funct_nr, int argc, reg_t *argv) { gfxop_set_visible_map(s->gfx_state, s->pic_visible_map); if (old_map != s->pic_visible_map) { - if (s->pic_visible_map == GFX_MASK_VISUAL) /* Full widget redraw */ + if (s->pic_visible_map == GFX_MASK_VISUAL) // Full widget redraw s->visual->draw(GFXW(s->visual), Common::Point(0, 0)); gfxop_update(s->gfx_state); @@ -455,9 +426,7 @@ kShow(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } - -reg_t -kPicNotValid(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kPicNotValid(state_t *s, int funct_nr, int argc, reg_t *argv) { s->r_acc = make_reg(0, s->pic_not_valid); if (argc) s->pic_not_valid = (byte)UKPV(0); @@ -465,8 +434,7 @@ kPicNotValid(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } -void -_k_redraw_box(state_t *s, int x1, int y1, int x2, int y2) { +void _k_redraw_box(state_t *s, int x1, int y1, int x2, int y2) { sciprintf("_k_redraw_box(): Unimplemented!\n"); #if 0 int i; @@ -476,15 +444,9 @@ _k_redraw_box(state_t *s, int x1, int y1, int x2, int y2) { 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].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); } @@ -497,8 +459,7 @@ _k_redraw_box(state_t *s, int x1, int y1, int x2, int y2) { #endif } -void -_k_graph_rebuild_port_with_color(state_t *s, gfx_color_t newbgcolor) { +void _k_graph_rebuild_port_with_color(state_t *s, gfx_color_t newbgcolor) { gfxw_port_t *port = s->port; gfxw_port_t *newport; @@ -524,15 +485,14 @@ static int activated_icon_bar; static int port_origin_x; static int port_origin_y; -reg_t -kGraph(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kGraph(state_t *s, int funct_nr, int argc, reg_t *argv) { rect_t area; gfxw_port_t *port = s->port; int redraw_port = 0; area = gfx_rect(SKPV(2), SKPV(1) , SKPV(4), SKPV(3)); - area.xl = area.xl - area.x; /* Since the actual coordinates are absolute */ + area.xl = area.xl - area.x; // Since the actual coordinates are absolute area.yl = area.yl - area.y; switch (SKPV(0)) { @@ -547,12 +507,10 @@ kGraph(state_t *s, int funct_nr, int argc, reg_t *argv) { gfx_color_t gfxcolor = graph_map_color(s, SKPV(5) & 0xf, SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1)); SCIkdebug(SCIkGRAPHICS, "draw_line((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n", - SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(5), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1), - gfxcolor.mask); + SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(5), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1), gfxcolor.mask); redraw_port = 1; - ADD_TO_CURRENT_BG_WIDGETS(GFXW(gfxw_new_line(Common::Point(SKPV(2), SKPV(1)), - Common::Point(SKPV(4), SKPV(3)), + ADD_TO_CURRENT_BG_WIDGETS(GFXW(gfxw_new_line(Common::Point(SKPV(2), SKPV(1)), Common::Point(SKPV(4), SKPV(3)), gfxcolor, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); } @@ -596,8 +554,7 @@ kGraph(state_t *s, int funct_nr, int argc, reg_t *argv) { color.mask = (byte)UKPV(5); SCIkdebug(SCIkGRAPHICS, "fill_box_any((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n", - SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(6), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1), - UKPV(5)); + SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(6), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1), UKPV(5)); ADD_TO_CURRENT_BG_WIDGETS(gfxw_new_box(s->gfx_state, area, color, color, GFX_BOX_SHADE_FLAT)); @@ -606,8 +563,7 @@ kGraph(state_t *s, int funct_nr, int argc, reg_t *argv) { case K_GRAPH_UPDATE_BOX: { - SCIkdebug(SCIkGRAPHICS, "update_box(%d, %d, %d, %d)\n", - SKPV(1), SKPV(2), SKPV(3), SKPV(4)); + SCIkdebug(SCIkGRAPHICS, "update_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4)); area.x += s->port->zone.x; area.y += s->port->zone.y; @@ -620,8 +576,7 @@ kGraph(state_t *s, int funct_nr, int argc, reg_t *argv) { case K_GRAPH_REDRAW_BOX: { - SCIkdebug(SCIkGRAPHICS, "redraw_box(%d, %d, %d, %d)\n", - SKPV(1), SKPV(2), SKPV(3), SKPV(4)); + SCIkdebug(SCIkGRAPHICS, "redraw_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4)); area.x += s->port->zone.x; area.y += s->port->zone.y; @@ -652,12 +607,11 @@ kGraph(state_t *s, int funct_nr, int argc, reg_t *argv) { FULL_REDRAW(); gfxop_update(s->gfx_state); + return s->r_acc; } - -reg_t -kTextSize(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kTextSize(state_t *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); @@ -669,17 +623,14 @@ kTextSize(state_t *s, int funct_nr, int argc, reg_t *argv) { dest[0] = dest[1] = NULL_REG; - if (!text || !*text || !dest) { /* Empty text */ + if (!text || !*text || !dest) { // Empty text dest[2] = dest[3] = make_reg(0, 0); - SCIkdebug(SCIkSTRINGS, "GetTextSize: Empty string\n"); return s->r_acc; } - GFX_ASSERT(gfxop_get_text_params(s->gfx_state, font_nr, text, - maxwidth ? maxwidth : MAX_TEXT_WIDTH_MAGIC_VALUE, - &width, &height, 0, - NULL, NULL, NULL)); + GFX_ASSERT(gfxop_get_text_params(s->gfx_state, font_nr, text, maxwidth ? maxwidth : MAX_TEXT_WIDTH_MAGIC_VALUE, + &width, &height, 0, NULL, NULL, NULL)); SCIkdebug(SCIkSTRINGS, "GetTextSize '%s' -> %dx%d\n", text, width, height); dest[2] = make_reg(0, height); @@ -689,24 +640,20 @@ kTextSize(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } - int debug_sleeptime_factor = 1; -reg_t -kWait(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kWait(state_t *s, int funct_nr, int argc, reg_t *argv) { GTimeVal time; int sleep_time = UKPV(0); sci_get_current_time(&time); - s->r_acc = make_reg(0, ((time.tv_usec - s->last_wait_time.tv_usec) * 60 / 1000000) + - (time.tv_sec - s->last_wait_time.tv_sec) * 60); + s->r_acc = make_reg(0, ((time.tv_usec - s->last_wait_time.tv_usec) * 60 / 1000000) + (time.tv_sec - s->last_wait_time.tv_sec) * 60); memcpy(&(s->last_wait_time), &time, sizeof(GTimeVal)); - /* Reset optimization flags: Game is playing along nicely anyway */ - s->kernel_opt_flags &= ~(KERNEL_OPT_FLAG_GOT_EVENT - | KERNEL_OPT_FLAG_GOT_2NDEVENT); + // Reset optimization flags: Game is playing along nicely anyway + s->kernel_opt_flags &= ~(KERNEL_OPT_FLAG_GOT_EVENT | KERNEL_OPT_FLAG_GOT_2NDEVENT); sleep_time *= debug_sleeptime_factor; GFX_ASSERT(gfxop_usleep(s->gfx_state, sleep_time * 1000000 / 60)); @@ -714,27 +661,19 @@ kWait(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } - -reg_t -kCoordPri(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kCoordPri(state_t *s, int funct_nr, int argc, reg_t *argv) { int y = SKPV(0); return make_reg(0, VIEW_PRIORITY(y)); } - -reg_t -kPriCoord(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kPriCoord(state_t *s, int funct_nr, int argc, reg_t *argv) { int priority = SKPV(0); return make_reg(0, PRIORITY_BAND_FIRST(priority)); } - - -void -_k_dirloop(reg_t obj, word angle, state_t *s, int funct_nr, - int argc, reg_t *argv) { +void _k_dirloop(reg_t obj, word angle, state_t *s, int funct_nr, int argc, reg_t *argv) { int view = GET_SEL32V(obj, view); int signal = GET_SEL32V(obj, signal); int loop; @@ -779,9 +718,7 @@ _k_dirloop(reg_t obj, word angle, state_t *s, int funct_nr, PUT_SEL32V(obj, loop, loop); } - -reg_t -kDirLoop(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kDirLoop(state_t *s, int funct_nr, int argc, reg_t *argv) { _k_dirloop(argv[0], UKPV(1), s, funct_nr, argc, argv); return s->r_acc; @@ -790,18 +727,13 @@ kDirLoop(state_t *s, int funct_nr, int argc, reg_t *argv) { #define GASEOUS_VIEW_MASK_ACTIVE (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_IGNORE_ACTOR) #define GASEOUS_VIEW_MASK_PASSIVE (_K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_IGNORE_ACTOR) -abs_rect_t -set_base(struct _state *s, reg_t object); +abs_rect_t set_base(struct _state *s, reg_t object); -inline abs_rect_t -get_nsrect(struct _state *s, reg_t object, byte clip); +inline abs_rect_t get_nsrect(struct _state *s, reg_t object, byte clip); -static inline abs_rect_t -nsrect_clip(state_t *s, int y, abs_rect_t retval, int priority); +static inline abs_rect_t nsrect_clip(state_t *s, int y, abs_rect_t retval, int priority); -static int -collides_with(state_t *s, abs_rect_t area, reg_t other_obj, int use_nsrect, int view_mask, int funct_nr, int argc, - reg_t *argv) { +static int collides_with(state_t *s, abs_rect_t area, reg_t other_obj, int use_nsrect, int view_mask, int funct_nr, int argc, reg_t *argv) { int other_signal = GET_SEL32V(other_obj, signal); int other_priority = GET_SEL32V(other_obj, priority); int y = GET_SEL32SV(other_obj, y); @@ -818,40 +750,30 @@ collides_with(state_t *s, abs_rect_t area, reg_t other_obj, int use_nsrect, int } if (other_area.xend < 0 || other_area.yend < 0 || area.xend < 0 || area.yend < 0) - return 0; /* Out of scope */ + return 0; // Out of scope if (other_area.x >= 320 || other_area.y >= 190 || area.xend >= 320 || area.yend >= 190) - return 0; /* Out of scope */ + return 0; // Out of scope - SCIkdebug(SCIkBRESEN, "OtherSignal=%04x, z=%04x obj="PREG"\n", other_signal, - (other_signal & view_mask), PRINT_REG(other_obj)); + SCIkdebug(SCIkBRESEN, "OtherSignal=%04x, z=%04x obj="PREG"\n", other_signal, (other_signal & view_mask), PRINT_REG(other_obj)); if ((other_signal & (view_mask)) == 0) { - /* check whether the other object ignores actors */ + // check whether the other object ignores actors - SCIkdebug(SCIkBRESEN, " against (%d,%d) to (%d,%d)\n", - other_area.x, other_area.y, other_area.xend, other_area.yend); + SCIkdebug(SCIkBRESEN, " against (%d,%d) to (%d,%d)\n", other_area.x, other_area.y, other_area.xend, other_area.yend); - - if (((other_area.xend > area.x) - && (other_area.x < area.xend)) /* [other_x, other_xend] intersects [x, xend])? */ - && - ((other_area.yend > area.y) - && (other_area.y < area.yend))) /* [other_y, other_yend] intersects [y, yend]? */ + if (((other_area.xend > area.x) && (other_area.x < area.xend)) // [other_x, other_xend] intersects [x, xend])? + && ((other_area.yend > area.y) && (other_area.y < area.yend))) // [other_y, other_yend] intersects [y, yend]? return 1; /* CR (from :Bob Heitman:) Collision rects have Mac semantics, ((0,0),(1,1)) only - ** covers the coordinate (0,0) */ - - + ** covers the coordinate (0,0) */ } SCIkdebug(SCIkBRESEN, " (no)\n"); return 0; } - -reg_t -kCanBeHere(state_t *s, int funct_nr, int argc, reg_t * argv) { +reg_t kCanBeHere(state_t *s, int funct_nr, int argc, reg_t * argv) { reg_t obj = argv[0]; reg_t cliplist_ref = KP_ALT(1, NULL_REG); list_t *cliplist = NULL; @@ -864,47 +786,41 @@ kCanBeHere(state_t *s, int funct_nr, int argc, reg_t * argv) { word edgehit; word illegal_bits; - abs_zone.x = GET_SEL32SV(obj, brLeft); abs_zone.xend = GET_SEL32SV(obj, brRight); abs_zone.y = GET_SEL32SV(obj, brTop); abs_zone.yend = GET_SEL32SV(obj, brBottom); - zone = gfx_rect(abs_zone.x + port->zone.x, abs_zone.y + port->zone.y, - abs_zone.xend - abs_zone.x, abs_zone.yend - abs_zone.y); + zone = gfx_rect(abs_zone.x + port->zone.x, abs_zone.y + port->zone.y, abs_zone.xend - abs_zone.x, abs_zone.yend - abs_zone.y); signal = GET_SEL32V(obj, signal); SCIkdebug(SCIkBRESEN, "Checking collision: (%d,%d) to (%d,%d) ([%d..%d]x[%d..%d]), obj="PREG", sig=%04x, cliplist="PREG"\n", - GFX_PRINT_RECT(zone), - abs_zone.x, abs_zone.xend, abs_zone.y, abs_zone.yend, + GFX_PRINT_RECT(zone), abs_zone.x, abs_zone.xend, abs_zone.y, abs_zone.yend, PRINT_REG(obj), signal, PRINT_REG(cliplist_ref)); illegal_bits = GET_SEL32V(obj, illegalBits); - retval = !(illegal_bits - & (edgehit = gfxop_scan_bitmask(s->gfx_state, zone, GFX_MASK_CONTROL))); + retval = !(illegal_bits & (edgehit = gfxop_scan_bitmask(s->gfx_state, zone, GFX_MASK_CONTROL))); SCIkdebug(SCIkBRESEN, "edgehit = %04x (illegalBits %04x)\n", edgehit, illegal_bits); if (retval == 0) { SCIkdebug(SCIkBRESEN, " -> %04x\n", retval); - return not_register(s, NULL_REG); /* Can'tBeHere */ + return not_register(s, NULL_REG); // Can't BeHere } retval = 0; - if ((illegal_bits & 0x8000) /* If we are vulnerable to those views at all... */ - && s->dyn_views) { /* ...check against all stop-updated dynviews */ + if ((illegal_bits & 0x8000) // If we are vulnerable to those views at all... + && s->dyn_views) { // ...check against all stop-updated dynviews gfxw_dyn_view_t *widget = (gfxw_dyn_view_t *) s->dyn_views->contents; SCIkdebug(SCIkBRESEN, "Checking vs dynviews:\n"); while (widget) { - if (widget->ID - && (widget->signal & _K_VIEW_SIG_FLAG_FREESCI_STOPUPD) + if (widget->ID && (widget->signal & _K_VIEW_SIG_FLAG_FREESCI_STOPUPD) && ((widget->ID != obj.segment) || (widget->subID != obj.offset)) && is_object(s, make_reg(widget->ID, widget->subID))) - if (collides_with(s, abs_zone, make_reg(widget->ID, widget->subID), 1, - GASEOUS_VIEW_MASK_ACTIVE, funct_nr, argc, argv)) + if (collides_with(s, abs_zone, make_reg(widget->ID, widget->subID), 1, GASEOUS_VIEW_MASK_ACTIVE, funct_nr, argc, argv)) return not_register(s, NULL_REG); widget = (gfxw_dyn_view_t *) widget->next; @@ -912,9 +828,9 @@ kCanBeHere(state_t *s, int funct_nr, int argc, reg_t * argv) { } if (signal & GASEOUS_VIEW_MASK_ACTIVE) { - retval = signal & GASEOUS_VIEW_MASK_ACTIVE; /* CanBeHere- it's either being disposed, or it ignores actors anyway */ + retval = signal & GASEOUS_VIEW_MASK_ACTIVE; // CanBeHere- it's either being disposed, or it ignores actors anyway SCIkdebug(SCIkBRESEN, " -> %04x\n", retval); - return not_register(s, make_reg(0, retval)); /* CanBeHere */ + return not_register(s, make_reg(0, retval)); // CanBeHere } if (cliplist_ref.segment) @@ -923,23 +839,23 @@ kCanBeHere(state_t *s, int funct_nr, int argc, reg_t * argv) { if (cliplist) { node_t *node = LOOKUP_NODE(cliplist->first); - retval = 0; /* Assume that we Can'tBeHere... */ + retval = 0; // Assume that we Can'tBeHere... - while (node) { /* Check each object in the list against our bounding rectangle */ + while (node) { // Check each object in the list against our bounding rectangle reg_t other_obj = node->value; SCIkdebug(SCIkBRESEN, " comparing against "PREG"\n", PRINT_REG(other_obj)); if (!is_object(s, other_obj)) { SCIkdebug(SCIkWARNING, "CanBeHere() cliplist contains non-object %04x\n", other_obj); - } else if (!REG_EQ(other_obj, obj)) { /* Clipping against yourself is not recommended */ + } else if (!REG_EQ(other_obj, obj)) { // Clipping against yourself is not recommended if (collides_with(s, abs_zone, other_obj, 0, GASEOUS_VIEW_MASK_PASSIVE, funct_nr, argc, argv)) { SCIkdebug(SCIkBRESEN, " -> %04x\n", retval); return not_register(s, NULL_REG); } - } /* if (other_obj != obj) */ - node = LOOKUP_NODE(node->succ); /* move on */ + } // if (other_obj != obj) + node = LOOKUP_NODE(node->succ); // move on } } @@ -948,10 +864,9 @@ kCanBeHere(state_t *s, int funct_nr, int argc, reg_t * argv) { SCIkdebug(SCIkBRESEN, " -> %04x\n", retval); return not_register(s, make_reg(0, retval)); -} /* CanBeHere */ +} // CanBeHere -reg_t -kIsItSkip(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kIsItSkip(state_t *s, int funct_nr, int argc, reg_t *argv) { int view = SKPV(0); int loop = SKPV(1); int cel = SKPV(2); @@ -966,16 +881,15 @@ kIsItSkip(state_t *s, int funct_nr, int argc, reg_t *argv) { } pxm = res->loops[loop].cels[cel]; - if (x > pxm->index_xl) x = pxm->index_xl - 1; - if (y > pxm->index_yl) y = pxm->index_yl - 1; + if (x > pxm->index_xl) + x = pxm->index_xl - 1; + if (y > pxm->index_yl) + y = pxm->index_yl - 1; - return make_reg(0, - pxm->index_data[y*pxm->index_xl+x] == - pxm->color_key); + return make_reg(0, pxm->index_data[y * pxm->index_xl + x] == pxm->color_key); } -reg_t -kCelHigh(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kCelHigh(state_t *s, int funct_nr, int argc, reg_t *argv) { int view = SKPV(0); int loop = SKPV(1); int cel = SKPV(2); @@ -993,8 +907,7 @@ kCelHigh(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, height); } -reg_t -kCelWide(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kCelWide(state_t *s, int funct_nr, int argc, reg_t *argv) { int view = SKPV(0); int loop = SKPV(1); int cel = SKPV(2); @@ -1012,13 +925,11 @@ kCelWide(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, width); } -reg_t -kNumLoops(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kNumLoops(state_t *s, int funct_nr, int argc, reg_t *argv) { 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) { SCIkwarn(SCIkERROR, "view.%d (0x%x) not found\n", view, view); return NULL_REG; @@ -1029,17 +940,16 @@ kNumLoops(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, loops_nr); } - -reg_t -kNumCels(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kNumCels(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t obj = argv[0]; int loop = GET_SEL32V(obj, loop); int view = GET_SEL32V(obj, view); int cel = 0xffff; - if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { /* OK, this is a hack and there's a - ** real function to calculate cel numbers... */ + if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { + // OK, this is a hack and there's a + // real function to calculate cel numbers... SCIkwarn(SCIkERROR, "view.%d (0x%x) not found\n", view, view); return NULL_REG; } @@ -1049,14 +959,12 @@ kNumCels(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, cel + 1); } -reg_t -kOnControl(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kOnControl(state_t *s, int funct_nr, int argc, reg_t *argv) { int arg = 0; gfx_map_mask_t map; int xstart, ystart; int xlen = 1, ylen = 1; - if (argc == 2 || argc == 4) map = GFX_MASK_CONTROL; else { @@ -1075,13 +983,11 @@ kOnControl(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, gfxop_scan_bitmask(s->gfx_state, gfx_rect(xstart, ystart + 10, xlen, ylen), map)); } -void -_k_view_list_free_backgrounds(state_t *s, view_object_t *list, int list_nr); +void _k_view_list_free_backgrounds(state_t *s, view_object_t *list, int list_nr); int sci01_priority_table_flags = 0; -reg_t -kDrawPic(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kDrawPic(state_t *s, int funct_nr, int argc, reg_t *argv) { int pic_nr = SKPV(0); int add_to_pic = 1; int palette = SKPV_OR_ALT(3, 0); @@ -1092,9 +998,10 @@ kDrawPic(state_t *s, int funct_nr, int argc, reg_t *argv) { if (s->version < SCI_VERSION_FTU_NEWER_DRAWPIC_PARAMETERS) { if (!SKPV_OR_ALT(2, 0)) add_to_pic = 0; - } else + } else { if (SKPV_OR_ALT(2, 1)) add_to_pic = 0; + } gfxop_disable_dirty_frames(s->gfx_state); @@ -1157,7 +1064,7 @@ kDrawPic(state_t *s, int funct_nr, int argc, reg_t *argv) { s->pic_priority_table = NULL; if (argc > 1) - s->pic_animate = SKPV(1); /* The animation used during kAnimate() later on */ + s->pic_animate = SKPV(1); // The animation used during kAnimate() later on s->dyn_views = NULL; s->drop_views = NULL; @@ -1176,11 +1083,7 @@ kDrawPic(state_t *s, int funct_nr, int argc, reg_t *argv) { } - - - -abs_rect_t -set_base(state_t *s, reg_t object) { +abs_rect_t set_base(state_t *s, reg_t object) { int x, y, original_y, z, ystep, xsize, ysize; int xbase, ybase, xend, yend; int view, loop, cel; @@ -1196,7 +1099,7 @@ set_base(state_t *s, reg_t object) { else z = 0; - y -= z; /* Subtract z offset */ + y -= z; // Subtract z offset ystep = GET_SEL32SV(object, yStep); @@ -1220,14 +1123,12 @@ set_base(state_t *s, reg_t object) { PUT_SEL32V(object, cel, 0); } - gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, - &xsize, &ysize, &offset); + 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; @@ -1244,17 +1145,14 @@ set_base(state_t *s, reg_t object) { return retval; } - -void -_k_base_setter(state_t *s, reg_t object) { +void _k_base_setter(state_t *s, reg_t object) { abs_rect_t absrect = set_base(s, object); - if (lookup_selector(s, object, s->selector_map.brLeft, NULL, NULL) - != SELECTOR_VARIABLE) - return; /* non-fatal */ + if (lookup_selector(s, object, s->selector_map.brLeft, NULL, NULL) != SELECTOR_VARIABLE) + return; // non-fatal if (s->version <= SCI_VERSION_LTU_BASE_OB1) - --absrect.y; /* Compensate for early SCI OB1 'bug' */ + --absrect.y; // Compensate for early SCI OB1 'bug' PUT_SEL32V(object, brLeft, absrect.x); PUT_SEL32V(object, brRight, absrect.xend); @@ -1262,26 +1160,22 @@ _k_base_setter(state_t *s, reg_t object) { PUT_SEL32V(object, brBottom, absrect.yend); } -reg_t -kBaseSetter(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kBaseSetter(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t object = argv[0]; - _k_base_setter(s, object); return s->r_acc; -} /* kBaseSetter */ +} // kBaseSetter - -static inline abs_rect_t -nsrect_clip(state_t *s, int y, abs_rect_t retval, int priority) { +static inline abs_rect_t nsrect_clip(state_t *s, int y, abs_rect_t retval, int priority) { int pri_top; if (priority == -1) priority = VIEW_PRIORITY(y); pri_top = PRIORITY_BAND_FIRST(priority) + 1; - /* +1: Don't know why, but this seems to be happening */ + // +1: Don't know why, but this seems to be happening if (retval.y < pri_top) retval.y = pri_top; @@ -1292,8 +1186,7 @@ nsrect_clip(state_t *s, int y, abs_rect_t retval, int priority) { return retval; } -inline abs_rect_t -calculate_nsrect(state_t *s, int x, int y, int view, int loop, int cel) { +inline abs_rect_t calculate_nsrect(state_t *s, int x, int y, int view, int loop, int cel) { int xbase, ybase, xend, yend, xsize, ysize; int xmod = 0, ymod = 0; abs_rect_t retval = {0, 0, 0, 0}; @@ -1303,8 +1196,7 @@ calculate_nsrect(state_t *s, int x, int y, int view, int loop, int cel) { } else { Common::Point offset = Common::Point(0, 0); - gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, - &xsize, &ysize, &offset); + gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset); xmod = offset.x; ymod = offset.y; @@ -1312,7 +1204,7 @@ calculate_nsrect(state_t *s, int x, int y, int view, int loop, int cel) { xbase = x - xmod - (xsize >> 1); xend = xbase + xsize; - yend = y - ymod + 1; /* +1: magic modifier */ + yend = y - ymod + 1; // +1: magic modifier ybase = yend - ysize; retval.x = xbase; @@ -1323,8 +1215,7 @@ calculate_nsrect(state_t *s, int x, int y, int view, int loop, int cel) { return retval; } -inline abs_rect_t -get_nsrect(state_t *s, reg_t object, byte clip) { +inline abs_rect_t get_nsrect(state_t *s, reg_t object, byte clip) { int x, y, z; int view, loop, cel; abs_rect_t retval; @@ -1337,7 +1228,7 @@ get_nsrect(state_t *s, reg_t object, byte clip) { else z = 0; - y -= z; /* Subtract z offset */ + y -= z; // Subtract z offset view = GET_SEL32SV(object, view); loop = sign_extend_byte(GET_SEL32SV(object, loop)); @@ -1353,12 +1244,12 @@ get_nsrect(state_t *s, reg_t object, byte clip) { return retval; } -static void -_k_set_now_seen(state_t *s, reg_t object) { +static void _k_set_now_seen(state_t *s, reg_t object) { abs_rect_t absrect = get_nsrect(s, object, 0); - if (lookup_selector(s, object, s->selector_map.nsTop, NULL, NULL) - != SELECTOR_VARIABLE) { return; } /* This isn't fatal */ + if (lookup_selector(s, object, s->selector_map.nsTop, NULL, NULL) != SELECTOR_VARIABLE) { + return; + } // This isn't fatal PUT_SEL32V(object, nsLeft, absrect.x); PUT_SEL32V(object, nsRight, absrect.xend); @@ -1366,18 +1257,15 @@ _k_set_now_seen(state_t *s, reg_t object) { PUT_SEL32V(object, nsBottom, absrect.yend); } - -reg_t -kSetNowSeen(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kSetNowSeen(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t object = argv[0]; _k_set_now_seen(s, object); return s->r_acc; -} /* kSetNowSeen */ +} // kSetNowSeen -reg_t -kPalette(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kPalette(state_t *s, int funct_nr, int argc, reg_t *argv) { switch (UKPV(0)) { case 5 : { int r = UKPV(1); @@ -1399,8 +1287,8 @@ kPalette(state_t *s, int funct_nr, int argc, reg_t *argv) { } } - /* Don't warn about inexact mappings -- it's actually the - ** rule rather than the exception */ + // Don't warn about inexact mappings -- it's actually the + // rule rather than the exception return make_reg(0, bestindex); } @@ -1410,29 +1298,25 @@ kPalette(state_t *s, int funct_nr, int argc, reg_t *argv) { default : SCIkdebug(SCIkWARNING, "Unimplemented subfunction: %d\n", UKPV(0)); } + return s->r_acc; } -static void -_k_draw_control(state_t *s, reg_t obj, int inverse); - +static void _k_draw_control(state_t *s, reg_t obj, int inverse); -static void -_k_disable_delete_for_now(state_t *s, reg_t obj) { +static void _k_disable_delete_for_now(state_t *s, reg_t obj) { reg_t text_pos = GET_SEL32(obj, text); char *text = IS_NULL_REG(text_pos) ? NULL : (char *) sm_dereference(&s->seg_manager, text_pos, NULL); int type = GET_SEL32V(obj, type); int state = GET_SEL32V(obj, state); - if (type == K_CONTROL_BUTTON && text && - !strcmp(s->game_name, "sq4") && - s->version < SCI_VERSION(1, 001, 000) && - !strcmp(text, " Delete ")) + if (type == K_CONTROL_BUTTON && text && !strcmp(s->game_name, "sq4") && + s->version < SCI_VERSION(1, 001, 000) && !strcmp(text, " Delete ")) { PUT_SEL32V(obj, state, (state | CONTROL_STATE_GRAY) & ~CONTROL_STATE_ENABLED); + } } -reg_t -kDrawControl(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kDrawControl(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t obj = argv[0]; _k_disable_delete_for_now(s, obj); @@ -1441,56 +1325,46 @@ kDrawControl(state_t *s, int funct_nr, int argc, reg_t *argv) { return NULL_REG; } - -reg_t -kHiliteControl(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kHiliteControl(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t obj = argv[0]; - _k_draw_control(s, obj, 1); + return s->r_acc; } - -void -update_cursor_limits(int *display_offset, int *cursor, int max_displayed) { +void update_cursor_limits(int *display_offset, int *cursor, int max_displayed) { if (*cursor < *display_offset + 4) { if (*cursor < 8) *display_offset = 0; else *display_offset = *cursor - 8; - } else if (*cursor - *display_offset > max_displayed - 8) *display_offset = 12 + *cursor - max_displayed; - } #define _K_EDIT_DELETE \ - if (cursor < textlen) { \ - memmove(text + cursor, text + cursor + 1, textlen - cursor +1); \ -} + if (cursor < textlen) { \ + memmove(text + cursor, text + cursor + 1, textlen - cursor +1); \ + } #define _K_EDIT_BACKSPACE \ - if (cursor) { \ - --cursor; \ - memmove(text + cursor, text + cursor + 1, textlen - cursor +1); \ - --textlen; \ -} - - + if (cursor) { \ + --cursor; \ + memmove(text + cursor, text + cursor + 1, textlen - cursor +1); \ + --textlen; \ + } -reg_t -kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t obj = argv[0]; reg_t event = argv[1]; - if (obj.segment) { word ct_type = GET_SEL32V(obj, type); switch (ct_type) { case 0: - break; /* NOP */ + break; // NOP case K_CONTROL_EDIT: if (event.segment && ((GET_SEL32V(event, type)) == SCI_EVT_KEYBOARD)) { @@ -1506,8 +1380,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { int textlen; if (!text) { - SCIkdebug(SCIkWARNING, "Could not draw control: "PREG" does not reference text!\n", - PRINT_REG(text_pos)); + SCIkdebug(SCIkWARNING, "Could not draw control: "PREG" does not reference text!\n", PRINT_REG(text_pos)); return s->r_acc; } @@ -1539,7 +1412,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { break; case 'k': text[cursor] = 0; - break; /* Terminate string */ + break; // Terminate string case 'h': _K_EDIT_BACKSPACE; break; @@ -1549,8 +1422,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { } PUT_SEL32V(event, claimed, 1); - } else if (modifiers & SCI_EVM_ALT) { /* Ctrl has precedence over Alt */ - + } else if (modifiers & SCI_EVM_ALT) { // Ctrl has precedence over Alt switch (key) { case 0x2100 /* A-f */: while ((cursor < textlen) && (text[cursor++] != ' ')); @@ -1559,12 +1431,10 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { while ((cursor > 0) && (text[--cursor - 1] != ' ')); break; case 0x2000 /* A-d */: { - while ((cursor < textlen) && (text[cursor] == ' ')) { _K_EDIT_DELETE; textlen--; } - while ((cursor < textlen) && (text[cursor] != ' ')) { _K_EDIT_DELETE; textlen--; @@ -1573,11 +1443,8 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { } } PUT_SEL32V(event, claimed, 1); - } else if (key < 31) { - PUT_SEL32V(event, claimed, 1); - switch (key) { case SCI_K_BACKSPACE: _K_EDIT_BACKSPACE; @@ -1585,9 +1452,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { default: PUT_SEL32V(event, claimed, 0); } - } else if (key & 0xff00) { - switch (key) { case SCI_K_HOME: cursor = 0; @@ -1596,16 +1461,17 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { cursor = textlen; break; case SCI_K_RIGHT: - if (cursor + 1 <= textlen) ++cursor; + if (cursor + 1 <= textlen) + ++cursor; break; case SCI_K_LEFT: - if (cursor > 0) --cursor; + if (cursor > 0) + --cursor; break; case SCI_K_DELETE: _K_EDIT_DELETE; break; } - PUT_SEL32V(event, claimed, 1); } else if ((key > 31) && (key < 128)) { int inserting = (modifiers & SCI_EVM_INSERT); @@ -1615,7 +1481,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { if (cursor == textlen) { if (textlen < max) { text[cursor++] = key; - text[cursor] = 0; /* Terminate string */ + text[cursor] = 0; // Terminate string } } else if (inserting) { if (textlen < max) { @@ -1626,7 +1492,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { text[cursor++] = key; } - } else { /* Overwriting */ + } else { // Overwriting text[cursor++] = key; } @@ -1641,7 +1507,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { PUT_SEL32V(event, claimed, 1); } - PUT_SEL32V(obj, cursor, cursor); /* Write back cursor position */ + PUT_SEL32V(obj, cursor, cursor); // Write back cursor position } case K_CONTROL_ICON: @@ -1668,9 +1534,7 @@ kEditControl(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } - -static void -_k_draw_control(state_t *s, reg_t obj, int inverse) { +static void _k_draw_control(state_t *s, reg_t obj, int inverse) { int x = GET_SEL32SV(obj, nsLeft); int y = GET_SEL32SV(obj, nsTop); int xl = GET_SEL32SV(obj, nsRight) - x; @@ -1679,7 +1543,7 @@ _k_draw_control(state_t *s, reg_t obj, int inverse) { int font_nr = GET_SEL32V(obj, font); reg_t text_pos = GET_SEL32(obj, text); - char *text = IS_NULL_REG(text_pos) ? NULL : (char *) sm_dereference(&s->seg_manager, text_pos, NULL); + char *text = IS_NULL_REG(text_pos) ? NULL : (char *)sm_dereference(&s->seg_manager, text_pos, NULL); int view = GET_SEL32V(obj, view); int cel = sign_extend_byte(GET_SEL32V(obj, cel)); int loop = sign_extend_byte(GET_SEL32V(obj, loop)); @@ -1695,13 +1559,10 @@ _k_draw_control(state_t *s, reg_t obj, int inverse) { } switch (type) { - case K_CONTROL_BUTTON: - SCIkdebug(SCIkGRAPHICS, "drawing button "PREG" to %d,%d\n", PRINT_REG(obj), x, y); ADD_TO_CURRENT_BG_WIDGETS(sciw_new_button_control(s->port, obj, area, text, font_nr, - (gint8)(state & CONTROL_STATE_FRAMED), - (gint8)inverse, (gint8)(state & CONTROL_STATE_GRAY))); + (gint8)(state & CONTROL_STATE_FRAMED), (gint8)inverse, (gint8)(state & CONTROL_STATE_GRAY))); break; case K_CONTROL_TEXT: @@ -1709,10 +1570,8 @@ _k_draw_control(state_t *s, reg_t obj, int inverse) { SCIkdebug(SCIkGRAPHICS, "drawing text "PREG" to %d,%d, mode=%d\n", PRINT_REG(obj), x, y, mode); - ADD_TO_CURRENT_BG_WIDGETS( - sciw_new_text_control(s->port, obj, area, text, font_nr, mode, - (gint8)(!!(state & CONTROL_STATE_DITHER_FRAMED)), - (gint8)inverse)); + ADD_TO_CURRENT_BG_WIDGETS(sciw_new_text_control(s->port, obj, area, text, font_nr, mode, + (gint8)(!!(state & CONTROL_STATE_DITHER_FRAMED)), (gint8)inverse)); break; case K_CONTROL_EDIT: @@ -1750,18 +1609,17 @@ _k_draw_control(state_t *s, reg_t obj, int inverse) { int entry_size = GET_SEL32V(obj, x); int i; - SCIkdebug(SCIkGRAPHICS, "drawing list control %04x to %d,%d, diff %d\n", obj, x, y, - SCI_MAX_SAVENAME_LENGTH); + SCIkdebug(SCIkGRAPHICS, "drawing list control %04x to %d,%d, diff %d\n", obj, x, y, SCI_MAX_SAVENAME_LENGTH); cursor = GET_SEL32V(obj, cursor) - text_pos.offset; entries_nr = 0; seeker = text; - while (seeker[0]) { /* Count string entries in NULL terminated string list */ + while (seeker[0]) { // Count string entries in NULL terminated string list ++entries_nr; seeker += entry_size; } - if (entries_nr) { /* determine list_top, selection, and the entries_list */ + if (entries_nr) { // determine list_top, selection, and the entries_list seeker = text; entries_list = (char**)sci_malloc(sizeof(char *) * entries_nr); for (i = 0; i < entries_nr; i++) { @@ -1795,29 +1653,23 @@ _k_draw_control(state_t *s, reg_t obj, int inverse) { } -static void -draw_rect_to_control_map(state_t *s, abs_rect_t abs_zone) { +static void draw_rect_to_control_map(state_t *s, abs_rect_t abs_zone) { gfxw_box_t *box; gfx_color_t color; gfxop_set_color(s->gfx_state, &color, -1, -1, -1, -1, -1, 0xf); - SCIkdebug(SCIkGRAPHICS, " adding control block (%d,%d)to(%d,%d)\n", - abs_zone.x, abs_zone.y, abs_zone.xend, abs_zone.yend); + SCIkdebug(SCIkGRAPHICS, " adding control block (%d,%d)to(%d,%d)\n", abs_zone.x, abs_zone.y, abs_zone.xend, abs_zone.yend); - box = gfxw_new_box(s->gfx_state, - gfx_rect(abs_zone.x, abs_zone.y, - abs_zone.xend - abs_zone.x, - abs_zone.yend - abs_zone.y), - color, color, GFX_BOX_SHADE_FLAT); + box = gfxw_new_box(s->gfx_state, gfx_rect(abs_zone.x, abs_zone.y, abs_zone.xend - abs_zone.x, + abs_zone.yend - abs_zone.y), color, color, GFX_BOX_SHADE_FLAT); assert_primary_widget_lists(s); ADD_TO_CURRENT_PICTURE_PORT(box); } -static inline void -draw_obj_to_control_map(state_t *s, gfxw_dyn_view_t *view) { +static inline void draw_obj_to_control_map(state_t *s, gfxw_dyn_view_t *view) { reg_t obj = make_reg(view->ID, view->subID); if (!is_object(s, obj)) @@ -1829,9 +1681,7 @@ draw_obj_to_control_map(state_t *s, gfxw_dyn_view_t *view) { } } - -static void -_k_view_list_do_postdraw(state_t *s, gfxw_list_t *list) { +static void _k_view_list_do_postdraw(state_t *s, gfxw_list_t *list) { gfxw_dyn_view_t *widget = (gfxw_dyn_view_t *) list->contents; while (widget) { @@ -1873,8 +1723,8 @@ _k_view_list_do_postdraw(state_t *s, gfxw_list_t *list) { #endif } #ifdef DEBUG_LSRECT - else fprintf(stderr, "Not lsRecting "PREG" because %d\n", PRINT_REG(obj), - lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL)); + else + fprintf(stderr, "Not lsRecting "PREG" because %d\n", PRINT_REG(obj), lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL)); #endif if (widget->signal & _K_VIEW_SIG_FLAG_HIDDEN) @@ -1892,8 +1742,7 @@ _k_view_list_do_postdraw(state_t *s, gfxw_list_t *list) { } } -void -_k_view_list_mark_free(state_t *s, reg_t off) { +void _k_view_list_mark_free(state_t *s, reg_t off) { if (s->dyn_views) { gfxw_dyn_view_t *w = (gfxw_dyn_view_t *) s->dyn_views->contents; @@ -1911,12 +1760,9 @@ _k_view_list_mark_free(state_t *s, reg_t off) { static int _k_animate_ran = 0; -int -_k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, - int funct_nr, int argc, reg_t *argv) -/* disposes all list members flagged for disposal; funct_nr is the invoking kfunction */ -/* returns non-zero IFF views were dropped */ -{ +int _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, int funct_nr, int argc, reg_t *argv) { +// disposes all list members flagged for disposal; funct_nr is the invoking kfunction +// returns non-zero IFF views were dropped int signal; int dropped = 0; @@ -1924,10 +1770,10 @@ _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, if (widget) { int retval; - /* Recurse: */ + // Recurse: retval = _k_view_list_dispose_loop(s, list, (gfxw_dyn_view_t *) widget->next, funct_nr, argc, argv); - if (retval == -1) /* Bail out on annihilation, rely on re-start from Animate() */ + if (retval == -1) // Bail out on annihilation, rely on re-start from Animate() return -1; if (GFXW_IS_DYN_VIEW(widget) && (widget->ID != GFXW_NO_ID)) { @@ -1937,24 +1783,17 @@ _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, reg_t under_bits = NULL_REG; if (!is_object(s, obj)) { - SCIkwarn(SCIkERROR, "Non-object "PREG" present" - " in view list during delete time\n", - PRINT_REG(obj)); + SCIkwarn(SCIkERROR, "Non-object "PREG" present in view list during delete time\n", PRINT_REG(obj)); obj = NULL_REG; } else - - if (widget->under_bitsp) { /* Is there a bg picture left to clean? */ - + if (widget->under_bitsp) { // Is there a bg picture left to clean? reg_t mem_handle = *((reg_t*)(widget->under_bitsp)); if (mem_handle.segment) { if (!kfree(s, mem_handle)) { *((reg_t*)(widget->under_bitsp)) = make_reg(0, widget->under_bits = 0); } else { - SCIkwarn(SCIkWARNING, - "Treating viewobj "PREG - " as no longer" - " present\n", PRINT_REG(obj)); + SCIkwarn(SCIkWARNING, "Treating viewobj "PREG" as no longer present\n", PRINT_REG(obj)); obj = NULL_REG; } } @@ -1962,11 +1801,9 @@ _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, if (is_object(s, obj)) { if (invoke_selector(INV_SEL(obj, delete_, 1), 0)) - SCIkwarn(SCIkWARNING, "Object at "PREG" requested deletion, but does not have" - " a delete funcselector\n", PRINT_REG(obj)); + SCIkwarn(SCIkWARNING, "Object at "PREG" requested deletion, but does not have a delete funcselector\n", PRINT_REG(obj)); if (_k_animate_ran) { - SCIkwarn(SCIkWARNING, "Object at "PREG" invoked kAnimate() during deletion!\n", - PRINT_REG(obj)); + SCIkwarn(SCIkWARNING, "Object at "PREG" invoked kAnimate() during deletion!\n", PRINT_REG(obj)); return dropped; } @@ -1978,15 +1815,12 @@ _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, graph_restore_box(s, under_bits); } - SCIkdebug(SCIkGRAPHICS, "Freeing "PREG" with signal=%04x\n", - PRINT_REG(obj), signal); + SCIkdebug(SCIkGRAPHICS, "Freeing "PREG" with signal=%04x\n", PRINT_REG(obj), signal); if (!(signal & _K_VIEW_SIG_FLAG_HIDDEN)) { - SCIkdebug(SCIkGRAPHICS, "Adding view at "PREG" to background\n", - PRINT_REG(obj)); + SCIkdebug(SCIkGRAPHICS, "Adding view at "PREG" to background\n", PRINT_REG(obj)); if (!(gfxw_remove_id(widget->parent, widget->ID, widget->subID) == GFXW(widget))) { - SCIkwarn(SCIkERROR, "Attempt to remove view with ID %x:%x from list failed!\n", - widget->ID, widget->subID); + SCIkwarn(SCIkERROR, "Attempt to remove view with ID %x:%x from list failed!\n", widget->ID, widget->subID); BREAKPOINT(); } @@ -2000,7 +1834,7 @@ _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, SCIkdebug(SCIkGRAPHICS, "Deleting view at "PREG"\n", PRINT_REG(obj)); widget->flags |= GFXW_FLAG_VISIBLE; gfxw_annihilate(GFXW(widget)); - return -1; /* restart: Done in Animate() */ + return -1; // restart: Done in Animate() } } } @@ -2016,8 +1850,7 @@ _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, #define _K_MAKE_VIEW_LIST_CALC_PRIORITY 2 #define _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP 4 -static gfxw_dyn_view_t * -_k_make_dynview_obj(state_t *s, reg_t obj, int options, int nr, int funct_nr, int argc, reg_t *argv) { +static gfxw_dyn_view_t *_k_make_dynview_obj(state_t *s, reg_t obj, int options, int nr, int funct_nr, int argc, reg_t *argv) { short oldloop, oldcel; int cel, loop, view_nr = GET_SEL32SV(obj, view); int palette; @@ -2035,11 +1868,11 @@ _k_make_dynview_obj(state_t *s, reg_t obj, int options, int nr, int funct_nr, in pos.x = GET_SEL32SV(obj, x); pos.y = GET_SEL32SV(obj, y); - pos.y++; /* magic: Sierra appears to do something like this */ + pos.y++; // magic: Sierra appears to do something like this z = GET_SEL32SV(obj, z); - /* !-- nsRect used to be checked here! */ + // !-- nsRect used to be checked here! loop = oldloop = sign_extend_byte(GET_SEL32V(obj, loop)); cel = oldcel = sign_extend_byte(GET_SEL32V(obj, cel)); @@ -2048,7 +1881,7 @@ _k_make_dynview_obj(state_t *s, reg_t obj, int options, int nr, int funct_nr, in else palette = 0; - /* Clip loop and cel, write back if neccessary */ + // Clip loop and cel, write back if neccessary if (gfxop_check_cel(s->gfx_state, view_nr, &loop, &cel)) { return NULL; } @@ -2065,16 +1898,14 @@ _k_make_dynview_obj(state_t *s, reg_t obj, int options, int nr, int funct_nr, in PUT_SEL32V(obj, cel, cel); } - if (lookup_selector(s, obj, s->selector_map.underBits, &(under_bitsp), NULL) - != SELECTOR_VARIABLE) { + if (lookup_selector(s, obj, s->selector_map.underBits, &(under_bitsp), NULL) != SELECTOR_VARIABLE) { under_bitsp = NULL; under_bits = NULL_REG; SCIkdebug(SCIkGRAPHICS, "Object at "PREG" has no underBits\n", PRINT_REG(obj)); } else under_bits = *((reg_t *)under_bitsp); - if (lookup_selector(s, obj, s->selector_map.signal, &(signalp), NULL) - != SELECTOR_VARIABLE) { + if (lookup_selector(s, obj, s->selector_map.signal, &(signalp), NULL) != SELECTOR_VARIABLE) { signalp = NULL; signal = 0; SCIkdebug(SCIkGRAPHICS, "Object at "PREG" has no signal selector\n", PRINT_REG(obj)); @@ -2083,15 +1914,12 @@ _k_make_dynview_obj(state_t *s, reg_t obj, int options, int nr, int funct_nr, in SCIkdebug(SCIkGRAPHICS, " with signal = %04x\n", signal); } - widget = gfxw_new_dyn_view(s->gfx_state, pos, z, view_nr, loop, cel, palette, - -1, -1, ALIGN_CENTER, ALIGN_BOTTOM, nr); + widget = gfxw_new_dyn_view(s->gfx_state, pos, z, view_nr, loop, cel, palette, -1, -1, ALIGN_CENTER, ALIGN_BOTTOM, nr); if (widget) { - widget = (gfxw_dyn_view_t *) gfxw_set_id(GFXW(widget), obj.segment, obj.offset); - widget = gfxw_dyn_view_set_params(widget, under_bits.segment, - under_bitsp, signal, signalp); - widget->flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; /* Only works the first time 'round */ + widget = gfxw_dyn_view_set_params(widget, under_bits.segment, under_bitsp, signal, signalp); + widget->flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; // Only works the first time 'round' return widget; } else { @@ -2100,15 +1928,11 @@ _k_make_dynview_obj(state_t *s, reg_t obj, int options, int nr, int funct_nr, in } } - -static void -_k_make_view_list(state_t *s, gfxw_list_t **widget_list, list_t *list, int options, - int funct_nr, int argc, reg_t *argv) +static void _k_make_view_list(state_t *s, gfxw_list_t **widget_list, list_t *list, int options, int funct_nr, int argc, reg_t *argv) { /* Creates a view_list from a node list in heap space. Returns the list, stores the ** number of list entries in *list_nr. Calls doit for each entry if cycle is set. ** argc, argv, funct_nr should be the same as in the calling kernel function. */ -{ node_t *node; int sequence_nr = 0; gfxw_dyn_view_t *widget; @@ -2119,17 +1943,17 @@ _k_make_view_list(state_t *s, gfxw_list_t **widget_list, list_t *list, int optio }; assert_primary_widget_lists(s); - /* In case one of the views' doit() does a DrawPic... */ - /* Yes, this _does_ happen! */ + // In case one of the views' doit() does a DrawPic... + // Yes, this _does_ happen! - if (!list) { /* list sanity check */ + if (!list) { // list sanity check SCIkwarn(SCIkERROR, "Attempt to make list from non-list!\n"); BREAKPOINT(); } node = LOOKUP_NODE(list->first); while (node) { - reg_t obj = node->value; /* The object we're using */ + reg_t obj = node->value; // The object we're using reg_t next_node; gfxw_dyn_view_t *tempWidget; @@ -2139,28 +1963,25 @@ _k_make_view_list(state_t *s, gfxw_list_t **widget_list, list_t *list, int optio if (!(signal & _K_VIEW_SIG_FLAG_FROZEN)) { SCIkdebug(SCIkGRAPHICS, " invoking "PREG"::doit()\n", PRINT_REG(obj)); - invoke_selector(INV_SEL(obj, doit, 1), 0); /* Call obj::doit() if neccessary */ + invoke_selector(INV_SEL(obj, doit, 1), 0); // Call obj::doit() if neccessary } } - next_node = node->succ; /* In case the cast list was changed */ + next_node = node->succ; // In case the cast list was changed - if (list->first.segment == 0 && - list->first.offset == 0) /* The cast list was completely emptied! */ + if (list->first.segment == 0 && list->first.offset == 0) // The cast list was completely emptied! break; - tempWidget = _k_make_dynview_obj(s, obj, options, sequence_nr--, - funct_nr, argc, argv); + tempWidget = _k_make_dynview_obj(s, obj, options, sequence_nr--, funct_nr, argc, argv); if (tempWidget) GFX_ASSERT((*widget_list)->add(GFXWC(*widget_list), GFXW(tempWidget))); - node = LOOKUP_NODE(next_node); /* Next node */ + node = LOOKUP_NODE(next_node); // Next node } - widget = (gfxw_dyn_view_t *)(*widget_list)->contents; - while (widget) { /* Read back widget values */ + while (widget) { // Read back widget values if (widget->signalp) widget->signal = ((reg_t *)(widget->signalp))->offset; @@ -2168,9 +1989,7 @@ _k_make_view_list(state_t *s, gfxw_list_t **widget_list, list_t *list, int optio } } - -static void -_k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { +static void _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) list->contents; while (view) { reg_t obj = make_reg(view->ID, view->subID); @@ -2179,27 +1998,24 @@ _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { int oldsignal = view->signal; _k_set_now_seen(s, obj); - _priority = /*GET_SELECTOR(obj, y); */((view->pos.y));/**/ + _priority = /*GET_SELECTOR(obj, y); */((view->pos.y)); _priority = _find_view_priority(s, _priority - 1); - if (options & _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP) { /* Picview */ + if (options & _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP) { // Picview priority = GET_SEL32SV(obj, priority); if (priority < 0) - priority = _priority; /* Always for picviews */ - } else { /* Dynview */ - if (has_nsrect - && !(view->signal & _K_VIEW_SIG_FLAG_FIX_PRI_ON)) { /* Calculate priority */ - + priority = _priority; // Always for picviews + } else { // Dynview + if (has_nsrect && !(view->signal & _K_VIEW_SIG_FLAG_FIX_PRI_ON)) { // Calculate priority if (options & _K_MAKE_VIEW_LIST_CALC_PRIORITY) PUT_SEL32V(obj, priority, _priority); priority = _priority; - } else /* DON'T calculate the priority */ + } else // DON'T calculate the priority priority = GET_SEL32SV(obj, priority); } - view->color.priority = priority; if (priority > -1) @@ -2207,8 +2023,8 @@ _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { else view->color.mask &= ~GFX_MASK_PRIORITY; - /* CR (from :Bob Heitman:) stopupdated views (like pic views) have - ** their clipped nsRect drawn to the control map */ + // CR (from :Bob Heitman:) stopupdated views (like pic views) have + // their clipped nsRect drawn to the control map if (view->signal & _K_VIEW_SIG_FLAG_STOP_UPDATE) { view->signal |= _K_VIEW_SIG_FLAG_FREESCI_STOPUPD; SCIkdebug(SCIkGRAPHICS, "Setting magic STOP_UPD for "PREG"\n", PRINT_REG(obj)); @@ -2217,14 +2033,13 @@ _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { if ((options & _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP)) draw_obj_to_control_map(s, view); - - /* Extreme Pattern Matching ugliness ahead... */ + // Extreme Pattern Matching ugliness ahead... if (view->signal & _K_VIEW_SIG_FLAG_NO_UPDATE) { - if (((view->signal & (_K_VIEW_SIG_FLAG_UPDATED | _K_VIEW_SIG_FLAG_FORCE_UPDATE))) /* 9.1.1.1 */ + if (((view->signal & (_K_VIEW_SIG_FLAG_UPDATED | _K_VIEW_SIG_FLAG_FORCE_UPDATE))) // 9.1.1.1 || ((view->signal & (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_REMOVE)) == _K_VIEW_SIG_FLAG_HIDDEN) - || ((view->signal & (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_REMOVE)) == _K_VIEW_SIG_FLAG_REMOVE) /* 9.1.1.2 */ - || ((view->signal & (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)) == _K_VIEW_SIG_FLAG_ALWAYS_UPDATE) /* 9.1.1.3 */ - || ((view->signal & (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)) == (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE))) { /* 9.1.1.4 */ + || ((view->signal & (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_REMOVE)) == _K_VIEW_SIG_FLAG_REMOVE) // 9.1.1.2 + || ((view->signal & (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)) == _K_VIEW_SIG_FLAG_ALWAYS_UPDATE) // 9.1.1.3 + || ((view->signal & (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)) == (_K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE))) { // 9.1.1.4 s->pic_not_valid++; view->signal &= ~_K_VIEW_SIG_FLAG_STOP_UPDATE; } @@ -2239,7 +2054,7 @@ _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { if (view->signal & _K_VIEW_SIG_FLAG_STOP_UPDATE) { s->pic_not_valid++; view->signal &= ~_K_VIEW_SIG_FLAG_FORCE_UPDATE; - } else { /* if not STOP_UPDATE */ + } else { // if not STOP_UPDATE if (view->signal & _K_VIEW_SIG_FLAG_ALWAYS_UPDATE) s->pic_not_valid++; view->signal &= ~_K_VIEW_SIG_FLAG_FORCE_UPDATE; @@ -2248,8 +2063,8 @@ _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { SCIkdebug(SCIkGRAPHICS, " dv["PREG"]: signal %04x -> %04x\n", PRINT_REG(obj), oldsignal, view->signal); - /* Never happens - if (view->signal & 0) { + // Never happens +/* if (view->signal & 0) { view->signal &= ~_K_VIEW_SIG_FLAG_FREESCI_STOPUPD; fprintf(stderr, "Unsetting magic StopUpd for view "PREG"\n", PRINT_REG(obj)); } */ @@ -2258,8 +2073,8 @@ _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { } } -static void -_k_update_signals_in_view_list(gfxw_list_t *old_list, gfxw_list_t *new_list) { /* O(n^2)... a bit painful, but much faster than the redraws it helps prevent */ +static void _k_update_signals_in_view_list(gfxw_list_t *old_list, gfxw_list_t *new_list) { + // O(n^2)... a bit painful, but much faster than the redraws it helps prevent gfxw_dyn_view_t *old_widget = (gfxw_dyn_view_t *) old_list->contents; /* Traverses all old widgets, updates them with signals from the new widgets. @@ -2278,17 +2093,16 @@ _k_update_signals_in_view_list(gfxw_list_t *old_list, gfxw_list_t *new_list) { / if (new_widget) { int carry = old_widget->signal & _K_VIEW_SIG_FLAG_FREESCI_STOPUPD; - /* Transfer 'stopupd' flag */ + // Transfer 'stopupd' flag if ((new_widget->pos.x != old_widget->pos.x) || (new_widget->pos.y != old_widget->pos.y) - /* ** No idea why this is supposed to be bad ** - || (new_widget->z != old_widget->z) + // No idea why this is supposed to be bad +/* || (new_widget->z != old_widget->z) || (new_widget->view != old_widget->view) || (new_widget->loop != old_widget->loop) || (new_widget->cel != old_widget->cel) - */ - ) + */) carry = 0; old_widget->signal = new_widget->signal |= carry; @@ -2298,20 +2112,18 @@ _k_update_signals_in_view_list(gfxw_list_t *old_list, gfxw_list_t *new_list) { / } } -static void -_k_view_list_kryptonize(gfxw_widget_t *v) { +static void _k_view_list_kryptonize(gfxw_widget_t *v) { if (v) { v->flags &= ~GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; _k_view_list_kryptonize(v->next); } } -static void -_k_raise_topmost_in_view_list(state_t *s, gfxw_list_t *list, gfxw_dyn_view_t *view) { +static void _k_raise_topmost_in_view_list(state_t *s, gfxw_list_t *list, gfxw_dyn_view_t *view) { if (view) { - gfxw_dyn_view_t *next = (gfxw_dyn_view_t *) view->next; + gfxw_dyn_view_t *next = (gfxw_dyn_view_t *)view->next; - /* step 11 */ + // step 11 if ((view->signal & (_K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)) == 0) { SCIkdebug(SCIkGRAPHICS, "Forcing precedence 2 at ["PREG"] with %04x\n", PRINT_REG(make_reg(view->ID, view->subID)), view->signal); view->force_precedence = 2; @@ -2336,22 +2148,20 @@ _k_raise_topmost_in_view_list(state_t *s, gfxw_list_t *list, gfxw_dyn_view_t *vi } } - -static void -_k_redraw_view_list(state_t *s, gfxw_list_t *list) { +static void _k_redraw_view_list(state_t *s, gfxw_list_t *list) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) list->contents; while (view) { SCIkdebug(SCIkGRAPHICS, " dv["PREG"]: signal %04x\n", make_reg(view->ID, view->subID), view->signal); - /* step 1 of subalgorithm */ + // step 1 of subalgorithm if (view->signal & _K_VIEW_SIG_FLAG_NO_UPDATE) { if (view->signal & _K_VIEW_SIG_FLAG_FORCE_UPDATE) view->signal &= ~_K_VIEW_SIG_FLAG_FORCE_UPDATE; if (view->signal & _K_VIEW_SIG_FLAG_UPDATED) view->signal &= ~(_K_VIEW_SIG_FLAG_UPDATED | _K_VIEW_SIG_FLAG_NO_UPDATE); - } else { /* NO_UPD is not set */ + } else { // NO_UPD is not set if (view->signal & _K_VIEW_SIG_FLAG_STOP_UPDATE) { view->signal &= ~_K_VIEW_SIG_FLAG_STOP_UPDATE; view->signal |= _K_VIEW_SIG_FLAG_NO_UPDATE; @@ -2361,8 +2171,7 @@ _k_redraw_view_list(state_t *s, gfxw_list_t *list) { SCIkdebug(SCIkGRAPHICS, " at substep 6: signal %04x\n", view->signal); if (view->signal & _K_VIEW_SIG_FLAG_ALWAYS_UPDATE) - view->signal &= ~(_K_VIEW_SIG_FLAG_STOP_UPDATE | _K_VIEW_SIG_FLAG_UPDATED - | _K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_FORCE_UPDATE); + view->signal &= ~(_K_VIEW_SIG_FLAG_STOP_UPDATE | _K_VIEW_SIG_FLAG_UPDATED | _K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_FORCE_UPDATE); SCIkdebug(SCIkGRAPHICS, " at substep 11/14: signal %04x\n", view->signal); @@ -2380,29 +2189,24 @@ _k_redraw_view_list(state_t *s, gfxw_list_t *list) { } } - -/* Flags for _k_draw_view_list */ -/* Whether some magic with the base object's "signal" selector should be done: */ +// Flags for _k_draw_view_list +// Whether some magic with the base object's "signal" selector should be done: #define _K_DRAW_VIEW_LIST_USE_SIGNAL 1 -/* This flag draws all views with the "DISPOSE_ME" flag set: */ +// This flag draws all views with the "DISPOSE_ME" flag set: #define _K_DRAW_VIEW_LIST_DISPOSEABLE 2 -/* Use this one to draw all views with "DISPOSE_ME" NOT set: */ +// Use this one to draw all views with "DISPOSE_ME" NOT set: #define _K_DRAW_VIEW_LIST_NONDISPOSEABLE 4 -/* Draw as picviews */ +// Draw as picviews #define _K_DRAW_VIEW_LIST_PICVIEW 8 - -void -_k_draw_view_list(state_t *s, gfxw_list_t *list, int flags) -/* Draws list_nr members of list to s->pic. */ -{ +void _k_draw_view_list(state_t *s, gfxw_list_t *list, int flags) { + // Draws list_nr members of list to s->pic. gfxw_dyn_view_t *widget = (gfxw_dyn_view_t *) list->contents; if (GFXWC(s->port) != GFXWC(s->dyn_views->parent)) - return; /* Return if the pictures are meant for a different port */ + return; // Return if the pictures are meant for a different port while (widget) { - if (flags & _K_DRAW_VIEW_LIST_PICVIEW) widget = gfxw_picviewize_dynview(widget); @@ -2419,29 +2223,27 @@ _k_draw_view_list(state_t *s, gfxw_list_t *list, int flags) || ((flags & _K_DRAW_VIEW_LIST_NONDISPOSEABLE) && !(signal & _K_VIEW_SIG_FLAG_DISPOSE_ME))) { if (flags & _K_DRAW_VIEW_LIST_USE_SIGNAL) { - signal &= ~(_K_VIEW_SIG_FLAG_STOP_UPDATE | _K_VIEW_SIG_FLAG_UPDATED | - _K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_FORCE_UPDATE); - /* Clear all of those flags */ + signal &= ~(_K_VIEW_SIG_FLAG_STOP_UPDATE | _K_VIEW_SIG_FLAG_UPDATED | _K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_FORCE_UPDATE); + // Clear all of those flags if (signal & _K_VIEW_SIG_FLAG_HIDDEN) gfxw_hide_widget(GFXW(widget)); else gfxw_show_widget(GFXW(widget)); - *((reg_t *)(widget->signalp)) = make_reg(0, signal); /* Write the changes back */ + *((reg_t *)(widget->signalp)) = make_reg(0, signal); // Write the changes back }; - } /* ...if we're drawing disposeables and this one is disposeable, or if we're drawing non- - ** disposeables and this one isn't disposeable */ + } // ...if we're drawing disposeables and this one is disposeable, or if we're drawing non- + // disposeables and this one isn't disposeable } widget = (gfxw_dyn_view_t *) widget->next; - } /* while (widget) */ + } // while (widget) } -reg_t -kAddToPic(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kAddToPic(state_t *s, int funct_nr, int argc, reg_t *argv) { gfxw_list_t *pic_views; reg_t list_ref = argv[0]; @@ -2467,26 +2269,19 @@ kAddToPic(state_t *s, int funct_nr, int argc, reg_t *argv) { } else { widget->ID = -1; if (control >= 0) { - abs_rect_t abs_zone = nsrect_clip(s, y, - calculate_nsrect(s, x, y, - view, loop, cel), - priority); - + abs_rect_t abs_zone = nsrect_clip(s, y, calculate_nsrect(s, x, y, view, loop, cel), priority); draw_rect_to_control_map(s, abs_zone); } ADD_TO_CURRENT_PICTURE_PORT(gfxw_picviewize_dynview((gfxw_dyn_view_t *) widget)); } - } else { list_t *list; if (!list_ref.segment) { - SCIkdebug(SCIkWARNING, "Attempt to AddToPic single non-list: "PREG"\n", - PRINT_REG(list_ref)); + SCIkdebug(SCIkWARNING, "Attempt to AddToPic single non-list: "PREG"\n", PRINT_REG(list_ref)); return s->r_acc; } - list = LOOKUP_LIST(list_ref); pic_views = gfxw_new_list(s->picture_port->bounds, 1); @@ -2494,12 +2289,12 @@ kAddToPic(state_t *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkGRAPHICS, "Preparing picview list...\n"); _k_make_view_list(s, &pic_views, list, 0, funct_nr, argc, argv); _k_prepare_view_list(s, pic_views, _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP); - /* Store pic views for later re-use */ + // Store pic views for later re-use SCIkdebug(SCIkGRAPHICS, "Drawing picview list...\n"); ADD_TO_CURRENT_PICTURE_PORT(pic_views); _k_draw_view_list(s, pic_views, _K_DRAW_VIEW_LIST_NONDISPOSEABLE | _K_DRAW_VIEW_LIST_DISPOSEABLE | _K_DRAW_VIEW_LIST_PICVIEW); - /* Draw relative to the bottom center */ + // Draw relative to the bottom center SCIkdebug(SCIkGRAPHICS, "Returning.\n"); } reparentize_primary_widget_lists(s, s->port); @@ -2507,15 +2302,11 @@ kAddToPic(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } - -reg_t -kGetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kGetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, s->port->ID); } - -reg_t -kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { if (activated_icon_bar && argc == 6) { port_origin_x = port_origin_y = 0; activated_icon_bar = 0; @@ -2542,7 +2333,7 @@ kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { return NULL_REG; } - s->port->draw(GFXW(s->port), gfxw_point_zero); /* Update the port we're leaving */ + s->port->draw(GFXW(s->port), gfxw_point_zero); // Update the port we're leaving s->port = new_port; return s->r_acc; } @@ -2551,7 +2342,7 @@ kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { port_origin_x = SKPV(1); if (SKPV(0) == -10) { - s->port->draw(GFXW(s->port), gfxw_point_zero); /* Update the port we're leaving */ + s->port->draw(GFXW(s->port), gfxw_point_zero); // Update the port we're leaving s->port = s->iconbar_port; activated_icon_bar = 1; return s->r_acc; @@ -2559,8 +2350,8 @@ kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { s->gfx_state->options->pic_port_bounds = gfx_rect(UKPV(5), UKPV(4), UKPV(3), UKPV(2)); - /* FIXME: Should really only invalidate all loaded pic resources here; - this is overkill */ + // FIXME: Should really only invalidate all loaded pic resources here; + // this is overkill gfxr_free_all_resources(s->gfx_state->driver, s->gfx_state->resstate); break; @@ -2573,8 +2364,7 @@ kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { return NULL_REG; } -static inline void -add_to_chrono(state_t *s, gfxw_widget_t *widget) { +static inline void add_to_chrono(state_t *s, gfxw_widget_t *widget) { gfxw_port_t *chrono_port; gfxw_list_t *tw; @@ -2585,8 +2375,7 @@ add_to_chrono(state_t *s, gfxw_widget_t *widget) { ADD_TO_CURRENT_PORT(chrono_port); } -reg_t -kDrawCel(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kDrawCel(state_t *s, int funct_nr, int argc, reg_t *argv) { int view = SKPV(0); int loop = SKPV(1); int cel = SKPV(2); @@ -2595,20 +2384,19 @@ kDrawCel(state_t *s, int funct_nr, int argc, reg_t *argv) { int priority = SKPV_OR_ALT(5, -1); gfxw_view_t *new_view; - /* - if (!view) { - SCIkwarn(SCIkERROR, "Attempt to draw non-existing view.%03d\n", view); - return; - } - */ +/* + if (!view) { + SCIkwarn(SCIkERROR, "Attempt to draw non-existing view.%03d\n", view); + return; + } +*/ if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { SCIkwarn(SCIkERROR, "Attempt to draw non-existing view.%03d\n", view); return s->r_acc; } - SCIkdebug(SCIkGRAPHICS, "DrawCel((%d,%d), (view.%d, %d, %d), p=%d)\n", x, y, view, loop, - cel, priority); + SCIkdebug(SCIkGRAPHICS, "DrawCel((%d,%d), (view.%d, %d, %d), p=%d)\n", x, y, view, loop, cel, priority); new_view = gfxw_new_view(s->gfx_state, Common::Point(x, y), view, loop, cel, 0, priority, -1, ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET); @@ -2620,13 +2408,10 @@ kDrawCel(state_t *s, int funct_nr, int argc, reg_t *argv) { #endif FULL_REDRAW(); - - return s->r_acc; } -reg_t -kDisposeWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kDisposeWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { unsigned int goner_nr = SKPV(0); gfxw_port_t *goner; gfxw_port_t *pred; @@ -2644,16 +2429,15 @@ kDisposeWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { } if (s->drop_views && GFXWC(s->drop_views->parent) == GFXWC(goner)) - s->drop_views = NULL; /* Kill it */ + s->drop_views = NULL; // Kill it pred = gfxw_remove_port(s->visual, goner); - if (goner == s->port) /* Did we kill the active port? */ + if (goner == s->port) // Did we kill the active port? s->port = pred; - /* Find the last port that exists and that isn't marked no-switch */ - while ((!s->visual->port_refs[id] && id >= 0) || - (s->visual->port_refs[id]->flags & GFXW_FLAG_NO_IMPLICIT_SWITCH)) + // Find the last port that exists and that isn't marked no-switch + while ((!s->visual->port_refs[id] && id >= 0) || (s->visual->port_refs[id]->flags & GFXW_FLAG_NO_IMPLICIT_SWITCH)) id--; sciprintf("Activating port %d after disposing window %d\n", id, goner_nr); @@ -2663,11 +2447,11 @@ kDisposeWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { s->port = gfxw_find_default_port(s->visual); gfxop_update(s->gfx_state); + return s->r_acc; } -reg_t -kNewWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kNewWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { gfxw_port_t *window; int x, y, xl, yl, flags; gfx_color_t bgcolor; @@ -2675,7 +2459,7 @@ kNewWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { gfx_color_t black; gfx_color_t lWhite; int priority; - int argextra = argc == 13 ? 4 : 0; /* Triggers in PQ3 */ + int argextra = argc == 13 ? 4 : 0; // Triggers in PQ3 y = SKPV(0); x = SKPV(1); @@ -2711,23 +2495,17 @@ kNewWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { black.visual = *(get_pic_color(s, 0)); black.mask = GFX_MASK_VISUAL; black.alpha = 0; - lWhite.visual = *(get_pic_color(s, s->resmgr->sci_version < SCI_VERSION_01_VGA ? 15 : 255)), - lWhite.mask = GFX_MASK_VISUAL; + lWhite.visual = *(get_pic_color(s, s->resmgr->sci_version < SCI_VERSION_01_VGA ? 15 : 255)), lWhite.mask = GFX_MASK_VISUAL; lWhite.alpha = 0; - window = sciw_new_window(s, gfx_rect(x, y, xl, yl), s->titlebar_port->font_nr, - fgcolor, bgcolor, s->titlebar_port->font_nr, - lWhite, - black, - argv[4+argextra].segment ? kernel_dereference_char_pointer(s, argv[4+argextra], 0) : NULL, - flags); + window = sciw_new_window(s, gfx_rect(x, y, xl, yl), s->titlebar_port->font_nr, fgcolor, bgcolor, + s->titlebar_port->font_nr, lWhite, black, argv[4 + argextra].segment ? + kernel_dereference_char_pointer(s, argv[4 + argextra], 0) : NULL, flags); - /* PQ3 has the interpreter store underBits implicitly. - The feature was promptly removed after its release, never to be seen again. */ + // PQ3 has the interpreter store underBits implicitly. + // The feature was promptly removed after its release, never to be seen again. if (argextra) - gfxw_port_auto_restore_background(s->visual, window, - gfx_rect(SKPV(5), SKPV(4), - SKPV(7) - SKPV(5), SKPV(6) - SKPV(4))); + gfxw_port_auto_restore_background(s->visual, window, gfx_rect(SKPV(5), SKPV(4), SKPV(7) - SKPV(5), SKPV(6) - SKPV(4))); ADD_TO_WINDOW_PORT(window); FULL_REDRAW(); @@ -2735,49 +2513,45 @@ kNewWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { window->draw(GFXW(window), gfxw_point_zero); gfxop_update(s->gfx_state); - s->port = window; /* Set active port */ + s->port = window; // Set active port return make_reg(0, window->ID); } - -#define K_ANIMATE_CENTER_OPEN_H 0 /* horizontally open from center */ -#define K_ANIMATE_CENTER_OPEN_V 1 /* vertically open from center */ -#define K_ANIMATE_RIGHT_OPEN 2 /* open from right */ -#define K_ANIMATE_LEFT_OPEN 3 /* open from left */ -#define K_ANIMATE_BOTTOM_OPEN 4 /* open from bottom */ -#define K_ANIMATE_TOP_OPEN 5 /* open from top */ -#define K_ANIMATE_BORDER_OPEN_F 6 /* open from edges to center */ -#define K_ANIMATE_CENTER_OPEN_F 7 /* open from center to edges */ -#define K_ANIMATE_OPEN_CHECKERS 8 /* open random checkboard */ -#define K_ANIMATE_BORDER_CLOSE_H_CENTER_OPEN_H 9 /* horizontally close to center,reopen from center */ -#define K_ANIMATE_BORDER_CLOSE_V_CENTER_OPEN_V 10 /* vertically close to center, reopen from center */ -#define K_ANIMATE_LEFT_CLOSE_RIGHT_OPEN 11 /* close to right, reopen from right */ -#define K_ANIMATE_RIGHT_CLOSE_LEFT_OPEN 12 /* close to left, reopen from left */ -#define K_ANIMATE_TOP_CLOSE_BOTTOM_OPEN 13 /* close to bottom, reopen from bottom */ -#define K_ANIMATE_BOTTOM_CLOSE_TOP_OPEN 14 /* close to top, reopen from top */ -#define K_ANIMATE_CENTER_CLOSE_F_BORDER_OPEN_F 15 /* close from center to edges, -** reopen from edges to center */ -#define K_ANIMATE_BORDER_CLOSE_F_CENTER_OPEN_F 16 /* close from edges to center, reopen from -** center to edges */ -#define K_ANIMATE_CLOSE_CHECKERS_OPEN_CHECKERS 17 /* close random checkboard, reopen */ +#define K_ANIMATE_CENTER_OPEN_H 0 // horizontally open from center +#define K_ANIMATE_CENTER_OPEN_V 1 // vertically open from center +#define K_ANIMATE_RIGHT_OPEN 2 // open from right +#define K_ANIMATE_LEFT_OPEN 3 // open from left +#define K_ANIMATE_BOTTOM_OPEN 4 // open from bottom +#define K_ANIMATE_TOP_OPEN 5 // open from top +#define K_ANIMATE_BORDER_OPEN_F 6 // open from edges to center +#define K_ANIMATE_CENTER_OPEN_F 7 // open from center to edges +#define K_ANIMATE_OPEN_CHECKERS 8 // open random checkboard +#define K_ANIMATE_BORDER_CLOSE_H_CENTER_OPEN_H 9 // horizontally close to center,reopen from center +#define K_ANIMATE_BORDER_CLOSE_V_CENTER_OPEN_V 10 // vertically close to center, reopen from center +#define K_ANIMATE_LEFT_CLOSE_RIGHT_OPEN 11 // close to right, reopen from right +#define K_ANIMATE_RIGHT_CLOSE_LEFT_OPEN 12 // close to left, reopen from left +#define K_ANIMATE_TOP_CLOSE_BOTTOM_OPEN 13 // close to bottom, reopen from bottom +#define K_ANIMATE_BOTTOM_CLOSE_TOP_OPEN 14 // close to top, reopen from top +#define K_ANIMATE_CENTER_CLOSE_F_BORDER_OPEN_F 15 // close from center to edges, +// reopen from edges to center +#define K_ANIMATE_BORDER_CLOSE_F_CENTER_OPEN_F 16 // close from edges to center, reopen from +// center to edges */ +#define K_ANIMATE_CLOSE_CHECKERS_OPEN_CHECKERS 17 // close random checkboard, reopen #define K_ANIMATE_SCROLL_LEFT 0x28 #define K_ANIMATE_SCROLL_RIGHT 0x29 #define K_ANIMATE_SCROLL_DOWN 0x2a #define K_ANIMATE_SCROLL_UP 0x2b -#define K_ANIMATE_OPEN_SIMPLE 100 /* No animation */ - +#define K_ANIMATE_OPEN_SIMPLE 100 // No animation #define GRAPH_BLANK_BOX(s, x, y, xl, yl, color) GFX_ASSERT(gfxop_fill_box(s->gfx_state, \ - gfx_rect(x, (((y) < 10)? 10 : (y)), xl, (((y) < 10)? ((y) - 10) : 0) + (yl)), s->ega_colors[color])); + gfx_rect(x, (((y) < 10)? 10 : (y)), xl, (((y) < 10)? ((y) - 10) : 0) + (yl)), s->ega_colors[color])); #define GRAPH_UPDATE_BOX(s, x, y, xl, yl) GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, \ gfx_rect(x, (((y) < 10)? 10 : (y)) - 10, xl, (((y) < 10)? ((y) - 10) : 0) + (yl)), Common::Point(x, ((y) < 10)? 10 : (y) ))); - -static void -animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { +static void animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { int i, remaining_checkers; int update_counter; int granularity0 = s->animation_granularity << 1; @@ -2802,17 +2576,15 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, gfx_rect(0, 0, 320, 190), Common::Point(0, 10))); gfxop_update_box(s->gfx_state, gfx_rect(0, 0, 320, 200)); - /*SCIkdebug(SCIkGRAPHICS, "Animating pic opening type %x\n", s->pic_animate);*/ + //SCIkdebug(SCIkGRAPHICS, "Animating pic opening type %x\n", s->pic_animate); gfxop_enable_dirty_frames(s->gfx_state); if (s->animation_delay < 1) s->pic_animate = K_ANIMATE_OPEN_SIMPLE; - switch (s->pic_animate) { case K_ANIMATE_BORDER_CLOSE_H_CENTER_OPEN_H : - for (i = 0; i < 159 + granularity1; i += granularity1) { GRAPH_BLANK_BOX(s, i, 10, granularity1, 190, 0); gfxop_update(s->gfx_state); @@ -2953,25 +2725,20 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { int height = real_i * 3; int width = real_i * 5; - GRAPH_BLANK_BOX(s, width, 10 + height, - width_l, 190 - 2*height, 0); + GRAPH_BLANK_BOX(s, width, 10 + height, width_l, 190 - 2 * height, 0); gfxop_update(s->gfx_state); - GRAPH_BLANK_BOX(s, 320 - width_l - width, - 10 + height, width_l, 190 - 2*height, 0); + GRAPH_BLANK_BOX(s, 320 - width_l - width, 10 + height, width_l, 190 - 2 * height, 0); gfxop_update(s->gfx_state); - GRAPH_BLANK_BOX(s, width, 10 + height, - 320 - 2*width, height_l, 0); + GRAPH_BLANK_BOX(s, width, 10 + height, 320 - 2 * width, height_l, 0); gfxop_update(s->gfx_state); - GRAPH_BLANK_BOX(s, width, 200 - height_l - height, - 320 - 2*width, height_l, 0); + GRAPH_BLANK_BOX(s, width, 200 - height_l - height, 320 - 2 * width, height_l, 0); gfxop_update(s->gfx_state); gfxop_usleep(s->gfx_state, 4 * s->animation_delay); process_sound_events(s); } - case K_ANIMATE_BORDER_OPEN_F : for (i = 0; i < 31 + granularity3; i += granularity3) { @@ -2981,18 +2748,14 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { int height = real_i * 3; int width = real_i * 5; - GRAPH_UPDATE_BOX(s, width, 10 + height, - width_l, 190 - 2*height); + GRAPH_UPDATE_BOX(s, width, 10 + height, width_l, 190 - 2 * height); gfxop_update(s->gfx_state); - GRAPH_UPDATE_BOX(s, 320 - width_l - width, - 10 + height, width_l, 190 - 2*height); + GRAPH_UPDATE_BOX(s, 320 - width_l - width, 10 + height, width_l, 190 - 2 * height); gfxop_update(s->gfx_state); - GRAPH_UPDATE_BOX(s, width, 10 + height, - 320 - 2*width, height_l); + GRAPH_UPDATE_BOX(s, width, 10 + height, 320 - 2 * width, height_l); gfxop_update(s->gfx_state); - GRAPH_UPDATE_BOX(s, width, 200 - height_l - height, - 320 - 2*width, height_l); + GRAPH_UPDATE_BOX(s, width, 200 - height_l - height, 320 - 2 * width, height_l); gfxop_update(s->gfx_state); gfxop_usleep(s->gfx_state, 4 * s->animation_delay); @@ -3001,7 +2764,6 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { break; - case K_ANIMATE_BORDER_CLOSE_F_CENTER_OPEN_F : for (i = 0; i < 31 + granularity3; i += granularity3) { @@ -3011,25 +2773,20 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { int height = real_i * 3; int width = real_i * 5; - GRAPH_BLANK_BOX(s, width, 10 + height, - width_l, 190 - 2*height, 0); + GRAPH_BLANK_BOX(s, width, 10 + height, width_l, 190 - 2 * height, 0); gfxop_update(s->gfx_state); - GRAPH_BLANK_BOX(s, 320 - width_l - width, - 10 + height, width_l, 190 - 2*height, 0); + GRAPH_BLANK_BOX(s, 320 - width_l - width, 10 + height, width_l, 190 - 2 * height, 0); gfxop_update(s->gfx_state); - GRAPH_BLANK_BOX(s, width, 10 + height, - 320 - 2*width, height_l, 0); + GRAPH_BLANK_BOX(s, width, 10 + height, 320 - 2 * width, height_l, 0); gfxop_update(s->gfx_state); - GRAPH_BLANK_BOX(s, width, 200 - height_l - height, - 320 - 2*width, height_l, 0); + GRAPH_BLANK_BOX(s, width, 200 - height_l - height, 320 - 2 * width, height_l, 0); gfxop_update(s->gfx_state); gfxop_usleep(s->gfx_state, 7 * s->animation_delay); process_sound_events(s); } - case K_ANIMATE_CENTER_OPEN_F : for (i = 31; i >= 1 - granularity3; i -= granularity3) { @@ -3039,27 +2796,21 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { int height = real_i * 3; int width = real_i * 5; - GRAPH_UPDATE_BOX(s, width, 10 + height, - width_l, 190 - 2*height); + GRAPH_UPDATE_BOX(s, width, 10 + height, width_l, 190 - 2 * height); gfxop_update(s->gfx_state); - GRAPH_UPDATE_BOX(s, 320 - width_l - width, - 10 + height, width_l, 190 - 2*height); + GRAPH_UPDATE_BOX(s, 320 - width_l - width, 10 + height, width_l, 190 - 2*height); gfxop_update(s->gfx_state); - GRAPH_UPDATE_BOX(s, width, 10 + height, - 320 - 2 * width, height_l); + GRAPH_UPDATE_BOX(s, width, 10 + height, 320 - 2 * width, height_l); gfxop_update(s->gfx_state); - GRAPH_UPDATE_BOX(s, width, 200 - height_l - height, - 320 - 2 * width, height_l); + GRAPH_UPDATE_BOX(s, width, 200 - height_l - height, 320 - 2 * width, height_l); gfxop_update(s->gfx_state); gfxop_usleep(s->gfx_state, 7 * s->animation_delay); process_sound_events(s); } - break; - case K_ANIMATE_CLOSE_CHECKERS_OPEN_CHECKERS : memset(checkers, 0, sizeof(checkers)); @@ -3071,8 +2822,9 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { i = -1; while (checker) - if (checkers[++i] == 0) --checker; - checkers[i] = 1; /* Mark checker as used */ + if (checkers[++i] == 0) + --checker; + checkers[i] = 1; // Mark checker as used x = i % 32; y = i / 32; @@ -3103,7 +2855,7 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { while (checker) if (checkers[++i] == 0) --checker; - checkers[i] = 1; /* Mark checker as used */ + checkers[i] = 1; // Mark checker as used x = i % 32; y = i / 32; @@ -3128,14 +2880,9 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { case K_ANIMATE_SCROLL_LEFT : for (i = 0; i < 319; i += granularity0) { - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, - gfx_rect(320 - i, 0, i, 190), - Common::Point(0, 10))); - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, - gfx_rect(0, 0, 320 - i, 190), - Common::Point(i, 10))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, gfx_rect(320 - i, 0, i, 190), Common::Point(0, 10))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, gfx_rect(0, 0, 320 - i, 190), Common::Point(i, 10))); gfxop_update(s->gfx_state); - gfxop_usleep(s->gfx_state, s->animation_delay >> 3); } GRAPH_UPDATE_BOX(s, 0, 10, 320, 190); @@ -3144,14 +2891,9 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { case K_ANIMATE_SCROLL_RIGHT : for (i = 0; i < 319; i += granularity0) { - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, - gfx_rect(0, 0, i, 190), - Common::Point(319 - i, 10))); - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, - gfx_rect(i, 0, 320 - i, 190), - Common::Point(0, 10))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, gfx_rect(0, 0, i, 190), Common::Point(319 - i, 10))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, gfx_rect(i, 0, 320 - i, 190), Common::Point(0, 10))); gfxop_update(s->gfx_state); - gfxop_usleep(s->gfx_state, s->animation_delay >> 3); } GRAPH_UPDATE_BOX(s, 0, 10, 320, 190); @@ -3160,14 +2902,9 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { case K_ANIMATE_SCROLL_UP : for (i = 0; i < 189; i += granularity0) { - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, - gfx_rect(0, 190 - i, 320, i), - Common::Point(0, 10))); - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, - gfx_rect(0, 0, 320, 190 - i), - Common::Point(0, 10 + i))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, gfx_rect(0, 190 - i, 320, i), Common::Point(0, 10))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, gfx_rect(0, 0, 320, 190 - i), Common::Point(0, 10 + i))); gfxop_update(s->gfx_state); - gfxop_usleep(s->gfx_state, s->animation_delay >> 3); } GRAPH_UPDATE_BOX(s, 0, 10, 320, 190); @@ -3176,14 +2913,9 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { case K_ANIMATE_SCROLL_DOWN : for (i = 0; i < 189; i += granularity0) { - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, - gfx_rect(0, 0, 320, i), - Common::Point(0, 200 - i))); - GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, - gfx_rect(0, i, 320, 190 - i), - Common::Point(0, 10))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, newscreen, gfx_rect(0, 0, 320, i), Common::Point(0, 200 - i))); + GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, gfx_rect(0, i, 320, 190 - i), Common::Point(0, 10))); gfxop_update(s->gfx_state); - gfxop_usleep(s->gfx_state, s->animation_delay >> 3); } GRAPH_UPDATE_BOX(s, 0, 10, 320, 190); @@ -3199,23 +2931,18 @@ animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv) { GFX_ASSERT(gfxop_free_pixmap(s->gfx_state, s->old_screen)); GFX_ASSERT(gfxop_free_pixmap(s->gfx_state, newscreen)); s->old_screen = NULL; - } - -reg_t -kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) -/* Animations are supposed to take a maximum of s->animation_delay milliseconds. */ -{ +reg_t kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) { + // Animations are supposed to take a maximum of s->animation_delay milliseconds. reg_t cast_list_ref = KP_ALT(0, NULL_REG); int cycle = (KP_ALT(1, NULL_REG)).offset; list_t *cast_list = NULL; int open_animation = 0; - - process_sound_events(s); /* Take care of incoming events (kAnimate is called semi-regularly) */ - _k_animate_ran = 1; /* Used by some of the invoked functions to check for recursion, which may, - ** after all, damage the cast list */ + process_sound_events(s); // Take care of incoming events (kAnimate is called semi-regularly) + _k_animate_ran = 1; // Used by some of the invoked functions to check for recursion, which may, + // after all, damage the cast list if (cast_list_ref.segment) { cast_list = LOOKUP_LIST(cast_list_ref); @@ -3223,15 +2950,14 @@ kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) return s->r_acc; } - open_animation = (s->pic_is_new) && (s->pic_not_valid); s->pic_is_new = 0; assert_primary_widget_lists(s); - if (!s->dyn_views->contents /* Only reparentize empty dynview list */ - && ((GFXWC(s->port) != GFXWC(s->dyn_views->parent)) /* If dynviews are on other port... */ - || (s->dyn_views->next))) /* ... or not on top of the view list */ + if (!s->dyn_views->contents // Only reparentize empty dynview list + && ((GFXWC(s->port) != GFXWC(s->dyn_views->parent)) // If dynviews are on other port... + || (s->dyn_views->next))) // ... or not on top of the view list reparentize_primary_widget_lists(s, s->port); if (cast_list) { @@ -3240,17 +2966,16 @@ kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) _k_make_view_list(s, &(templist), cast_list, (cycle ? _K_MAKE_VIEW_LIST_CYCLE : 0) | _K_MAKE_VIEW_LIST_CALC_PRIORITY, funct_nr, argc, argv); - /* Make sure that none of the doits() did something evil */ + // Make sure that none of the doits() did something evil assert_primary_widget_lists(s); - if (!s->dyn_views->contents /* Only reparentize empty dynview list */ - && ((GFXWC(s->port) != GFXWC(s->dyn_views->parent)) /* If dynviews are on other port... */ - || (s->dyn_views->next))) /* ... or not on top of the view list */ + if (!s->dyn_views->contents // Only reparentize empty dynview list + && ((GFXWC(s->port) != GFXWC(s->dyn_views->parent)) // If dynviews are on other port... + || (s->dyn_views->next))) // ... or not on top of the view list reparentize_primary_widget_lists(s, s->port); - /* End of doit() recovery code */ - + // End of doit() recovery code - if (s->pic_is_new) { /* Happens if DrawPic() is executed by a dynview (yes, that happens) */ + if (s->pic_is_new) { // Happens if DrawPic() is executed by a dynview (yes, that happens) kAnimate(s, funct_nr, argc, argv); /* Tail-recurse */ return s->r_acc; } @@ -3266,20 +2991,20 @@ kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) _k_update_signals_in_view_list(s->dyn_views, templist); s->dyn_views->tag(GFXW(s->dyn_views)); - _k_raise_topmost_in_view_list(s, s->dyn_views, (gfxw_dyn_view_t *) templist->contents); + _k_raise_topmost_in_view_list(s, s->dyn_views, (gfxw_dyn_view_t *)templist->contents); templist->widfree(GFXW(templist)); - s->dyn_views->free_tagged(GFXWC(s->dyn_views)); /* Free obsolete dynviews */ - } /* if (cast_list) */ + s->dyn_views->free_tagged(GFXWC(s->dyn_views)); // Free obsolete dynviews + } // if (cast_list) if (open_animation) { - gfxop_clear_box(s->gfx_state, gfx_rect(0, 10, 320, 190)); /* Propagate pic */ + gfxop_clear_box(s->gfx_state, gfx_rect(0, 10, 320, 190)); // Propagate pic s->visual->add_dirty_abs(GFXWC(s->visual), gfx_rect_fullscreen, 0); - /* Mark screen as dirty so picviews will be drawn correctly */ + // Mark screen as dirty so picviews will be drawn correctly FULL_REDRAW(); animate_do_animation(s, funct_nr, argc, argv); - } /* if (open_animation) */ + } // if (open_animation) if (cast_list) { int retval; @@ -3289,7 +3014,7 @@ kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) _k_view_list_do_postdraw(s, s->dyn_views); - /* _k_view_list_dispose_loop() returns -1 if it requested a re-start, so we do just that. */ + // _k_view_list_dispose_loop() returns -1 if it requested a re-start, so we do just that. while ((retval = _k_view_list_dispose_loop(s, cast_list, (gfxw_dyn_view_t *) s->dyn_views->contents, funct_nr, argc, argv) < 0)) reparentize = 1; @@ -3304,9 +3029,9 @@ kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) } if ((reparentize | retval) - && (GFXWC(s->port) == GFXWC(s->dyn_views->parent)) /* If dynviews are on the same port... */ - && (s->dyn_views->next)) /* ... and not on top of the view list... */ - reparentize_primary_widget_lists(s, s->port); /* ...then reparentize. */ + && (GFXWC(s->port) == GFXWC(s->dyn_views->parent)) // If dynviews are on the same port... + && (s->dyn_views->next)) // ... and not on top of the view list... + reparentize_primary_widget_lists(s, s->port); // ...then reparentize. _k_view_list_kryptonize(s->dyn_views->contents); } @@ -3318,8 +3043,7 @@ kAnimate(state_t *s, int funct_nr, int argc, reg_t *argv) #define SHAKE_DOWN 1 #define SHAKE_RIGHT 2 -reg_t -kShakeScreen(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kShakeScreen(state_t *s, int funct_nr, int argc, reg_t *argv) { int shakes = SKPV_OR_ALT(0, 1); int directions = SKPV_OR_ALT(1, 1); gfx_pixmap_t *screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 0, 320, 200)); @@ -3346,7 +3070,6 @@ kShakeScreen(state_t *s, int funct_nr, int argc, reg_t *argv) { gfxop_update(s->gfx_state); gfxop_usleep(s->gfx_state, 50000); - gfxop_draw_pixmap(s->gfx_state, screen, gfx_rect(0, 0, 320, 200), Common::Point(0, 0)); gfxop_update(s->gfx_state); gfxop_usleep(s->gfx_state, 50000); @@ -3368,9 +3091,7 @@ kShakeScreen(state_t *s, int funct_nr, int argc, reg_t *argv) { #define K_DISPLAY_RESTORE_UNDER 108 #define K_DONT_UPDATE_IMMEDIATELY 121 - -reg_t -kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { int argpt; reg_t textp = argv[0]; int index = UKPV_OR_ALT(1, 0); @@ -3383,8 +3104,7 @@ kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { gfx_color_t color0, *color1, bg_color; gfx_alignment_t halign = ALIGN_LEFT; - rect_t area = gfx_rect(port->draw_pos.x, port->draw_pos.y, - 320 - port->draw_pos.x, 200 - port->draw_pos.y); + rect_t area = gfx_rect(port->draw_pos.x, port->draw_pos.y, 320 - port->draw_pos.x, 200 - port->draw_pos.y); int gray = port->gray_text; int font_nr = port->font_nr; gfxw_text_t *text_handle; @@ -3392,10 +3112,9 @@ kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { color0 = port->color; bg_color = port->bgcolor; - if (textp.segment) { argpt = 1; - text = (char *) kernel_dereference_bulk_pointer(s, textp, 0); + text = (char *)kernel_dereference_bulk_pointer(s, textp, 0); } else { argpt = 2; text = kernel_lookup_text(s, textp, index); @@ -3407,7 +3126,6 @@ kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { } while (argpt < argc) { - switch (UKPV(argpt++)) { case K_DISPLAY_SET_COORDS: @@ -3508,16 +3226,14 @@ kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { if (s->version >= SCI_VERSION_FTU_DISPLAY_COORDS_FUZZY) { if (halign == ALIGN_LEFT) - GFX_ASSERT(gfxop_get_text_params(s->gfx_state, font_nr, text, - area.xl, &area.xl, &area.yl, 0, - NULL, NULL, NULL)); + GFX_ASSERT(gfxop_get_text_params(s->gfx_state, font_nr, text, area.xl, &area.xl, &area.yl, 0, NULL, NULL, NULL)); - /* Make the text fit on the screen */ + // Make the text fit on the screen if (area.x + area.xl > 320) - area.x += 320 - area.x - area.xl; /* Plus negative number = subtraction */ + area.x += 320 - area.x - area.xl; // Plus negative number = subtraction if (area.y + area.yl > 200) { - area.y += 200 - area.y - area.yl; /* Plus negative number = subtraction */ + area.y += 200 - area.y - area.yl; // Plus negative number = subtraction } } @@ -3528,36 +3244,30 @@ kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { assert_primary_widget_lists(s); - text_handle = gfxw_new_text(s->gfx_state, area, font_nr, text, halign, - ALIGN_TOP, color0, *color1, bg_color, 0); + text_handle = gfxw_new_text(s->gfx_state, area, font_nr, text, halign, ALIGN_TOP, color0, *color1, bg_color, 0); if (!text_handle) { SCIkwarn(SCIkERROR, "Display: Failed to create text widget!\n"); return NULL_REG; } - if (save_under) { /* Backup */ + if (save_under) { // Backup rect_t save_area = text_handle->bounds; save_area.x += port->bounds.x; save_area.y += port->bounds.y; s->r_acc = graph_save_box(s, save_area); - text_handle->serial++; /* This is evil! */ - - SCIkdebug(SCIkGRAPHICS, "Saving (%d, %d) size (%d, %d) as "PREG"\n", - save_area.x, save_area.y, save_area.xl, save_area.yl, s->r_acc); + text_handle->serial++; // This is evil! + SCIkdebug(SCIkGRAPHICS, "Saving (%d, %d) size (%d, %d) as "PREG"\n", save_area.x, save_area.y, save_area.xl, save_area.yl, s->r_acc); } - SCIkdebug(SCIkGRAPHICS, "Display: Commiting text '%s'\n", text); - /* - ADD_TO_CURRENT_FG_WIDGETS(text_handle); - */ + //ADD_TO_CURRENT_FG_WIDGETS(text_handle); ADD_TO_CURRENT_FG_WIDGETS(GFXW(text_handle)); - if ((!s->pic_not_valid) && update_immediately) { /* Refresh if drawn to valid picture */ + if ((!s->pic_not_valid) && update_immediately) { // Refresh if drawn to valid picture FULL_REDRAW(); SCIkdebug(SCIkGRAPHICS, "Refreshing display...\n"); } -- cgit v1.2.3