From 921e6ff5cf3944c1a62a3ad9a91c29bb21aa9942 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 15 Feb 2009 22:33:36 +0000 Subject: SCI: Run astyle to make the code be more compliant with our Code Formatting Guidelines: gfx dir svn-id: r38321 --- engines/sci/gfx/alpha_mvi_crossblit.cpp | 413 +++++++------- engines/sci/gfx/antialias.cpp | 30 +- engines/sci/gfx/font.cpp | 69 ++- engines/sci/gfx/gfx_crossblit.cpp | 15 +- engines/sci/gfx/gfx_driver.cpp | 127 ++--- engines/sci/gfx/gfx_line.cpp | 5 +- engines/sci/gfx/gfx_pixmap_scale.cpp | 63 +-- engines/sci/gfx/gfx_res_options.cpp | 139 +++-- engines/sci/gfx/gfx_resource.cpp | 252 ++++----- engines/sci/gfx/gfx_support.cpp | 180 +++--- engines/sci/gfx/gfx_test.cpp | 781 +++++++++++++------------- engines/sci/gfx/gfx_tools.cpp | 68 +-- engines/sci/gfx/menubar.cpp | 114 ++-- engines/sci/gfx/operations.cpp | 725 ++++++++++++------------ engines/sci/gfx/resmgr.cpp | 183 +++--- engines/sci/gfx/resource/sci_cursor_0.cpp | 16 +- engines/sci/gfx/resource/sci_font.cpp | 14 +- engines/sci/gfx/resource/sci_pal_1.cpp | 29 +- engines/sci/gfx/resource/sci_pic_0.cpp | 631 +++++++++++---------- engines/sci/gfx/resource/sci_picfill.cpp | 95 ++-- engines/sci/gfx/resource/sci_picfill_aux.cpp | 29 +- engines/sci/gfx/resource/sci_resmgr.cpp | 123 ++--- engines/sci/gfx/resource/sci_view_0.cpp | 21 +- engines/sci/gfx/resource/sci_view_1.cpp | 210 ++++--- engines/sci/gfx/sbtree.cpp | 126 ++--- engines/sci/gfx/sci_widgets.cpp | 285 +++++----- engines/sci/gfx/widgets.cpp | 798 +++++++++++---------------- 27 files changed, 2570 insertions(+), 2971 deletions(-) (limited to 'engines') diff --git a/engines/sci/gfx/alpha_mvi_crossblit.cpp b/engines/sci/gfx/alpha_mvi_crossblit.cpp index 6a1e238c2b..f39561a1c0 100644 --- a/engines/sci/gfx/alpha_mvi_crossblit.cpp +++ b/engines/sci/gfx/alpha_mvi_crossblit.cpp @@ -41,13 +41,12 @@ void FUNCT_NAME(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_line, - int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel, - unsigned int alpha_test_mask, int alpha_shift + int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel, + unsigned int alpha_test_mask, int alpha_shift #ifdef PRIORITY - ,byte *priority_pos ,int bytes_per_priority_line, int bytes_per_priority_pixel, int priority + , byte *priority_pos , int bytes_per_priority_line, int bytes_per_priority_pixel, int priority #endif - ) -{ + ) { #ifdef USE_C_CODE #ifdef PRIORITY int left_mask = (255 << (((unsigned long) dest) & 7)) & 255; @@ -68,8 +67,8 @@ FUNCT_NAME(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_lin #ifdef PRIORITY byte *pri_next = priority_pos + bytes_per_priority_line; #endif - asm ("ldl $31, 0($31)\n\t" - "ldl $31, 0($31)\n\t"); /* Prefetch memory for next line */ + asm("ldl $31, 0($31)\n\t" + "ldl $31, 0($31)\n\t"); /* Prefetch memory for next line */ if (((unsigned long)src) & 4) data = *((unsigned int *) src); @@ -133,227 +132,227 @@ FUNCT_NAME(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_lin #ifdef PRIORITY assert(!(bytes_per_alpha_line & 7)); assert(bytes_per_alpha_pixel < 2); - real_alpha_shift |= (unsigned long) (priority << 16) | ((unsigned long) bytes_per_priority_pixel << 32); + real_alpha_shift |= (unsigned long)(priority << 16) | ((unsigned long) bytes_per_priority_pixel << 32); /* Work around gcc design bug allowing only 10 asm parameters */ #endif - __asm__ __volatile__ ( + __asm__ __volatile__( #ifdef PRIORITY - /* - ** dest: $16 - ** src: $17 - ** bytes_per_dest_line: $18 - ** bytes_per_src_line: $19 - ** xl : $20 - ** yl : $21 - ** alpha_test_mask: $24 - ** alpha_shift: $25 - ** 255: $8 - ** - ** bytes_per_priority_line: $9 - ** priority_pos: $10 - ** priority extended to 8 bytes: $7 - ** bytes_per_priority_pixel: $6 - ** - ** temp_priority_collection: $11 - ** priority_pos backup: $12 - ** left border mask: $13 - ** right border mask: $28 - ** priority test bit: $15 - ** ldq4priority result: $26 - */ - - "lda $30, -88($30) \n\t" - "stq $9, 0($30) \n\t" - "stq $10, 8($30) \n\t" - "stq $11, 16($30) \n\t" - "stq $12, 24($30) \n\t" - "stq $13, 32($30) \n\t" - "stq $15, 40($30) \n\t" - "stq $26, 48($30) \n\t" - "stq %8, 56($30) \n\t" - "stq %9, 64($30) \n\t" - "stq $7, 72($30) \n\t" - "stq $6, 80($30) \n\t" - - "mov %8, $9 \n\t" - "mov %9, $10 \n\t" + /* + ** dest: $16 + ** src: $17 + ** bytes_per_dest_line: $18 + ** bytes_per_src_line: $19 + ** xl : $20 + ** yl : $21 + ** alpha_test_mask: $24 + ** alpha_shift: $25 + ** 255: $8 + ** + ** bytes_per_priority_line: $9 + ** priority_pos: $10 + ** priority extended to 8 bytes: $7 + ** bytes_per_priority_pixel: $6 + ** + ** temp_priority_collection: $11 + ** priority_pos backup: $12 + ** left border mask: $13 + ** right border mask: $28 + ** priority test bit: $15 + ** ldq4priority result: $26 + */ + + "lda $30, -88($30) \n\t" + "stq $9, 0($30) \n\t" + "stq $10, 8($30) \n\t" + "stq $11, 16($30) \n\t" + "stq $12, 24($30) \n\t" + "stq $13, 32($30) \n\t" + "stq $15, 40($30) \n\t" + "stq $26, 48($30) \n\t" + "stq %8, 56($30) \n\t" + "stq %9, 64($30) \n\t" + "stq $7, 72($30) \n\t" + "stq $6, 80($30) \n\t" + + "mov %8, $9 \n\t" + "mov %9, $10 \n\t" #endif - "mov %6, $24 \n\t" - "mov %7, $25 \n\t" - "mov 255, $8 \n\t" - "subl $21, 1, $21 \n\t" + "mov %6, $24 \n\t" + "mov %7, $25 \n\t" + "mov 255, $8 \n\t" + "subl $21, 1, $21 \n\t" #ifdef PRIORITY - /* Defrobnicate real_alpha_shift data */ - "srl $25, 32, $6 \n\t" - "srl $25, 16, $7 \n\t" - "and $7, $8, $7 \n\t" - - /* Load first priority data quad */ - "andnot $10, 7, $0 \n\t" - "ldq $26, 0($0) \n\t" /* Load priority */ - "and $10, 7, $13 \n\t" - "sll $13, 3, $0 \n\t" - - /* Calculate right border mask */ - "addl $13, $20, $28\n\t" - "and $28, 7, $28 \n\t" - "beq $28, 7f \n\t" - "mov 8, $0 \n\t" - "subl $0, $28, $28 \n" - "7:\n\t" - "srl $8, $28, $28 \n\t" - /* Left border mask */ - "sll $8, $13, $13 \n\t" - "and $13, $8, $13 \n\t" - - "mov $10, $12 \n\t" - - "sll $7, 8, $0 \n\t" - "or $7, $0, $7 \n\t" - "sll $7, 16, $0 \n\t" - "or $7, $0, $7 \n\t" - "sll $7, 32, $0 \n\t" - "or $7, $0, $7 \n\t" - "cmpbge $7, $26, $3 \n\t" - - "and $10, 7, $0 \n\t" /* Init priority bitptr */ - "mov 1, $15 \n\t" /* .. */ - "sll $15, $0, $15 \n\t" /* .. */ - - /* -> Priority buffer */ - "and $3, $13, $11 \n\t" - "cmplt $20, 8, $0 \n\t" - "beq $0, 6f \n\t" - "and $11, $28, $11 \n\t" - "6:\n\t" + /* Defrobnicate real_alpha_shift data */ + "srl $25, 32, $6 \n\t" + "srl $25, 16, $7 \n\t" + "and $7, $8, $7 \n\t" + + /* Load first priority data quad */ + "andnot $10, 7, $0 \n\t" + "ldq $26, 0($0) \n\t" /* Load priority */ + "and $10, 7, $13 \n\t" + "sll $13, 3, $0 \n\t" + + /* Calculate right border mask */ + "addl $13, $20, $28\n\t" + "and $28, 7, $28 \n\t" + "beq $28, 7f \n\t" + "mov 8, $0 \n\t" + "subl $0, $28, $28 \n" + "7:\n\t" + "srl $8, $28, $28 \n\t" + /* Left border mask */ + "sll $8, $13, $13 \n\t" + "and $13, $8, $13 \n\t" + + "mov $10, $12 \n\t" + + "sll $7, 8, $0 \n\t" + "or $7, $0, $7 \n\t" + "sll $7, 16, $0 \n\t" + "or $7, $0, $7 \n\t" + "sll $7, 32, $0 \n\t" + "or $7, $0, $7 \n\t" + "cmpbge $7, $26, $3 \n\t" + + "and $10, 7, $0 \n\t" /* Init priority bitptr */ + "mov 1, $15 \n\t" /* .. */ + "sll $15, $0, $15 \n\t" /* .. */ + + /* -> Priority buffer */ + "and $3, $13, $11 \n\t" + "cmplt $20, 8, $0 \n\t" + "beq $0, 6f \n\t" + "and $11, $28, $11 \n\t" + "6:\n\t" #endif - "and $25, $8, $25 \n\t" - - /***/ - /*** Variable settings apply NOW ***/ - /***/ - - "mov $20, $1 \n\t" - "mov $16, $2 \n\t" - "mov $17, $3 \n" - "8:\n\t" - "addq $2, $18, $2 \n\t" - "ldl $31, 0($2) \n\t" /* Prefetch dest */ - "addq $3, $19, $3 \n\t" - "ldl $31, 0($3) \n" /* Prefetch src */ - "1:\n\t" - "addq $17, 4, $17 \n\t" - "beq $20, 3f \n\t" - "subl $20, 1, $20 \n\t" + "and $25, $8, $25 \n\t" + + /***/ + /*** Variable settings apply NOW ***/ + /***/ + + "mov $20, $1 \n\t" + "mov $16, $2 \n\t" + "mov $17, $3 \n" + "8:\n\t" + "addq $2, $18, $2 \n\t" + "ldl $31, 0($2) \n\t" /* Prefetch dest */ + "addq $3, $19, $3 \n\t" + "ldl $31, 0($3) \n" /* Prefetch src */ + "1:\n\t" + "addq $17, 4, $17 \n\t" + "beq $20, 3f \n\t" + "subl $20, 1, $20 \n\t" #ifdef PRIORITY - "5:\n\t" - "addq $10, 1, $10 \n\t" - "and $11, $15, $0 \n\t" /* Other priority beat our priority? */ - "beq $0, 2f \n\t" -#endif - "ldl $0, -4($17) \n\t" - "unpkbw $0, $5 \n\t" - "and $0, $24, $0 \n\t" - - "xor $0, $24, $4 \n\t" - "beq $4, 2f \n\t" - - "ldl $4, 0($16) \n\t" - "unpkbw $4, $4 \n\t" - "srl $0, $25, $0 \n\t" - "mulq $4, $0, $4 \n\t" - "subl $8, $0, $0 \n\t" - "mulq $5, $0, $5 \n\t" - "addq $4, $5, $4 \n\t" - "srl $4, 8, $4 \n\t" - "pkwb $4, $0 \n\t" - "stl $0, 0($16) \n\t" - "br 9f \n\t" - "2:\n" - "andnot $11, $15, $11 \n\t" /* Don't draw priority if we're fully transparent */ - "9:\n\t" - "addq $16, 4, $16 \n\t" + "5:\n\t" + "addq $10, 1, $10 \n\t" + "and $11, $15, $0 \n\t" /* Other priority beat our priority? */ + "beq $0, 2f \n\t" +#endif + "ldl $0, -4($17) \n\t" + "unpkbw $0, $5 \n\t" + "and $0, $24, $0 \n\t" + + "xor $0, $24, $4 \n\t" + "beq $4, 2f \n\t" + + "ldl $4, 0($16) \n\t" + "unpkbw $4, $4 \n\t" + "srl $0, $25, $0 \n\t" + "mulq $4, $0, $4 \n\t" + "subl $8, $0, $0 \n\t" + "mulq $5, $0, $5 \n\t" + "addq $4, $5, $4 \n\t" + "srl $4, 8, $4 \n\t" + "pkwb $4, $0 \n\t" + "stl $0, 0($16) \n\t" + "br 9f \n\t" + "2:\n" + "andnot $11, $15, $11 \n\t" /* Don't draw priority if we're fully transparent */ + "9:\n\t" + "addq $16, 4, $16 \n\t" #ifdef PRIORITY - "sll $15, 1, $15 \n\t" + "sll $15, 1, $15 \n\t" - "and $10, 7, $0 \n\t" /* Do we need to re-load priority mask? */ -/**/ "bne $0, 1b \n\t" + "and $10, 7, $0 \n\t" /* Do we need to re-load priority mask? */ + /**/ "bne $0, 1b \n\t" - /* Write back to priority buffer */ - "zap $26, $11, $26 \n\t" - "zapnot $7, $11, $0 \n\t" - "or $0, $26, $0 \n\t" - "stq $0, -8($10) \n\t" + /* Write back to priority buffer */ + "zap $26, $11, $26 \n\t" + "zapnot $7, $11, $0 \n\t" + "or $0, $26, $0 \n\t" + "stq $0, -8($10) \n\t" - "ldq $26, 0($10) \n\t" /* Load priority */ - "cmpbge $7, $26, $11\n\t" + "ldq $26, 0($10) \n\t" /* Load priority */ + "cmpbge $7, $26, $11\n\t" - "mov 1, $15 \n\t" /* Init bitcmpmask */ + "mov 1, $15 \n\t" /* Init bitcmpmask */ - "cmplt $20, 8, $0 \n\t" -/**/ "beq $0, 1b \n\t" - "and $11, $28, $11 \n\t" + "cmplt $20, 8, $0 \n\t" + /**/ "beq $0, 1b \n\t" + "and $11, $28, $11 \n\t" #endif - "br 1b \n" - "3:\n\t" + "br 1b \n" + "3:\n\t" #ifdef PRIORITY - "and $10, 7, $16 \n\t" - "beq $16, 7f \n\t" - "and $11, $28, $11 \n\t" - "zap $26, $11, $26 \n\t" - "zapnot $7, $11, $0 \n\t" - "or $0, $26, $0 \n\t" - "andnot $10, 7, $16 \n\t" - "stq $0, 0($16) \n" /* Write back */ - "7:\n\t" - - "addq $9, $12, $12 \n\t" - "mov $12, $10 \n\t" - "andnot $10, 7, $0 \n\t" - "ldq $26, 0($0) \n\t" - - "and $10, 7, $0 \n\t" - "mov 1, $15 \n\t" - "sll $15, $0, $15 \n\t" /* Store priority-induced write-enable mask */ - - "cmpbge $7, $26, $16 \n\t" - /* -> Priority buffer */ - "and $16, $13, $11 \n\t" + "and $10, 7, $16 \n\t" + "beq $16, 7f \n\t" + "and $11, $28, $11 \n\t" + "zap $26, $11, $26 \n\t" + "zapnot $7, $11, $0 \n\t" + "or $0, $26, $0 \n\t" + "andnot $10, 7, $16 \n\t" + "stq $0, 0($16) \n" /* Write back */ + "7:\n\t" + + "addq $9, $12, $12 \n\t" + "mov $12, $10 \n\t" + "andnot $10, 7, $0 \n\t" + "ldq $26, 0($0) \n\t" + + "and $10, 7, $0 \n\t" + "mov 1, $15 \n\t" + "sll $15, $0, $15 \n\t" /* Store priority-induced write-enable mask */ + + "cmpbge $7, $26, $16 \n\t" + /* -> Priority buffer */ + "and $16, $13, $11 \n\t" #endif - "beq $21, 4f \n\t" - "subl $21, 1, $21 \n\t" - "mov $1, $20 \n\t" - "mov $2, $16 \n\t" /* Set line numbers for next line */ - "mov $3, $17 \n\t" - "br 8b \n" - "4:\n\t" + "beq $21, 4f \n\t" + "subl $21, 1, $21 \n\t" + "mov $1, $20 \n\t" + "mov $2, $16 \n\t" /* Set line numbers for next line */ + "mov $3, $17 \n\t" + "br 8b \n" + "4:\n\t" #ifdef PRIORITY - "ldq $9, 0($30) \n\t" - "ldq $10, 8($30) \n\t" - "ldq $11, 16($30) \n\t" - "ldq $12, 24($30) \n\t" - "ldq $13, 32($30) \n\t" - "ldq $15, 40($30) \n\t" - "ldq $26, 48($30) \n\t" - "ldq %8, 56($30) \n\t" - "ldq %9, 64($30) \n\t" - "ldq $7, 72($30) \n\t" - "ldq $6, 80($30) \n\t" - "lda $30, 88($30) \n\t" + "ldq $9, 0($30) \n\t" + "ldq $10, 8($30) \n\t" + "ldq $11, 16($30) \n\t" + "ldq $12, 24($30) \n\t" + "ldq $13, 32($30) \n\t" + "ldq $15, 40($30) \n\t" + "ldq $26, 48($30) \n\t" + "ldq %8, 56($30) \n\t" + "ldq %9, 64($30) \n\t" + "ldq $7, 72($30) \n\t" + "ldq $6, 80($30) \n\t" + "lda $30, 88($30) \n\t" #endif - : - : - "r"(dest), "r"(src), "r"(bytes_per_dest_line), - /*3*/ "r"(bytes_per_src_line), "r"(xl), "r"(yl), - /*6*/ "r"((unsigned long) alpha_test_mask), "r"(real_alpha_shift) + : + : + "r"(dest), "r"(src), "r"(bytes_per_dest_line), + /*3*/ "r"(bytes_per_src_line), "r"(xl), "r"(yl), + /*6*/ "r"((unsigned long) alpha_test_mask), "r"(real_alpha_shift) #ifdef PRIORITY - , "r"(bytes_per_priority_line), "r"(priority_pos) + , "r"(bytes_per_priority_line), "r"(priority_pos) #endif - : "%0", "%1", "%2", "%3", "%4", "%5", "%6", - "%7", "$16", "$17", "$18", "$19", "$20", "$21", "$24", "$25", - "$8", "memory" - ); + : "%0", "%1", "%2", "%3", "%4", "%5", "%6", + "%7", "$16", "$17", "$18", "$19", "$20", "$21", "$24", "$25", + "$8", "memory" + ); #endif } diff --git a/engines/sci/gfx/antialias.cpp b/engines/sci/gfx/antialias.cpp index 47e70f09e0..a9468420f6 100644 --- a/engines/sci/gfx/antialias.cpp +++ b/engines/sci/gfx/antialias.cpp @@ -31,8 +31,7 @@ #include "sci/include/gfx_tools.h" static void -antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t *mode) -{ +antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t *mode) { int x, y, c; int bytespp = mode->bytespp; int line_size = bytespp * pixmap->xl; @@ -44,7 +43,7 @@ antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t lastline[1] = (char*)sci_malloc(line_size); for (y = 0; y < pixmap->yl; y++) { - int visimode = (y > 0 && y+1 < pixmap->yl)? 1 : 0; + int visimode = (y > 0 && y + 1 < pixmap->yl) ? 1 : 0; unsigned long last_pixel; memcpy(lastline[y & 1], data_p, line_size); @@ -55,7 +54,7 @@ antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t if (x == 1) visimode++; - else if (x+1 == pixmap->xl) + else if (x + 1 == pixmap->xl) visimode--; for (c = 0; c < 3; c++) { @@ -69,9 +68,9 @@ antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t */ for (y_mode = 0; y_mode < 2; y_mode++) if ((y_mode == 0 && y > 0) - || (y_mode == 1 && y+1 < pixmap->yl)) { + || (y_mode == 1 && y + 1 < pixmap->yl)) { - char *src = (y_mode)? data_p + line_size : lastline_p; + char *src = (y_mode) ? data_p + line_size : lastline_p; if (x > 0) { memcpy(&reader, src - bytespp, bytespp); @@ -81,7 +80,7 @@ antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t memcpy(&reader, src, bytespp); accum += ((reader >> shift_const) & mask[c]) << 1; - if (x+1 < pixmap->xl) { + if (x + 1 < pixmap->xl) { memcpy(&reader, src + bytespp, bytespp); accum += ((reader >> shift_const) & mask[c]) << 0; } @@ -95,23 +94,27 @@ antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t last_pixel = reader; accum += ((reader >> shift_const) & mask[c]) << 2; - if (x+1 < pixmap->xl) { + if (x + 1 < pixmap->xl) { memcpy(&reader, data_p + bytespp, bytespp); accum += ((reader >> shift_const) & mask[c]) << 1; } switch (visimode) { - case 0: accum /= 9; /* Only happens twelve times */ + case 0: + accum /= 9; /* Only happens twelve times */ break; - case 1: accum = (accum >> 6) + (accum >> 4); /* 15/16 intensity */ + case 1: + accum = (accum >> 6) + (accum >> 4); /* 15/16 intensity */ break; - case 2: accum >>= 4; + case 2: + accum >>= 4; break; - default: accum = (c == 0)? 0xffffffff : 0; /* Error: mark as red */ + default: + accum = (c == 0) ? 0xffffffff : 0; /* Error: mark as red */ } result |= (accum & mask[c]); @@ -130,8 +133,7 @@ antialiase_simple(gfx_pixmap_t *pixmap, int mask[], int shift_const, gfx_mode_t } void -gfxr_antialiase(gfx_pixmap_t *pixmap, gfx_mode_t *mode, gfxr_antialiasing_t type) -{ +gfxr_antialiase(gfx_pixmap_t *pixmap, gfx_mode_t *mode, gfxr_antialiasing_t type) { int masks[3]; int shift_const = 0; diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp index b8d5d5a800..0b0abac733 100644 --- a/engines/sci/gfx/font.cpp +++ b/engines/sci/gfx/font.cpp @@ -33,8 +33,7 @@ int font_counter = 0; void -gfxr_free_font(gfx_bitmap_font_t *font) -{ +gfxr_free_font(gfx_bitmap_font_t *font) { if (font->widths) free(font->widths); @@ -49,8 +48,7 @@ gfxr_free_font(gfx_bitmap_font_t *font) void -scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact, int yfact) -{ +scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact, int yfact) { int x, y; for (y = 0; y < height; y++) { @@ -90,8 +88,7 @@ scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact } gfx_bitmap_font_t * -gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) -{ +gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) { gfx_bitmap_font_t *font = (gfx_bitmap_font_t*)sci_malloc(sizeof(gfx_bitmap_font_t)); int height = orig_font->height * mode->yfact; int width = 0; @@ -121,18 +118,17 @@ gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) for (i = 0; i < font->chars_nr; i++) { font->widths[i] = orig_font->widths[i] * mode->xfact; scale_char(font->data + font->char_size * i, - orig_font->data + orig_font->char_size * i, - orig_font->row_size, orig_font->height, - font->row_size, - mode->xfact, mode->yfact); + orig_font->data + orig_font->char_size * i, + orig_font->row_size, orig_font->height, + font->row_size, + mode->xfact, mode->yfact); } return font; } gfx_bitmap_font_t * -gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) -{ +gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) { GFXWARN("This function hasn't been tested yet!\n"); switch (filter) { @@ -151,10 +147,9 @@ gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_ text_fragment_t * gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text, - int *width, int *height, - int *lines, int *line_height_p, int *last_offset_p, - int flags) -{ + int *width, int *height, + int *lines, int *line_height_p, int *last_offset_p, + int flags) { int est_char_width = font->widths[(font->chars_nr > 'M')? 'M' : font->chars_nr - 1]; /* 'M' is typically among the widest chars */ int fragments_nr; @@ -172,7 +167,8 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex if (line_height_p) *line_height_p = lineheight; - if (max_width>1) fragments_nr = 3 + (strlen(text) * est_char_width)*3 / (max_width << 1); else fragments_nr = 1; + if (max_width > 1) fragments_nr = 3 + (strlen(text) * est_char_width) * 3 / (max_width << 1); + else fragments_nr = 1; fragments = (text_fragment_t*)sci_calloc(sizeof(text_fragment_t), fragments_nr); @@ -183,7 +179,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex if (foo >= font->chars_nr) { GFXWARN("Invalid char 0x%02x (max. 0x%02x) encountered in text string '%s', font %04x\n", - foo, font->chars_nr, text, font->ID); + foo, font->chars_nr, text, font->ID); if (font->chars_nr > ' ') foo = ' '; else { @@ -193,7 +189,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex } if (((foo == '\n') || (foo == 0x0d)) - && !(flags & GFXR_FONT_FLAG_NO_NEWLINES)) { + && !(flags & GFXR_FONT_FLAG_NO_NEWLINES)) { fragments[current_fragment-1].length = text - 1 - fragments[current_fragment-1].offset; @@ -233,7 +229,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex if (last_breakpoint == 0) { GFXWARN("Warning: maxsize %d too small for '%s'\n", - max_allowed_width, text); + max_allowed_width, text); } if (last_breakpoint > maxwidth) @@ -251,10 +247,10 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex last_breakpoint = localmaxwidth = 0; } else if (*text == ' ') { - last_breakpoint = localmaxwidth; - last_break_width = font->widths[foo]; - breakpoint_ptr = text; - } + last_breakpoint = localmaxwidth; + last_break_width = font->widths[foo]; + breakpoint_ptr = text; + } } } @@ -279,8 +275,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex static inline void -render_char(byte *dest, byte *src, int width, int line_width, int lines, int bytes_per_src_line, int fg0, int fg1, int bg) -{ +render_char(byte *dest, byte *src, int width, int line_width, int lines, int bytes_per_src_line, int fg0, int fg1, int bg) { int x, y; for (y = 0; y < lines; y++) { @@ -297,7 +292,7 @@ render_char(byte *dest, byte *src, int width, int line_width, int lines, int byt xc--; if (dat & 0x80) - *vdest++ = ((xc ^ y) & 1)? fg0 : fg1; /* dither */ + *vdest++ = ((xc ^ y) & 1) ? fg0 : fg1; /* dither */ else *vdest++ = bg; @@ -310,8 +305,7 @@ render_char(byte *dest, byte *src, int width, int line_width, int lines, int byt gfx_pixmap_t * gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters, - gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg) -{ + gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg) { unsigned char *text = (unsigned char *) stext; int height = font->height; int width = 0; @@ -336,13 +330,12 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters, pxm = gfx_pixmap_alloc_index_data(gfx_new_pixmap(width, height, GFX_RESID_NONE, 0, 0)); pxm->colors_nr = !!fg0 + !!fg1 + !!bg; - if (pxm->colors_nr == 0) - { - GFXWARN("Pixmap would have zero colors, resetting!\n"); - pxm->colors_nr = 3; - hack = 1; - fg0 = fg1 = bg = &dummy; - } + if (pxm->colors_nr == 0) { + GFXWARN("Pixmap would have zero colors, resetting!\n"); + pxm->colors_nr = 3; + hack = 1; + fg0 = fg1 = bg = &dummy; + } pxm->colors = (gfx_pixmap_color_t*)sci_malloc(sizeof(gfx_pixmap_color_t) * pxm->colors_nr); #ifdef SATISFY_PURIFY memset(pxm->colors, 0, sizeof(gfx_pixmap_color_t) * pxm->colors_nr); @@ -374,8 +367,8 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters, width = font->widths[ch]; render_char(offset, font->data + (ch * font->char_size), width, - pxm->index_xl, pxm->index_yl, font->row_size, - fore_0, fore_1, back); + pxm->index_xl, pxm->index_yl, font->row_size, + fore_0, fore_1, back); offset += width; } diff --git a/engines/sci/gfx/gfx_crossblit.cpp b/engines/sci/gfx/gfx_crossblit.cpp index 03ddb7642d..b5dd39278a 100644 --- a/engines/sci/gfx/gfx_crossblit.cpp +++ b/engines/sci/gfx/gfx_crossblit.cpp @@ -52,13 +52,12 @@ #endif static void FUNCTION_NAME(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_line, - int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel, - unsigned int alpha_test_mask, unsigned int alpha_min + int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel, + unsigned int alpha_test_mask, unsigned int alpha_min #ifdef USE_PRIORITY - , byte *priority_buffer, int bytes_per_priority_line, int bytes_per_priority_pixel, int priority + , byte *priority_buffer, int bytes_per_priority_line, int bytes_per_priority_pixel, int priority #endif /* USE_PRIORITY */ - ) -{ + ) { int x, y; int alpha_end = xl * bytes_per_alpha_pixel; @@ -72,11 +71,11 @@ static void FUNCTION_NAME(byte *dest, byte *src, int bytes_per_dest_line, int by for (x = 0; x < alpha_end; x += bytes_per_alpha_pixel) { if ((alpha_test_mask & alpha[x]) #ifdef REVERSE_ALPHA - >= + >= #else - < + < #endif - alpha_min) + alpha_min) #ifdef USE_PRIORITY if (priority_buffer[priority_offset] <= priority) { priority_buffer[priority_offset] = priority; diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index a528673f6b..65acbe9cc8 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -18,8 +18,7 @@ struct _scummvm_driver_state { #define S ((struct _scummvm_driver_state *)(drv->state)) static int -scummvm_init_specific(struct _gfx_driver *drv, int xfact, int yfact, int bytespp) -{ +scummvm_init_specific(struct _gfx_driver *drv, int xfact, int yfact, int bytespp) { int i; if (!drv->state) // = S @@ -38,7 +37,7 @@ scummvm_init_specific(struct _gfx_driver *drv, int xfact, int yfact, int bytespp S->priority[i] = gfx_pixmap_alloc_index_data(gfx_new_pixmap(S->xsize, S->ysize, GFX_RESID_NONE, -i, -777)); if (!S->priority[i]) { printf("Out of memory: Could not allocate priority maps! (%dx%d)\n", - S->xsize, S->ysize); + S->xsize, S->ysize); return GFX_FATAL; } } @@ -48,28 +47,26 @@ scummvm_init_specific(struct _gfx_driver *drv, int xfact, int yfact, int bytespp S->visual[i] = new byte[S->xsize * S->ysize]; if (!S->visual[i]) { printf("Out of memory: Could not allocate visual buffers! (%dx%d)\n", - S->xsize, S->ysize); + S->xsize, S->ysize); return GFX_FATAL; } memset(S->visual[i], 0, S->xsize * S->ysize); } drv->mode = gfx_new_mode(xfact, yfact, bytespp, - 0, 0, 0, 0, - 0, 0, 0, 0, 256, 0); + 0, 0, 0, 0, + 0, 0, 0, 0, 256, 0); return GFX_OK; } static int -scummvm_init(struct _gfx_driver *drv) -{ +scummvm_init(struct _gfx_driver *drv) { return scummvm_init_specific(drv, 1, 1, GFX_COLOR_MODE_INDEX); } static void -scummvm_exit(struct _gfx_driver *drv) -{ +scummvm_exit(struct _gfx_driver *drv) { int i; if (S) { for (i = 0; i < 2; i++) { @@ -97,12 +94,11 @@ scummvm_exit(struct _gfx_driver *drv) /* This code shamelessly lifted from the SDL_gfxPrimitives package */ static void -lineColor2(byte *dst, int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) -{ +lineColor2(byte *dst, int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) { int pixx, pixy; - int x,y; - int dx,dy; - int sx,sy; + int x, y; + int dx, dy; + int sx, sy; int swaptmp; uint8 *pixel; @@ -119,27 +115,31 @@ lineColor2(byte *dst, int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) pixx *= sx; pixy *= sy; if (dx < dy) { - swaptmp = dx; dx = dy; dy = swaptmp; - swaptmp = pixx; pixx = pixy; pixy = swaptmp; + swaptmp = dx; + dx = dy; + dy = swaptmp; + swaptmp = pixx; + pixx = pixy; + pixy = swaptmp; } /* Draw */ - x=0; - y=0; - for(; x < dx; x++, pixel += pixx) { + x = 0; + y = 0; + for (; x < dx; x++, pixel += pixx) { *pixel = color; y += dy; if (y >= dx) { - y -= dx; pixel += pixy; + y -= dx; + pixel += pixy; } } } static int scummvm_draw_line(struct _gfx_driver *drv, point_t start, point_t end, - gfx_color_t color, - gfx_line_mode_t line_mode, gfx_line_style_t line_style) -{ + gfx_color_t color, + gfx_line_mode_t line_mode, gfx_line_style_t line_style) { uint32 scolor = color.visual.global_index; int xsize = S->xsize; int ysize = S->ysize; @@ -163,18 +163,18 @@ scummvm_draw_line(struct _gfx_driver *drv, point_t start, point_t end, if (nstart.x > xsize) nstart.x = xsize; if (nend.x >= xsize) - nend.x = xsize -1; + nend.x = xsize - 1; if (nstart.y > ysize) nstart.y = ysize; if (nend.y >= ysize) - nend.y = ysize -1; + nend.y = ysize - 1; lineColor2(S->visual[1], (int16)nstart.x, (int16)nstart.y, - (int16)nend.x, (int16)nend.y, scolor); + (int16)nend.x, (int16)nend.y, scolor); if (color.mask & GFX_MASK_PRIORITY) { gfx_draw_line_pixmap_i(S->priority[0], nstart, nend, - color.priority); + color.priority); } } @@ -183,9 +183,8 @@ scummvm_draw_line(struct _gfx_driver *drv, point_t start, point_t end, static int scummvm_draw_filled_rect(struct _gfx_driver *drv, rect_t rect, - gfx_color_t color1, gfx_color_t color2, - gfx_rectangle_fill_t shade_mode) -{ + gfx_color_t color1, gfx_color_t color2, + gfx_rectangle_fill_t shade_mode) { if (color1.mask & GFX_MASK_VISUAL) { for (int i = rect.y; i < rect.y + rect.yl; i++) { memset(S->visual[1] + i * S->xsize + rect.x, color1.visual.global_index, rect.xl); @@ -203,29 +202,27 @@ scummvm_draw_filled_rect(struct _gfx_driver *drv, rect_t rect, static int scummvm_draw_pixmap(struct _gfx_driver *drv, gfx_pixmap_t *pxm, int priority, - rect_t src, rect_t dest, gfx_buffer_t buffer) -{ - int bufnr = (buffer == GFX_BUFFER_STATIC)? 2:1; - int pribufnr = bufnr -1; + rect_t src, rect_t dest, gfx_buffer_t buffer) { + int bufnr = (buffer == GFX_BUFFER_STATIC) ? 2 : 1; + int pribufnr = bufnr - 1; if (dest.xl != src.xl || dest.yl != src.yl) { printf("Attempt to scale pixmap (%dx%d)->(%dx%d): Not supported\n", - src.xl, src.yl, dest.xl, dest.yl); + src.xl, src.yl, dest.xl, dest.yl); return GFX_ERROR; } gfx_crossblit_pixmap(drv->mode, pxm, priority, src, dest, - S->visual[bufnr], S->xsize, - S->priority[pribufnr]->index_data, - S->priority[pribufnr]->index_xl, 1, 0); + S->visual[bufnr], S->xsize, + S->priority[pribufnr]->index_data, + S->priority[pribufnr]->index_xl, 1, 0); return GFX_OK; } static int scummvm_grab_pixmap(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm, - gfx_map_mask_t map) -{ + gfx_map_mask_t map) { if (src.x < 0 || src.y < 0) { printf("Attempt to grab pixmap from invalid coordinates (%d,%d)\n", src.x, src.y); return GFX_ERROR; @@ -262,10 +259,9 @@ scummvm_grab_pixmap(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm, // Buffer operations static int -scummvm_update(struct _gfx_driver *drv, rect_t src, point_t dest, gfx_buffer_t buffer) -{ +scummvm_update(struct _gfx_driver *drv, rect_t src, point_t dest, gfx_buffer_t buffer) { //TODO - int data_source = (buffer == GFX_BUFFER_BACK)? 2 : 1; + int data_source = (buffer == GFX_BUFFER_BACK) ? 2 : 1; int data_dest = data_source - 1; /* @@ -283,7 +279,7 @@ scummvm_update(struct _gfx_driver *drv, rect_t src, point_t dest, gfx_buffer_t b // S->xsize * S->ysize); for (int i = 0; i < src.yl; i++) { memcpy(S->visual[data_dest] + (dest.y + i) * S->xsize + dest.x, - S->visual[data_source] + (src.y + i) * S->xsize + src.x, src.xl); + S->visual[data_source] + (src.y + i) * S->xsize + src.x, src.xl); } if ((src.x == dest.x) && (src.y == dest.y)) @@ -291,10 +287,10 @@ scummvm_update(struct _gfx_driver *drv, rect_t src, point_t dest, gfx_buffer_t b break; case GFX_BUFFER_FRONT: memcpy(S->visual[data_dest], S->visual[data_source], - S->xsize * S->ysize); + S->xsize * S->ysize); g_system->copyRectToScreen(S->visual[data_dest] + src.x + src.y * S->xsize, - S->xsize, dest.x, dest.y, src.xl, src.yl); + S->xsize, dest.x, dest.y, src.xl, src.yl); /* g_system->copyRectToScreen(S->visual[data_dest], S->xsize, 0, 0, S->xsize, S->ysize); @@ -311,8 +307,7 @@ scummvm_update(struct _gfx_driver *drv, rect_t src, point_t dest, gfx_buffer_t b } static int -scummvm_set_static_buffer(struct _gfx_driver *drv, gfx_pixmap_t *pic, gfx_pixmap_t *priority) -{ +scummvm_set_static_buffer(struct _gfx_driver *drv, gfx_pixmap_t *pic, gfx_pixmap_t *priority) { memcpy(S->visual[2], pic->data, S->xsize * S->ysize); /*gfx_crossblit_pixmap(drv->mode, pic, 0, rect, rect, S->visual[2], S->xsize, @@ -328,8 +323,7 @@ scummvm_set_static_buffer(struct _gfx_driver *drv, gfx_pixmap_t *pic, gfx_pixmap // Mouse pointer operations static int -scummvm_set_pointer(struct _gfx_driver *drv, gfx_pixmap_t *pointer) -{ +scummvm_set_pointer(struct _gfx_driver *drv, gfx_pixmap_t *pointer) { if (pointer == NULL) { g_system->showMouse(false); } else { @@ -346,8 +340,7 @@ scummvm_set_pointer(struct _gfx_driver *drv, gfx_pixmap_t *pointer) // Palette operations static int -scummvm_set_palette(struct _gfx_driver *drv, int index, byte red, byte green, byte blue) -{ +scummvm_set_palette(struct _gfx_driver *drv, int index, byte red, byte green, byte blue) { byte color[] = {red, green, blue, 255}; g_system->setPalette(color, index, 1); return GFX_OK; @@ -357,8 +350,7 @@ scummvm_set_palette(struct _gfx_driver *drv, int index, byte red, byte green, by // Event management static sci_event_t -scummvm_get_event(struct _gfx_driver *drv) -{ +scummvm_get_event(struct _gfx_driver *drv) { sci_event_t input; input.type = SCI_EVT_NONE; @@ -394,13 +386,13 @@ scummvm_get_event(struct _gfx_driver *drv) modifiers = em->getModifierState(); input.buckybits = - ((modifiers & Common::KBD_ALT) ? SCI_EVM_ALT : 0) | - ((modifiers & Common::KBD_CTRL) ? SCI_EVM_CTRL : 0) | - ((modifiers & Common::KBD_SHIFT) ? SCI_EVM_LSHIFT | SCI_EVM_RSHIFT : 0); - //TODO: SCI_EVM_SCRLOCK SCI_EVM_NUMLOCK SCI_EVM_CAPSLOCK SCI_EVM_INSERT + ((modifiers & Common::KBD_ALT) ? SCI_EVM_ALT : 0) | + ((modifiers & Common::KBD_CTRL) ? SCI_EVM_CTRL : 0) | + ((modifiers & Common::KBD_SHIFT) ? SCI_EVM_LSHIFT | SCI_EVM_RSHIFT : 0); + //TODO: SCI_EVM_SCRLOCK SCI_EVM_NUMLOCK SCI_EVM_CAPSLOCK SCI_EVM_INSERT switch (ev.type) { - // Keyboard events + // Keyboard events case Common::EVENT_KEYDOWN: input.data = ev.kbd.keycode; input.character = ev.kbd.ascii; @@ -414,7 +406,7 @@ scummvm_get_event(struct _gfx_driver *drv) input.data = SCI_K_TAB; if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT)) input.character = SCI_K_SHIFT_TAB; - else + else input.character = SCI_K_TAB; } } else if ((input.data >= Common::KEYCODE_F1) && input.data <= Common::KEYCODE_F10) { @@ -425,7 +417,7 @@ scummvm_get_event(struct _gfx_driver *drv) input.data = (input.data - Common::KEYCODE_F1 + SCI_K_F1) << 8; if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT)) input.character = input.data + ((SCI_K_SHIFT_F1 - SCI_K_F1) << 8); - else + else input.character = input.data; } else { // Special keys that need conversion @@ -461,7 +453,7 @@ scummvm_get_event(struct _gfx_driver *drv) case Common::KEYCODE_DELETE: input.data = SCI_K_DELETE; break; - //TODO: SCI_K_CENTER + //TODO: SCI_K_CENTER default: input.type = SCI_EVT_NONE; break; @@ -470,7 +462,7 @@ scummvm_get_event(struct _gfx_driver *drv) } break; - // Mouse events + // Mouse events case Common::EVENT_LBUTTONDOWN: input.type = SCI_EVT_MOUSE_PRESS; input.data = 1; @@ -496,7 +488,7 @@ scummvm_get_event(struct _gfx_driver *drv) drv->pointer_y = p.y; break; - // Misc events + // Misc events case Common::EVENT_QUIT: input.type = SCI_EVT_QUIT; break; @@ -510,9 +502,8 @@ scummvm_get_event(struct _gfx_driver *drv) } static int -scummvm_usec_sleep(struct _gfx_driver *drv, long usecs) -{ - g_system->delayMillis(usecs/1000); +scummvm_usec_sleep(struct _gfx_driver *drv, long usecs) { + g_system->delayMillis(usecs / 1000); return GFX_OK; } diff --git a/engines/sci/gfx/gfx_line.cpp b/engines/sci/gfx/gfx_line.cpp index 01b6a8fd2a..f671e39b13 100644 --- a/engines/sci/gfx/gfx_line.cpp +++ b/engines/sci/gfx/gfx_line.cpp @@ -45,8 +45,7 @@ static inline -void DRAWLINE_FUNC(byte *buffer, int linewidth, point_t start, point_t end, unsigned int color) -{ +void DRAWLINE_FUNC(byte *buffer, int linewidth, point_t start, point_t end, unsigned int color) { int dx, dy, incrE, incrNE, d, finalx, finaly; int x = start.x; int y = start.y; @@ -55,7 +54,7 @@ void DRAWLINE_FUNC(byte *buffer, int linewidth, point_t start, point_t end, unsi finalx = end.x; finaly = end.y; #ifdef WORDS_BIGENDIAN - color = GUINT32_SWAP_LE_BE_CONSTANT(color); + color = GUINT32_SWAP_LE_BE_CONSTANT(color); #endif dx = abs(dx); dy = abs(dy); diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index 006eef09b0..1d4b6d61fa 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -24,20 +24,19 @@ #define PALETTE_MODE mode->palette void -FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) -{ +FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { SIZETYPE result_colors[GFX_PIC_COLORS]; SIZETYPE alpha_color = 0xffffffff & mode->alpha_mask; SIZETYPE alpha_ormask = 0; - int xfact = (scale)? mode->xfact: 1; - int yfact = (scale)? mode->yfact: 1; + int xfact = (scale) ? mode->xfact : 1; + int yfact = (scale) ? mode->yfact : 1; int widthc, heightc; /* Width duplication counter */ int line_width = xfact * pxm->index_xl; int bytespp = mode->bytespp; int x, y; int i; - byte byte_transparent = (mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA)? 0 : 255; - byte byte_opaque = (mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA)? 255 : 0; + byte byte_transparent = (mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA) ? 0 : 255; + byte byte_opaque = (mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA) ? 255 : 0; byte *src = pxm->index_data; byte *dest = pxm->data; byte *alpha_dest = pxm->alpha_map; @@ -49,7 +48,7 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) alpha_color = 0; } - assert(bytespp == COPY_BYTES); + assert(bytespp == COPY_BYTES); if (separate_alpha_map && !alpha_dest) alpha_dest = pxm->alpha_map = (byte*)sci_malloc(pxm->index_xl * xfact * pxm->index_yl * yfact); @@ -91,7 +90,7 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) } if (separate_alpha_map) { /* Set separate alpha map */ - memset(alpha_dest, (isalpha)? byte_transparent : byte_opaque, xfact); + memset(alpha_dest, (isalpha) ? byte_transparent : byte_opaque, xfact); alpha_dest += xfact; } } @@ -182,12 +181,11 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) void -FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) -{ +FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { int xfact = mode->xfact; int yfact = mode->yfact; - int line_step = (yfact < 2)? 0 : 256 / (yfact & ~1); - int column_step = (xfact < 2)? 0 : 256 / (xfact & ~1); + int line_step = (yfact < 2) ? 0 : 256 / (yfact & ~1); + int column_step = (xfact < 2) ? 0 : 256 / (xfact & ~1); int bytespp = mode->bytespp; byte *src = pxm->index_data; byte *dest = pxm->data; @@ -195,7 +193,7 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) int using_alpha = pxm->color_key != GFX_PIXMAP_COLOR_KEY_NONE; int separate_alpha_map = (!mode->alpha_mask) && using_alpha; unsigned int masks[4], shifts[4], zero[3]; - int x,y; + int x, y; byte inverse_alpha = mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA; zero[0] = 255; @@ -206,7 +204,7 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) shifts[3] = 24; } - assert(bytespp == COPY_BYTES); + assert(bytespp == COPY_BYTES); assert(!PALETTE_MODE); masks[0] = mode->red_mask; @@ -229,7 +227,7 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) int otherline[4]; /* the above line or the line below */ int ctexel[4]; /* Current texel */ int subx, suby; - int line_valuator = line_step? 128 - (line_step >> 1) : 256; + int line_valuator = line_step ? 128 - (line_step >> 1) : 256; byte *wrpos, *alpha_wrpos; byte *sublinepos = linepos; byte *alpha_sublinepos = alpha_linepos; @@ -261,7 +259,7 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) /*-- Lower half --*/ line_valuator -= line_step; - MAKE_PIXEL((y+1 == pxm->index_yl), otherline, ctexel, src[pxm->index_xl]); + MAKE_PIXEL((y + 1 == pxm->index_yl), otherline, ctexel, src[pxm->index_xl]); WRITE_YPART(1, Y_CALC_INTENSITY_NORMAL); src++; @@ -284,9 +282,8 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) #ifndef GFX_GET_PIXEL_DELTA #define GFX_GET_PIXEL_DELTA static inline void -gfx_get_pixel_delta(unsigned int *color, int *delta, unsigned int *pixel0, unsigned int *pixel1) -{ - int j; +gfx_get_pixel_delta(unsigned int *color, int *delta, unsigned int *pixel0, unsigned int *pixel1) { + int j; int transp0 = pixel0[3] == 0xffffff; int transp1 = pixel1[3] == 0xffffff; @@ -311,11 +308,10 @@ gfx_get_pixel_delta(unsigned int *color, int *delta, unsigned int *pixel0, unsig static inline void -gfx_apply_delta(unsigned int *color, int *delta, int factor) -{ - int i; +gfx_apply_delta(unsigned int *color, int *delta, int factor) { + int i; for (i = 0; i < 4; i++) - color[i] += delta[i] * factor; + color[i] += delta[i] * factor; } #endif @@ -335,12 +331,11 @@ gfx_apply_delta(unsigned int *color, int *delta, int factor) #define REVERSE_ALPHA(foo) ((inverse_alpha)? ~(foo) : (foo)) void -FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) -{ +FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { int xfact = mode->xfact; int yfact = mode->yfact; - int line_step = (yfact < 2)? 0 : 256 / yfact; - int column_step = (xfact < 2)? 0 : 256 / xfact; + int line_step = (yfact < 2) ? 0 : 256 / yfact; + int column_step = (xfact < 2) ? 0 : 256 / xfact; int bytespp = mode->bytespp; byte *src = pxm->index_data; byte *dest = pxm->data; @@ -351,7 +346,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) unsigned int pixels[4][4]; /* 0 1 ** 2 3 */ - int x,y; + int x, y; byte inverse_alpha = mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA; if (separate_alpha_map) { @@ -359,7 +354,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) shifts[3] = 24; } - assert(bytespp == COPY_BYTES); + assert(bytespp == COPY_BYTES); assert(!PALETTE_MODE); masks[0] = mode->red_mask; @@ -382,7 +377,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) for (y = 0; y <= pxm->index_yl; y++) { byte *y_dest_backup = dest; byte *y_alpha_dest_backup = alpha_dest; - int y_valuator = (y > 0)? 0 : 128; + int y_valuator = (y > 0) ? 0 : 128; int yc_count; @@ -399,7 +394,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) for (x = 0; x <= pxm->index_xl; x++) { byte *x_dest_backup = dest; byte *x_alpha_dest_backup = alpha_dest; - int x_valuator = (x > 0)? 0 : 128; + int x_valuator = (x > 0) ? 0 : 128; int xc_count; unsigned int leftcolor[4], rightcolor[4]; int leftdelta[4], rightdelta[4]; @@ -419,7 +414,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) MAKE_PIXEL_TRILINEAR((y && (x < pxm->index_xl)), pixels[1], src[1]); MAKE_PIXEL_TRILINEAR(((y < pxm->index_yl) && x), pixels[2], src[pxm->index_xl]); MAKE_PIXEL_TRILINEAR(((y < pxm->index_yl) && (x < pxm->index_xl)), - pixels[3], src[pxm->index_xl + 1]); + pixels[3], src[pxm->index_xl + 1]); /* OptimizeMe */ @@ -429,7 +424,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) gfx_apply_delta(rightcolor, rightdelta, y_valuator); for (yc = 0; yc < yc_count; yc++) { - unsigned int color[4]; + unsigned int color[4]; int delta[4]; byte *yc_dest_backup = dest; byte *yc_alpha_dest_backup = alpha_dest; @@ -468,7 +463,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) alpha_dest = x_alpha_dest_backup + xc_count; if (x < pxm->index_xl) - src++; + src++; } dest = y_dest_backup + pxm->index_xl * xfact * yc_count * COPY_BYTES; alpha_dest = y_alpha_dest_backup + pxm->index_xl * xfact * yc_count; diff --git a/engines/sci/gfx/gfx_res_options.cpp b/engines/sci/gfx/gfx_res_options.cpp index 349058427f..e19f453879 100644 --- a/engines/sci/gfx/gfx_res_options.cpp +++ b/engines/sci/gfx/gfx_res_options.cpp @@ -42,8 +42,7 @@ /*#define DEBUG*/ static gfx_res_pattern_list_t* -pattern_list_insert(gfx_res_pattern_list_t *list, int min, int max) -{ +pattern_list_insert(gfx_res_pattern_list_t *list, int min, int max) { gfx_res_pattern_list_t *retval = (gfx_res_pattern_list_t*)sci_malloc(sizeof(gfx_res_pattern_list_t)); retval->pattern.min = min; retval->pattern.max = max; @@ -53,8 +52,7 @@ pattern_list_insert(gfx_res_pattern_list_t *list, int min, int max) } static int -pattern_list_len(gfx_res_pattern_list_t *list) -{ +pattern_list_len(gfx_res_pattern_list_t *list) { int v = 0; while (list) { ++v; @@ -65,8 +63,7 @@ pattern_list_len(gfx_res_pattern_list_t *list) } static void -pattern_list_flatten(gfx_res_pattern_t *dest, gfx_res_pattern_list_t *list) -{ +pattern_list_flatten(gfx_res_pattern_t *dest, gfx_res_pattern_list_t *list) { while (list) { *dest++ = list->pattern; list = list->next; @@ -74,8 +71,7 @@ pattern_list_flatten(gfx_res_pattern_t *dest, gfx_res_pattern_list_t *list) } static inline void -pattern_list_free(gfx_res_pattern_list_t *list) -{ +pattern_list_free(gfx_res_pattern_list_t *list) { if (list) pattern_list_free(list->next); @@ -85,8 +81,7 @@ pattern_list_free(gfx_res_pattern_list_t *list) static inline int extract_pattern(gfx_res_pattern_list_t **destp, - char *src, int offset) -{ + char *src, int offset) { char *src_orig = src - offset; int final = 0; int wildcard = 0; @@ -102,7 +97,7 @@ extract_pattern(gfx_res_pattern_list_t **destp, ++src; if (*src == '*' - || *src == '_') { + || *src == '_') { wildcard = 1; ++src; } else if (*src == '.' || isdigit(*src)) { @@ -110,7 +105,7 @@ extract_pattern(gfx_res_pattern_list_t **destp, int start = strtol(src, &endp, 0); if (*src == '.' - && src[1] == '.') { + && src[1] == '.') { start = GFX_RES_PATTERN_MIN; endp = src; } @@ -123,7 +118,7 @@ extract_pattern(gfx_res_pattern_list_t **destp, if (*src) { int stop; if (*src == '.' - && src[1] == '.') { + && src[1] == '.') { src += 2; while (*src && isblank(*src)) @@ -141,7 +136,7 @@ extract_pattern(gfx_res_pattern_list_t **destp, src = endp; *destp = pattern_list_insert(*destp, - start, stop); + start, stop); } else { /* No ellipsis */ if (end) @@ -150,7 +145,7 @@ extract_pattern(gfx_res_pattern_list_t **destp, } } else /* End of sub-pattern */ *destp = pattern_list_insert(*destp, - start, start); + start, start); while (*src && isblank(*src)) ++src; @@ -165,10 +160,10 @@ extract_pattern(gfx_res_pattern_list_t **destp, if (end) *end = ','; sciprintf("[gfx-conf] Unexpected character '%c'\n", - *src); + *src); goto lexical_error_label; } - + if (!final) { *end = ','; src = end + 1; @@ -182,15 +177,14 @@ extract_pattern(gfx_res_pattern_list_t **destp, return 0; - lexical_error_label: +lexical_error_label: sciprintf("[gfx-conf] Lexical error in pattern at offset %d\n", - src - src_orig); + src - src_orig); return 1; } static int -extract_mod_rule(char *src, gfx_res_mod_t *rule) -{ +extract_mod_rule(char *src, gfx_res_mod_t *rule) { char *orig_src = src; char *endp; float f[3]; @@ -212,7 +206,7 @@ extract_mod_rule(char *src, gfx_res_mod_t *rule) ++src; if (!*src || !(isdigit(*src) || *src == '.')) { sciprintf("[gfx-conf] Unexpected character '%c'\n", - *src); + *src); goto mod_error_label; } f[i++] = strtod(src, &endp); @@ -225,9 +219,9 @@ extract_mod_rule(char *src, gfx_res_mod_t *rule) if ((i == 3) && *src != ')') { sciprintf("[gfx-conf] Error: Expected ')' at end of modification rule\n"); goto mod_error_label; - } else if (i<3 && !isdigit(*src) && *src != '.' && *src != ',') { + } else if (i < 3 && !isdigit(*src) && *src != '.' && *src != ',') { sciprintf("[gfx-conf] Error: Expected ',' as separator in modification rule, not '%c'\n", - *src); + *src); goto mod_error_label; } ++src; @@ -247,9 +241,9 @@ extract_mod_rule(char *src, gfx_res_mod_t *rule) } return 0; - mod_error_label: +mod_error_label: sciprintf("[gfx-conf] Ill-formed modification rule '%s'\n", - orig_src); + orig_src); return 1; } @@ -258,8 +252,7 @@ extern gfx_pixmap_color_t gfx_sci0_image_colors[][GFX_SCI0_IMAGE_COLORS_NR]; #define PREDEFINED_PALETTES_NR 4 static int -extract_assign_rule(char *src, gfx_res_assign_t *rule) -{ +extract_assign_rule(char *src, gfx_res_assign_t *rule) { /*char *orig_src = src;*/ struct { const char *name; @@ -278,16 +271,16 @@ extract_assign_rule(char *src, gfx_res_assign_t *rule) for (i = 0; i < PREDEFINED_PALETTES_NR; i++) if (!strcmp(src, predefined_palettes[i].name)) { rule->assign.palette.colors_nr = - predefined_palettes[i].colors_nr; + predefined_palettes[i].colors_nr; rule->assign.palette.colors = - predefined_palettes[i].colors; + predefined_palettes[i].colors; return 0; } sciprintf("[gfx-conf] Unknown palette '%s'\n", src); return 1; /* - assign_error_label: + assign_error_label: sciprintf("[gfx-conf] Ill-formed assignment rule '%s'\n", orig_src); return 1; @@ -296,8 +289,7 @@ extract_assign_rule(char *src, gfx_res_assign_t *rule) #define CLASSES_NR 3 int -gfx_update_conf(gfx_options_t *options, char *str) -{ +gfx_update_conf(gfx_options_t *options, char *str) { int total_patterns; int mod = 0; /* Modifier or assignment rule? */ char *orig_str = str; @@ -356,7 +348,7 @@ gfx_update_conf(gfx_options_t *options, char *str) goto unexpected_end; if (*str == '=' - || *str == '*') + || *str == '*') break; if (*str == '(') { @@ -364,21 +356,21 @@ gfx_update_conf(gfx_options_t *options, char *str) if (fieldcnt >= fields_nr) { sciprintf("[gfx-conf] Error: Patterns of class '%s' may only be" - " constrained by %d arguments\n", - pat_name_str, fields_nr); + " constrained by %d arguments\n", + pat_name_str, fields_nr); goto failure_label; } if (!end) { sciprintf("[gfx-conf] Unmatched parentheses at offset %d\n", - str - orig_str); + str - orig_str); goto failure_label; } *end = 0; if (extract_pattern(fields[fieldcnt++], - str + 1, - str + 1 - orig_str)) + str + 1, + str + 1 - orig_str)) goto failure_label; *end = ')'; @@ -388,10 +380,10 @@ gfx_update_conf(gfx_options_t *options, char *str) } sciprintf("[gfx-conf] Lexical error in pattern at offset %d: Unexpected '%c'\n", - str - orig_str, *str); + str - orig_str, *str); goto failure_label; } while (1); - + /* Flatten patterns */ conf->patterns = NULL; @@ -432,7 +424,7 @@ gfx_update_conf(gfx_options_t *options, char *str) } do { *sem_end-- = 0; } while (sem_end >= str - && isblank(*sem_end)); + && isblank(*sem_end)); if (mod) { if (extract_mod_rule(str, &conf->conf.mod)) @@ -456,7 +448,7 @@ gfx_update_conf(gfx_options_t *options, char *str) /* Error handling */ unexpected_end: sciprintf("[gfx-conf] Unexpected end of pattern encountered\n"); - failure_label: +failure_label: sciprintf("[gfx-conf] Error occured in: '%s'\n", orig_str); pattern_list_free(patterns); pattern_list_free(loops); @@ -468,12 +460,11 @@ unexpected_end: } static inline int -matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) -{ +matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) { int i; for (i = 0; i < nr; i++) if (patterns[i].min <= val - && patterns[i].max >= val) + && patterns[i].max >= val) return 1; return 0; @@ -481,22 +472,20 @@ matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) #ifdef DEBUG static void -print_pattern(gfx_res_pattern_t *pat) -{ +print_pattern(gfx_res_pattern_t *pat) { fprintf(stderr, "[%d..%d]", - pat->min, pat->max); + pat->min, pat->max); } #endif static inline int resource_matches_patternlists(gfx_res_conf_t *conf, - int type, int nr, int loop, int cel) -{ + int type, int nr, int loop, int cel) { int loc; #ifdef DEBUG int i; fprintf(stderr, "[DEBUG:gfx-res] Trying to match against %d/%d/%d choices\n", - conf->patterns_nr, conf->loops_nr, conf->cels_nr); + conf->patterns_nr, conf->loops_nr, conf->cels_nr); for (i = 0; i < conf->patterns_nr; i++) { fprintf(stderr, "[DEBUG:gfx-res] Pat #%d: ", i); print_pattern(conf->patterns + i); @@ -516,9 +505,9 @@ resource_matches_patternlists(gfx_res_conf_t *conf, } #endif if (conf->patterns_nr && - !matches_patternlist(conf->patterns, - conf->patterns_nr, - nr)) + !matches_patternlist(conf->patterns, + conf->patterns_nr, + nr)) return 0; if (type == GFX_RESOURCE_TYPE_CURSOR) @@ -528,9 +517,9 @@ resource_matches_patternlists(gfx_res_conf_t *conf, ** and, for views, the cel as well */ loc = conf->patterns_nr; if (conf->loops_nr && - !matches_patternlist(conf->patterns + loc, - conf->loops_nr, - loop)) + !matches_patternlist(conf->patterns + loc, + conf->loops_nr, + loop)) return 0; if (type != GFX_RESOURCE_TYPE_VIEW) @@ -540,19 +529,18 @@ resource_matches_patternlists(gfx_res_conf_t *conf, if (!conf->cels_nr) return 1; - + return matches_patternlist(conf->patterns + loc, - conf->cels_nr, - cel); + conf->cels_nr, + cel); } static inline gfx_res_conf_t * find_match(gfx_res_conf_t *conflist, - int type, int nr, int loop, int cel) -{ + int type, int nr, int loop, int cel) { while (conflist) { if (resource_matches_patternlists(conflist, - type, nr, loop, cel)) { + type, nr, loop, cel)) { #ifdef DEBUG fprintf(stderr, "[DEBUG:gfx-res] Found match!\n"); #endif @@ -565,8 +553,7 @@ find_match(gfx_res_conf_t *conflist, } void -apply_assign(gfx_res_assign_t *conf, gfx_pixmap_t *pxm) -{ +apply_assign(gfx_res_assign_t *conf, gfx_pixmap_t *pxm) { /* Has a dynamically allocated palette? Must clean up */ if (!(pxm->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) { if (pxm->colors) @@ -579,8 +566,7 @@ apply_assign(gfx_res_assign_t *conf, gfx_pixmap_t *pxm) } void -apply_mod(gfx_res_mod_t *mod, gfx_pixmap_t *pxm) -{ +apply_mod(gfx_res_mod_t *mod, gfx_pixmap_t *pxm) { gfx_pixmap_color_t *pal = pxm->colors; int i, pal_size = pxm->colors_nr; @@ -601,10 +587,10 @@ apply_mod(gfx_res_mod_t *mod, gfx_pixmap_t *pxm) int v; #define UPDATE_COL(nm, idx) \ - v = pal[i].nm; \ - v *= mod->mod.factor[idx]; \ - v >>= 4; \ - pal[i].nm = (v > 255)? 255 : v; + v = pal[i].nm; \ + v *= mod->mod.factor[idx]; \ + v >>= 4; \ + pal[i].nm = (v > 255)? 255 : v; UPDATE_COL(r, 0); UPDATE_COL(g, 1); @@ -620,8 +606,7 @@ apply_mod(gfx_res_mod_t *mod, gfx_pixmap_t *pxm) } int -gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) -{ +gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) { int restype = GFXR_RES_TYPE(pxm->ID); int nr = GFXR_RES_NR(pxm->ID); int loop = pxm->loop; @@ -631,14 +616,14 @@ gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) #ifdef DEBUG fprintf(stderr, "[DEBUG:gfx-res] Trying to conf %d/%d/%d/%d (ID=%d)\n", - restype, nr, loop, cel, pxm->ID); + restype, nr, loop, cel, pxm->ID); #endif if (pxm->ID < 0 || restype < 0 || restype >= GFX_RESOURCE_TYPES_NR) return 1; /* Not appropriate */ conf = find_match(options->res_conf.assign[restype], - restype, nr, loop, cel); + restype, nr, loop, cel); if (conf) apply_assign(&(conf->conf.assign), pxm); @@ -646,7 +631,7 @@ gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) conf = options->res_conf.mod[restype]; while (conf) { conf = find_match(conf, - restype, nr, loop, cel); + restype, nr, loop, cel); if (conf) { apply_mod(&(conf->conf.mod), pxm); conf = conf->next; diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp index ed4a827916..7ff920b04e 100644 --- a/engines/sci/gfx/gfx_resource.cpp +++ b/engines/sci/gfx/gfx_resource.cpp @@ -41,8 +41,7 @@ gfx_mode_t mode_1x1_color_index = { /* Fake 1x1 mode */ static void -gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) -{ +gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) { int i; if (loop->cels) { @@ -55,8 +54,7 @@ gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) } void -gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) -{ +gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) { int i; if (view->colors && !(view->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) @@ -73,147 +71,145 @@ gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) static void -pixmap_endianness_reverse_2_simple(byte *data, int area) -{ - int c; - for (c = 0; c < area; c++) { - byte val = *data; - *data = data[1]; - data[1] = val; - - data += 2; - } +pixmap_endianness_reverse_2_simple(byte *data, int area) { + int c; + for (c = 0; c < area; c++) { + byte val = *data; + *data = data[1]; + data[1] = val; + + data += 2; + } } static void -pixmap_endianness_reverse_2(byte *data, int area) -{ - int c; - int sl = sizeof(unsigned long); +pixmap_endianness_reverse_2(byte *data, int area) { + int c; + int sl = sizeof(unsigned long); - for (c = 0; c < (area & ~(sl-1)); c += (sl>>1)) { - unsigned long temp; + for (c = 0; c < (area & ~(sl - 1)); c += (sl >> 1)) { + unsigned long temp; - memcpy(&temp, data, sl); + memcpy(&temp, data, sl); - /* The next line will give warnings on 32 bit archs, but - ** that's OK. */ + /* The next line will give warnings on 32 bit archs, but + ** that's OK. */ #if SIZEOF_LONG < 8 - temp = 0; + temp = 0; #else - temp = ((temp & 0xff00ff00ff00ff00l) >> 8) - | ((temp & 0x00ff00ff00ff00ffl) << 8); + temp = ((temp & 0xff00ff00ff00ff00l) >> 8) + | ((temp & 0x00ff00ff00ff00ffl) << 8); #endif /* SIZEOF_INT < 8 */ - memcpy(data, &temp, sl); + memcpy(data, &temp, sl); - data += sl; - } + data += sl; + } - pixmap_endianness_reverse_2_simple(data, area & (sl-1)); + pixmap_endianness_reverse_2_simple(data, area & (sl - 1)); } static void -pixmap_endianness_reverse_3_simple(byte *data, int area) -{ - int c; - for (c = 0; c < area; c++) { - byte val0 = data[0]; +pixmap_endianness_reverse_3_simple(byte *data, int area) { + int c; + for (c = 0; c < area; c++) { + byte val0 = data[0]; - data[0] = data[2]; - data[2] = val0; + data[0] = data[2]; + data[2] = val0; - data += 3; - } + data += 3; + } } static void -pixmap_endianness_reverse_4_simple(byte *data, int area) -{ - int c; - for (c = 0; c < area; c++) { - byte val0 = data[0]; - byte val1 = data[1]; +pixmap_endianness_reverse_4_simple(byte *data, int area) { + int c; + for (c = 0; c < area; c++) { + byte val0 = data[0]; + byte val1 = data[1]; - data[0] = data[3]; - data[3] = val0; + data[0] = data[3]; + data[3] = val0; - data[1] = data[2]; - data[2] = val1; + data[1] = data[2]; + data[2] = val1; - data += 4; - } + data += 4; + } } static void -pixmap_endianness_reverse_4(byte *data, int area) -{ - int c; - int sl = sizeof(unsigned long); +pixmap_endianness_reverse_4(byte *data, int area) { + int c; + int sl = sizeof(unsigned long); - for (c = 0; c < (area & ~(sl-1)); c += (sl>>2)) { - unsigned long temp; + for (c = 0; c < (area & ~(sl - 1)); c += (sl >> 2)) { + unsigned long temp; - memcpy(&temp, data, sl); + memcpy(&temp, data, sl); - /* The next lines will give warnings on 32 bit archs, but - ** that's OK. */ + /* The next lines will give warnings on 32 bit archs, but + ** that's OK. */ #if SIZEOF_LONG < 8 - temp = 0l; + temp = 0l; #else - temp = ((temp & 0xffff0000ffff0000l) >> 16) - | ((temp & 0x0000ffff0000ffffl) << 16); - temp = ((temp & 0xff00ff00ff00ff00l) >> 8) - | ((temp & 0x00ff00ff00ff00ffl) << 8); + temp = ((temp & 0xffff0000ffff0000l) >> 16) + | ((temp & 0x0000ffff0000ffffl) << 16); + temp = ((temp & 0xff00ff00ff00ff00l) >> 8) + | ((temp & 0x00ff00ff00ff00ffl) << 8); #endif /* SIZEOF_LONG < 8 */ - memcpy(data, &temp, sl); + memcpy(data, &temp, sl); - data += sl; - } + data += sl; + } - pixmap_endianness_reverse_4_simple(data, area & (sl-1)); + pixmap_endianness_reverse_4_simple(data, area & (sl - 1)); } gfx_pixmap_t * -gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) -{ - int bytespp; - byte *data; +gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { + int bytespp; + byte *data; - if (!pixmap || !pixmap->data || !mode) { - GFXERROR("gfxr_endianness_adjust(): Invoked with invalid values\n"); + if (!pixmap || !pixmap->data || !mode) { + GFXERROR("gfxr_endianness_adjust(): Invoked with invalid values\n"); BREAKPOINT(); - return NULL; - } + return NULL; + } - if (!(mode->flags & GFX_MODE_FLAG_REVERSE_ENDIAN)) - return pixmap; + if (!(mode->flags & GFX_MODE_FLAG_REVERSE_ENDIAN)) + return pixmap; - bytespp = mode->bytespp; + bytespp = mode->bytespp; - data = pixmap->data; + data = pixmap->data; - switch (bytespp) { - case 1: - break; + switch (bytespp) { + case 1: + break; - case 2: pixmap_endianness_reverse_2(data, pixmap->xl - * pixmap->yl); - break; + case 2: + pixmap_endianness_reverse_2(data, pixmap->xl + * pixmap->yl); + break; - case 3: pixmap_endianness_reverse_3_simple(data, pixmap->xl - * pixmap->yl); - break; + case 3: + pixmap_endianness_reverse_3_simple(data, pixmap->xl + * pixmap->yl); + break; - case 4: pixmap_endianness_reverse_4(data, pixmap->xl * pixmap->yl); - break; + case 4: + pixmap_endianness_reverse_4(data, pixmap->xl * pixmap->yl); + break; - default: fprintf(stderr,"gfxr_endianness_adjust(): Cannot adjust endianness for %d bytespp!\n", bytespp); - return NULL; - } + default: + fprintf(stderr, "gfxr_endianness_adjust(): Cannot adjust endianness for %d bytespp!\n", bytespp); + return NULL; + } - return pixmap; + return pixmap; } @@ -262,20 +258,23 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) #undef SIZETYPE static inline void -_gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) -{ +_gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { switch (mode->bytespp) { - case 1:_gfx_xlate_pixmap_unfiltered_1(mode, pxm, scale); + case 1: + _gfx_xlate_pixmap_unfiltered_1(mode, pxm, scale); break; - case 2:_gfx_xlate_pixmap_unfiltered_2(mode, pxm, scale); + case 2: + _gfx_xlate_pixmap_unfiltered_2(mode, pxm, scale); break; - case 3:_gfx_xlate_pixmap_unfiltered_3(mode, pxm, scale); + case 3: + _gfx_xlate_pixmap_unfiltered_3(mode, pxm, scale); break; - case 4:_gfx_xlate_pixmap_unfiltered_4(mode, pxm, scale); + case 4: + _gfx_xlate_pixmap_unfiltered_4(mode, pxm, scale); break; default: @@ -293,8 +292,7 @@ _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) } static inline void -_gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) -{ +_gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { if (mode->palette || !scale) { /* fall back to unfiltered */ _gfx_xlate_pixmap_unfiltered(mode, pxm, scale); return; @@ -305,16 +303,20 @@ _gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) switch (mode->bytespp) { - case 1:_gfx_xlate_pixmap_linear_1(mode, pxm, scale); + case 1: + _gfx_xlate_pixmap_linear_1(mode, pxm, scale); break; - case 2:_gfx_xlate_pixmap_linear_2(mode, pxm, scale); + case 2: + _gfx_xlate_pixmap_linear_2(mode, pxm, scale); break; - case 3:_gfx_xlate_pixmap_linear_3(mode, pxm, scale); + case 3: + _gfx_xlate_pixmap_linear_3(mode, pxm, scale); break; - case 4:_gfx_xlate_pixmap_linear_4(mode, pxm, scale); + case 4: + _gfx_xlate_pixmap_linear_4(mode, pxm, scale); break; default: @@ -325,8 +327,7 @@ _gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) } static inline void -_gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) -{ +_gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { if (mode->palette || !scale) { /* fall back to unfiltered */ _gfx_xlate_pixmap_unfiltered(mode, pxm, scale); return; @@ -337,16 +338,20 @@ _gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) switch (mode->bytespp) { - case 1:_gfx_xlate_pixmap_trilinear_1(mode, pxm, scale); + case 1: + _gfx_xlate_pixmap_trilinear_1(mode, pxm, scale); break; - case 2:_gfx_xlate_pixmap_trilinear_2(mode, pxm, scale); + case 2: + _gfx_xlate_pixmap_trilinear_2(mode, pxm, scale); break; - case 3:_gfx_xlate_pixmap_trilinear_3(mode, pxm, scale); + case 3: + _gfx_xlate_pixmap_trilinear_3(mode, pxm, scale); break; - case 4:_gfx_xlate_pixmap_trilinear_4(mode, pxm, scale); + case 4: + _gfx_xlate_pixmap_trilinear_4(mode, pxm, scale); break; default: @@ -357,18 +362,17 @@ _gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) } void -gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter) -{ +gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter) { int was_allocated = 0; if (mode->palette - && !(pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED)) { + && !(pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED)) { int i; for (i = 0; i < pxm->colors_nr; i++) { if (gfx_alloc_color(mode->palette, pxm->colors + i) < 0) { GFXWARN("Failed to allocate color %d/%d in pixmap (color %02x/%02x/%02x)!\n", - i, pxm->colors_nr, pxm->colors[i].r, pxm->colors[i].g, pxm->colors[i].b); + i, pxm->colors_nr, pxm->colors[i].r, pxm->colors[i].g, pxm->colors[i].b); pxm->colors[i].global_index = 0; } /* @@ -393,13 +397,16 @@ gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter) switch (filter) { - case GFX_XLATE_FILTER_NONE: _gfx_xlate_pixmap_unfiltered(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)); + case GFX_XLATE_FILTER_NONE: + _gfx_xlate_pixmap_unfiltered(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)); break; - case GFX_XLATE_FILTER_LINEAR: _gfx_xlate_pixmap_linear(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)); + case GFX_XLATE_FILTER_LINEAR: + _gfx_xlate_pixmap_linear(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)); break; - case GFX_XLATE_FILTER_TRILINEAR: _gfx_xlate_pixmap_trilinear(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)); + case GFX_XLATE_FILTER_TRILINEAR: + _gfx_xlate_pixmap_trilinear(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)); break; default: @@ -415,8 +422,7 @@ gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter) void -gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic) -{ +gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic) { gfx_free_pixmap(driver, pic->visual_map); gfx_free_pixmap(driver, pic->priority_map); gfx_free_pixmap(driver, pic->control_map); diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 5f6037a4e8..05cf5b7d76 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -62,8 +62,7 @@ int gfx_crossblit_alpha_threshold = 128; #undef DRAWLINE_FUNC inline void -gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, point_t start, point_t end, unsigned int color) -{ +gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, point_t start, point_t end, unsigned int color) { switch (pixelwidth) { case 1: @@ -93,8 +92,7 @@ gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, point_t start, void -gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, point_t start, point_t end, int color) -{ +gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, point_t start, point_t end, int color) { gfx_draw_line_buffer(pxm->index_data, pxm->index_xl, 1, start, end, color); } @@ -102,27 +100,25 @@ gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, point_t start, point_t end, int color) void -gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) -{ - byte *dest = buffer + zone.x + (linewidth * zone.y); - int i; - - if (zone.xl <= 0 || zone.yl <= 0) - return; - - for (i = 0; i < zone.yl; i++) { - memset(dest, color, zone.xl); - dest += linewidth; - } +gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) { + byte *dest = buffer + zone.x + (linewidth * zone.y); + int i; + + if (zone.xl <= 0 || zone.yl <= 0) + return; + + for (i = 0; i < zone.yl; i++) { + memset(dest, color, zone.xl); + dest += linewidth; + } } void -gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color) -{ - gfx_clip_box_basic(&box, pxm->index_xl - 1, pxm->index_yl - 1); +gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color) { + gfx_clip_box_basic(&box, pxm->index_xl - 1, pxm->index_yl - 1); - gfx_draw_box_buffer(pxm->index_data, pxm->index_xl, box, color); + gfx_draw_box_buffer(pxm->index_data, pxm->index_xl, box, color); } @@ -243,39 +239,38 @@ gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color) #undef BYTESPP #undef REVERSE_ALPHA -static void (*crossblit_fns[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int) = -{ NULL, - _gfx_crossblit_8, - _gfx_crossblit_16, - _gfx_crossblit_24, - _gfx_crossblit_32 }; - -static void (*crossblit_fns_P[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = -{ NULL, - _gfx_crossblit_8_P, - _gfx_crossblit_16_P, - _gfx_crossblit_24_P, - _gfx_crossblit_32_P }; - -static void (*crossblit_fns_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int) = -{ NULL, - _gfx_crossblit_8_RA, - _gfx_crossblit_16_RA, - _gfx_crossblit_24_RA, - _gfx_crossblit_32_RA }; - -static void (*crossblit_fns_P_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = -{ NULL, - _gfx_crossblit_8_P_RA, - _gfx_crossblit_16_P_RA, - _gfx_crossblit_24_P_RA, - _gfx_crossblit_32_P_RA }; - +static void (*crossblit_fns[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int) = { NULL, + _gfx_crossblit_8, + _gfx_crossblit_16, + _gfx_crossblit_24, + _gfx_crossblit_32 + }; + +static void (*crossblit_fns_P[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL, + _gfx_crossblit_8_P, + _gfx_crossblit_16_P, + _gfx_crossblit_24_P, + _gfx_crossblit_32_P + }; + +static void (*crossblit_fns_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int) = { NULL, + _gfx_crossblit_8_RA, + _gfx_crossblit_16_RA, + _gfx_crossblit_24_RA, + _gfx_crossblit_32_RA + }; + +static void (*crossblit_fns_P_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL, + _gfx_crossblit_8_P_RA, + _gfx_crossblit_16_P_RA, + _gfx_crossblit_24_P_RA, + _gfx_crossblit_32_P_RA + }; + void -_gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, - int xl, int yl, int bpp) -{ +_gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, + int xl, int yl, int bpp) { int line_width = xl * bpp; int i; @@ -288,23 +283,22 @@ _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_w int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, - rect_t src_coords, - rect_t dest_coords, byte *dest, int dest_line_width, - byte *priority_dest, int priority_line_width, - int priority_skip, int flags) -{ + rect_t src_coords, + rect_t dest_coords, byte *dest, int dest_line_width, + byte *priority_dest, int priority_line_width, + int priority_skip, int flags) { int maxx = 320 * mode->xfact; int maxy = 200 * mode->yfact; byte *src = pxm->data; - byte *alpha = pxm->alpha_map? pxm->alpha_map : pxm->data; + byte *alpha = pxm->alpha_map ? pxm->alpha_map : pxm->data; byte *priority_pos = priority_dest; unsigned int alpha_mask, alpha_min; int bpp = mode->bytespp; - int bytes_per_alpha_pixel = pxm->alpha_map? 1 : bpp; + int bytes_per_alpha_pixel = pxm->alpha_map ? 1 : bpp; int bytes_per_alpha_line = bytes_per_alpha_pixel * pxm->xl; int xl = pxm->xl, yl = pxm->yl; - int xoffset = (dest_coords.x < 0)? - dest_coords.x : 0; - int yoffset = (dest_coords.y < 0)? - dest_coords.y : 0; + int xoffset = (dest_coords.x < 0) ? - dest_coords.x : 0; + int yoffset = (dest_coords.y < 0) ? - dest_coords.y : 0; int revalpha = mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA; if (src_coords.x + src_coords.xl > xl) @@ -313,12 +307,12 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, if (src_coords.y + src_coords.yl > yl) src_coords.yl = yl - src_coords.y; -/** --???-- **/ + /** --???-- **/ if (src_coords.y > yl) return GFX_OK; if (src_coords.x > xl) return GFX_OK; -/** --???-- **/ + /** --???-- **/ if (dest_coords.x + xl >= maxx) xl = maxx - dest_coords.x; @@ -337,26 +331,26 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, /* Set destination offsets */ /* Set x offsets */ - if (!(flags & GFX_CROSSBLIT_FLAG_DATA_IS_HOMED)) - dest += dest_coords.x * bpp; + if (!(flags & GFX_CROSSBLIT_FLAG_DATA_IS_HOMED)) + dest += dest_coords.x * bpp; priority_pos += dest_coords.x * priority_skip; /* Set y offsets */ - if (!(flags & GFX_CROSSBLIT_FLAG_DATA_IS_HOMED)) - dest += dest_coords.y * dest_line_width; + if (!(flags & GFX_CROSSBLIT_FLAG_DATA_IS_HOMED)) + dest += dest_coords.y * dest_line_width; priority_pos += dest_coords.y * priority_line_width; /* Set source offsets */ if (xoffset += src_coords.x) { dest_coords.x = 0; - src += xoffset * bpp; + src += xoffset * bpp; alpha += xoffset * bytes_per_alpha_pixel; } if (yoffset += src_coords.y) { dest_coords.y = 0; - src += yoffset * bpp * pxm->xl; + src += yoffset * bpp * pxm->xl; alpha += yoffset * bytes_per_alpha_line; } @@ -397,11 +391,11 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, if (mode->alpha_mask && axp_have_mvi && bpp == 4) { if (priority == GFX_NO_PRIORITY) alpha_mvi_crossblit_32(dest, src, dest_line_width, pxm->xl * bpp, - xl, yl, NULL, 0, 0, mode->alpha_mask, 24 - mode->alpha_shift); + xl, yl, NULL, 0, 0, mode->alpha_mask, 24 - mode->alpha_shift); else alpha_mvi_crossblit_32_P(dest, src, dest_line_width, pxm->xl * bpp, - xl, yl, NULL, 0, 0, mode->alpha_mask, 24 - mode->alpha_shift, - priority_pos, priority_line_width, priority_skip, priority); + xl, yl, NULL, 0, 0, mode->alpha_mask, 24 - mode->alpha_shift, + priority_pos, priority_line_width, priority_skip, priority); } else { #endif @@ -412,32 +406,32 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, if (revalpha) alpha_min = 255 - alpha_min; /* Since we use it for the reverse effect */ - + if (!alpha_mask) - _gfx_crossblit_simple(dest, src, dest_line_width, pxm->xl * bpp, - xl, yl, bpp); + _gfx_crossblit_simple(dest, src, dest_line_width, pxm->xl * bpp, + xl, yl, bpp); else - if (priority == GFX_NO_PRIORITY) { - if (bpp > 0 && bpp < 5) - ((revalpha) ? crossblit_fns_RA : crossblit_fns)[bpp](dest, src, dest_line_width, pxm->xl * bpp, - xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, - alpha_mask, alpha_min); - else { - GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); - return GFX_ERROR; + if (priority == GFX_NO_PRIORITY) { + if (bpp > 0 && bpp < 5) + ((revalpha) ? crossblit_fns_RA : crossblit_fns)[bpp](dest, src, dest_line_width, pxm->xl * bpp, + xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, + alpha_mask, alpha_min); + else { + GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); + return GFX_ERROR; + } + } else { /* priority */ + if (bpp > 0 && bpp < 5) + ((revalpha) ? crossblit_fns_P_RA : crossblit_fns_P)[bpp](dest, src, dest_line_width, pxm->xl * bpp, + xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, + alpha_mask, alpha_min, priority_pos, + priority_line_width, priority_skip, priority); + else { + GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); + return GFX_ERROR; + } } - } else { /* priority */ - if (bpp > 0 && bpp < 5) - ((revalpha) ? crossblit_fns_P_RA : crossblit_fns_P)[bpp](dest, src, dest_line_width, pxm->xl * bpp, - xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, - alpha_mask, alpha_min, priority_pos, - priority_line_width, priority_skip, priority); - else { - GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); - return GFX_ERROR; - } - } #ifdef HAVE_ALPHA_EV6_SUPPORT } #endif diff --git a/engines/sci/gfx/gfx_test.cpp b/engines/sci/gfx/gfx_test.cpp index 56502384bf..e3690afaa5 100644 --- a/engines/sci/gfx/gfx_test.cpp +++ b/engines/sci/gfx/gfx_test.cpp @@ -50,14 +50,12 @@ sci0_palette; gfx_pixmap_color_t gfx_sci0_image_colors[1][16]; gfx_pixmap_color_t * -gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) -{ +gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) { return NULL; } int -sciprintf(const char *fmt, ...) -{ +sciprintf(const char *fmt, ...) { va_list argp; va_start(argp, fmt); vprintf(fmt, argp); @@ -67,8 +65,7 @@ sciprintf(const char *fmt, ...) void * -memdup(void *mem, size_t size) -{ +memdup(void *mem, size_t size) { void *r = malloc(size); if (r) memcpy(r, mem, size); @@ -80,17 +77,16 @@ memdup(void *mem, size_t size) #endif void -sci_gettime(long *seconds, long *useconds) -{ - struct timeval tv; +sci_gettime(long *seconds, long *useconds) { + struct timeval tv; #ifdef WIN32 timeBeginPeriod(0); #endif - assert(!gettimeofday(&tv, NULL)); - *seconds = time(NULL); - *useconds = tv.tv_usec; + assert(!gettimeofday(&tv, NULL)); + *seconds = time(NULL); + *useconds = tv.tv_usec; #ifdef WIN32 timeEndPeriod(0); @@ -135,8 +131,7 @@ static struct { }; int -init_driver(gfx_driver_t *drv) -{ +init_driver(gfx_driver_t *drv) { int i; state->driver = drv; @@ -182,15 +177,13 @@ int test_fonts[TEST_FONTS_NR] = {0}; int test_cursors[TEST_CURSORS_NR] = {0, 1}; int -gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_options_t *options, void *internal, int palette) -{ +gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_options_t *options, void *internal, int palette) { return 0; } int * -arrdup(int *src, int count) -{ +arrdup(int *src, int count) { int *retval = sci_malloc(sizeof(int) * count); memcpy(retval, src, sizeof(int) * count); return retval; @@ -198,8 +191,7 @@ arrdup(int *src, int count) int * gfxr_interpreter_get_resources(gfx_resstate_t *resstate, gfx_resource_type_t type, - int version, int *entries_nr, void *internal) -{ + int version, int *entries_nr, void *internal) { switch (type) { case GFX_RESOURCE_TYPE_VIEW: @@ -219,7 +211,7 @@ gfxr_interpreter_get_resources(gfx_resstate_t *resstate, gfx_resource_type_t typ return arrdup(test_cursors, TEST_CURSORS_NR); default: - fprintf(stderr,"Attept to get resource list for invalid resource type %d\n", type); + fprintf(stderr, "Attept to get resource list for invalid resource type %d\n", type); return NULL; } } @@ -262,8 +254,7 @@ gfx_pixmap_color_t pic_colors[PIC_COLORS_NR] = { }; gfxr_pic_t * -gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) -{ +gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) { gfxr_pic_t *pic = sci_malloc(sizeof(gfxr_pic_t)); pic->mode = mode; @@ -272,7 +263,7 @@ gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) pic->control_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, ID, 2, 0)); pic->priority_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320 * mode->xfact, - 200 * mode->yfact, ID, 1, 0)); + 200 * mode->yfact, ID, 1, 0)); pic->visual_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, ID, 0, 0)); pic->visual_map->colors = pic_colors; @@ -293,8 +284,7 @@ gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) void -gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) -{ +gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) { memset(pic->visual_map->index_data, 0x00, 320 * 200); memset(pic->priority_map->index_data, 0, 320 * pic->mode->xfact * 200 * pic->mode->yfact); memset(pic->control_map->index_data, 0, GFXR_AUX_MAP_SIZE); @@ -304,8 +294,7 @@ gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, - int flags, int default_palette, int nr, void *internal) -{ + int flags, int default_palette, int nr, void *internal) { gfxr_pic_t *pic = scaled_pic; int i, x, y, pos; int xfact = pic->mode->xfact; @@ -342,13 +331,13 @@ gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gf memset(pic->visual_map->index_data + i*320 + 140, 15, 80); for (j = 0; j < pic->mode->yfact; j++) - memset(pic->priority_map->index_data + (i*yfact+j)*320*xfact - + 140*xfact , 20, 80*xfact); + memset(pic->priority_map->index_data + (i*yfact + j)*320*xfact + + 140*xfact , 20, 80*xfact); } break; default: - fprintf(stderr,"Attempt to reference invalid pic #%d\n", nr); + fprintf(stderr, "Attempt to reference invalid pic #%d\n", nr); } printf(">> resource manager retrieved pic #%d\n", nr); @@ -378,8 +367,7 @@ gfx_pixmap_color_t view_colors[VIEW_COLORS_NR] = { }; gfxr_view_t * -gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) -{ +gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) { gfxr_view_t *view; gfxr_loop_t *loop; int i; @@ -402,7 +390,7 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal for (i = 0; i < 3; i++) { gfx_pixmap_t *pxm = gfx_pixmap_alloc_index_data(gfx_new_pixmap(16, 16, 2048 | nr, 0, i)); - int offset = (i == 1)? 8 : 0; + int offset = (i == 1) ? 8 : 0; int x, y; pxm->colors_nr = VIEW_COLORS_NR; @@ -413,18 +401,18 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal for (y = 0; y < 16; y++) for (x = 0; x < 16; x++) { - int dx = (8-x); - int dy = (8-y); - int dist = dx*dx + dy*dy; + int dx = (8 - x); + int dy = (8 - y); + int dist = dx * dx + dy * dy; int index = (dist * 8) / 64; - int pos = x + y*16; + int pos = x + y * 16; if (i == 2) { - offset = (!dx || !dy)? 8 : 0; + offset = (!dx || !dy) ? 8 : 0; if (offset == 8) index <<= 1; } - index = 7-index; + index = 7 - index; if (index < 0) pxm->index_data[pos] = 0xff; else @@ -446,8 +434,7 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal extern byte builtin_font[]; gfx_bitmap_font_t * -gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) -{ +gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) { gfx_bitmap_font_t *font; int i; if (nr < 0 || nr > TEST_FONTS_NR) @@ -476,8 +463,7 @@ gfx_pixmap_color_t _cursor_colors[3] = { }; gfx_pixmap_t * -gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) -{ +gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) { gfx_pixmap_t *cursor; int xl, yl, x, y; @@ -500,32 +486,32 @@ gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) switch (nr) { case 0: - cursor->colors_nr = multicolored_pointers? 3 : 2; + cursor->colors_nr = multicolored_pointers ? 3 : 2; cursor->xoffset = 16; cursor->yoffset = 16; for (x = 0; x < 31; x++) if (x != 16) { - cursor->index_data[31*x + 16] = 1; - cursor->index_data[31*16 + x] = 1; - - if (multicolored_pointers && ((x < 8) || (x > 23))) { - cursor->index_data[31*x + 14] = 0; - cursor->index_data[31*x + 15] = 2; - cursor->index_data[31*x + 17] = 2; - cursor->index_data[31*x + 18] = 0; - - cursor->index_data[31*14 + x] = 0; - cursor->index_data[31*15 + x] = 2; - cursor->index_data[31*17 + x] = 2; - cursor->index_data[31*18 + x] = 0; - } else { - cursor->index_data[31*x + 15] = 0; - cursor->index_data[31*x + 17] = 0; - - cursor->index_data[31*15 + x] = 0; - cursor->index_data[31*17 + x] = 0; + cursor->index_data[31*x + 16] = 1; + cursor->index_data[31*16 + x] = 1; + + if (multicolored_pointers && ((x < 8) || (x > 23))) { + cursor->index_data[31*x + 14] = 0; + cursor->index_data[31*x + 15] = 2; + cursor->index_data[31*x + 17] = 2; + cursor->index_data[31*x + 18] = 0; + + cursor->index_data[31*14 + x] = 0; + cursor->index_data[31*15 + x] = 2; + cursor->index_data[31*17 + x] = 2; + cursor->index_data[31*18 + x] = 0; + } else { + cursor->index_data[31*x + 15] = 0; + cursor->index_data[31*x + 17] = 0; + + cursor->index_data[31*15 + x] = 0; + cursor->index_data[31*17 + x] = 0; + } } - } break; case 1: @@ -538,7 +524,7 @@ gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) break; default: - fprintf(stderr,"Attempt to load invalid pointer %d\n", nr); + fprintf(stderr, "Attempt to load invalid pointer %d\n", nr); gfx_free_pixmap(state->driver, cursor); return NULL; } @@ -549,22 +535,19 @@ gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) } gfx_pixmap_color_t * -gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr) -{ +gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr) { return NULL; } int -gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) -{ +gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) { return multicolored_pointers; } gfx_color_t red, green, blue, dblue, white, white8, white16, white24, black, transparent; void -init_colors() -{ +init_colors() { gfxop_set_color(state, &red, 0xff, 0x00, 0x00, 0x00, -1, -1); gfxop_set_color(state, &green, 0x00, 0xff, 0x00, 0x00, -1, -1); gfxop_set_color(state, &blue, 0x00, 0x00, 0xff, 0x00, -1, -1); @@ -586,8 +569,7 @@ init_colors() int -waitkey(void) -{ +waitkey(void) { int count = 100000; sci_event_t event; @@ -603,8 +585,7 @@ waitkey(void) } int -wait_specific_key(int key) -{ +wait_specific_key(int key) { int count = 20000; sci_event_t event; @@ -612,7 +593,7 @@ wait_specific_key(int key) event = gfxop_get_event(state, SCI_EVT_ANY); if (event.type == SCI_EVT_KEYBOARD - && event.data == key) + && event.data == key) return 0; gfxop_usleep(state, 1000); @@ -622,14 +603,13 @@ wait_specific_key(int key) int -message(char *msg) -{ +message(char *msg) { gfx_text_handle_t *handle; rect_t text_rect = gfx_rect(0, 150, 320, 50); handle = gfxop_new_text(state, 0, msg, 320, ALIGN_CENTER, ALIGN_TOP, - white, white, black, 0); + white, white, black, 0); if (!handle) return 1; @@ -643,37 +623,32 @@ message(char *msg) } void -update(void) -{ +update(void) { /* gfxop_update_box(state, gfx_rect(0, 0, 320, 150)); */ gfxop_update(state); } void -explicit_clear_buffer(void) -{ +explicit_clear_buffer(void) { gfxop_clear_box(state, gfx_rect(0, 0, 320, 150)); gfxop_update(state); } void -clear_buffer(void) -{ +clear_buffer(void) { gfxop_disable_dirty_frames(state); gfxop_clear_box(state, gfx_rect(0, 0, 320, 150)); gfxop_enable_dirty_frames(state); } void -clear(void) -{ +clear(void) { gfxop_fill_box(state, gfx_rect(0, 0, 320, 150), black); } void -identify_event(sci_event_t event) -{ - switch(event.type) { +identify_event(sci_event_t event) { + switch (event.type) { case SCI_EVT_NONE: MESSAGE("No event"); @@ -681,12 +656,12 @@ identify_event(sci_event_t event) case SCI_EVT_MOUSE_PRESS: MESSAGE4("Mouse press at (%d,%d)\ndata/modifiers (%d/%d)", - state->pointer_pos.x, state->pointer_pos.y, event.data, event.buckybits); + state->pointer_pos.x, state->pointer_pos.y, event.data, event.buckybits); break; case SCI_EVT_MOUSE_RELEASE: MESSAGE4("Mouse release at (%d,%d)\ndata/modifiers (%d/%d)", - state->pointer_pos.x, state->pointer_pos.y, event.data, event.buckybits); + state->pointer_pos.x, state->pointer_pos.y, event.data, event.buckybits); break; case SCI_EVT_KEYBOARD: @@ -704,16 +679,16 @@ identify_event(sci_event_t event) MESSAGE("Error event"); break; - default: MESSAGE1("Unknown event type %d!\n", event.type); + default: + MESSAGE1("Unknown event type %d!\n", event.type); } } int -test_a(void) -{ +test_a(void) { if (message("-- Test A --\nText display and basic input\nPlease press 'space' within 20 seconds")) - return 1; + return 1; return (wait_specific_key(' ')); } @@ -750,8 +725,7 @@ int test_b_lines[LINES_NR][4] = { }; void -test_b(void) -{ +test_b(void) { int i; MESSAGE("-- Test B --\nLines"); @@ -802,8 +776,7 @@ test_b(void) void -test_c(void) -{ +test_c(void) { int i; clear(); update(); @@ -825,7 +798,7 @@ test_c(void) for (i = 0; i <= 40; i++) { gfxop_update_box(state, gfx_rect(i*4, 0 , 4, 150)); - gfxop_update_box(state, gfx_rect(317-i*4, 0 , 4, 150)); + gfxop_update_box(state, gfx_rect(317 - i*4, 0 , 4, 150)); gfxop_usleep(state, 4000); } @@ -835,11 +808,11 @@ test_c(void) gfxop_enable_dirty_frames(state); MESSAGE("C.2: Single line propagation\nPress a key to propagate a red box.\nNote that dirty frame\naccounting must be dis-\n" - "abled for manual updates\nto work like this."); + "abled for manual updates\nto work like this."); waitkey(); for (i = 159; i >= 0; i--) { gfxop_update_box(state, gfx_rect(i, 0 , 1, 150)); - gfxop_update_box(state, gfx_rect(319-i, 0 , 1, 150)); + gfxop_update_box(state, gfx_rect(319 - i, 0 , 1, 150)); gfxop_usleep(state, 1000); } @@ -858,8 +831,7 @@ test_c(void) void -test_d(void) -{ +test_d(void) { rect_t line; int pressed = 0; sci_event_t event; @@ -932,8 +904,7 @@ test_d(void) void -test_e(void) -{ +test_e(void) { int x; gfxop_set_pointer_cursor(state, 1); @@ -996,8 +967,8 @@ test_e(void) MESSAGE("E.5: Animation with partial updates\nIf you're running high-res,\nthis should be considerably\nfaster."); waitkey(); for (x = -20; x < 340; x++) { - gfxop_clear_box(state, gfx_rect(x-9, 40-8, 17, 16)); - gfxop_clear_box(state, gfx_rect(x-9, 70-8, 17, 16)); + gfxop_clear_box(state, gfx_rect(x - 9, 40 - 8, 17, 16)); + gfxop_clear_box(state, gfx_rect(x - 9, 70 - 8, 17, 16)); gfxop_draw_cel(state, 0, 0, 2, gfx_point(x, 40), white16, 0); gfxop_draw_cel(state, 0, 0, 2, gfx_point(x, 70), white16, 0); gfxop_update(state); @@ -1009,12 +980,11 @@ test_e(void) } void -test_wrap(int width, char *text) -{ +test_wrap(int width, char *text) { rect_t rect = gfx_rect(0, 0, width, 120); gfx_text_handle_t *handle = gfxop_new_text(state, 0, - text, - width, ALIGN_LEFT, ALIGN_TOP, white, white, transparent, 0); + text, + width, ALIGN_LEFT, ALIGN_TOP, white, white, transparent, 0); gfxop_fill_box(state, rect, dblue); gfxop_draw_rectangle(state, rect, blue, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL); @@ -1023,8 +993,7 @@ test_wrap(int width, char *text) } void -test_f(void) -{ +test_f(void) { int i; int x, y; gfx_text_handle_t *handle; @@ -1032,13 +1001,13 @@ test_f(void) waitkey(); handle = gfxop_new_text(state, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890", - 320, ALIGN_LEFT, ALIGN_TOP, white, white, transparent, 0); + 320, ALIGN_LEFT, ALIGN_TOP, white, white, transparent, 0); gfxop_draw_text(state, handle, gfx_rect(0, 0, 320, 150)); gfxop_free_text(state, handle); update(); MESSAGE("F.0: Font wrap\nYou should now see the alphabet\n(capitals, then small letters),\nand the numbers from 1 to 0" - "\nwrapped with a maxwidth of\n320 (screen width)"); + "\nwrapped with a maxwidth of\n320 (screen width)"); waitkey(); MESSAGE("F.1: Font wrap:\nMisc. wrap widths\nAll text should be /within/ the\nblue box (it may touch\nthe border, though)"); @@ -1052,7 +1021,7 @@ test_f(void) } handle = gfxop_new_text(state, 0, "And now for something completely different.", - 320, ALIGN_LEFT, ALIGN_TOP, red, green, black, 0); + 320, ALIGN_LEFT, ALIGN_TOP, red, green, black, 0); gfxop_draw_text(state, handle, gfx_rect(0, 0, 320, 150)); gfxop_free_text(state, handle); update(); @@ -1061,12 +1030,13 @@ test_f(void) clear_buffer(); handle = gfxop_new_text(state, 0, "foo!", - 320, ALIGN_CENTER, ALIGN_CENTER, blue, blue, transparent, 0); - x = 10; y = 10; + 320, ALIGN_CENTER, ALIGN_CENTER, blue, blue, transparent, 0); + x = 10; + y = 10; for (i = 0; i < 1000; i++) { - x = (x+(70 + (i / y) + y*y*x / (i+1))); - y = (y+(30 + (i / x) + x*x*y / (i+1))); + x = (x + (70 + (i / y) + y * y * x / (i + 1))); + y = (y + (30 + (i / x) + x * x * y / (i + 1))); gfxop_draw_text(state, handle, gfx_rect(x % 320, y % 140, 0, 0)); } @@ -1077,8 +1047,7 @@ test_f(void) } void -do_tests(char *conf) -{ +do_tests(char *conf) { init_colors(); @@ -1103,15 +1072,13 @@ do_tests(char *conf) } int -c_quit(void *S) -{ - exit(0); - return 0; /* hahaha */ +c_quit(void *S) { + exit(0); + return 0; /* hahaha */ } int -main(int argc, char **argv) -{ +main(int argc, char **argv) { gfx_driver_t *drv = NULL; char c; @@ -1134,22 +1101,25 @@ main(int argc, char **argv) "-n: Immediately stop after displaying (for performance tests)\n" "-g: Select any of the graphics drivers shown with -l\n" "-t: Select the tests to run:\n" - "\ta: Text display and basic input\n" - "\tb: Lines\n" - "\tc: Boxes and updates\n" - "\td: Pointers and input\n" - "\te: Pics and Views\n" - " -- for example, use \"-t abc\" to run tests A, B, and C\n" - ); + "\ta: Text display and basic input\n" + "\tb: Lines\n" + "\tc: Boxes and updates\n" + "\td: Pointers and input\n" + "\te: Pics and Views\n" + " -- for example, use \"-t abc\" to run tests A, B, and C\n" + ); return 0; - case 'n': nowait = 1; + case 'n': + nowait = 1; break; - case 's': skip_intro = 1; + case 's': + skip_intro = 1; break; - case 'g': if (driver) sci_free(driver); + case 'g': + if (driver) sci_free(driver); driver = sci_strdup(optarg); break; @@ -1165,7 +1135,8 @@ main(int argc, char **argv) printf("%s", gfx_get_driver_name(i++)); } printf("\n"); - } break; + } + break; case 't': strcpy(tests, optarg); @@ -1174,7 +1145,7 @@ main(int argc, char **argv) case 'x': set_mode = xres = atoi(optarg); if (xres < 1) { - fprintf(stderr,"Invalid x scale factor!\n"); + fprintf(stderr, "Invalid x scale factor!\n"); return 1; } break; @@ -1182,7 +1153,7 @@ main(int argc, char **argv) case 'y': set_mode = yres = atoi(optarg); if (yres < 1) { - fprintf(stderr,"Invalid y scale factor!\n"); + fprintf(stderr, "Invalid y scale factor!\n"); return 1; } break; @@ -1190,13 +1161,13 @@ main(int argc, char **argv) case 'c': set_mode = color_mode = atoi(optarg); if (color_mode < 1 || color_mode > 4) { - fprintf(stderr,"Invalid number of bytes per pixel!\n"); + fprintf(stderr, "Invalid number of bytes per pixel!\n"); return 1; } break; default: - fprintf(stderr,"Run 'gfx_test -h' for help\n"); + fprintf(stderr, "Run 'gfx_test -h' for help\n"); return 1; } @@ -1221,17 +1192,17 @@ main(int argc, char **argv) } if (init_driver(drv)) { - fprintf(stderr,"Initialization failed!\n"); + fprintf(stderr, "Initialization failed!\n"); return 1; } do_tests(tests); if (gfxop_exit(state)) { - fprintf(stderr,"Something weird happened while exitting...\n"); + fprintf(stderr, "Something weird happened while exitting...\n"); } } else { - fprintf(stderr,"No graphics driver found!\n"); + fprintf(stderr, "No graphics driver found!\n"); return 1; } @@ -1241,262 +1212,262 @@ main(int argc, char **argv) byte builtin_font[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, - 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, - 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, - 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, - 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0xd6, 0x10, 0x38, - 0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x7c, 0x10, 0x38, - 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, - 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, - 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, - 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, - 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78, - 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, - 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0, - 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0, - 0x18, 0xdb, 0x3c, 0xe7, 0xe7, 0x3c, 0xdb, 0x18, - 0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, - 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00, - 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, - 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, - 0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, - 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff, - 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, - 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, - 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, - 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, - 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, - 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00, - 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, - 0x18, 0x3e, 0x60, 0x3c, 0x06, 0x7c, 0x18, 0x00, - 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00, - 0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00, - 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, - 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, - 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, - 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, - 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, - 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, - 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, - 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, - 0x7c, 0xc6, 0x06, 0x1c, 0x30, 0x66, 0xfe, 0x00, - 0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00, - 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, - 0xfe, 0xc0, 0xc0, 0xfc, 0x06, 0xc6, 0x7c, 0x00, - 0x38, 0x60, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00, - 0xfe, 0xc6, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00, - 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00, - 0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, - 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30, - 0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00, - 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, - 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00, - 0x7c, 0xc6, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x00, - 0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00, - 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, - 0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, - 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00, - 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, - 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00, - 0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, - 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3a, 0x00, - 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, - 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, - 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00, - 0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, - 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00, - 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, - 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, - 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xce, 0x7c, 0x0e, - 0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00, - 0x3c, 0x66, 0x30, 0x18, 0x0c, 0x66, 0x3c, 0x00, - 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, - 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, - 0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x00, - 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x00, - 0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, - 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, - 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00, - 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, - 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, - 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, - 0xe0, 0x60, 0x7c, 0x66, 0x66, 0x66, 0xdc, 0x00, - 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x00, - 0x1c, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, - 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, - 0x3c, 0x66, 0x60, 0xf8, 0x60, 0x60, 0xf0, 0x00, - 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, - 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, - 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x06, 0x00, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, - 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00, - 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0x00, - 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00, - 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, - 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e, - 0x00, 0x00, 0xdc, 0x76, 0x60, 0x60, 0xf0, 0x00, - 0x00, 0x00, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0x00, - 0x30, 0x30, 0xfc, 0x30, 0x30, 0x36, 0x1c, 0x00, - 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, - 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, - 0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, - 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, - 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc, - 0x00, 0x00, 0x7e, 0x4c, 0x18, 0x32, 0x7e, 0x00, - 0x0e, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0e, 0x00, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, - 0x70, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x70, 0x00, - 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00, - 0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18, - 0x38, 0x6c, 0x64, 0xf0, 0x60, 0x66, 0xfc, 0x00, - 0x00, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0x00, - 0x66, 0x66, 0x3c, 0x7e, 0x18, 0x7e, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, - 0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c, - 0x00, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7e, 0x81, 0x9d, 0xa1, 0xa1, 0x9d, 0x81, 0x7e, - 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, - 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, - 0x7e, 0x81, 0xb9, 0xa5, 0xb9, 0xa5, 0x81, 0x7e, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00, - 0x78, 0x0c, 0x18, 0x30, 0x7c, 0x00, 0x00, 0x00, - 0x78, 0x0c, 0x38, 0x0c, 0x78, 0x00, 0x00, 0x00, - 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0xc0, - 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x38, - 0x18, 0x38, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, - 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, - 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, - 0x63, 0xe6, 0x6c, 0x7a, 0x36, 0x6a, 0xdf, 0x06, - 0x63, 0xe6, 0x6c, 0x7e, 0x33, 0x66, 0xcc, 0x0f, - 0xe1, 0x32, 0xe4, 0x3a, 0xf6, 0x2a, 0x5f, 0x86, - 0x18, 0x00, 0x18, 0x18, 0x30, 0x63, 0x3e, 0x00, - 0x18, 0x0c, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, - 0x30, 0x60, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, - 0x7c, 0x82, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, - 0x76, 0xdc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, - 0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, - 0x38, 0x6c, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, - 0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00, - 0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x0c, 0x78, - 0x30, 0x18, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00, - 0x18, 0x30, 0xfe, 0xc0, 0xf8, 0xc0, 0xfe, 0x00, - 0x7c, 0x82, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00, - 0xc6, 0x00, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00, - 0x30, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x0c, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x3c, 0x42, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x66, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0xf8, 0x6c, 0x66, 0xf6, 0x66, 0x6c, 0xf8, 0x00, - 0x76, 0xdc, 0x00, 0xe6, 0xf6, 0xde, 0xce, 0x00, - 0x0c, 0x06, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, - 0x30, 0x60, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, - 0x7c, 0x82, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, - 0x76, 0xdc, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, - 0xc6, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x00, - 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, - 0x3a, 0x6c, 0xce, 0xd6, 0xe6, 0x6c, 0xb8, 0x00, - 0x60, 0x30, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x18, 0x30, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x7c, 0x82, 0x00, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x0c, 0x18, 0x66, 0x66, 0x3c, 0x18, 0x3c, 0x00, - 0xf0, 0x60, 0x7c, 0x66, 0x7c, 0x60, 0xf0, 0x00, - 0x78, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xcc, 0x00, - 0x30, 0x18, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, - 0x18, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, - 0x7c, 0x82, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, - 0x76, 0xdc, 0x7c, 0x06, 0x7e, 0xc6, 0x7e, 0x00, - 0xc6, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, - 0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, - 0x00, 0x00, 0x7e, 0x12, 0xfe, 0x90, 0xfe, 0x00, - 0x00, 0x00, 0x7e, 0xc0, 0xc0, 0x7e, 0x0c, 0x38, - 0x30, 0x18, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, - 0x0c, 0x18, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, - 0x7c, 0x82, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, - 0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, - 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00, - 0x0c, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00, - 0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, - 0x30, 0x7e, 0x0c, 0x7c, 0xcc, 0xcc, 0x78, 0x00, - 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x00, - 0x30, 0x18, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x0c, 0x18, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x7c, 0x82, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x76, 0xdc, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, - 0x00, 0x02, 0x7c, 0xce, 0xd6, 0xe6, 0x7c, 0x80, - 0x60, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, - 0x18, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, - 0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00, - 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, - 0x18, 0x30, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc, - 0xe0, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0xf0, - 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, + 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, + 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, + 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, + 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0xd6, 0x10, 0x38, + 0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x7c, 0x10, 0x38, + 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, + 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, + 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, + 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, + 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78, + 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, + 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0, + 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0, + 0x18, 0xdb, 0x3c, 0xe7, 0xe7, 0x3c, 0xdb, 0x18, + 0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, + 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00, + 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, + 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, + 0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, + 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff, + 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, + 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, + 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, + 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, + 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, + 0x18, 0x3e, 0x60, 0x3c, 0x06, 0x7c, 0x18, 0x00, + 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00, + 0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00, + 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, + 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, + 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, + 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, + 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, + 0x7c, 0xc6, 0x06, 0x1c, 0x30, 0x66, 0xfe, 0x00, + 0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00, + 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, + 0xfe, 0xc0, 0xc0, 0xfc, 0x06, 0xc6, 0x7c, 0x00, + 0x38, 0x60, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00, + 0xfe, 0xc6, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00, + 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00, + 0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00, + 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, + 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00, + 0x7c, 0xc6, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00, + 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, + 0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, + 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00, + 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, + 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00, + 0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, + 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3a, 0x00, + 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, + 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, + 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00, + 0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, + 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00, + 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, + 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, + 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xce, 0x7c, 0x0e, + 0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00, + 0x3c, 0x66, 0x30, 0x18, 0x0c, 0x66, 0x3c, 0x00, + 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, + 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, + 0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x00, + 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x00, + 0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, + 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, + 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00, + 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, + 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0xe0, 0x60, 0x7c, 0x66, 0x66, 0x66, 0xdc, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x00, + 0x1c, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, + 0x3c, 0x66, 0x60, 0xf8, 0x60, 0x60, 0xf0, 0x00, + 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, + 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, + 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x06, 0x00, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, + 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00, + 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0x00, + 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, + 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e, + 0x00, 0x00, 0xdc, 0x76, 0x60, 0x60, 0xf0, 0x00, + 0x00, 0x00, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0x00, + 0x30, 0x30, 0xfc, 0x30, 0x30, 0x36, 0x1c, 0x00, + 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, + 0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, + 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc, + 0x00, 0x00, 0x7e, 0x4c, 0x18, 0x32, 0x7e, 0x00, + 0x0e, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0e, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x70, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x70, 0x00, + 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00, + 0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18, + 0x38, 0x6c, 0x64, 0xf0, 0x60, 0x66, 0xfc, 0x00, + 0x00, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0x00, + 0x66, 0x66, 0x3c, 0x7e, 0x18, 0x7e, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, + 0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c, + 0x00, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7e, 0x81, 0x9d, 0xa1, 0xa1, 0x9d, 0x81, 0x7e, + 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, + 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x7e, 0x81, 0xb9, 0xa5, 0xb9, 0xa5, 0x81, 0x7e, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00, + 0x78, 0x0c, 0x18, 0x30, 0x7c, 0x00, 0x00, 0x00, + 0x78, 0x0c, 0x38, 0x0c, 0x78, 0x00, 0x00, 0x00, + 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0xc0, + 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x38, + 0x18, 0x38, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, + 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, + 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, + 0x63, 0xe6, 0x6c, 0x7a, 0x36, 0x6a, 0xdf, 0x06, + 0x63, 0xe6, 0x6c, 0x7e, 0x33, 0x66, 0xcc, 0x0f, + 0xe1, 0x32, 0xe4, 0x3a, 0xf6, 0x2a, 0x5f, 0x86, + 0x18, 0x00, 0x18, 0x18, 0x30, 0x63, 0x3e, 0x00, + 0x18, 0x0c, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, + 0x30, 0x60, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, + 0x7c, 0x82, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, + 0x76, 0xdc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00, + 0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, + 0x38, 0x6c, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, + 0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00, + 0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x0c, 0x78, + 0x30, 0x18, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00, + 0x18, 0x30, 0xfe, 0xc0, 0xf8, 0xc0, 0xfe, 0x00, + 0x7c, 0x82, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00, + 0xc6, 0x00, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00, + 0x30, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x0c, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x3c, 0x42, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x66, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0xf8, 0x6c, 0x66, 0xf6, 0x66, 0x6c, 0xf8, 0x00, + 0x76, 0xdc, 0x00, 0xe6, 0xf6, 0xde, 0xce, 0x00, + 0x0c, 0x06, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, + 0x30, 0x60, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, + 0x7c, 0x82, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, + 0x76, 0xdc, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00, + 0xc6, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x00, + 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, + 0x3a, 0x6c, 0xce, 0xd6, 0xe6, 0x6c, 0xb8, 0x00, + 0x60, 0x30, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x18, 0x30, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x7c, 0x82, 0x00, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x0c, 0x18, 0x66, 0x66, 0x3c, 0x18, 0x3c, 0x00, + 0xf0, 0x60, 0x7c, 0x66, 0x7c, 0x60, 0xf0, 0x00, + 0x78, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xcc, 0x00, + 0x30, 0x18, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x18, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x7c, 0x82, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x76, 0xdc, 0x7c, 0x06, 0x7e, 0xc6, 0x7e, 0x00, + 0xc6, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x00, 0x00, 0x7e, 0x12, 0xfe, 0x90, 0xfe, 0x00, + 0x00, 0x00, 0x7e, 0xc0, 0xc0, 0x7e, 0x0c, 0x38, + 0x30, 0x18, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, + 0x0c, 0x18, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, + 0x7c, 0x82, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, + 0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, + 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00, + 0x0c, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00, + 0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0x30, 0x7e, 0x0c, 0x7c, 0xcc, 0xcc, 0x78, 0x00, + 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x00, + 0x30, 0x18, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x0c, 0x18, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x7c, 0x82, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x76, 0xdc, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, + 0x00, 0x02, 0x7c, 0xce, 0xd6, 0xe6, 0x7c, 0x80, + 0x60, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x18, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x18, 0x30, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc, + 0xe0, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0xf0, + 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc }; diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 4a8fdd58f7..5d071439b2 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -39,8 +39,7 @@ rect_t gfx_rect_fullscreen = {0, 0, 320, 200}; void -gfx_clip_box_basic(rect_t *box, int maxx, int maxy) -{ +gfx_clip_box_basic(rect_t *box, int maxx, int maxy) { if (box->x < 0) box->x = 0; @@ -57,9 +56,8 @@ gfx_clip_box_basic(rect_t *box, int maxx, int maxy) gfx_mode_t * gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask, - unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift, - int blue_shift, int alpha_shift, int palette, int flags) -{ + unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift, + int blue_shift, int alpha_shift, int palette, int flags) { gfx_mode_t *mode = (gfx_mode_t*)sci_malloc(sizeof(gfx_mode_t)); #ifdef SATISFY_PURIFY memset(mode, 0, sizeof(gfx_mode_t)); @@ -87,13 +85,12 @@ gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned mode->palette->colors = (gfx_palette_color_t*)sci_calloc(sizeof(gfx_palette_color_t), palette); /* Initialize with empty entries */ } else mode->palette = NULL; - return mode; + return mode; } void -gfx_free_mode(gfx_mode_t *mode) -{ +gfx_free_mode(gfx_mode_t *mode) { if (mode->palette) { free(mode->palette->colors); free(mode->palette); @@ -104,8 +101,7 @@ gfx_free_mode(gfx_mode_t *mode) void -gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) -{ +gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) { int width, height; int offset; @@ -130,8 +126,7 @@ gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) gfx_pixmap_t * -gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) -{ +gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { gfx_pixmap_t *clone = (gfx_pixmap_t*)sci_malloc(sizeof(gfx_pixmap_t)); *clone = *pxm; clone->index_data = NULL; @@ -149,8 +144,7 @@ gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) } gfx_pixmap_t * -gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) -{ +gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) { gfx_pixmap_t *pxm = (gfx_pixmap_t*)sci_malloc(sizeof(gfx_pixmap_t)); #ifdef SATISFY_PURIFY memset(pxm, 0, sizeof(gfx_pixmap_t)); @@ -180,8 +174,7 @@ gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) void -gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) -{ +gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) { if (driver) { if (pxm->flags & GFX_PIXMAP_FLAG_INSTALLED) { if (driver->capabilities & GFX_CAPABILITY_PIXMAP_REGISTRY) @@ -189,9 +182,9 @@ gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) } if (driver->mode->palette - && pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED - && !(pxm->flags & GFX_PIXMAP_FLAG_DONT_UNALLOCATE_PALETTE) - && !(pxm->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) { + && pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED + && !(pxm->flags & GFX_PIXMAP_FLAG_DONT_UNALLOCATE_PALETTE) + && !(pxm->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) { int i; int error = 0; GFXDEBUG("UNALLOCATING %d\n", pxm->colors_nr); @@ -201,7 +194,7 @@ gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) if (error) { GFXWARN("%d errors occured while freeing %d colors of pixmap with ID %06x/%d/%d\n", - error, pxm->colors_nr,pxm->ID, pxm->loop, pxm->cel); + error, pxm->colors_nr, pxm->ID, pxm->loop, pxm->cel); } } } @@ -223,8 +216,7 @@ gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) gfx_pixmap_t * -gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) -{ +gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) { int size; if (pixmap->index_data) { @@ -245,8 +237,7 @@ gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) gfx_pixmap_t * -gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) -{ +gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) { if (!pixmap->index_data) { GFXWARN("Attempt to free pixmap index data twice!\n"); return pixmap; @@ -259,8 +250,7 @@ gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) gfx_pixmap_t * -gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) -{ +gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { int size; if (pixmap->data) { @@ -286,8 +276,7 @@ gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) gfx_pixmap_t * -gfx_pixmap_free_data(gfx_pixmap_t *pixmap) -{ +gfx_pixmap_free_data(gfx_pixmap_t *pixmap) { if (!pixmap->data) { GFXWARN("Attempt to free pixmap data twice!\n"); return pixmap; @@ -300,8 +289,7 @@ gfx_pixmap_free_data(gfx_pixmap_t *pixmap) int -gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) -{ +gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { int i; int dr, dg, db; /* deltas */ int bestdelta = 1 + ((0x100 * 0x100) * 3); @@ -320,7 +308,7 @@ gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) if (color->global_index != GFX_COLOR_INDEX_UNMAPPED) { #if 0 GFXDEBUG("Attempt to allocate color twice: index 0x%d (%02x/%02x/%02x)!\n", - color->global_index, color->r, color->g, color->b); + color->global_index, color->r, color->g, color->b); #endif return GFX_OK; } @@ -368,8 +356,7 @@ gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) int -gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) -{ +gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { gfx_palette_color_t *palette_color = pal->colors + color->global_index; if (!pal) @@ -383,13 +370,13 @@ gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) if (color->global_index >= pal->max_colors_nr) { GFXERROR("Attempt to free invalid color index %d (%02x/%02x/%02x)!\n", - color->global_index, color->r, color->g, color->b); + color->global_index, color->r, color->g, color->b); return GFX_ERROR; } if (!palette_color->lockers) { GFXERROR("Attempt to free unused color index %d (%02x/%02x/%02x)!\n", - color->global_index, color->r, color->g, color->b); + color->global_index, color->r, color->g, color->b); return GFX_ERROR; } @@ -402,8 +389,7 @@ gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) gfx_pixmap_t * -gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) -{ +gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { byte *old_data, *new_data, *initial_new_data; byte *linestart; int linewidth; @@ -442,10 +428,10 @@ gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) new_data += linewidth; old_data += linewidth; } else for (i = 0; i < xl; i++) { - byte fillc = *old_data++; - memset(new_data, fillc, xfact); - new_data += xfact; - } + byte fillc = *old_data++; + memset(new_data, fillc, xfact); + new_data += xfact; + } for (i = 1; i < yfact; i++) { memcpy(new_data, linestart, linewidth); diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp index f0b5b40805..e08f17a823 100644 --- a/engines/sci/gfx/menubar.cpp +++ b/engines/sci/gfx/menubar.cpp @@ -69,8 +69,7 @@ __my_free(void *origin, char *function, int line) */ menubar_t * -menubar_new() -{ +menubar_new() { menubar_t *tmp = (menubar_t*)sci_malloc(sizeof(menubar_t)); tmp->menus_nr = 0; @@ -78,8 +77,7 @@ menubar_new() } void -menubar_free(menubar_t *menubar) -{ +menubar_free(menubar_t *menubar) { int i; for (i = 0; i < menubar->menus_nr; i++) { @@ -88,9 +86,9 @@ menubar_free(menubar_t *menubar) for (j = 0; j < menu->items_nr; j++) { if (menu->items[j].keytext) - free (menu->items[j].keytext); + free(menu->items[j].keytext); if (menu->items[j].text) - free (menu->items[j].text); + free(menu->items[j].text); } free(menu->items); @@ -98,7 +96,7 @@ menubar_free(menubar_t *menubar) } if (menubar->menus_nr) - free (menubar->menus); + free(menubar->menus); free(menubar); } @@ -106,7 +104,7 @@ menubar_free(menubar_t *menubar) int _menubar_add_menu_item(gfx_state_t *state, menu_t *menu, int type, char *left, char *right, - int font, int key, int modifiers, int tag, reg_t text_pos) + int font, int key, int modifiers, int tag, reg_t text_pos) /* Returns the total text size, plus MENU_BOX_CENTER_PADDING if (right != NULL) */ { menu_item_t *item; @@ -136,13 +134,13 @@ _menubar_add_menu_item(gfx_state_t *state, menu_t *menu, int type, char *left, c item->key = key; item->modifiers = modifiers; } else { - item->keytext=NULL; + item->keytext = NULL; item->flags = 0; } if (right) { gfxop_get_text_params(state, font, right, SIZE_INF, &width, &height, 0, - NULL, NULL, NULL); + NULL, NULL, NULL); total_left_size = MENU_BOX_CENTER_PADDING + (item->keytext_size = width); } @@ -150,15 +148,14 @@ _menubar_add_menu_item(gfx_state_t *state, menu_t *menu, int type, char *left, c item->tag = tag; item->text_pos = text_pos; gfxop_get_text_params(state, font, left, SIZE_INF, &width, &height, 0, - NULL, NULL, NULL); + NULL, NULL, NULL); return total_left_size + width; } void menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entries, int font, - reg_t entries_base) -{ + reg_t entries_base) { int i, add_freesci = 0; menu_t *menu; char tracker; @@ -174,7 +171,7 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr #endif menubar->menus = (menu_t*)sci_malloc(sizeof(menu_t)); menubar->menus_nr = 1; - } else menubar->menus = (menu_t*)sci_realloc(menubar->menus, ++(menubar->menus_nr) * sizeof (menu_t)); + } else menubar->menus = (menu_t*)sci_realloc(menubar->menus, ++(menubar->menus_nr) * sizeof(menu_t)); menu = &(menubar->menus[menubar->menus_nr-1]); memset(menu, 0, sizeof(menu_t)); @@ -182,7 +179,7 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr menu->title = sci_strdup(title); gfxop_get_text_params(state, font, menu->title, SIZE_INF, &(menu->title_width), &height, 0, - NULL, NULL, NULL); + NULL, NULL, NULL); do { tracker = *entries++; @@ -209,17 +206,17 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr inleft++; /* Seek beginning of actual string */ if (!strncmp(inleft, MENU_HBAR_STRING_1, strlen(MENU_HBAR_STRING_1)) - || !strncmp(inleft, MENU_HBAR_STRING_2, strlen(MENU_HBAR_STRING_2)) - || !strncmp(inleft, MENU_HBAR_STRING_3, strlen(MENU_HBAR_STRING_3))) - { - entrytype = MENU_TYPE_HBAR; /* Horizontal bar */ - free(left); - left = NULL; - } + || !strncmp(inleft, MENU_HBAR_STRING_2, strlen(MENU_HBAR_STRING_2)) + || !strncmp(inleft, MENU_HBAR_STRING_3, strlen(MENU_HBAR_STRING_3))) { + entrytype = MENU_TYPE_HBAR; /* Horizontal bar */ + free(left); + left = NULL; + } - beginning = entries_base; beginning.offset -= string_len + 1; + beginning = entries_base; + beginning.offset -= string_len + 1; c_width = _menubar_add_menu_item(state, menu, entrytype, left, NULL, font, 0, 0, tag, - beginning); + beginning); if (c_width > max_width) max_width = c_width; @@ -228,15 +225,14 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr } else if (tracker == '`') { /* Start of right string */ - if (!left) - { - left_origin = entries_base; left_origin.offset -= string_len + 1; - left = sci_strndup(entries - string_len -1, string_len); + if (!left) { + left_origin = entries_base; + left_origin.offset -= string_len + 1; + left = sci_strndup(entries - string_len - 1, string_len); } string_len = 0; /* Continue with the right string */ - } - else string_len++; /* Nothing special */ + } else string_len++; /* Nothing special */ } else { /* Left string finished => working on right string */ if ((tracker == ':') || (tracker == 0)) { /* End of entry */ @@ -252,12 +248,11 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr if (right[1] == '0') key = SCI_K_F10; /* F10 */ - if (right[2]=='=') { + if (right[2] == '=') { tag = atoi(right + 3); right[2] = 0; }; - } - else if (right[0] == '@') { /* Alt key */ + } else if (right[0] == '@') { /* Alt key */ right[0] = SCI_SPECIAL_CHAR_ALT; /* ALT */ key = right[1]; modifiers = SCI_EVM_ALT; @@ -265,13 +260,12 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr if ((key >= 'a') && (key <= 'z')) right[1] = key - 'a' + 'A'; - if (right[2]=='=') { - tag = atoi(right+3); + if (right[2] == '=') { + tag = atoi(right + 3); right[2] = 0; }; - } - else { + } else { if (right[0] == '^') { right[0] = SCI_SPECIAL_CHAR_CTRL; /* Control key - there must be a replacement... */ @@ -281,19 +275,18 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr if ((key >= 'a') && (key <= 'z')) right[1] = key - 'a' + 'A'; - if (right[2]=='=') { - tag = atoi(right+3); + if (right[2] == '=') { + tag = atoi(right + 3); right[2] = 0; } - } - else { + } else { key = right[0]; if ((key >= 'a') && (key <= 'z')) right[0] = key - 'a' + 'A'; - if (right[1]=='=') { - tag=atoi(right+2); + if (right[1] == '=') { + tag = atoi(right + 2); right[1] = 0; } } @@ -305,11 +298,11 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr i = strlen(right); - while (i>0 && right[--i] == ' ') + while (i > 0 && right[--i] == ' ') right[i] = 0; /* Cut off chars to the right */ c_width = _menubar_add_menu_item(state, menu, MENU_TYPE_NORMAL, left, right, font, key, - modifiers, tag, left_origin); + modifiers, tag, left_origin); tag = 0; if (c_width > max_width) max_width = c_width; @@ -325,7 +318,7 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr #ifdef MENU_FREESCI_BLATANT_PLUG if (add_freesci) { - char *freesci_text = sci_strdup ("About FreeSCI"); + char *freesci_text = sci_strdup("About FreeSCI"); c_width = _menubar_add_menu_item(state, menu, MENU_TYPE_NORMAL, freesci_text, NULL, font, 0, 0, 0, NULL_REG); if (c_width > max_width) max_width = c_width; @@ -337,24 +330,22 @@ menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entr } int -menubar_match_key(menu_item_t *item, int message, int modifiers) -{ +menubar_match_key(menu_item_t *item, int message, int modifiers) { if ((item->key == message) - && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == item->modifiers)) + && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == item->modifiers)) return 1; if (message == '\t' - && item->key == 'i' - && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == 0) - && item->modifiers == SCI_EVM_CTRL) + && item->key == 'i' + && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == 0) + && item->modifiers == SCI_EVM_CTRL) return 1; /* Match TAB to ^I */ return 0; } int -menubar_set_attribute(state_t *s, int menu_nr, int item_nr, int attribute, reg_t value) -{ +menubar_set_attribute(state_t *s, int menu_nr, int item_nr, int attribute, reg_t value) { menubar_t *menubar = s->menubar; menu_item_t *item; @@ -421,7 +412,7 @@ menubar_set_attribute(state_t *s, int menu_nr, int item_nr, int attribute, reg_t default: sciprintf("Attempt to set invalid attribute of menu %d, item %d: 0x%04x\n", - menu_nr, item_nr, attribute); + menu_nr, item_nr, attribute); return 1; } @@ -429,8 +420,7 @@ menubar_set_attribute(state_t *s, int menu_nr, int item_nr, int attribute, reg_t } reg_t -menubar_get_attribute(state_t *s, int menu_nr, int item_nr, int attribute) -{ +menubar_get_attribute(state_t *s, int menu_nr, int item_nr, int attribute) { menubar_t *menubar = s->menubar; menu_item_t *item; @@ -460,14 +450,13 @@ menubar_get_attribute(state_t *s, int menu_nr, int item_nr, int attribute) default: sciprintf("Attempt to read invalid attribute from menu %d, item %d: 0x%04x\n", - menu_nr, item_nr, attribute); + menu_nr, item_nr, attribute); return make_reg(0, -1); } } int -menubar_item_valid(state_t *s, int menu_nr, int item_nr) -{ +menubar_item_valid(state_t *s, int menu_nr, int item_nr) { menubar_t *menubar = s->menubar; menu_item_t *item; @@ -480,7 +469,7 @@ menubar_item_valid(state_t *s, int menu_nr, int item_nr) item = menubar->menus[menu_nr].items + item_nr; if ((item->type == MENU_TYPE_NORMAL) - && item->enabled) + && item->enabled) return 1; return 0; /* May not be selected */ @@ -488,8 +477,7 @@ menubar_item_valid(state_t *s, int menu_nr, int item_nr) int -menubar_map_pointer(state_t *s, int *menu_nr, int *item_nr, gfxw_port_t *port) -{ +menubar_map_pointer(state_t *s, int *menu_nr, int *item_nr, gfxw_port_t *port) { menubar_t *menubar = s->menubar; menu_t *menu; diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 44d58f4a75..13e4cd6008 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -33,7 +33,7 @@ #define PRECISE_PRIORITY_MAP /* Duplicate all operations on the local priority map as appropriate */ #undef GFXW_DEBUG_DIRTY /* Enable to debug stuff relevant for dirty rects - ** in widget management */ +** in widget management */ #ifdef GFXW_DEBUG_DIRTY # define DDIRTY fprintf(stderr, "%s:%5d| ", __FILE__, __LINE__); fprintf @@ -43,15 +43,15 @@ /* Default color maps */ #define DEFAULT_COLORS_NR 16 -gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = - {{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xaa}, - {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa}, - {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0xaa}, - {GFX_COLOR_SYSTEM, 0xaa, 0x55, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0xaa, 0xaa}, - {GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0x55, 0xff}, - {GFX_COLOR_SYSTEM, 0x55, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff}, - {GFX_COLOR_SYSTEM, 0xff, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff}, - {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}; /* "Normal" EGA */ +gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = {{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xaa}, + {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa}, + {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0xaa}, + {GFX_COLOR_SYSTEM, 0xaa, 0x55, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0xaa, 0xaa}, + {GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0x55, 0xff}, + {GFX_COLOR_SYSTEM, 0x55, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff}, + {GFX_COLOR_SYSTEM, 0xff, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff}, + {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff} +}; /* "Normal" EGA */ #define POINTER_VISIBLE_BUT_CLIPPED 2 @@ -78,8 +78,7 @@ if (!state->driver) { \ /* Internal operations */ static void -_gfxop_scale_rect(rect_t *rect, gfx_mode_t *mode) -{ +_gfxop_scale_rect(rect_t *rect, gfx_mode_t *mode) { int xfact = mode->xfact; int yfact = mode->yfact; @@ -90,8 +89,7 @@ _gfxop_scale_rect(rect_t *rect, gfx_mode_t *mode) } static void -_gfxop_scale_point(point_t *point, gfx_mode_t *mode) -{ +_gfxop_scale_point(point_t *point, gfx_mode_t *mode) { int xfact = mode->xfact; int yfact = mode->yfact; @@ -100,8 +98,7 @@ _gfxop_scale_point(point_t *point, gfx_mode_t *mode) } static void -_gfxop_alloc_colors(gfx_state_t *state, gfx_pixmap_color_t *colors, int colors_nr) -{ +_gfxop_alloc_colors(gfx_state_t *state, gfx_pixmap_color_t *colors, int colors_nr) { int i; if (!PALETTE_MODE) @@ -114,8 +111,7 @@ _gfxop_alloc_colors(gfx_state_t *state, gfx_pixmap_color_t *colors, int colors_n #if 0 // Unreferenced - removed static void -_gfxop_free_colors(gfx_state_t *state, gfx_pixmap_color_t *colors, int colors_nr) -{ +_gfxop_free_colors(gfx_state_t *state, gfx_pixmap_color_t *colors, int colors_nr) { int i; if (!PALETTE_MODE) @@ -130,8 +126,8 @@ int _gfxop_clip(rect_t *rect, rect_t clipzone) /* Returns 1 if nothing is left */ { #if 0 - printf ("Clipping (%d, %d) size (%d, %d) by (%d,%d)(%d,%d)\n", rect->x, rect->y, rect->xl, rect->yl, - clipzone.x, clipzone.y, clipzone.xl, clipzone.yl); + printf("Clipping (%d, %d) size (%d, %d) by (%d,%d)(%d,%d)\n", rect->x, rect->y, rect->xl, rect->yl, + clipzone.x, clipzone.y, clipzone.xl, clipzone.yl); #endif if (rect->x < clipzone.x) { @@ -156,15 +152,15 @@ int _gfxop_clip(rect_t *rect, rect_t clipzone) rect->yl = 0; #if 0 - printf (" => (%d, %d) size (%d, %d)\n", rect->x, rect->y, rect->xl, rect->yl); + printf(" => (%d, %d) size (%d, %d)\n", rect->x, rect->y, rect->xl, rect->yl); #endif return (rect->xl <= 0 || rect->yl <= 0); } static int _gfxop_grab_pixmap(gfx_state_t *state, gfx_pixmap_t **pxmp, int x, int y, - int xl, int yl, int priority, rect_t *zone) - /* Returns 1 if the resulting data size was zero, GFX_OK or an error code otherwise */ + int xl, int yl, int priority, rect_t *zone) +/* Returns 1 if the resulting data size was zero, GFX_OK or an error code otherwise */ { int xfact = state->driver->mode->xfact; int yfact = state->driver->mode->yfact; @@ -173,8 +169,8 @@ _gfxop_grab_pixmap(gfx_state_t *state, gfx_pixmap_t **pxmp, int x, int y, *zone = gfx_rect(x, y, xl, yl); if (_gfxop_clip(zone, gfx_rect(0, 0, - 320 * state->driver->mode->xfact, - 200 * state->driver->mode->yfact))) + 320 * state->driver->mode->xfact, + 200 * state->driver->mode->yfact))) return GFX_ERROR; if (!*pxmp) @@ -191,7 +187,7 @@ _gfxop_grab_pixmap(gfx_state_t *state, gfx_pixmap_t **pxmp, int x, int y, gfx_pixmap_alloc_data(*pxmp, state->driver->mode); } return state->driver->grab_pixmap(state->driver, *zone, *pxmp, - priority? GFX_MASK_PRIORITY : GFX_MASK_VISUAL); + priority ? GFX_MASK_PRIORITY : GFX_MASK_VISUAL); } @@ -241,12 +237,11 @@ DRAW_LOOP(map->index_data[offset] < color) /* Draw only lower priority */ #undef DRAW_LOOP static int -_gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) -{ +_gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) { int error; if (driver->capabilities & GFX_CAPABILITY_PIXMAP_REGISTRY - && !(pxm->flags & GFX_PIXMAP_FLAG_INSTALLED)) { + && !(pxm->flags & GFX_PIXMAP_FLAG_INSTALLED)) { error = driver->register_pixmap(driver, pxm); if (error) { @@ -257,21 +252,21 @@ _gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) } if (driver->mode->palette && - (!(pxm->flags & GFX_PIXMAP_FLAG_PALETTE_SET))) { + (!(pxm->flags & GFX_PIXMAP_FLAG_PALETTE_SET))) { int i; int error; for (i = 0; i < pxm->colors_nr; i++) { if ((error = driver->set_palette(driver, pxm->colors[i].global_index, - pxm->colors[i].r, - pxm->colors[i].g, - pxm->colors[i].b))) { + pxm->colors[i].r, + pxm->colors[i].g, + pxm->colors[i].b))) { GFXWARN("driver->set_palette(%d, %02x/%02x/%02x) failed!\n", - pxm->colors[i].global_index, - pxm->colors[i].r, - pxm->colors[i].g, - pxm->colors[i].b); + pxm->colors[i].global_index, + pxm->colors[i].r, + pxm->colors[i].g, + pxm->colors[i].b); if (error == GFX_FATAL) return GFX_FATAL; @@ -285,15 +280,14 @@ _gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) static int _gfxop_draw_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm, int priority, int control, - rect_t src, rect_t dest, rect_t clip, int static_buf, gfx_pixmap_t *control_map, - gfx_pixmap_t *priority_map) -{ + rect_t src, rect_t dest, rect_t clip, int static_buf, gfx_pixmap_t *control_map, + gfx_pixmap_t *priority_map) { int error; rect_t clipped_dest = gfx_rect(dest.x, dest.y, dest.xl, dest.yl); if (control >= 0 || priority >= 0) { point_t original_pos = gfx_point(dest.x / driver->mode->xfact, - dest.y / driver->mode->yfact); + dest.y / driver->mode->yfact); if (control >= 0) _gfxop_draw_control(control_map, pxm, control, original_pos); @@ -304,7 +298,7 @@ _gfxop_draw_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm, int priority, int co #endif } - + if (_gfxop_clip(&clipped_dest, clip)) return GFX_OK; @@ -323,7 +317,7 @@ _gfxop_draw_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm, int priority, int co clipped_dest.yl / driver->mode->yfact); error = driver->draw_pixmap(driver, pxm, priority, src, clipped_dest, - static_buf? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); + static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); if (error) { GFXERROR("driver->draw_pixmap() returned error!\n"); @@ -333,11 +327,10 @@ _gfxop_draw_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm, int priority, int co } static int -_gfxop_remove_pointer(gfx_state_t *state) -{ +_gfxop_remove_pointer(gfx_state_t *state) { if (state->mouse_pointer_visible - && !state->mouse_pointer_in_hw - && state->mouse_pointer_bg) { + && !state->mouse_pointer_in_hw + && state->mouse_pointer_bg) { int retval; if (state->mouse_pointer_visible == POINTER_VISIBLE_BUT_CLIPPED) { @@ -350,9 +343,9 @@ _gfxop_remove_pointer(gfx_state_t *state) state->mouse_pointer_visible = 0; retval = state->driver->draw_pixmap(state->driver, state->mouse_pointer_bg, GFX_NO_PRIORITY, - gfx_rect(0, 0, state->mouse_pointer_bg->xl, state->mouse_pointer_bg->yl), - state->pointer_bg_zone, - GFX_BUFFER_BACK); + gfx_rect(0, 0, state->mouse_pointer_bg->xl, state->mouse_pointer_bg->yl), + state->pointer_bg_zone, + GFX_BUFFER_BACK); state->pointer_pos.x = state->driver->pointer_x / state->driver->mode->xfact; state->pointer_pos.y = state->driver->pointer_y / state->driver->mode->yfact; @@ -367,8 +360,7 @@ _gfxop_remove_pointer(gfx_state_t *state) } static int /* returns 1 if there are no pointer bounds, 0 otherwise */ -_gfxop_get_pointer_bounds(gfx_state_t *state, rect_t *rect) -{ +_gfxop_get_pointer_bounds(gfx_state_t *state, rect_t *rect) { gfx_pixmap_t *ppxm = state->mouse_pointer; if (!ppxm) @@ -380,15 +372,14 @@ _gfxop_get_pointer_bounds(gfx_state_t *state, rect_t *rect) rect->yl = ppxm->yl; return (_gfxop_clip(rect, gfx_rect(0, 0, 320 * state->driver->mode->xfact, - 200 * state->driver->mode->yfact))); + 200 * state->driver->mode->yfact))); } static int _gfxop_buffer_propagate_box(gfx_state_t *state, rect_t box, gfx_buffer_t buffer); static int -_gfxop_draw_pointer(gfx_state_t *state) -{ +_gfxop_draw_pointer(gfx_state_t *state) { if (state->mouse_pointer_visible || !state->mouse_pointer || state->mouse_pointer_in_hw) return GFX_OK; else { @@ -408,8 +399,8 @@ _gfxop_draw_pointer(gfx_state_t *state) * we should reuse the buffer instead of malloc/free for better performance */ retval = _gfxop_grab_pixmap(state, &(state->mouse_pointer_bg), x, y, - ppxm->xl, ppxm->yl, 0, - &(state->pointer_bg_zone)); + ppxm->xl, ppxm->yl, 0, + &(state->pointer_bg_zone)); if (retval == GFX_ERROR) { state->pointer_bg_zone = gfx_rect(0, 0, 320, 200); @@ -421,10 +412,10 @@ _gfxop_draw_pointer(gfx_state_t *state) return retval; error = _gfxop_draw_pixmap(state->driver, ppxm, -1, -1, - gfx_rect(0, 0, ppxm->xl, ppxm->yl), - gfx_rect(x, y, ppxm->xl, ppxm->yl), - gfx_rect(0, 0, xfact * 320 , yfact * 200), - 0, state->control_map, state->priority_map); + gfx_rect(0, 0, ppxm->xl, ppxm->yl), + gfx_rect(x, y, ppxm->xl, ppxm->yl), + gfx_rect(0, 0, xfact * 320 , yfact * 200), + 0, state->control_map, state->priority_map); if (error) return error; @@ -435,8 +426,7 @@ _gfxop_draw_pointer(gfx_state_t *state) } gfx_pixmap_t * -_gfxr_get_cel(gfx_state_t *state, int nr, int *loop, int *cel, int palette) -{ +_gfxr_get_cel(gfx_state_t *state, int nr, int *loop, int *cel, int palette) { gfxr_view_t *view = gfxr_get_view(state->resstate, nr, loop, cel, palette); gfxr_loop_t *indexed_loop; @@ -444,17 +434,17 @@ _gfxr_get_cel(gfx_state_t *state, int nr, int *loop, int *cel, int palette) return NULL; if (*loop >= view->loops_nr - || *loop < 0) { + || *loop < 0) { GFXWARN("Attempt to get cel from loop %d/%d inside view %d\n", *loop, - view->loops_nr, nr); + view->loops_nr, nr); return NULL; } indexed_loop = view->loops + *loop; if (*cel >= indexed_loop->cels_nr - || *cel < 0) { + || *cel < 0) { GFXWARN("Attempt to get cel %d/%d from view %d/%d\n", *cel, indexed_loop->cels_nr, - nr, *loop); + nr, *loop); return NULL; } @@ -464,14 +454,13 @@ _gfxr_get_cel(gfx_state_t *state, int nr, int *loop, int *cel, int palette) /*** Dirty rectangle operations ***/ static inline int -_gfxop_update_box(gfx_state_t *state, rect_t box) -{ +_gfxop_update_box(gfx_state_t *state, rect_t box) { int retval; _gfxop_scale_rect(&box, state->driver->mode); if ((retval = _gfxop_buffer_propagate_box(state, box, GFX_BUFFER_FRONT))) { GFXERROR("Error occured while propagating box (%d,%d,%d,%d) to front buffer\n", - box.x, box.y, box.xl, box.yl); + box.x, box.y, box.xl, box.yl); return retval; } return GFX_OK; @@ -479,8 +468,7 @@ _gfxop_update_box(gfx_state_t *state, rect_t box) static struct _dirty_rect * -_rect_create(rect_t box) -{ + _rect_create(rect_t box) { struct _dirty_rect *rect; rect = (struct _dirty_rect*)sci_malloc(sizeof(struct _dirty_rect)); @@ -492,8 +480,7 @@ _rect_create(rect_t box) gfx_dirty_rect_t * -gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy) -{ +gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy) { if (box.xl < 0) { box.x += box.xl; box.xl = - box.xl; @@ -505,7 +492,7 @@ gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy) } #ifdef GFXOP_DEBUG_DIRTY fprintf(stderr, "Adding new dirty (%d %d %d %d)\n", - GFX_PRINT_RECT(box)); + GFX_PRINT_RECT(box)); #endif if (_gfxop_clip(&box, gfx_rect(0, 0, 320, 200))) return base; @@ -533,7 +520,8 @@ gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy) } *rectp = _rect_create(box); - } break; + } + break; default: GFXERROR("Attempt to use invalid dirty frame mode %d!\nPlease refer to gfx_options.h.", strategy); @@ -544,8 +532,7 @@ gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy) } static void -_gfxop_add_dirty(gfx_state_t *state, rect_t box) -{ +_gfxop_add_dirty(gfx_state_t *state, rect_t box) { if (state->disable_dirty) return; @@ -554,7 +541,7 @@ _gfxop_add_dirty(gfx_state_t *state, rect_t box) static inline void _gfxop_add_dirty_x(gfx_state_t *state, rect_t box) - /* Extends the box size by one before adding (used for lines) */ +/* Extends the box size by one before adding (used for lines) */ { if (box.xl < 0) box.xl--; @@ -570,8 +557,7 @@ _gfxop_add_dirty_x(gfx_state_t *state, rect_t box) } static int -_gfxop_clear_dirty_rec(gfx_state_t *state, struct _dirty_rect *rect) -{ +_gfxop_clear_dirty_rec(gfx_state_t *state, struct _dirty_rect *rect) { int retval; if (!rect) @@ -579,7 +565,7 @@ _gfxop_clear_dirty_rec(gfx_state_t *state, struct _dirty_rect *rect) #ifdef GFXOP_DEBUG_DIRTY fprintf(stderr, "\tClearing dirty (%d %d %d %d)\n", - GFX_PRINT_RECT(rect->rect)); + GFX_PRINT_RECT(rect->rect)); #endif if (!state->fullscreen_override) retval = _gfxop_update_box(state, rect->rect); @@ -596,8 +582,7 @@ _gfxop_clear_dirty_rec(gfx_state_t *state, struct _dirty_rect *rect) /*** Exported operations ***/ static void -init_aux_pixmap(gfx_pixmap_t **pixmap) -{ +init_aux_pixmap(gfx_pixmap_t **pixmap) { *pixmap = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, GFX_RESID_NONE, 0, 0)); (*pixmap)->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; (*pixmap)->colors_nr = DEFAULT_COLORS_NR; @@ -605,23 +590,22 @@ init_aux_pixmap(gfx_pixmap_t **pixmap) } static int -_gfxop_init_common(gfx_state_t *state, gfx_options_t *options, void *misc_payload) -{ +_gfxop_init_common(gfx_state_t *state, gfx_options_t *options, void *misc_payload) { state->options = options; if (!((state->resstate = gfxr_new_resource_manager(state->version, - state->options, - state->driver, - misc_payload)))) { + state->options, + state->driver, + misc_payload)))) { GFXERROR("Failed to initialize resource manager!\n"); return GFX_FATAL; } if ((state->static_palette = - gfxr_interpreter_get_static_palette(state->resstate, - state->version, - &(state->static_palette_entries), - misc_payload))) + gfxr_interpreter_get_static_palette(state->resstate, + state->version, + &(state->static_palette_entries), + misc_payload))) _gfxop_alloc_colors(state, state->static_palette, state->static_palette_entries); state->visible_map = GFX_MASK_VISUAL; @@ -655,8 +639,7 @@ _gfxop_init_common(gfx_state_t *state, gfx_options_t *options, void *misc_payloa } int -gfxop_init_default(gfx_state_t *state, gfx_options_t *options, void *misc_info) -{ +gfxop_init_default(gfx_state_t *state, gfx_options_t *options, void *misc_info) { BASIC_CHECKS(GFX_FATAL); if (state->driver->init(state->driver)) return GFX_FATAL; @@ -667,9 +650,8 @@ gfxop_init_default(gfx_state_t *state, gfx_options_t *options, void *misc_info) int gfxop_init(gfx_state_t *state, int xfact, int yfact, gfx_color_mode_t bpp, - gfx_options_t *options, void *misc_info) -{ - int color_depth = bpp? bpp : 1; + gfx_options_t *options, void *misc_info) { + int color_depth = bpp ? bpp : 1; int initialized = 0; BASIC_CHECKS(GFX_FATAL); @@ -689,8 +671,7 @@ gfxop_init(gfx_state_t *state, int xfact, int yfact, gfx_color_mode_t bpp, int -gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value) -{ +gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value) { BASIC_CHECKS(GFX_FATAL); return state->driver->set_parameter(state->driver, attribute, value); @@ -698,8 +679,7 @@ gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value) int -gfxop_exit(gfx_state_t *state) -{ +gfxop_exit(gfx_state_t *state) { BASIC_CHECKS(GFX_ERROR); gfxr_free_resource_manager(state->driver, state->resstate); @@ -729,15 +709,13 @@ gfxop_exit(gfx_state_t *state) int -gfxop_have_mouse(gfx_state_t *state) -{ +gfxop_have_mouse(gfx_state_t *state) { return state->driver->capabilities & GFX_CAPABILITY_MOUSE_SUPPORT; } static int -_gfxop_scan_one_bitmask(gfx_pixmap_t *pixmap, rect_t zone) -{ +_gfxop_scan_one_bitmask(gfx_pixmap_t *pixmap, rect_t zone) { int retval = 0; int pixmap_xscale = pixmap->index_xl / 320; int pixmap_yscale = pixmap->index_yl / 200; @@ -762,15 +740,14 @@ _gfxop_scan_one_bitmask(gfx_pixmap_t *pixmap, rect_t zone) } int -gfxop_scan_bitmask(gfx_state_t *state, rect_t area, gfx_map_mask_t map) -{ - gfxr_pic_t *pic = (state->pic_unscaled)? state->pic_unscaled : state->pic; +gfxop_scan_bitmask(gfx_state_t *state, rect_t area, gfx_map_mask_t map) { + gfxr_pic_t *pic = (state->pic_unscaled) ? state->pic_unscaled : state->pic; int retval = 0; _gfxop_clip(&area, gfx_rect(0, 10, 320, 200)); if (area.xl <= 0 - || area.yl <= 0) + || area.yl <= 0) return 0; if (map & GFX_MASK_VISUAL) @@ -791,8 +768,7 @@ gfxop_scan_bitmask(gfx_state_t *state, rect_t area, gfx_map_mask_t map) #define MAX_Y 199 int -gfxop_set_clip_zone(gfx_state_t *state, rect_t zone) -{ +gfxop_set_clip_zone(gfx_state_t *state, rect_t zone) { int xfact, yfact; BASIC_CHECKS(GFX_ERROR); @@ -829,13 +805,12 @@ gfxop_set_clip_zone(gfx_state_t *state, rect_t zone) int gfxop_set_color(gfx_state_t *state, gfx_color_t *color, int r, int g, int b, int a, - int priority, int control) -{ + int priority, int control) { gfx_pixmap_color_t pixmap_color = {0}; int error_code; int mask = ((r >= 0 && g >= 0 && b >= 0) ? GFX_MASK_VISUAL : 0) - | ((priority >= 0)? GFX_MASK_PRIORITY : 0) - | ((control >= 0)? GFX_MASK_CONTROL : 0); + | ((priority >= 0) ? GFX_MASK_PRIORITY : 0) + | ((control >= 0) ? GFX_MASK_CONTROL : 0); BASIC_CHECKS(GFX_FATAL); @@ -865,7 +840,7 @@ gfxop_set_color(gfx_state_t *state, gfx_color_t *color, int r, int g, int b, int return error_code; } else if ((error_code = state->driver->set_palette(state->driver, pixmap_color.global_index, (byte) r, (byte) g, (byte) b))) { GFXWARN("Graphics driver failed to set color index %d to (%02x/%02x/%02x)\n", - pixmap_color.global_index, r, g, b); + pixmap_color.global_index, r, g, b); return error_code; } } @@ -876,8 +851,7 @@ gfxop_set_color(gfx_state_t *state, gfx_color_t *color, int r, int g, int b, int } int -gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color) -{ +gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color) { gfx_palette_color_t *palette_colors; BASIC_CHECKS(GFX_FATAL); @@ -885,7 +859,7 @@ gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color) return GFX_OK; if (color->visual.global_index < 0 - || color->visual.global_index >= state->driver->mode->palette->max_colors_nr) { + || color->visual.global_index >= state->driver->mode->palette->max_colors_nr) { GFXERROR("Attempt to set invalid color index %02x as system color\n", color->visual.global_index); return GFX_ERROR; } @@ -897,8 +871,7 @@ gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color) } int -gfxop_free_color(gfx_state_t *state, gfx_color_t *color) -{ +gfxop_free_color(gfx_state_t *state, gfx_color_t *color) { gfx_palette_color_t *palette_color = {0}; gfx_pixmap_color_t pixmap_color = {0}; int error_code; @@ -908,7 +881,7 @@ gfxop_free_color(gfx_state_t *state, gfx_color_t *color) return GFX_OK; if (color->visual.global_index < 0 - || color->visual.global_index >= state->driver->mode->palette->max_colors_nr) { + || color->visual.global_index >= state->driver->mode->palette->max_colors_nr) { GFXERROR("Attempt to free invalid color index %02x\n", color->visual.global_index); return GFX_ERROR; } @@ -933,8 +906,7 @@ gfxop_free_color(gfx_state_t *state, gfx_color_t *color) static int -line_check_bar(int *start, int *length, int clipstart, int cliplength) -{ +line_check_bar(int *start, int *length, int clipstart, int cliplength) { int overlength; if (*start < clipstart) { @@ -951,8 +923,7 @@ line_check_bar(int *start, int *length, int clipstart, int cliplength) } static void -clip_line_partial(float *start, float *end, float delta_val, float pos_val, float start_val, float end_val) -{ +clip_line_partial(float *start, float *end, float delta_val, float pos_val, float start_val, float end_val) { float my_start = (start_val - pos_val) * delta_val; float my_end = (end_val - pos_val) * delta_val; @@ -978,41 +949,40 @@ line_clip(rect_t *line, rect_t clip, int xfact, int yfact) } else - if (!line->yl) {/* hbar */ - if (line->y < clip.y || line->y >= (clip.y + clip.yl)) - return 1; + if (!line->yl) {/* hbar */ + if (line->y < clip.y || line->y >= (clip.y + clip.yl)) + return 1; - return line_check_bar(&(line->x), &(line->xl), clip.x, clip.xl); + return line_check_bar(&(line->x), &(line->xl), clip.x, clip.xl); - } else { /* "normal" line */ - float start = 0.0, end = 1.0; - float xv = (float) line->xl; - float yv = (float) line->yl; + } else { /* "normal" line */ + float start = 0.0, end = 1.0; + float xv = (float) line->xl; + float yv = (float) line->yl; - if (line->xl < 0) - clip_line_partial(&start, &end, (float) (1.0 / xv), (float) line->x, (float) (clip.x + clip.xl), (float) clip.x); - else - clip_line_partial(&start, &end, (float) (1.0 / xv), (float) line->x, (float) clip.x, (float) (clip.x + clip.xl)); + if (line->xl < 0) + clip_line_partial(&start, &end, (float)(1.0 / xv), (float) line->x, (float)(clip.x + clip.xl), (float) clip.x); + else + clip_line_partial(&start, &end, (float)(1.0 / xv), (float) line->x, (float) clip.x, (float)(clip.x + clip.xl)); - if (line->yl < 0) - clip_line_partial(&start, &end, (float) (1.0 / yv), (float) line->y, (float) (clip.y + clip.yl), (float) clip.y); - else - clip_line_partial(&start, &end, (float) (1.0 / yv), (float) line->y, (float) clip.y, (float) (clip.y + clip.yl)); + if (line->yl < 0) + clip_line_partial(&start, &end, (float)(1.0 / yv), (float) line->y, (float)(clip.y + clip.yl), (float) clip.y); + else + clip_line_partial(&start, &end, (float)(1.0 / yv), (float) line->y, (float) clip.y, (float)(clip.y + clip.yl)); - line->x += (int) (xv * start); - line->y += (int) (yv * start); + line->x += (int)(xv * start); + line->y += (int)(yv * start); - line->xl = (int) (xv * (end-start)); - line->yl = (int) (yv * (end-start)); + line->xl = (int)(xv * (end - start)); + line->yl = (int)(yv * (end - start)); - return (start > 1.0 || end < 0.0); - } + return (start > 1.0 || end < 0.0); + } return 0; } static int -point_clip(point_t *start, point_t *end, rect_t clip, int xfact, int yfact) -{ +point_clip(point_t *start, point_t *end, rect_t clip, int xfact, int yfact) { rect_t line = gfx_rect(start->x, start->y, end->x - start->x, end->y - start->y); int retval = line_clip(&line, clip, xfact, yfact); @@ -1028,8 +998,7 @@ point_clip(point_t *start, point_t *end, rect_t clip, int xfact, int yfact) static void -draw_line_to_control_map(gfx_state_t *state, point_t start, point_t end, gfx_color_t color) -{ +draw_line_to_control_map(gfx_state_t *state, point_t start, point_t end, gfx_color_t color) { if (color.mask & GFX_MASK_CONTROL) if (!point_clip(&start, &end, state->clip_zone_unscaled, 0, 0)) gfx_draw_line_pixmap_i(state->control_map, start, end, color.control); @@ -1037,13 +1006,13 @@ draw_line_to_control_map(gfx_state_t *state, point_t start, point_t end, gfx_col static int simulate_stippled_line_draw(gfx_driver_t *driver, int skipone, point_t start, point_t end, gfx_color_t color, gfx_line_mode_t line_mode) - /* Draws a stippled line if this isn't supported by the driver (skipone is ignored ATM) */ +/* Draws a stippled line if this isn't supported by the driver (skipone is ignored ATM) */ { int xl = end.x - start.x; int yl = end.y - start.y; - int stepwidth = (xl)? driver->mode->xfact : driver->mode->yfact; - int dbl_stepwidth = 2*stepwidth; - int linelength = (line_mode == GFX_LINE_MODE_FINE)? stepwidth - 1 : 0; + int stepwidth = (xl) ? driver->mode->xfact : driver->mode->yfact; + int dbl_stepwidth = 2 * stepwidth; + int linelength = (line_mode == GFX_LINE_MODE_FINE) ? stepwidth - 1 : 0; int *posvar; int length; int delta; @@ -1052,12 +1021,12 @@ simulate_stippled_line_draw(gfx_driver_t *driver, int skipone, point_t start, po if (!xl) { /* xl = 0, so we move along yl */ posvar = &start.y; length = yl; - delta = (yl < 0)? -dbl_stepwidth : dbl_stepwidth; + delta = (yl < 0) ? -dbl_stepwidth : dbl_stepwidth; } else { - assert (!yl); /* We don't do diagonals; that's not needed ATM. */ + assert(!yl); /* We don't do diagonals; that's not needed ATM. */ posvar = &start.x; length = xl; - delta = (xl < 0)? -dbl_stepwidth : dbl_stepwidth; + delta = (xl < 0) ? -dbl_stepwidth : dbl_stepwidth; } length_left = length; @@ -1081,9 +1050,9 @@ simulate_stippled_line_draw(gfx_driver_t *driver, int skipone, point_t start, po point_t nextpos = gfx_point(start.x + xl, start.y + yl); if ((retval = driver->draw_line(driver, start, nextpos, - color, line_mode, GFX_LINE_STYLE_NORMAL))) { + color, line_mode, GFX_LINE_STYLE_NORMAL))) { GFXERROR("Failed to draw partial stippled line (%d,%d) -- (%d,%d)\n", - GFX_PRINT_POINT(start), GFX_PRINT_POINT(nextpos)); + GFX_PRINT_POINT(start), GFX_PRINT_POINT(nextpos)); return retval; } *posvar += delta; @@ -1106,7 +1075,7 @@ simulate_stippled_line_draw(gfx_driver_t *driver, int skipone, point_t start, po if ((retval = driver->draw_line(driver, start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL))) { GFXERROR("Failed to draw partial stippled line (%d,%d) -- (%d,%d)\n", - GFX_PRINT_POINT(start), GFX_PRINT_POINT(nextpos)); + GFX_PRINT_POINT(start), GFX_PRINT_POINT(nextpos)); return retval; } } @@ -1117,8 +1086,7 @@ simulate_stippled_line_draw(gfx_driver_t *driver, int skipone, point_t start, po static int _gfxop_draw_line_clipped(gfx_state_t *state, point_t start, point_t end, gfx_color_t color, gfx_line_mode_t line_mode, - gfx_line_style_t line_style) -{ + gfx_line_style_t line_style) { int retval; int skipone = (start.x ^ end.y) & 1; /* Used for simulated line stippling */ @@ -1133,17 +1101,17 @@ _gfxop_draw_line_clipped(gfx_state_t *state, point_t start, point_t end, gfx_col } if (start.x < state->clip_zone.x - || start.y < state->clip_zone.y - || end.x >= (state->clip_zone.x + state->clip_zone.xl) - || end.y >= (state->clip_zone.y + state->clip_zone.yl)) + || start.y < state->clip_zone.y + || end.x >= (state->clip_zone.x + state->clip_zone.xl) + || end.y >= (state->clip_zone.y + state->clip_zone.yl)) if (point_clip(&start, &end, state->clip_zone, state->driver->mode->xfact - 1, - state->driver->mode->yfact - 1)) + state->driver->mode->yfact - 1)) return GFX_OK; /* Clipped off */ if (line_style == GFX_LINE_STYLE_STIPPLED) { if (start.x != end.x && start.y != end.y) { GFXWARN("Attempt to draw stippled line which is neither an hbar nor a vbar: (%d,%d) -- (%d,%d)\n", - GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); + GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); return GFX_ERROR; } if (!(state->driver->capabilities & GFX_CAPABILITY_STIPPLED_LINES)) @@ -1151,12 +1119,12 @@ _gfxop_draw_line_clipped(gfx_state_t *state, point_t start, point_t end, gfx_col } if (line_mode == GFX_LINE_MODE_FINE - && !(state->driver->capabilities & GFX_CAPABILITY_FINE_LINES)) + && !(state->driver->capabilities & GFX_CAPABILITY_FINE_LINES)) line_mode = GFX_LINE_MODE_FAST; if ((retval = state->driver->draw_line(state->driver, start, end, color, line_mode, line_style))) { GFXERROR("Failed to draw line (%d,%d) -- (%d,%d)\n", - GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); + GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); return retval; } return GFX_OK; @@ -1164,9 +1132,8 @@ _gfxop_draw_line_clipped(gfx_state_t *state, point_t start, point_t end, gfx_col int gfxop_draw_line(gfx_state_t *state, point_t start, point_t end, - gfx_color_t color, gfx_line_mode_t line_mode, - gfx_line_style_t line_style) -{ + gfx_color_t color, gfx_line_mode_t line_mode, + gfx_line_style_t line_style) { int xfact, yfact; BASIC_CHECKS(GFX_FATAL); @@ -1193,8 +1160,7 @@ gfxop_draw_line(gfx_state_t *state, point_t start, point_t end, int gfxop_draw_rectangle(gfx_state_t *state, rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, - gfx_line_style_t line_style) -{ + gfx_line_style_t line_style) { int retval = 0; int xfact, yfact; int xunit, yunit; @@ -1209,7 +1175,7 @@ gfxop_draw_rectangle(gfx_state_t *state, rect_t rect, gfx_color_t color, gfx_lin yfact = state->driver->mode->yfact; if (line_mode == GFX_LINE_MODE_FINE - && state->driver->capabilities & GFX_CAPABILITY_FINE_LINES) { + && state->driver->capabilities & GFX_CAPABILITY_FINE_LINES) { xunit = yunit = 1; xl = 1 + (rect.xl - 1) * xfact; yl = 1 + (rect.yl - 1) * yfact; @@ -1240,10 +1206,10 @@ gfxop_draw_rectangle(gfx_state_t *state, rect_t rect, gfx_color_t color, gfx_lin _gfxop_add_dirty_x(state, \ gfx_rect(pt1##_u.x, pt1##_u.y, pt2##_u.x - pt1##_u.x, pt2##_u.y - pt1##_u.y)) - PARTIAL_LINE (upper_left, upper_right); - PARTIAL_LINE (upper_right, lower_right); - PARTIAL_LINE (lower_right, lower_left); - PARTIAL_LINE (lower_left, upper_left); + PARTIAL_LINE(upper_left, upper_right); + PARTIAL_LINE(upper_right, lower_right); + PARTIAL_LINE(lower_right, lower_left); + PARTIAL_LINE(lower_left, upper_left); #undef PARTIAL_LINE if (retval) { @@ -1259,8 +1225,7 @@ gfxop_draw_rectangle(gfx_state_t *state, rect_t rect, gfx_color_t color, gfx_lin int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t color2, - gfx_box_shade_t shade_type) -{ + gfx_box_shade_t shade_type) { gfx_driver_t *drv = state->driver; int reverse = 0; /* switch color1 and color2 */ float mod_offset = 0.0, mod_breadth = 1.0; /* 0.0 to 1.0: Color adjustment */ @@ -1305,18 +1270,20 @@ gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t c driver_shade_type = GFX_SHADE_FLAT; break; - case GFX_BOX_SHADE_LEFT: reverse = 1; + case GFX_BOX_SHADE_LEFT: + reverse = 1; case GFX_BOX_SHADE_RIGHT: driver_shade_type = GFX_SHADE_HORIZONTALLY; - mod_offset = (float) (((new_box.x - box.x) * 1.0) / (box.xl * 1.0)); - mod_breadth = (float) ((new_box.xl * 1.0) / (box.xl * 1.0)); + mod_offset = (float)(((new_box.x - box.x) * 1.0) / (box.xl * 1.0)); + mod_breadth = (float)((new_box.xl * 1.0) / (box.xl * 1.0)); break; - case GFX_BOX_SHADE_UP: reverse = 1; + case GFX_BOX_SHADE_UP: + reverse = 1; case GFX_BOX_SHADE_DOWN: driver_shade_type = GFX_SHADE_VERTICALLY; - mod_offset = (float) (((new_box.y - box.y) * 1.0) / (box.yl * 1.0)); - mod_breadth = (float) ((new_box.yl * 1.0) / (box.yl * 1.0)); + mod_offset = (float)(((new_box.y - box.y) * 1.0) / (box.yl * 1.0)); + mod_breadth = (float)((new_box.yl * 1.0) / (box.yl * 1.0)); break; default: @@ -1326,7 +1293,7 @@ gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t c if (reverse) - mod_offset = (float) (1.0 - (mod_offset + mod_breadth)); + mod_offset = (float)(1.0 - (mod_offset + mod_breadth)); /* Reverse offset if we have to interpret colors inversely */ if (shade_type == GFX_BOX_SHADE_FLAT) @@ -1363,16 +1330,14 @@ gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t c int -gfxop_fill_box(gfx_state_t *state, rect_t box, gfx_color_t color) -{ +gfxop_fill_box(gfx_state_t *state, rect_t box, gfx_color_t color) { return gfxop_draw_box(state, box, color, color, GFX_BOX_SHADE_FLAT); } static int -_gfxop_buffer_propagate_box(gfx_state_t *state, rect_t box, gfx_buffer_t buffer) -{ +_gfxop_buffer_propagate_box(gfx_state_t *state, rect_t box, gfx_buffer_t buffer) { int error; if (_gfxop_clip(&box, gfx_rect(0, 0, 320 * state->driver->mode->xfact, 200 * state->driver->mode->yfact))) @@ -1380,7 +1345,7 @@ _gfxop_buffer_propagate_box(gfx_state_t *state, rect_t box, gfx_buffer_t buffer) if ((error = state->driver->update(state->driver, box, gfx_point(box.x, box.y), buffer))) { GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", - box.x, box.y, box.xl, box.yl, buffer); + box.x, box.y, box.xl, box.yl, buffer); return error; } return GFX_OK; @@ -1388,15 +1353,14 @@ _gfxop_buffer_propagate_box(gfx_state_t *state, rect_t box, gfx_buffer_t buffer) extern int sci0_palette; int -gfxop_clear_box(gfx_state_t *state, rect_t box) -{ +gfxop_clear_box(gfx_state_t *state, rect_t box) { BASIC_CHECKS(GFX_FATAL); REMOVE_POINTER; _gfxop_add_dirty(state, box); DDIRTY(stderr, "[] clearing box %d %d %d %d\n", GFX_PRINT_RECT(box)); if (box.x == 29 - && box.y == 77 - && (sci0_palette == 1)) { + && box.y == 77 + && (sci0_palette == 1)) { BREAKPOINT(); } @@ -1412,8 +1376,7 @@ gfxop_clear_box(gfx_state_t *state, rect_t box) } int -gfxop_set_visible_map(gfx_state_t *state, gfx_map_mask_t visible_map) -{ +gfxop_set_visible_map(gfx_state_t *state, gfx_map_mask_t visible_map) { switch (visible_map) { case GFX_MASK_VISUAL: @@ -1443,8 +1406,7 @@ gfxop_set_visible_map(gfx_state_t *state, gfx_map_mask_t visible_map) } int -gfxop_update(gfx_state_t *state) -{ +gfxop_update(gfx_state_t *state) { int retval; BASIC_CHECKS(GFX_FATAL); @@ -1458,7 +1420,7 @@ gfxop_update(gfx_state_t *state) /* We've been asked to re-draw the active full-screen image, essentially. */ rect_t rect = gfx_rect(0, 0, 320, 200); gfx_xlate_pixmap(state->fullscreen_override, state->driver->mode, GFX_XLATE_FILTER_NONE); - gfxop_draw_pixmap(state, state->fullscreen_override, rect, gfx_point(0,0)); + gfxop_draw_pixmap(state, state->fullscreen_override, rect, gfx_point(0, 0)); retval |= _gfxop_update_box(state, rect); } @@ -1477,8 +1439,7 @@ gfxop_update(gfx_state_t *state) int -gfxop_update_box(gfx_state_t *state, rect_t box) -{ +gfxop_update_box(gfx_state_t *state, rect_t box) { BASIC_CHECKS(GFX_FATAL); DRAW_POINTER; @@ -1491,8 +1452,7 @@ gfxop_update_box(gfx_state_t *state, rect_t box) } int -gfxop_enable_dirty_frames(gfx_state_t *state) -{ +gfxop_enable_dirty_frames(gfx_state_t *state) { BASIC_CHECKS(GFX_ERROR); state->disable_dirty = 0; @@ -1500,8 +1460,7 @@ gfxop_enable_dirty_frames(gfx_state_t *state) } int -gfxop_disable_dirty_frames(gfx_state_t *state) -{ +gfxop_disable_dirty_frames(gfx_state_t *state) { BASIC_CHECKS(GFX_ERROR); state->disable_dirty = 1; @@ -1522,17 +1481,16 @@ gfxop_disable_dirty_frames(gfx_state_t *state) #define GFXOP_FULL_POINTER_REFRESH if (_gfxop_full_pointer_refresh(state)) { GFXERROR("Failed to do full pointer refresh!\n"); return GFX_ERROR; } static int -_gfxop_full_pointer_refresh(gfx_state_t *state) -{ +_gfxop_full_pointer_refresh(gfx_state_t *state) { rect_t pointer_bounds; rect_t old_pointer_bounds = {0, 0, 0, 0}; int new_x = state->driver->pointer_x; int new_y = state->driver->pointer_y; if (new_x != state->old_pointer_draw_pos.x - || new_y != state->old_pointer_draw_pos.y) { + || new_y != state->old_pointer_draw_pos.y) { point_t pp_new = gfx_point(new_x / state->driver->mode->xfact, - new_y / state->driver->mode->yfact); + new_y / state->driver->mode->yfact); if (!_gfxop_get_pointer_bounds(state, &pointer_bounds)) { memcpy(&old_pointer_bounds, &(state->pointer_bg_zone), sizeof(rect_t)); @@ -1551,8 +1509,7 @@ _gfxop_full_pointer_refresh(gfx_state_t *state) } int -gfxop_usleep(gfx_state_t *state, long usecs) -{ +gfxop_usleep(gfx_state_t *state, long usecs) { long time, utime; long wakeup_time, wakeup_utime; long add_seconds; @@ -1582,8 +1539,7 @@ gfxop_usleep(gfx_state_t *state, long usecs) int -_gfxop_set_pointer(gfx_state_t *state, gfx_pixmap_t *pxm) -{ +_gfxop_set_pointer(gfx_state_t *state, gfx_pixmap_t *pxm) { rect_t old_pointer_bounds = {0}; rect_t pointer_bounds = {0}; int retval = -1; @@ -1600,16 +1556,16 @@ _gfxop_set_pointer(gfx_state_t *state, gfx_pixmap_t *pxm) draw_old = state->driver->capabilities & GFX_CAPABILITY_COLOR_MOUSE_POINTER; if (!draw_old - && state->mouse_pointer - && (state->driver->capabilities & GFX_CAPABILITY_POINTER_PIXMAP_REGISTRY)) - if ((retval = state->driver->unregister_pixmap(state->driver, state->mouse_pointer))){ + && state->mouse_pointer + && (state->driver->capabilities & GFX_CAPABILITY_POINTER_PIXMAP_REGISTRY)) + if ((retval = state->driver->unregister_pixmap(state->driver, state->mouse_pointer))) { GFXERROR("Pointer un-registration failed!\n"); return retval; } if (pxm == NULL - || (state->driver->capabilities & GFX_CAPABILITY_COLOR_MOUSE_POINTER) - || pxm->colors_nr <= 2) { + || (state->driver->capabilities & GFX_CAPABILITY_COLOR_MOUSE_POINTER) + || pxm->colors_nr <= 2) { if (state->driver->capabilities & GFX_CAPABILITY_POINTER_PIXMAP_REGISTRY) { if ((pxm) && (retval = state->driver->register_pixmap(state->driver, pxm))) { GFXERROR("Pixmap-registering a new mouse pointer failed!\n"); @@ -1659,8 +1615,7 @@ _gfxop_set_pointer(gfx_state_t *state, gfx_pixmap_t *pxm) int -gfxop_set_pointer_cursor(gfx_state_t *state, int nr) -{ +gfxop_set_pointer_cursor(gfx_state_t *state, int nr) { gfx_pixmap_t *new_pointer = NULL; BASIC_CHECKS(GFX_FATAL); @@ -1680,8 +1635,7 @@ gfxop_set_pointer_cursor(gfx_state_t *state, int nr) int -gfxop_set_pointer_view(gfx_state_t *state, int nr, int loop, int cel, point_t *hotspot) -{ +gfxop_set_pointer_view(gfx_state_t *state, int nr, int loop, int cel, point_t *hotspot) { int real_loop = loop; int real_cel = cel; gfx_pixmap_t *new_pointer = NULL; @@ -1689,10 +1643,9 @@ gfxop_set_pointer_view(gfx_state_t *state, int nr, int loop, int cel, point_t * BASIC_CHECKS(GFX_FATAL); new_pointer = _gfxr_get_cel(state, nr, &real_loop, &real_cel, - 0); /* FIXME: For now, don't palettize pointers */ + 0); /* FIXME: For now, don't palettize pointers */ - if (hotspot) - { + if (hotspot) { new_pointer->xoffset = hotspot->x; new_pointer->yoffset = hotspot->y; } @@ -1700,25 +1653,22 @@ gfxop_set_pointer_view(gfx_state_t *state, int nr, int loop, int cel, point_t * if (!new_pointer) { GFXWARN("Attempt to set invalid pointer #%d\n", nr); return GFX_ERROR; - } else - { + } else { if (real_loop != loop || real_cel != cel) { GFXDEBUG("Changed loop/cel from %d/%d to %d/%d in view %d\n", - loop, cel, real_loop, real_cel, nr); + loop, cel, real_loop, real_cel, nr); } return _gfxop_set_pointer(state, new_pointer); } } int -gfxop_set_pointer_position(gfx_state_t *state, point_t pos) -{ +gfxop_set_pointer_position(gfx_state_t *state, point_t pos) { BASIC_CHECKS(GFX_ERROR); state->pointer_pos = pos; - if (pos.x > 320 || pos.y > 200) - { + if (pos.x > 320 || pos.y > 200) { GFXWARN("Attempt to place pointer at invalid coordinates (%d, %d)\n", pos.x, pos.y); return 0; /* Not fatal */ } @@ -1743,7 +1693,7 @@ struct scancode_row { static int _gfxop_scancode(int ch) - /* Calculates a PC keyboard scancode from a character */ +/* Calculates a PC keyboard scancode from a character */ { int row; int c = toupper((char)ch); @@ -1764,13 +1714,12 @@ _gfxop_scancode(int ch) return ch; /* not found */ } -/* static */ int -_gfxop_shiftify(int c) -{ +/* static */ +int +_gfxop_shiftify(int c) { char shifted_numbers[] = ")!@#$%^&*("; - - if (c < 256) - { + + if (c < 256) { c = toupper((char)c); if (c >= 'A' && c <= 'Z') @@ -1778,64 +1727,96 @@ _gfxop_shiftify(int c) if (c >= '0' && c <= '9') return shifted_numbers[c-'0']; - + switch (c) { - case SCI_K_TAB: return SCI_K_SHIFT_TAB; - case ']': return '}'; - case '[': return '{'; - case '`': return '~'; - case '-': return '_'; - case '=': return '+'; - case ';': return ':'; - case '\'': return '"'; - case '\\': return '|'; - case ',': return '<'; - case '.': return '>'; - case '/': return '?'; - default: return c; /* No match */ + case SCI_K_TAB: + return SCI_K_SHIFT_TAB; + case ']': + return '}'; + case '[': + return '{'; + case '`': + return '~'; + case '-': + return '_'; + case '=': + return '+'; + case ';': + return ':'; + case '\'': + return '"'; + case '\\': + return '|'; + case ',': + return '<'; + case '.': + return '>'; + case '/': + return '?'; + default: + return c; /* No match */ } } - switch (c) - { - case SCI_K_F1 : return SCI_K_SHIFT_F1; - case SCI_K_F2 : return SCI_K_SHIFT_F2; - case SCI_K_F3 : return SCI_K_SHIFT_F3; - case SCI_K_F4 : return SCI_K_SHIFT_F4; - case SCI_K_F5 : return SCI_K_SHIFT_F5; - case SCI_K_F6 : return SCI_K_SHIFT_F6; - case SCI_K_F7 : return SCI_K_SHIFT_F7; - case SCI_K_F8 : return SCI_K_SHIFT_F8; - case SCI_K_F9 : return SCI_K_SHIFT_F9; - case SCI_K_F10 : return SCI_K_SHIFT_F10; + switch (c) { + case SCI_K_F1 : + return SCI_K_SHIFT_F1; + case SCI_K_F2 : + return SCI_K_SHIFT_F2; + case SCI_K_F3 : + return SCI_K_SHIFT_F3; + case SCI_K_F4 : + return SCI_K_SHIFT_F4; + case SCI_K_F5 : + return SCI_K_SHIFT_F5; + case SCI_K_F6 : + return SCI_K_SHIFT_F6; + case SCI_K_F7 : + return SCI_K_SHIFT_F7; + case SCI_K_F8 : + return SCI_K_SHIFT_F8; + case SCI_K_F9 : + return SCI_K_SHIFT_F9; + case SCI_K_F10 : + return SCI_K_SHIFT_F10; } return c; } static int -_gfxop_numlockify(int c) -{ +_gfxop_numlockify(int c) { switch (c) { - case SCI_K_DELETE: return '.'; - case SCI_K_INSERT: return '0'; - case SCI_K_END: return '1'; - case SCI_K_DOWN: return '2'; - case SCI_K_PGDOWN: return '3'; - case SCI_K_LEFT: return '4'; - case SCI_K_CENTER: return '5'; - case SCI_K_RIGHT: return '6'; - case SCI_K_HOME: return '7'; - case SCI_K_UP: return '8'; - case SCI_K_PGUP: return '9'; - default: return c; /* Unchanged */ + case SCI_K_DELETE: + return '.'; + case SCI_K_INSERT: + return '0'; + case SCI_K_END: + return '1'; + case SCI_K_DOWN: + return '2'; + case SCI_K_PGDOWN: + return '3'; + case SCI_K_LEFT: + return '4'; + case SCI_K_CENTER: + return '5'; + case SCI_K_RIGHT: + return '6'; + case SCI_K_HOME: + return '7'; + case SCI_K_UP: + return '8'; + case SCI_K_PGUP: + return '9'; + default: + return c; /* Unchanged */ } } sci_event_t -gfxop_get_event(gfx_state_t *state, unsigned int mask) -{ +gfxop_get_event(gfx_state_t *state, unsigned int mask) { sci_event_t error_event = { SCI_EVT_ERROR, 0, 0 }; sci_event_t event; event.data = 0; @@ -1858,21 +1839,20 @@ gfxop_get_event(gfx_state_t *state, unsigned int mask) } else { event.type = 0; - if (!(mask & SCI_EVT_NONBLOCK)) - { + if (!(mask & SCI_EVT_NONBLOCK)) { do { if (event.type) { *seekerp = (gfx_input_event_t*)sci_malloc(sizeof(gfx_input_event_t)); (*seekerp)->next = NULL; - - event.data = (char) (event.data); + + event.data = (char)(event.data); /* Clip illegal bits */ - + (*seekerp)->event = event; seekerp = &((*seekerp)->next); } event = state->driver->get_event(state->driver); - + } while (event.type && !(event.type & mask)); } } @@ -1883,7 +1863,7 @@ gfxop_get_event(gfx_state_t *state, unsigned int mask) } if (event.type == SCI_EVT_KEYBOARD - && !(state->driver->capabilities & GFX_CAPABILITY_KEYTRANSLATE)) { + && !(state->driver->capabilities & GFX_CAPABILITY_KEYTRANSLATE)) { /* Do we still have to translate the key? */ event.character = event.data; @@ -1894,10 +1874,10 @@ gfxop_get_event(gfx_state_t *state, unsigned int mask) /* Shift if appropriate */ else if (((event.buckybits & (SCI_EVM_RSHIFT | SCI_EVM_LSHIFT)) - && !(event.buckybits & SCI_EVM_CAPSLOCK)) - || - (!(event.buckybits & (SCI_EVM_RSHIFT | SCI_EVM_LSHIFT)) - && (event.buckybits & SCI_EVM_CAPSLOCK))) + && !(event.buckybits & SCI_EVM_CAPSLOCK)) + || + (!(event.buckybits & (SCI_EVM_RSHIFT | SCI_EVM_LSHIFT)) + && (event.buckybits & SCI_EVM_CAPSLOCK))) event.character = _gfxop_shiftify(event.character); /* Numlockify if appropriate */ @@ -1914,8 +1894,7 @@ gfxop_get_event(gfx_state_t *state, unsigned int mask) /*******************/ int -gfxop_lookup_view_get_loops(gfx_state_t *state, int nr) -{ +gfxop_lookup_view_get_loops(gfx_state_t *state, int nr) { int loop = 0, cel = 0; gfxr_view_t *view = NULL; @@ -1933,8 +1912,7 @@ gfxop_lookup_view_get_loops(gfx_state_t *state, int nr) int -gfxop_lookup_view_get_cels(gfx_state_t *state, int nr, int loop) -{ +gfxop_lookup_view_get_cels(gfx_state_t *state, int nr, int loop) { int real_loop = loop, cel = 0; gfxr_view_t *view = NULL; @@ -1954,9 +1932,8 @@ gfxop_lookup_view_get_cels(gfx_state_t *state, int nr, int loop) int -gfxop_check_cel(gfx_state_t *state, int nr, int *loop, int *cel) -{ - BASIC_CHECKS(GFX_ERROR); +gfxop_check_cel(gfx_state_t *state, int nr, int *loop, int *cel) { + BASIC_CHECKS(GFX_ERROR); if (!gfxr_get_view(state->resstate, nr, loop, cel, 0)) { GFXWARN("Attempt to verify loop/cel values for invalid view %d\n", nr); @@ -1967,11 +1944,10 @@ gfxop_check_cel(gfx_state_t *state, int nr, int *loop, int *cel) } int -gfxop_overflow_cel(gfx_state_t *state, int nr, int *loop, int *cel) -{ +gfxop_overflow_cel(gfx_state_t *state, int nr, int *loop, int *cel) { int loop_v = *loop; int cel_v = *cel; - BASIC_CHECKS(GFX_ERROR); + BASIC_CHECKS(GFX_ERROR); if (!gfxr_get_view(state->resstate, nr, &loop_v, &cel_v, 0)) { GFXWARN("Attempt to verify loop/cel values for invalid view %d\n", nr); @@ -1982,7 +1958,7 @@ gfxop_overflow_cel(gfx_state_t *state, int nr, int *loop, int *cel) *loop = 0; if (loop_v != *loop - || cel_v != *cel) + || cel_v != *cel) *cel = 0; return GFX_OK; @@ -1991,8 +1967,7 @@ gfxop_overflow_cel(gfx_state_t *state, int nr, int *loop, int *cel) int gfxop_get_cel_parameters(gfx_state_t *state, int nr, int loop, int cel, - int *width, int *height, point_t *offset) -{ + int *width, int *height, point_t *offset) { gfxr_view_t *view = NULL; gfx_pixmap_t *pxm = NULL; BASIC_CHECKS(GFX_ERROR); @@ -2014,11 +1989,10 @@ gfxop_get_cel_parameters(gfx_state_t *state, int nr, int loop, int cel, static int _gfxop_draw_cel_buffer(gfx_state_t *state, int nr, int loop, int cel, - point_t pos, gfx_color_t color, int static_buf, - int palette) -{ - int priority = (color.mask & GFX_MASK_PRIORITY)? color.priority : -1; - int control = (color.mask & GFX_MASK_CONTROL)? color.control : -1; + point_t pos, gfx_color_t color, int static_buf, + int palette) { + int priority = (color.mask & GFX_MASK_PRIORITY) ? color.priority : -1; + int control = (color.mask & GFX_MASK_CONTROL) ? color.control : -1; gfxr_view_t *view = NULL; gfx_pixmap_t *pxm = NULL; int old_x, old_y; @@ -2040,35 +2014,33 @@ _gfxop_draw_cel_buffer(gfx_state_t *state, int nr, int loop, int cel, _gfxop_add_dirty(state, gfx_rect(old_x, old_y, pxm->index_xl, pxm->index_yl)); return _gfxop_draw_pixmap(state->driver, pxm, priority, control, - gfx_rect(0, 0, pxm->xl, pxm->yl), - gfx_rect(pos.x, pos.y, pxm->xl, pxm->yl), - state->clip_zone, - static_buf , state->control_map, - static_buf - ? state->static_priority_map - : state->priority_map); + gfx_rect(0, 0, pxm->xl, pxm->yl), + gfx_rect(pos.x, pos.y, pxm->xl, pxm->yl), + state->clip_zone, + static_buf , state->control_map, + static_buf + ? state->static_priority_map + : state->priority_map); } int gfxop_draw_cel(gfx_state_t *state, int nr, int loop, int cel, point_t pos, - gfx_color_t color, int palette) -{ + gfx_color_t color, int palette) { return _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 0, palette); } int gfxop_draw_cel_static(gfx_state_t *state, int nr, int loop, int cel, point_t pos, - gfx_color_t color, int palette) -{ + gfx_color_t color, int palette) { int retval; rect_t oldclip = state->clip_zone; state->clip_zone = gfx_rect_fullscreen; _gfxop_scale_rect(&(state->clip_zone), state->driver->mode); retval = gfxop_draw_cel_static_clipped(state, nr, loop, cel, pos, color, - palette); + palette); /* Except that the area it's clipped against is... unusual ;-) */ state->clip_zone = oldclip; @@ -2078,8 +2050,7 @@ gfxop_draw_cel_static(gfx_state_t *state, int nr, int loop, int cel, point_t pos int gfxop_draw_cel_static_clipped(gfx_state_t *state, int nr, int loop, int cel, - point_t pos, gfx_color_t color, int palette) -{ + point_t pos, gfx_color_t color, int palette) { return _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 1, palette); } @@ -2089,10 +2060,9 @@ gfxop_draw_cel_static_clipped(gfx_state_t *state, int nr, int loop, int cel, /******************/ static int -_gfxop_set_pic(gfx_state_t *state) -{ +_gfxop_set_pic(gfx_state_t *state) { gfx_copy_pixmap_box_i(state->control_map, state->pic->control_map, gfx_rect(0, 0, 320, 200)); - gfx_copy_pixmap_box_i(state->priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); + gfx_copy_pixmap_box_i(state->priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); gfx_copy_pixmap_box_i(state->static_priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); _gfxop_install_pixmap(state->driver, state->pic->visual_map); @@ -2104,15 +2074,13 @@ _gfxop_set_pic(gfx_state_t *state) void * -gfxop_get_pic_metainfo(gfx_state_t *state) -{ - return (state->pic)? state->pic->internal : NULL; +gfxop_get_pic_metainfo(gfx_state_t *state) { + return (state->pic) ? state->pic->internal : NULL; } int -gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) -{ +gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) { BASIC_CHECKS(GFX_FATAL); gfxr_tag_resources(state->resstate); @@ -2147,8 +2115,7 @@ gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) int -gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette) -{ +gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette) { BASIC_CHECKS(GFX_FATAL); if (!state->pic) { @@ -2157,14 +2124,14 @@ gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette) } if (!(state->pic = gfxr_add_to_pic(state->resstate, state->pic_nr, nr, - GFX_MASK_VISUAL, flags, state->palette_nr, default_palette, 1))) { + GFX_MASK_VISUAL, flags, state->palette_nr, default_palette, 1))) { GFXERROR("Could not add pic #%d to pic #%d!\n", state->pic_nr, nr); return GFX_ERROR; } state->pic_unscaled = gfxr_add_to_pic(state->resstate, state->pic_nr, nr, - GFX_MASK_VISUAL, flags, - state->palette_nr, - default_palette, 1); + GFX_MASK_VISUAL, flags, + state->palette_nr, + default_palette, 1); return _gfxop_set_pic(state); } @@ -2176,8 +2143,7 @@ gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette) int -gfxop_get_font_height(gfx_state_t *state, int font_nr) -{ +gfxop_get_font_height(gfx_state_t *state, int font_nr) { gfx_bitmap_font_t *font; BASIC_CHECKS(GFX_FATAL); @@ -2190,9 +2156,8 @@ gfxop_get_font_height(gfx_state_t *state, int font_nr) int gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, - int maxwidth, int *width, int *height, int text_flags, - int *lines_nr, int *lineheight, int *lastline_width) -{ + int maxwidth, int *width, int *height, int text_flags, + int *lines_nr, int *lineheight, int *lastline_width) { text_fragment_t *textsplits; gfx_bitmap_font_t *font; @@ -2207,10 +2172,10 @@ gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, } textsplits = gfxr_font_calculate_size(font, maxwidth, text, width, - height, lines_nr, - lineheight, lastline_width, - (state->options->workarounds & GFX_WORKAROUND_WHITESPACE_COUNT) - | text_flags); + height, lines_nr, + lineheight, lastline_width, + (state->options->workarounds & GFX_WORKAROUND_WHITESPACE_COUNT) + | text_flags); if (!textsplits) { @@ -2241,14 +2206,13 @@ gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, gfx_text_handle_t * gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, - gfx_alignment_t halign, gfx_alignment_t valign, - gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, - int flags) -{ + gfx_alignment_t halign, gfx_alignment_t valign, + gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, + int flags) { gfx_text_handle_t *handle = {0}; gfx_bitmap_font_t *font = {0}; int i; - gfx_pixmap_color_t pxm_col1, pxm_col2, pxm_colbg= {0}; + gfx_pixmap_color_t pxm_col1, pxm_col2, pxm_colbg = {0}; BASIC_CHECKS(NULL); COL_XLATE(pxm_col1, color1); @@ -2271,12 +2235,12 @@ gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, handle->line_height = font->line_height; handle->lines = - gfxr_font_calculate_size(font, maxwidth, handle->text, &(handle->width), &(handle->height), - &(handle->lines_nr), - NULL, NULL, - ((state->options->workarounds & GFX_WORKAROUND_WHITESPACE_COUNT)? - GFXR_FONT_FLAG_COUNT_WHITESPACE : 0) - | flags); + gfxr_font_calculate_size(font, maxwidth, handle->text, &(handle->width), &(handle->height), + &(handle->lines_nr), + NULL, NULL, + ((state->options->workarounds & GFX_WORKAROUND_WHITESPACE_COUNT) ? + GFXR_FONT_FLAG_COUNT_WHITESPACE : 0) + | flags); if (!handle->lines) { free(handle->text); @@ -2297,9 +2261,9 @@ gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, int chars_nr = handle->lines[i].length; handle->text_pixmaps[i] = gfxr_draw_font(font, handle->lines[i].offset, chars_nr, - (color1.mask & GFX_MASK_VISUAL)? &pxm_col1 : NULL, - (color2.mask & GFX_MASK_VISUAL)? &pxm_col2 : NULL, - (bg_color.mask & GFX_MASK_VISUAL)? &pxm_colbg : NULL); + (color1.mask & GFX_MASK_VISUAL) ? &pxm_col1 : NULL, + (color2.mask & GFX_MASK_VISUAL) ? &pxm_col2 : NULL, + (bg_color.mask & GFX_MASK_VISUAL) ? &pxm_colbg : NULL); if (!handle->text_pixmaps[i]) { int j; @@ -2317,16 +2281,15 @@ gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, handle->font = font; - handle->priority = (color1.mask & GFX_MASK_PRIORITY)? color1.priority : -1; - handle->control = (color1.mask & GFX_MASK_CONTROL)? color1.control : -1; + handle->priority = (color1.mask & GFX_MASK_PRIORITY) ? color1.priority : -1; + handle->control = (color1.mask & GFX_MASK_CONTROL) ? color1.control : -1; return handle; } int -gfxop_free_text(gfx_state_t *state, gfx_text_handle_t *handle) -{ +gfxop_free_text(gfx_state_t *state, gfx_text_handle_t *handle) { int j; BASIC_CHECKS(GFX_ERROR); @@ -2345,8 +2308,7 @@ gfxop_free_text(gfx_state_t *state, gfx_text_handle_t *handle) int -gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) -{ +gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) { int line_height; rect_t pos; int i; @@ -2426,8 +2388,8 @@ gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) _gfxop_add_dirty(state, pos); _gfxop_draw_pixmap(state->driver, pxm, handle->priority, handle->control, - gfx_rect(0, 0, pxm->xl, pxm->yl), pos, state->clip_zone, 0, - state->control_map, state->priority_map); + gfx_rect(0, 0, pxm->xl, pxm->yl), pos, state->clip_zone, 0, + state->control_map, state->priority_map); pos.y += line_height; } @@ -2437,8 +2399,7 @@ gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) gfx_pixmap_t * -gfxop_grab_pixmap(gfx_state_t *state, rect_t area) -{ +gfxop_grab_pixmap(gfx_state_t *state, rect_t area) { gfx_pixmap_t *pixmap = NULL; rect_t resultzone; /* Ignored for this application */ BASIC_CHECKS(NULL); @@ -2457,8 +2418,7 @@ gfxop_grab_pixmap(gfx_state_t *state, rect_t area) } int -gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, point_t pos) -{ +gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, point_t pos) { rect_t target; BASIC_CHECKS(GFX_ERROR); @@ -2482,13 +2442,12 @@ gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, point_t po _gfxop_scale_rect(&target, state->driver->mode); return _gfxop_draw_pixmap(state->driver, pxm, -1, -1, zone, target, - gfx_rect(0, 0, 320*state->driver->mode->xfact, - 200*state->driver->mode->yfact), 0, NULL, NULL); + gfx_rect(0, 0, 320*state->driver->mode->xfact, + 200*state->driver->mode->yfact), 0, NULL, NULL); } int -gfxop_free_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm) -{ +gfxop_free_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm) { BASIC_CHECKS(GFX_ERROR); gfx_free_pixmap(state->driver, pxm); return GFX_OK; diff --git a/engines/sci/gfx/resmgr.cpp b/engines/sci/gfx/resmgr.cpp index d7893738ba..ca436d484b 100644 --- a/engines/sci/gfx/resmgr.cpp +++ b/engines/sci/gfx/resmgr.cpp @@ -46,8 +46,7 @@ struct param_struct { gfx_resstate_t * gfxr_new_resource_manager(int version, gfx_options_t *options, - gfx_driver_t *driver, void *misc_payload) -{ + gfx_driver_t *driver, void *misc_payload) { gfx_resstate_t *state = (gfx_resstate_t*)sci_malloc(sizeof(gfx_resstate_t)); int ii; @@ -62,7 +61,7 @@ gfxr_new_resource_manager(int version, gfx_options_t *options, sbtree_t *tree; int entries_nr; int *resources = gfxr_interpreter_get_resources(state, i, version, - &entries_nr, misc_payload); + &entries_nr, misc_payload); if (!resources) state->resource_trees[i] = NULL; @@ -96,8 +95,7 @@ gfxr_new_resource_manager(int version, gfx_options_t *options, void -gfxr_free_resource(gfx_driver_t *driver, gfx_resource_t *resource, int type) -{ +gfxr_free_resource(gfx_driver_t *driver, gfx_resource_t *resource, int type) { if (!resource) return; @@ -130,8 +128,7 @@ gfxr_free_resource(gfx_driver_t *driver, gfx_resource_t *resource, int type) void * -gfxr_sbtree_free_func(sbtree_t *tree, const int key, const void *value, void *args) -{ +gfxr_sbtree_free_func(sbtree_t *tree, const int key, const void *value, void *args) { struct param_struct *params = (struct param_struct *) args; int type = params->args[0]; gfx_driver_t *driver = params->driver; @@ -150,8 +147,7 @@ gfxr_sbtree_free_func(sbtree_t *tree, const int key, const void *value, void *ar #define ARG_ACTION_DECREMENT 1 void * -gfxr_sbtree_free_tagged_func(sbtree_t *tree, const int key, const void *value, void *args) -{ +gfxr_sbtree_free_tagged_func(sbtree_t *tree, const int key, const void *value, void *args) { struct param_struct *params = (struct param_struct *) args; int type = params->args[SBTREE_FREE_TAGGED_ARG_TYPE]; int tag_value = params->args[SBTREE_FREE_TAGGED_ARG_TAGVALUE]; @@ -174,8 +170,7 @@ gfxr_sbtree_free_tagged_func(sbtree_t *tree, const int key, const void *value, v void -gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state) -{ +gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state) { struct param_struct params; int i; sbtree_t *tree = NULL; @@ -189,8 +184,7 @@ gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state) } void -gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state) -{ +gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state) { struct param_struct params; int i; sbtree_t *tree = NULL; @@ -208,16 +202,14 @@ gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state) void -gfxr_tag_resources(gfx_resstate_t *state) -{ +gfxr_tag_resources(gfx_resstate_t *state) { (state->tag_lock_counter)++; } void -gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state) -{ +gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state) { /* Current heuristics: free tagged views and old pics */ struct param_struct params; @@ -258,34 +250,32 @@ gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state) static gfxr_pic_t * gfxr_pic_xlate_common(gfx_resource_t *res, int maps, int scaled, - int force, gfx_mode_t *mode, gfx_xlate_filter_t filter, int endianize, - gfx_options_t *options) -{ + int force, gfx_mode_t *mode, gfx_xlate_filter_t filter, int endianize, + gfx_options_t *options) { XLATE_AS_APPROPRIATE(GFX_MASK_VISUAL, visual_map); XLATE_AS_APPROPRIATE(GFX_MASK_PRIORITY, priority_map); XLATE_AS_APPROPRIATE(GFX_MASK_CONTROL, control_map); - if (endianize && (maps & GFX_MASK_VISUAL) && res->scaled_data.pic->visual_map) - gfxr_endianness_adjust(res->scaled_data.pic->visual_map, mode); + if (endianize && (maps & GFX_MASK_VISUAL) && res->scaled_data.pic->visual_map) + gfxr_endianness_adjust(res->scaled_data.pic->visual_map, mode); - return scaled? res->scaled_data.pic : res->unscaled_data.pic; + return scaled ? res->scaled_data.pic : res->unscaled_data.pic; } #undef XLATE_AS_APPROPRIATE gfxr_pic_t * -gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_palette, int scaled) -{ +gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_palette, int scaled) { gfxr_pic_t *npic = NULL; gfx_resource_type_t restype = GFX_RESOURCE_TYPE_PIC; sbtree_t *tree = state->resource_trees[restype]; gfx_resource_t *res = NULL; int hash = gfxr_interpreter_options_hash(restype, state->version, - state->options, state->misc_payload, 0); - int must_post_process_pic = 0; + state->options, state->misc_payload, 0); + int must_post_process_pic = 0; int need_unscaled = - (state->driver->mode->xfact != 1 || state->driver->mode->yfact != 1); + (state->driver->mode->xfact != 1 || state->driver->mode->yfact != 1); if (!tree) return NULL; @@ -301,13 +291,13 @@ gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_pal if (state->options->pic0_unscaled) { need_unscaled = 0; pic = gfxr_interpreter_init_pic(state->version, - &mode_1x1_color_index, - GFXR_RES_ID(restype, nr), - state->misc_payload); + &mode_1x1_color_index, + GFXR_RES_ID(restype, nr), + state->misc_payload); } else pic = gfxr_interpreter_init_pic(state->version, - state->driver->mode, - GFXR_RES_ID(restype, nr), - state->misc_payload); + state->driver->mode, + GFXR_RES_ID(restype, nr), + state->misc_payload); if (!pic) { GFXERROR("Failed to allocate scaled pic!\n"); @@ -318,34 +308,34 @@ gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_pal if (need_unscaled) { unscaled_pic = gfxr_interpreter_init_pic(state->version, - &mode_1x1_color_index, - GFXR_RES_ID(restype, nr), - state->misc_payload); + &mode_1x1_color_index, + GFXR_RES_ID(restype, nr), + state->misc_payload); if (!unscaled_pic) { GFXERROR("Failed to allocate unscaled pic!\n"); return NULL; } gfxr_interpreter_clear_pic(state->version, unscaled_pic, - state->misc_payload); + state->misc_payload); } #ifdef TIME_PICDRAWING {long start_sec, start_usec; - long end_sec, end_usec; - sci_gettime(&start_sec, &start_usec); + long end_sec, end_usec; + sci_gettime(&start_sec, &start_usec); #endif - if (gfxr_interpreter_calculate_pic(state, pic, unscaled_pic, flags, - default_palette, nr, - state->misc_payload)) { - gfxr_free_pic(state->driver, pic); - if (unscaled_pic) - gfxr_free_pic(state->driver, unscaled_pic); + if (gfxr_interpreter_calculate_pic(state, pic, unscaled_pic, flags, + default_palette, nr, + state->misc_payload)) { + gfxr_free_pic(state->driver, pic); + if (unscaled_pic) + gfxr_free_pic(state->driver, unscaled_pic); - return NULL; - } + return NULL; + } #ifdef TIME_PICDRAWING - sci_gettime(&end_sec, &end_usec); - printf("\nTIME: %d for drawing pic.%03d\n", - (end_sec - start_sec) * 1000000 + (end_usec - start_usec), nr); + sci_gettime(&end_sec, &end_usec); + printf("\nTIME: %d for drawing pic.%03d\n", + (end_sec - start_sec) * 1000000 + (end_usec - start_usec), nr); } #endif @@ -367,23 +357,23 @@ gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_pal res->lock_sequence_nr = state->options->buffer_pics_nr; /* Update lock counter */ } - must_post_process_pic = res->scaled_data.pic->visual_map->data == NULL; + must_post_process_pic = res->scaled_data.pic->visual_map->data == NULL; /* If the pic was only just drawn, we'll have to antialiase and endianness-adjust it now */ npic = gfxr_pic_xlate_common(res, maps, - scaled || state->options->pic0_unscaled, - 0, state->driver->mode, - state->options->pic_xlate_filter, 0, - state->options); + scaled || state->options->pic0_unscaled, + 0, state->driver->mode, + state->options->pic_xlate_filter, 0, + state->options); if (must_post_process_pic) { if (scaled || state->options->pic0_unscaled && maps & GFX_MASK_VISUAL) - gfxr_antialiase(npic->visual_map, state->driver->mode, - state->options->pic0_antialiasing); + gfxr_antialiase(npic->visual_map, state->driver->mode, + state->options->pic0_antialiasing); - gfxr_endianness_adjust(npic->visual_map, state->driver->mode); + gfxr_endianness_adjust(npic->visual_map, state->driver->mode); } return npic; @@ -391,8 +381,7 @@ gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_pal static void -set_pic_id(gfx_resource_t *res, int id) -{ +set_pic_id(gfx_resource_t *res, int id) { if (res->scaled_data.pic) { gfxr_pic_t *pic = res->scaled_data.pic; pic->control_map->ID = id; @@ -409,8 +398,7 @@ set_pic_id(gfx_resource_t *res, int id) } static int -get_pic_id(gfx_resource_t *res) -{ +get_pic_id(gfx_resource_t *res) { if (res->scaled_data.pic) return res->scaled_data.pic->visual_map->ID; else @@ -418,8 +406,7 @@ get_pic_id(gfx_resource_t *res) } static void -_gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) -{ +_gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) { int xmod = mode->xfact; /* Step size horizontally */ int ymod = pxm->index_xl * mode->yfact; /* Vertical step size */ int maxpos = pxm->index_xl * pxm->index_yl; @@ -433,7 +420,7 @@ _gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) int c; for (c = 0; c < pxm->index_xl; c += xmod) - *dest++ = pxm->index_data[pos + c]; /* No overwrite since + * dest++ = pxm->index_data[pos + c]; /* No overwrite since ** line and offset ** readers move much ** faster @@ -451,17 +438,16 @@ _gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) gfxr_pic_t * gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int maps, int flags, - int old_default_palette, int default_palette, int scaled) -{ + int old_default_palette, int default_palette, int scaled) { gfx_resource_type_t restype = GFX_RESOURCE_TYPE_PIC; sbtree_t *tree = state->resource_trees[restype]; gfxr_pic_t *pic = NULL; gfx_resource_t *res = NULL; int hash = gfxr_interpreter_options_hash(restype, state->version, - state->options, - state->misc_payload, 0); + state->options, + state->misc_payload, 0); int need_unscaled = !(state->options->pic0_unscaled) - && (state->driver->mode->xfact != 1 || state->driver->mode->yfact != 1); + && (state->driver->mode->xfact != 1 || state->driver->mode->yfact != 1); if (!tree) { GFXERROR("No pics registered\n"); @@ -471,8 +457,8 @@ gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int maps, int fla res = (gfx_resource_t *) sbtree_get(tree, old_nr); if (!res || - (res->mode != MODE_INVALID - && res->mode != hash)) { + (res->mode != MODE_INVALID + && res->mode != hash)) { gfxr_get_pic(state, old_nr, 0, flags, old_default_palette, scaled); res = (gfx_resource_t *) sbtree_get(tree, old_nr); @@ -489,9 +475,9 @@ gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int maps, int fla if (scaled) { res->lock_sequence_nr = state->options->buffer_pics_nr; - gfxr_interpreter_calculate_pic(state, res->scaled_data.pic, need_unscaled? res->unscaled_data.pic : NULL, - flags | DRAWPIC01_FLAG_OVERLAID_PIC, - default_palette, new_nr, state->misc_payload); + gfxr_interpreter_calculate_pic(state, res->scaled_data.pic, need_unscaled ? res->unscaled_data.pic : NULL, + flags | DRAWPIC01_FLAG_OVERLAID_PIC, + default_palette, new_nr, state->misc_payload); } res->mode = MODE_INVALID; /* Invalidate */ @@ -502,28 +488,27 @@ gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int maps, int fla int old_ID = get_pic_id(res); set_pic_id(res, GFXR_RES_ID(restype, new_nr)); /* To ensure that our graphical translation optoins work properly */ pic = gfxr_pic_xlate_common(res, maps, scaled, 1, state->driver->mode, - state->options->pic_xlate_filter, 1, - state->options); + state->options->pic_xlate_filter, 1, + state->options); set_pic_id(res, old_ID); } if (scaled || state->options->pic0_unscaled && maps & GFX_MASK_VISUAL) gfxr_antialiase(pic->visual_map, state->driver->mode, - state->options->pic0_antialiasing); + state->options->pic0_antialiasing); return pic; } gfxr_view_t * -gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, int palette) -{ +gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, int palette) { gfx_resource_type_t restype = GFX_RESOURCE_TYPE_VIEW; sbtree_t *tree = state->resource_trees[restype]; gfx_resource_t *res = NULL; int hash = gfxr_interpreter_options_hash(restype, state->version, - state->options, state->misc_payload, - palette); + state->options, state->misc_payload, + palette); gfxr_view_t *view = NULL; gfxr_loop_t *loop_data = NULL; gfx_pixmap_t *cel_data = NULL; @@ -570,18 +555,15 @@ gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, int palette) } loop_data = view->loops + (*loop); - if (loop_data == NULL) - { + if (loop_data == NULL) { GFXWARN("Trying to load invalid loop %d of view %d\n", *loop, nr); return NULL; } - if (*cel < 0) - { + if (*cel < 0) { sciprintf("Resetting cel! %d\n", *cel); *cel = 0; - } - else + } else if (*cel >= loop_data->cels_nr) *cel = loop_data->cels_nr - 1; @@ -591,8 +573,7 @@ gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, int palette) } cel_data = loop_data->cels[*cel]; - if (loop_data == NULL) - { + if (loop_data == NULL) { GFXWARN("Trying to load invalid view/loop/cel %d/%d/%d\n", nr, *loop, *cel); return NULL; } @@ -600,8 +581,8 @@ gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, int palette) if (!cel_data->data) { gfx_get_res_config(state->options, cel_data); gfx_xlate_pixmap(cel_data, state->driver->mode, state->options->view_xlate_filter); - gfxr_endianness_adjust(cel_data, state->driver->mode); - } + gfxr_endianness_adjust(cel_data, state->driver->mode); + } return view; } @@ -610,8 +591,7 @@ extern gfx_bitmap_font_t gfxfont_5x8; extern gfx_bitmap_font_t gfxfont_6x10; gfx_bitmap_font_t * -gfxr_get_font(gfx_resstate_t *state, int nr, int scaled) -{ +gfxr_get_font(gfx_resstate_t *state, int nr, int scaled) { gfx_resource_type_t restype = GFX_RESOURCE_TYPE_FONT; sbtree_t *tree = NULL; gfx_resource_t *res = NULL; @@ -625,7 +605,7 @@ gfxr_get_font(gfx_resstate_t *state, int nr, int scaled) tree = state->resource_trees[restype]; hash = gfxr_interpreter_options_hash(restype, state->version, - state->options, state->misc_payload, 0); + state->options, state->misc_payload, 0); if (!tree) return NULL; @@ -634,7 +614,7 @@ gfxr_get_font(gfx_resstate_t *state, int nr, int scaled) if (!res || res->mode != hash) { gfx_bitmap_font_t *font = gfxr_interpreter_get_font(state, nr, - state->misc_payload); + state->misc_payload); if (!font) return NULL; @@ -664,13 +644,12 @@ gfxr_get_font(gfx_resstate_t *state, int nr, int scaled) gfx_pixmap_t * -gfxr_get_cursor(gfx_resstate_t *state, int nr) -{ +gfxr_get_cursor(gfx_resstate_t *state, int nr) { gfx_resource_type_t restype = GFX_RESOURCE_TYPE_CURSOR; sbtree_t *tree = state->resource_trees[restype]; gfx_resource_t *res = NULL; int hash = gfxr_interpreter_options_hash(restype, state->version, - state->options, state->misc_payload, 0); + state->options, state->misc_payload, 0); if (!tree) return NULL; @@ -679,7 +658,7 @@ gfxr_get_cursor(gfx_resstate_t *state, int nr) if (!res || res->mode != hash) { gfx_pixmap_t *cursor = gfxr_interpreter_get_cursor(state, nr, - state->misc_payload); + state->misc_payload); if (!cursor) return NULL; @@ -696,7 +675,7 @@ gfxr_get_cursor(gfx_resstate_t *state, int nr) } gfx_get_res_config(state->options, cursor); gfx_xlate_pixmap(cursor, state->driver->mode, state->options->cursor_xlate_filter); - gfxr_endianness_adjust(cursor, state->driver->mode); + gfxr_endianness_adjust(cursor, state->driver->mode); res->unscaled_data.pointer = cursor; diff --git a/engines/sci/gfx/resource/sci_cursor_0.cpp b/engines/sci/gfx/resource/sci_cursor_0.cpp index 06a8d2b7aa..99b080ef01 100644 --- a/engines/sci/gfx/resource/sci_cursor_0.cpp +++ b/engines/sci/gfx/resource/sci_cursor_0.cpp @@ -41,12 +41,12 @@ gfx_pixmap_color_t gfx_sci01_cursor_colors[GFX_SCI01_CURSOR_COLORS_NR] = { {GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x00}, {GFX_COLOR_INDEX_UNMAPPED, 0xff, 0xff, 0xff}, - {GFX_COLOR_INDEX_UNMAPPED, 0xaa, 0xaa, 0xaa}}; + {GFX_COLOR_INDEX_UNMAPPED, 0xaa, 0xaa, 0xaa} +}; static gfx_pixmap_t * -_gfxr_draw_cursor(int id, byte *resource, int size, int sci01) -{ +_gfxr_draw_cursor(int id, byte *resource, int size, int sci01) { int colors[4] = {0, 1, GFX_CURSOR_TRANSPARENT, 1}; int line; byte *data; @@ -62,7 +62,7 @@ _gfxr_draw_cursor(int id, byte *resource, int size, int sci01) retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(CURSOR_SIZE, CURSOR_SIZE, id, 0, 0)); retval->colors = gfx_sci01_cursor_colors; - retval->colors_nr = sci01? GFX_SCI01_CURSOR_COLORS_NR : GFX_SCI0_CURSOR_COLORS_NR; + retval->colors_nr = sci01 ? GFX_SCI01_CURSOR_COLORS_NR : GFX_SCI0_CURSOR_COLORS_NR; retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; retval->color_key = GFX_CURSOR_TRANSPARENT; @@ -84,7 +84,7 @@ _gfxr_draw_cursor(int id, byte *resource, int size, int sci01) for (i = 0; i < 16; i++) { int color_code = ((mask_a << i) & 0x8000) - | (((mask_b << i) >> 1) & 0x4000); + | (((mask_b << i) >> 1) & 0x4000); *data++ = colors[color_code >> 14]; } @@ -94,14 +94,12 @@ _gfxr_draw_cursor(int id, byte *resource, int size, int sci01) gfx_pixmap_t * -gfxr_draw_cursor0(int id, byte *resource, int size) -{ +gfxr_draw_cursor0(int id, byte *resource, int size) { return _gfxr_draw_cursor(id, resource, size, 0); } gfx_pixmap_t * -gfxr_draw_cursor01(int id, byte *resource, int size) -{ +gfxr_draw_cursor01(int id, byte *resource, int size) { return _gfxr_draw_cursor(id, resource, size, 1); } diff --git a/engines/sci/gfx/resource/sci_font.cpp b/engines/sci/gfx/resource/sci_font.cpp index f1ae4edb19..adad727324 100644 --- a/engines/sci/gfx/resource/sci_font.cpp +++ b/engines/sci/gfx/resource/sci_font.cpp @@ -38,8 +38,7 @@ extern int font_counter; #define FONT_MAXCHAR_OFFSET 2 static int -calc_char(byte *dest, int total_width, int total_height, byte *src, int size) -{ +calc_char(byte *dest, int total_width, int total_height, byte *src, int size) { int width = src[0]; int height = src[1]; int byte_width = (width + 7) >> 3; @@ -68,8 +67,7 @@ calc_char(byte *dest, int total_width, int total_height, byte *src, int size) gfx_bitmap_font_t * -gfxr_read_font(int id, byte *resource, int size) -{ +gfxr_read_font(int id, byte *resource, int size) { gfx_bitmap_font_t *font = (gfx_bitmap_font_t*)sci_calloc(sizeof(gfx_bitmap_font_t), 1); int chars_nr; int max_width = 0, max_height; @@ -89,7 +87,7 @@ gfxr_read_font(int id, byte *resource, int size) if (chars_nr < 0 || chars_nr > 256 || max_height < 0) { if (chars_nr < 0 || chars_nr > 256) GFXERROR("Font %04x: Invalid number of characters: %d\n", id, - chars_nr); + chars_nr); if (max_height < 0) GFXERROR("Font %04x: Invalid font height: %d\n", id, max_height); gfxr_free_font(font); @@ -98,7 +96,7 @@ gfxr_read_font(int id, byte *resource, int size) if (size < 6 + chars_nr * 2) { GFXERROR("Font %04x: Insufficient space for %d characters in font\n", - id, chars_nr); + id, chars_nr); gfxr_free_font(font); return NULL; } @@ -111,7 +109,7 @@ gfxr_read_font(int id, byte *resource, int size) if (offset >= size) { GFXERROR("Font %04x: Error: Character 0x%02x is at offset 0x%04x (beyond 0x%04x)\n", - id, i, offset, size); + id, i, offset, size); gfxr_free_font(font); return NULL; } @@ -140,7 +138,7 @@ gfxr_read_font(int id, byte *resource, int size) int offset = get_int_16(resource + (i << 1) + 6); if (calc_char(font->data + (font->char_size * i), font->row_size, max_height, - resource + offset, size - offset)) { + resource + offset, size - offset)) { GFXERROR("Problem occured in font %04x, char %d/%d\n", id, i, chars_nr); gfxr_free_font(font); return NULL; diff --git a/engines/sci/gfx/resource/sci_pal_1.cpp b/engines/sci/gfx/resource/sci_pal_1.cpp index 2f12f8180c..97d5f7c296 100644 --- a/engines/sci/gfx/resource/sci_pal_1.cpp +++ b/engines/sci/gfx/resource/sci_pal_1.cpp @@ -38,8 +38,7 @@ #define SCI_PAL_FORMAT_CONSTANT_FLAGS 1 gfx_pixmap_color_t * -gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) -{ +gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) { int start_color = resource[25]; int format = resource[32]; int entry_size = 0; @@ -48,8 +47,7 @@ gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) int _colors_nr = *colors_nr = getUInt16(resource + 29); int i; - switch (format) - { + switch (format) { case SCI_PAL_FORMAT_VARIABLE_FLAGS : entry_size = 4; break; @@ -59,20 +57,17 @@ gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) } retval = (gfx_pixmap_color_t *) - sci_malloc(sizeof(gfx_pixmap_color_t) * (_colors_nr + start_color)); + sci_malloc(sizeof(gfx_pixmap_color_t) * (_colors_nr + start_color)); memset(retval, 0, sizeof(gfx_pixmap_color_t) * (_colors_nr + start_color)); - for (i = 0; i < start_color; i ++) - { + for (i = 0; i < start_color; i ++) { retval[i].global_index = GFX_COLOR_INDEX_UNMAPPED; retval[i].r = 0; retval[i].g = 0; retval[i].b = 0; } - for (i = start_color; i < start_color + _colors_nr; i ++) - { - switch (format) - { + for (i = start_color; i < start_color + _colors_nr; i ++) { + switch (format) { case SCI_PAL_FORMAT_CONSTANT_FLAGS: retval[i].global_index = GFX_COLOR_INDEX_UNMAPPED; retval[i].r = pal_data[0]; @@ -93,8 +88,7 @@ gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) } gfx_pixmap_color_t * -gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) -{ +gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) { int counter = 0; int pos; unsigned int colors[MAX_COLORS] = {0}; @@ -110,9 +104,9 @@ gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) while (pos < size/* && resource[pos] == COLOR_OK && counter < MAX_COLORS*/) { int color = resource[pos] - | (resource[pos + 1] << 8) - | (resource[pos + 2] << 16) - | (resource[pos + 3] << 24); + | (resource[pos + 1] << 8) + | (resource[pos + 2] << 16) + | (resource[pos + 3] << 24); pos += 4; @@ -148,8 +142,7 @@ gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) } gfx_pixmap_color_t * -gfxr_read_pal1_amiga(int *colors_nr, FILE *f) -{ +gfxr_read_pal1_amiga(int *colors_nr, FILE *f) { int i; gfx_pixmap_color_t *retval; diff --git a/engines/sci/gfx/resource/sci_pic_0.cpp b/engines/sci/gfx/resource/sci_pic_0.cpp index 88553b2c9b..158f20b3bb 100644 --- a/engines/sci/gfx/resource/sci_pic_0.cpp +++ b/engines/sci/gfx/resource/sci_pic_0.cpp @@ -51,25 +51,25 @@ int sci0_palette = 0; /* Default color maps */ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLORS_NR] = { {{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xaa}, - {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa}, - {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0xaa}, - {GFX_COLOR_SYSTEM, 0xaa, 0x55, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0xaa, 0xaa}, - {GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0x55, 0xff}, - {GFX_COLOR_SYSTEM, 0x55, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff}, - {GFX_COLOR_SYSTEM, 0xff, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff}, - {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, /* "Normal" EGA */ + {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa}, + {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0xaa}, + {GFX_COLOR_SYSTEM, 0xaa, 0x55, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0xaa, 0xaa}, + {GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0x55, 0xff}, + {GFX_COLOR_SYSTEM, 0x55, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff}, + {GFX_COLOR_SYSTEM, 0xff, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff}, + {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, /* "Normal" EGA */ {{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xff}, - {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa}, - {GFX_COLOR_SYSTEM, 0xce, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xbe, 0x71, 0xde}, - {GFX_COLOR_SYSTEM, 0x8d, 0x50, 0x00}, {GFX_COLOR_SYSTEM, 0xbe, 0xbe, 0xbe}, - {GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x00, 0xbe, 0xff}, - {GFX_COLOR_SYSTEM, 0x00, 0xce, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff}, - {GFX_COLOR_SYSTEM, 0xff, 0x9d, 0x8d}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff}, - {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x00}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, /* AGI Amiga-ish */ - -/* RGB and I intensities (former taken from the GIMP) */ + {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa}, + {GFX_COLOR_SYSTEM, 0xce, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xbe, 0x71, 0xde}, + {GFX_COLOR_SYSTEM, 0x8d, 0x50, 0x00}, {GFX_COLOR_SYSTEM, 0xbe, 0xbe, 0xbe}, + {GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x00, 0xbe, 0xff}, + {GFX_COLOR_SYSTEM, 0x00, 0xce, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff}, + {GFX_COLOR_SYSTEM, 0xff, 0x9d, 0x8d}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff}, + {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x00}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, /* AGI Amiga-ish */ + + /* RGB and I intensities (former taken from the GIMP) */ #define GR 30 #define GG 59 #define GB 11 @@ -80,13 +80,14 @@ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLO #define CC(x) (((x)*255)/FULL),(((x)*255)/FULL),(((x)*255)/FULL) /* Combines color intensities */ {{GFX_COLOR_SYSTEM, CC(0) }, {GFX_COLOR_SYSTEM, CC(GB) }, - {GFX_COLOR_SYSTEM, CC(GG) }, {GFX_COLOR_SYSTEM, CC(GB+GG) }, - {GFX_COLOR_SYSTEM, CC(GR) }, {GFX_COLOR_SYSTEM, CC(GB+GR) }, - {GFX_COLOR_SYSTEM, CC(GG+GR) }, {GFX_COLOR_SYSTEM, CC(GB+GG+GR) }, - {GFX_COLOR_SYSTEM, CC(GI) }, {GFX_COLOR_SYSTEM, CC(GB+GI) }, - {GFX_COLOR_SYSTEM, CC(GG+GI) }, {GFX_COLOR_SYSTEM, CC(GB+GG+GI) }, - {GFX_COLOR_SYSTEM, CC(GR+GI) }, {GFX_COLOR_SYSTEM, CC(GB+GR+GI) }, - {GFX_COLOR_SYSTEM, CC(GG+GR+GI) }, {GFX_COLOR_SYSTEM, CC(GB+GG+GR+GI) }}}; /* Grayscale */ + {GFX_COLOR_SYSTEM, CC(GG) }, {GFX_COLOR_SYSTEM, CC(GB + GG) }, + {GFX_COLOR_SYSTEM, CC(GR) }, {GFX_COLOR_SYSTEM, CC(GB + GR) }, + {GFX_COLOR_SYSTEM, CC(GG + GR) }, {GFX_COLOR_SYSTEM, CC(GB + GG + GR) }, + {GFX_COLOR_SYSTEM, CC(GI) }, {GFX_COLOR_SYSTEM, CC(GB + GI) }, + {GFX_COLOR_SYSTEM, CC(GG + GI) }, {GFX_COLOR_SYSTEM, CC(GB + GG + GI) }, + {GFX_COLOR_SYSTEM, CC(GR + GI) }, {GFX_COLOR_SYSTEM, CC(GB + GR + GI) }, + {GFX_COLOR_SYSTEM, CC(GG + GR + GI) }, {GFX_COLOR_SYSTEM, CC(GB + GG + GR + GI) }} +}; /* Grayscale */ #undef GR #undef GG @@ -115,33 +116,31 @@ int fillmagc = 30000000; /* Color mapping used while scaling embedded views. */ gfx_pixmap_color_t embedded_view_colors[16] = { {0x00, 0, 0, 0}, {0x11, 0, 0, 0}, {0x22, 0, 0, 0}, {0x33, 0, 0, 0}, - {0x44, 0, 0, 0}, {0x55, 0, 0, 0}, {0x66, 0, 0, 0}, {0x77, 0, 0, 0}, - {0x88, 0, 0, 0}, {0x99, 0, 0, 0}, {0xaa, 0, 0, 0}, {0xbb, 0, 0, 0}, - {0xcc, 0, 0, 0}, {0xdd, 0, 0, 0}, {0xee, 0, 0, 0}, {0xff, 0, 0, 0} + {0x44, 0, 0, 0}, {0x55, 0, 0, 0}, {0x66, 0, 0, 0}, {0x77, 0, 0, 0}, + {0x88, 0, 0, 0}, {0x99, 0, 0, 0}, {0xaa, 0, 0, 0}, {0xbb, 0, 0, 0}, + {0xcc, 0, 0, 0}, {0xdd, 0, 0, 0}, {0xee, 0, 0, 0}, {0xff, 0, 0, 0} }; void -gfxr_init_static_palette() -{ +gfxr_init_static_palette() { if (!_gfxr_pic0_colors_initialized) { for (int i = 0; i < 256; i++) { gfx_sci0_pic_colors[i].global_index = GFX_COLOR_INDEX_UNMAPPED; gfx_sci0_pic_colors[i].r = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].r, - gfx_sci0_image_colors[sci0_palette][i >> 4].r); + gfx_sci0_image_colors[sci0_palette][i >> 4].r); gfx_sci0_pic_colors[i].g = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].g, - gfx_sci0_image_colors[sci0_palette][i >> 4].g); + gfx_sci0_image_colors[sci0_palette][i >> 4].g); gfx_sci0_pic_colors[i].b = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].b, - gfx_sci0_image_colors[sci0_palette][i >> 4].b); + gfx_sci0_image_colors[sci0_palette][i >> 4].b); } //WARNING("Uncomment me after fixing sci0_palette changes to reset me"); - /* _gfxr_pic0_colors_initialized = 1; */ + /* _gfxr_pic0_colors_initialized = 1; */ } } gfxr_pic_t * -gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) -{ +gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) { gfxr_pic_t *pic = (gfxr_pic_t*)sci_malloc(sizeof(gfxr_pic_t)); pic->mode = mode; @@ -149,11 +148,11 @@ gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) pic->control_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, ID, 2, 0)); pic->priority_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(mode->xfact * 320, mode->yfact * 200, - ID, 1, 0)); + ID, 1, 0)); pic->visual_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320 * mode->xfact, - 200 * mode->yfact, ID, 0, 0)); + 200 * mode->yfact, ID, 0, 0)); pic->visual_map->colors = gfx_sci0_pic_colors; pic->visual_map->colors_nr = GFX_SCI0_PIC_COLORS_NR; pic->visual_map->color_key = GFX_PIXMAP_COLOR_KEY_NONE; @@ -190,8 +189,7 @@ gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) /****************************/ void -gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) -{ +gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) { memset(pic->visual_map->index_data, 0x00, (320 * pic->mode->xfact * sci_titlebar_size * pic->mode->yfact)); memset(pic->visual_map->index_data + (320 * pic->mode->xfact * sci_titlebar_size * pic->mode->yfact), 0xff, pic->mode->xfact * 320 * pic->mode->yfact * (200 - sci_titlebar_size)); /* white */ @@ -228,8 +226,7 @@ gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) buffer[linewidth * y + x] operation color; static void -_gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int sci_titlebar_size) -{ +_gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int sci_titlebar_size) { int dx, dy, incrE, incrNE, d, finalx, finaly; int x = line.x; int y = line.y + sci_titlebar_size; @@ -276,8 +273,7 @@ _gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int } static void -_gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titlebar_size) -{ +_gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titlebar_size) { int dx, dy, incrE, incrNE, d, finalx, finaly; int x = line.x; int y = line.y + sci_titlebar_size; @@ -328,16 +324,15 @@ _gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titleba #ifdef WITH_PIC_SCALING static void -_gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) -{ +_gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) { /* Propagates all filled bits into the planes described by bitmask */ unsigned long *data = (unsigned long *) pic->aux_map; unsigned long clearmask = 0x07070707; unsigned long andmask = - (bitmask << 3) - | (bitmask << (3+8)) - | (bitmask << (3+16)) - | (bitmask << (3+24)); + (bitmask << 3) + | (bitmask << (3 + 8)) + | (bitmask << (3 + 16)) + | (bitmask << (3 + 24)); if (sizeof(unsigned long) == 8) { /* UltraSparc, Alpha, newer MIPSens, etc */ andmask |= (andmask << 32); @@ -355,8 +350,7 @@ _gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) static inline void -_gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) -{ +_gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) { int i; for (i = 0; i < width; i++) pic->aux_map[i+pos] |= FRESH_PAINT; @@ -365,15 +359,14 @@ _gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) #if 0 // Unreferenced - removed static void -_gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *max_y) -{ +_gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *max_y) { /* Tries to spread by approximating the first derivation of the border function. ** Draws to the current and the last line, thus taking up to twice as long as neccessary. ** Other than that, it's O(n^2) */ int intervals_nr = 0, old_intervals_nr; - int x, y, i, pos = 10*320; + int x, y, i, pos = 10 * 320; struct interval_struct { int xl, xr, tag; } intervals[2][160]; @@ -383,11 +376,11 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - fprintf(stderr,"------------------------------------------------\n"); - fprintf(stderr,"LineID: "); + fprintf(stderr, "------------------------------------------------\n"); + fprintf(stderr, "LineID: "); for (i = 0; i < 5; i++) - fprintf(stderr," %d ", i); - fprintf(stderr,"\n"); + fprintf(stderr, " %d ", i); + fprintf(stderr, "\n"); } #endif @@ -419,10 +412,10 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma i = old_intervals_start_offset; while (!done && i < old_intervals_nr) { - if (intervals[!ivi][i].xl > xr+1) + if (intervals[!ivi][i].xl > xr + 1) done = 1; - else if (intervals[!ivi][i].xr < xl-1) { + else if (intervals[!ivi][i].xr < xl - 1) { int o_xl = intervals[!ivi][i].xl; int o_xr = intervals[!ivi][i].xr; if (o_xr == o_xl && !intervals[!ivi][i].tag) { /* thin bar */ @@ -444,7 +437,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma int write_left_width, write_right_width; intervals[!ivi][i].tag = 1; - while (k+1 < old_intervals_nr && intervals[!ivi][k+1].xl <= xr) { + while (k + 1 < old_intervals_nr && intervals[!ivi][k+1].xl <= xr) { ++k; intervals[!ivi][i].tag = 1; } @@ -453,10 +446,10 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma dwidth_r = abs(old_xr - xr); /* Current line */ - write_left_width = (dwidth_l > xl)? xl : dwidth_l; + write_left_width = (dwidth_l > xl) ? xl : dwidth_l; _gfxr_auxbuf_tag_line(pic, pos + xl - write_left_width, write_left_width); - write_right_width = (dwidth_r + xr > 319)? 320 - xr : dwidth_r; + write_right_width = (dwidth_r + xr > 319) ? 320 - xr : dwidth_r; _gfxr_auxbuf_tag_line(pic, pos + xr, write_right_width); if (xl - write_left_width < *min_x) @@ -465,15 +458,15 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma *max_x = xr + write_right_width; /* Previous line */ - write_left_width = (dwidth_l > old_xl)? old_xl : dwidth_l; - write_right_width = (dwidth_r + old_xr > 319)? 320 - old_xr : dwidth_r; + write_left_width = (dwidth_l > old_xl) ? old_xl : dwidth_l; + write_right_width = (dwidth_r + old_xr > 319) ? 320 - old_xr : dwidth_r; if (i == k) { /* Only one predecessor interval */ _gfxr_auxbuf_tag_line(pic, pos - 320 + old_xl - write_left_width, write_left_width); _gfxr_auxbuf_tag_line(pic, pos - 320 + old_xr, write_right_width); } else /* Fill entire line */ _gfxr_auxbuf_tag_line(pic, pos - 320 + old_xl - write_left_width, old_xr - old_xl - + 1 + write_left_width + write_right_width); + + 1 + write_left_width + write_right_width); if (xl - write_left_width < *min_x) *min_x = xl - write_left_width; @@ -489,10 +482,10 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc && intervals_nr) { - fprintf(stderr,"AI L#%03d:", y); + fprintf(stderr, "AI L#%03d:", y); for (int j = 0; j < intervals_nr; j++) - fprintf(stderr, "%c[%03d,%03d]", intervals[ivi][j].tag? ' ':'-', intervals[ivi][j].xl, intervals[ivi][j].xr); - fprintf(stderr,"\n"); + fprintf(stderr, "%c[%03d,%03d]", intervals[ivi][j].tag ? ' ' : '-', intervals[ivi][j].xl, intervals[ivi][j].xr); + fprintf(stderr, "\n"); } #endif @@ -505,7 +498,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma pos += 320; } - for (pos = 320*200 - 1; pos >= 320; pos--) + for (pos = 320 * 200 - 1; pos >= 320; pos--) if (pic->aux_map[pos - 320] & 0x40) pic->aux_map[pos] |= 0x40; @@ -560,13 +553,13 @@ enum { #define SCI1_OP_OFFSET 42 enum { - PIC_SCI1_OPX_SET_PALETTE_ENTRIES = 0+SCI1_OP_OFFSET, - PIC_SCI1_OPX_EMBEDDED_VIEW = 1+SCI1_OP_OFFSET, - PIC_SCI1_OPX_SET_PALETTE = 2+SCI1_OP_OFFSET, - PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST = 3+SCI1_OP_OFFSET, - PIC_SCI1_OPX_PRIORITY_TABLE_EXPLICIT = 4+SCI1_OP_OFFSET + PIC_SCI1_OPX_SET_PALETTE_ENTRIES = 0 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_EMBEDDED_VIEW = 1 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_SET_PALETTE = 2 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST = 3 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_PRIORITY_TABLE_EXPLICIT = 4 + SCI1_OP_OFFSET }; - + #ifdef GFXR_DEBUG_PIC0 #define p0printf sciprintf @@ -583,15 +576,14 @@ enum { static void _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, - int rad_x, int rad_y, int color, int fillstyle) -{ + int rad_x, int rad_y, int color, int fillstyle) { int xx = 0, yy = rad_y; int i, x_i, y_i; int xr = 2 * rad_x * rad_x; int yr = 2 * rad_y * rad_y; x_i = 1; - y_i = xr * rad_y -1; + y_i = xr * rad_y - 1; i = y_i >> 1; while (yy >= 0) { @@ -612,11 +604,11 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, if (oldyy != yy) { int j; - int offset0 = (y-oldyy) * linewidth; - int offset1 = (y+oldyy) * linewidth; + int offset0 = (y - oldyy) * linewidth; + int offset1 = (y + oldyy) * linewidth; - offset0 += x-oldxx; - offset1 += x-oldxx; + offset0 += x - oldxx; + offset1 += x - oldxx; if (oldyy == 0) offset1 = 0; /* We never have to draw ellipses in the menu bar */ @@ -632,7 +624,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, break; case ELLIPSE_OR: - for (j=0; j < (oldxx << 1) + 1; j++) { + for (j = 0; j < (oldxx << 1) + 1; j++) { buffer[offset0 + j] |= color; if (offset1) buffer[offset1 + j] |= color; @@ -640,7 +632,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, break; default: - fprintf(stderr,"%s L%d: Invalid ellipse fill mode!\n", __FILE__, __LINE__); + fprintf(stderr, "%s L%d: Invalid ellipse fill mode!\n", __FILE__, __LINE__); return; } @@ -650,8 +642,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, static inline void _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int plot, - int color, gfx_brush_mode_t brush_mode, int randseed) -{ + int color, gfx_brush_mode_t brush_mode, int randseed) { /* yoffset 63680, offset 320, plot 1, color 34, brush_mode 0, randseed 432)*/ /* Auxplot: Used by plot_aux_pattern to plot to visual and priority */ int xc, yc; @@ -673,38 +664,38 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int case GFX_BRUSH_MODE_ELLIPSES: if (plot) { - int x = offset * pic->mode->xfact + ((pic->mode->xfact -1) >> 1); - int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact -1) >> 1); /* Ouch! */ + int x = offset * pic->mode->xfact + ((pic->mode->xfact - 1) >> 1); + int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1); /* Ouch! */ _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1, - color, ELLIPSE_SOLID); + color, ELLIPSE_SOLID); } break; case GFX_BRUSH_MODE_RANDOM_ELLIPSES: if (plot) { - int x = offset * pic->mode->xfact + ((pic->mode->xfact -1) >> 1); - int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact -1) >> 1); /* Ouch! */ + int x = offset * pic->mode->xfact + ((pic->mode->xfact - 1) >> 1); + int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1); /* Ouch! */ int sizex = pic->mode->xfact >> 1; int sizey = pic->mode->yfact >> 1; srand(randseed); - x -= (int) ((sizex * rand()*1.0)/(RAND_MAX + 1.0)); - x += (int) ((sizex * rand()*1.0)/(RAND_MAX + 1.0)); - y -= (int) ((sizey * rand()*1.0)/(RAND_MAX + 1.0)); - y += (int) ((sizey * rand()*1.0)/(RAND_MAX + 1.0)); - sizex = (int) ((sizex * rand()*1.0)/(RAND_MAX + 1.0)); - sizey = (int) ((sizey * rand()*1.0)/(RAND_MAX + 1.0)); + x -= (int)((sizex * rand() * 1.0) / (RAND_MAX + 1.0)); + x += (int)((sizex * rand() * 1.0) / (RAND_MAX + 1.0)); + y -= (int)((sizey * rand() * 1.0) / (RAND_MAX + 1.0)); + y += (int)((sizey * rand() * 1.0) / (RAND_MAX + 1.0)); + sizex = (int)((sizex * rand() * 1.0) / (RAND_MAX + 1.0)); + sizey = (int)((sizey * rand() * 1.0) / (RAND_MAX + 1.0)); _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1, - color, ELLIPSE_SOLID); + color, ELLIPSE_SOLID); srand(time(NULL)); /* Make sure we don't accidently forget to re-init the random number generator */ } break; case GFX_BRUSH_MODE_MORERANDOM: { - int mask = plot? 7 : 1; + int mask = plot ? 7 : 1; srand(randseed); for (yc = 0; yc < pic->mode->yfact; yc++) { for (xc = 0; xc < pic->mode->xfact; xc++) @@ -722,9 +713,8 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int static void _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int random, - int mask, int color, int priority, int control, - gfx_brush_mode_t brush_mode, int map_nr) -{ + int mask, int color, int priority, int control, + gfx_brush_mode_t brush_mode, int map_nr) { /* Plots an appropriate pattern to the aux buffer and the control buffer, ** if mask & GFX_MASK_CONTROL ** random should be set to the random index, or -1 to disable @@ -739,13 +729,15 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int {4, 4, 4, 3, 1}, {5, 5, 4, 4, 3, 1}, {6, 6, 6, 5, 5, 4, 2}, - {7, 7, 7, 6, 6, 5, 4, 2}}; + {7, 7, 7, 6, 6, 5, 4, 2} + }; /* 'Random' fill patterns, provided by Carl Muckenhoupt: */ byte random_data[32] = { 0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2, 0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14, 0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10, - 0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04}; + 0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04 + }; /* 'Random' fill offsets, provided by Carl Muckenhoupt: */ byte random_offset[128] = { @@ -773,9 +765,15 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int gfx_pixmap_t *map = NULL; switch (map_nr) { - case GFX_MASK_VISUAL: map = pic->visual_map; break; - case GFX_MASK_PRIORITY: map = pic->priority_map; break; - default: map = pic->control_map; break; + case GFX_MASK_VISUAL: + map = pic->visual_map; + break; + case GFX_MASK_PRIORITY: + map = pic->priority_map; + break; + default: + map = pic->control_map; + break; } if (random >= 0) @@ -816,24 +814,24 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int if (mask & GFX_MASK_VISUAL) _gfxr_auxplot_brush(pic, pic->visual_map->index_data, - yoffset, x + offset + j, - 1, color, brush_mode, random_index + x); + yoffset, x + offset + j, + 1, color, brush_mode, random_index + x); if (mask & GFX_MASK_PRIORITY) _gfxr_auxplot_brush(pic, pic->priority_map->index_data, - yoffset, x + offset + j, - 1, priority, brush_mode, random_index + x); + yoffset, x + offset + j, + 1, priority, brush_mode, random_index + x); } else { if (mask & GFX_MASK_VISUAL) _gfxr_auxplot_brush(pic, pic->visual_map->index_data, - yoffset, x + offset + j, - 0, color, brush_mode, random_index + x); + yoffset, x + offset + j, + 0, color, brush_mode, random_index + x); if (mask & GFX_MASK_PRIORITY) _gfxr_auxplot_brush(pic, pic->priority_map->index_data, - yoffset, x + offset + j, - 0, priority, brush_mode, random_index + x); + yoffset, x + offset + j, + 0, priority, brush_mode, random_index + x); } random_index = (random_index + 1) & 0xff; } @@ -846,14 +844,13 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int static void _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int control, int drawenable, - int pattern_code, int pattern_size, int pattern_nr, gfx_brush_mode_t brush_mode, - int sci_titlebar_size) -{ + int pattern_code, int pattern_size, int pattern_nr, gfx_brush_mode_t brush_mode, + int sci_titlebar_size) { int xsize = (pattern_size + 1) * pic->mode->xfact - 1; int ysize = (pattern_size + 1) * pic->mode->yfact - 1; int scaled_x, scaled_y; rect_t boundaries; - int max_x = (pattern_code & PATTERN_FLAG_RECTANGLE)? 318 : 319; /* Rectangles' width is size+1 */ + int max_x = (pattern_code & PATTERN_FLAG_RECTANGLE) ? 318 : 319; /* Rectangles' width is size+1 */ p0printf(stderr, "Pattern at (%d,%d) size %d, rand=%d, code=%02x\n", x, y, pattern_size, pattern_nr, pattern_code); @@ -896,15 +893,15 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c if (pattern_code & PATTERN_FLAG_USE_PATTERN) { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0, pattern_nr, - drawenable, color, priority, - control, brush_mode, GFX_MASK_CONTROL); + drawenable, color, priority, + control, brush_mode, GFX_MASK_CONTROL); } else { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, control, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_CONTROL); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, control, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_CONTROL); if (drawenable & GFX_MASK_VISUAL) gfx_draw_box_pixmap_i(pic->visual_map, boundaries, color); @@ -919,42 +916,42 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c if (pattern_code & PATTERN_FLAG_USE_PATTERN) { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, pattern_nr, - drawenable, color, priority, - control, brush_mode, GFX_MASK_CONTROL); + drawenable, color, priority, + control, brush_mode, GFX_MASK_CONTROL); } else { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, control, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_CONTROL); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, control, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_CONTROL); if (pic->mode->xfact == 1 && pic->mode->yfact == 1) { if (drawenable & GFX_MASK_VISUAL) _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, color, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_VISUAL); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, color, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_VISUAL); if (drawenable & GFX_MASK_PRIORITY) _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, priority, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_PRIORITY); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, priority, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_PRIORITY); } else { if (drawenable & GFX_MASK_VISUAL) _gfxr_fill_ellipse(pic, pic->visual_map->index_data, 320 * pic->mode->xfact, - scaled_x, scaled_y, xsize, ysize, - color, ELLIPSE_SOLID); + scaled_x, scaled_y, xsize, ysize, + color, ELLIPSE_SOLID); if (drawenable & GFX_MASK_PRIORITY) _gfxr_fill_ellipse(pic, pic->priority_map->index_data, 320 * pic->mode->xfact, - scaled_x, scaled_y, xsize, ysize, - priority, ELLIPSE_SOLID); + scaled_x, scaled_y, xsize, ysize, + priority, ELLIPSE_SOLID); } } } @@ -962,21 +959,20 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c static inline void -_gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int priority, int drawenable) -{ +_gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int priority, int drawenable) { point_t start; point_t end; - + start.x = x; start.y = y; end.x = ex; end.y = ey; - if (ex >= pic->visual_map->index_xl || ey >= pic->visual_map->index_yl || x < 0 || y < 0) { - fprintf(stderr,"While drawing pic0: INVALID LINE %d,%d,%d,%d\n", - GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); - return; - } + if (ex >= pic->visual_map->index_xl || ey >= pic->visual_map->index_yl || x < 0 || y < 0) { + fprintf(stderr, "While drawing pic0: INVALID LINE %d,%d,%d,%d\n", + GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); + return; + } if (drawenable & GFX_MASK_VISUAL) gfx_draw_line_pixmap_i(pic->visual_map, start, end, color); @@ -988,16 +984,15 @@ _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int static void _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, - int priority, int control, int drawenable, int line_mode, - int cmd, int sci_titlebar_size) -{ + int priority, int control, int drawenable, int line_mode, + int cmd, int sci_titlebar_size) { int scale_x = pic->mode->xfact; int scale_y = pic->mode->yfact; int xc, yc; rect_t line; int mask; int partially_white = (drawenable & GFX_MASK_VISUAL) - && (((color & 0xf0) == 0xf0) || ((color & 0x0f) == 0x0f)); + && (((color & 0xf0) == 0xf0) || ((color & 0x0f) == 0x0f)); line.x = x; line.y = y; @@ -1005,7 +1000,7 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, line.yl = ey - y; if (x > 319 || y > 199 || x < 0 || y < 0 - || ex > 319 || ey > 199 || ex < 0 || ey < 0) { + || ex > 319 || ey > 199 || ex < 0 || ey < 0) { GFXWARN("While building pic: Attempt to draw line (%d,%d) to (%d,%d): cmd was %d\n", x, y, ex, ey, cmd); return; } @@ -1022,11 +1017,11 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, /* Calculate everything that is changed to SOLID */ mask = drawenable & - ( - ((color != 0xff)? 1 : 0) - | ((priority)? 2 : 0) - | ((control)? 4 : 0) - ); + ( + ((color != 0xff) ? 1 : 0) + | ((priority) ? 2 : 0) + | ((control) ? 4 : 0) + ); if (mask) { int mask2 = mask; @@ -1037,11 +1032,11 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, /* Calculate everything that is changed to TRANSPARENT */ mask = drawenable & - ( - ((color == 0xff)? 1 : 0) - | ((!priority)? 2 : 0) - | ((!control)? 4 : 0) - ); + ( + ((color == 0xff) ? 1 : 0) + | ((!priority) ? 2 : 0) + | ((!control) ? 4 : 0) + ); if (mask) _gfxr_auxbuf_line_clear(pic, line, ~mask, sci_titlebar_size); @@ -1093,29 +1088,29 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, for (xc = 0; xc < width; xc++) _gfxr_draw_subline(pic, - x + xc + x_offset, y + y_offset, - ex + xc + x_offset, ey + y_offset, - color, priority, drawenable); + x + xc + x_offset, y + y_offset, + ex + xc + x_offset, ey + y_offset, + color, priority, drawenable); if (height > 0) for (xc = 0; xc < width; xc++) _gfxr_draw_subline(pic, - x + xc + x_offset, y + height - 1 + y_offset, - ex + xc + x_offset, ey + height - 1 + y_offset, - color, priority, drawenable); + x + xc + x_offset, y + height - 1 + y_offset, + ex + xc + x_offset, ey + height - 1 + y_offset, + color, priority, drawenable); if (height > 1) { for (yc = 1; yc < height - 1; yc++) _gfxr_draw_subline(pic, - x + x_offset, y + yc + y_offset, - ex + x_offset, ey + yc + y_offset, - color, priority, drawenable); + x + x_offset, y + yc + y_offset, + ex + x_offset, ey + yc + y_offset, + color, priority, drawenable); if (width > 0) for (yc = 1; yc < height - 1; yc++) _gfxr_draw_subline(pic, - x + width - 1 + x_offset, y + yc + y_offset, - ex + width - 1 + x_offset, ey + yc + y_offset, - color, priority, drawenable); + x + width - 1 + x_offset, y + yc + y_offset, + ex + width - 1 + x_offset, ey + yc + y_offset, + color, priority, drawenable); } } } @@ -1145,15 +1140,14 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, static inline int /* returns -1 on failure, 0 on success */ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_y, int x_320, - int y_200, int color, int drawenable, int *x, int *y) -{ + int y_200, int color, int drawenable, int *x, int *y) { int linewidth = pic->mode->xfact * 320; int mpos, ix, iy; int size_x = (max_x - min_x + 1) >> 1; int size_y = (max_y - min_y + 1) >> 1; int mid_x = min_x + size_x; int mid_y = min_y + size_y; - int max_size = (size_x > size_y)? size_x : size_y; + int max_size = (size_x > size_y) ? size_x : size_y; int size; int legalcolor; int legalmask; @@ -1169,7 +1163,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ if ((color & 0xf) == 0xf /* When dithering with white, do more ** conservative checks */ - || (color & 0xf0) == 0xf0) + || (color & 0xf0) == 0xf0) legalcolor = 0xff; else legalcolor = 0xf0; /* Only check the second color */ @@ -1188,7 +1182,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ int i; if (size <= size_y) { - int limited_size = (size > size_x)? size_x : size; + int limited_size = (size > size_x) ? size_x : size; for (i = mid_x - limited_size; i <= mid_x + limited_size; i++) { TEST_POINT(i, mid_y - size); @@ -1197,7 +1191,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ } if (size <= size_x) { - int limited_size = (size - 1 > size_y)? size_y : size - 1; + int limited_size = (size - 1 > size_y) ? size_y : size - 1; for (i = mid_y - limited_size; i <= mid_y + limited_size; i++) { TEST_POINT(mid_x - size, i); @@ -1269,8 +1263,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ inline static void -check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r, byte u, byte d) -{ +check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r, byte u, byte d) { if (*dest == legalcolor) { if (*srcp == legalcolor) return; @@ -1303,8 +1296,7 @@ check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r void -gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) -{ +gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) { int x_320, y_200; int bound_x = dest->mode->xfact; int bound_y = dest->mode->yfact; @@ -1330,11 +1322,11 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) for (sub_y = 0; sub_y < bound_y; sub_y++) { for (sub_x = 0; sub_x < bound_x; sub_x++) { check_and_remove_artifact(dest->visual_map->index_data + write_offset, - src_visualp, (int)0xff, - (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); + src_visualp, (int)0xff, + (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); check_and_remove_artifact(dest->priority_map->index_data + write_offset, - src_priorityp, 0, - (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); + src_priorityp, 0, + (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); ++write_offset; } write_offset += scaled_line_size - bound_x; @@ -1347,34 +1339,30 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) static void view_transparentize(gfx_pixmap_t *view, byte *pic_index_data, - int posx, int posy, - int width, int height) -{ - int i,j; - - for (i=0;iindex_data[j*width+i] == view->color_key) - { - view->index_data[j*width+i] = - pic_index_data[(j+posy)*width+i+posx]; + int posx, int posy, + int width, int height) { + int i, j; + + for (i = 0;i < width;i++) + for (j = 0;j < height;j++) { + if (view->index_data[j*width+i] == view->color_key) { + view->index_data[j*width+i] = + pic_index_data[(j+posy)*width+i+posx]; } } } extern gfx_pixmap_t * -gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored); + gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored); extern gfx_pixmap_t * -gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game); + gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game); extern void -_gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp); + _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp); void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, - byte *resource, gfxr_pic0_params_t *style, int resid, int sci1, - gfx_pixmap_color_t *static_pal, int static_pal_nr) -{ + byte *resource, gfxr_pic0_params_t *style, int resid, int sci1, + gfx_pixmap_color_t *static_pal, int static_pal_nr) { const int default_palette_table[GFXR_PIC0_PALETTE_SIZE] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x88, @@ -1461,7 +1449,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, pal = *(resource + pos++); index = pal % GFXR_PIC0_PALETTE_SIZE; pal /= GFXR_PIC0_PALETTE_SIZE; /* Ignore pal */ - + priority = priority_table[index]; } else priority = *(resource + pos++); @@ -1486,7 +1474,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); while (*(resource + pos) < PIC_OP_FIRST) { if (pattern_code & PATTERN_FLAG_USE_PATTERN) { @@ -1497,7 +1485,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_REL_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); } goto end_op_loop; @@ -1507,16 +1495,17 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(oldx, oldy); while (*(resource + pos) < PIC_OP_FIRST) { #if 0 - fprintf(stderr,"Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, - 0xff & resource[pos], 0xff & resource[pos+1], *((signed char *) resource + pos + 1)); + fprintf(stderr, "Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, + 0xff & resource[pos], 0xff & resource[pos+1], *((signed char *) resource + pos + 1)); #endif GET_MEDREL_COORDS(oldx, oldy); #if 0 fprintf(stderr, " to %d,%d\n", x, y); #endif - _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, - PIC_OP_MEDIUM_LINES, sci_titlebar_size); - oldx = x; oldy = y; + _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, + PIC_OP_MEDIUM_LINES, sci_titlebar_size); + oldx = x; + oldy = y; } goto end_op_loop; @@ -1525,10 +1514,11 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, p0printf("Long lines @%d\n", pos); GET_ABS_COORDS(oldx, oldy); while (*(resource + pos) < PIC_OP_FIRST) { - GET_ABS_COORDS(x,y); - _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, - PIC_OP_LONG_LINES, sci_titlebar_size); - oldx = x; oldy = y; + GET_ABS_COORDS(x, y); + _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, + PIC_OP_LONG_LINES, sci_titlebar_size); + oldx = x; + oldy = y; } goto end_op_loop; @@ -1536,12 +1526,14 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, case PIC_OP_SHORT_LINES: p0printf("Short lines @%d\n", pos); GET_ABS_COORDS(oldx, oldy); - x = oldx; y = oldy; + x = oldx; + y = oldy; while (*(resource + pos) < PIC_OP_FIRST) { - GET_REL_COORDS(x,y); - _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, - PIC_OP_SHORT_LINES, sci_titlebar_size); - oldx = x; oldy = y; + GET_REL_COORDS(x, y); + _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, + PIC_OP_SHORT_LINES, sci_titlebar_size); + oldx = x; + oldy = y; } goto end_op_loop; @@ -1555,14 +1547,14 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /*fprintf(stderr,"C=(%d,%d)\n", x, y + sci_titlebar_size);*/ #ifdef WITH_PIC_SCALING if (pic->mode->xfact > 1 - || pic->mode->yfact > 1) - _gfxr_fill_any(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY)? - color : 0, priority, control, drawenable, sci_titlebar_size); + || pic->mode->yfact > 1) + _gfxr_fill_any(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY) ? + color : 0, priority, control, drawenable, sci_titlebar_size); else #endif - _gfxr_fill_1(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY)? - color : 0, priority, control, drawenable, sci_titlebar_size); + _gfxr_fill_1(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY) ? + color : 0, priority, control, drawenable, sci_titlebar_size); if (fill_count++ > SCI_PIC0_MAX_FILL) { sci_sched_yield(); @@ -1571,7 +1563,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - int x,y; + int x, y; if (getenv("FOO1")) for (x = 0; x < 320; x++) for (y = 0; y < 200; y++) { @@ -1603,7 +1595,8 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, pic->visual_map->index_data[x + y*320*pic->mode->xfact] = pix; } return; - } --fillmagc; + } + --fillmagc; #endif /* GFXR_DEBUG_PIC0 */ } goto end_op_loop; @@ -1627,7 +1620,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); } goto end_op_loop; @@ -1655,9 +1648,10 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(oldx, oldy); _gfxr_draw_pattern(pic, oldx, oldy, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); - x = oldx; y = oldy; + x = oldx; + y = oldy; while (*(resource + pos) < PIC_OP_FIRST) { if (pattern_code & PATTERN_FLAG_USE_PATTERN) { pattern_nr = ((*(resource + pos++)) >> 1) & 0x7f; @@ -1667,7 +1661,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_MEDREL_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); } goto end_op_loop; @@ -1724,7 +1718,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, p0printf("Set palette @%d\n", pos); pic->visual_map->flags &= ~GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; pic->visual_map->colors = gfxr_read_pal1(resid, &pic->visual_map->colors_nr, - resource+pos, SCI1_PALETTE_SIZE); + resource + pos, SCI1_PALETTE_SIZE); pos += SCI1_PALETTE_SIZE; goto end_op_loop; @@ -1748,11 +1742,10 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, case PIC_SCI0_OPX_EMBEDDED_VIEW: - case PIC_SCI1_OPX_EMBEDDED_VIEW: - { + case PIC_SCI1_OPX_EMBEDDED_VIEW: { int posx, posy; int bytesize; -/* byte *vismap = pic->visual_map->index_data; */ + /* byte *vismap = pic->visual_map->index_data; */ int nodraw = 0; gfx_pixmap_t *view; @@ -1762,27 +1755,27 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /* Set up mode structure for resizing the view */ mode = gfx_new_mode( - pic->visual_map->index_xl/320, - pic->visual_map->index_yl/200, - 1, /* 1bpp, which handles masks and the rest for us */ - 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); + pic->visual_map->index_xl / 320, + pic->visual_map->index_yl / 200, + 1, /* 1bpp, which handles masks and the rest for us */ + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); GET_ABS_COORDS(posx, posy); - bytesize = (*(resource + pos))+(*(resource + pos + 1) << 8); + bytesize = (*(resource + pos)) + (*(resource + pos + 1) << 8); p0printf("(%d, %d)\n", posx, posy); pos += 2; - if (!sci1 && !nodraw) - view = gfxr_draw_cel0(-1,-1,-1, resource + pos, bytesize, NULL, 0); + if (!sci1 && !nodraw) + view = gfxr_draw_cel0(-1, -1, -1, resource + pos, bytesize, NULL, 0); else - view = gfxr_draw_cel1(-1,-1,-1, 0, resource + pos, bytesize, NULL, - static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR); - pos+=bytesize; + view = gfxr_draw_cel1(-1, -1, -1, 0, resource + pos, bytesize, NULL, + static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR); + pos += bytesize; if (nodraw) continue; - p0printf("(%d, %d)-(%d, %d)\n", - posx, - posy, - posx + view->index_xl, - posy + view->index_yl); + p0printf("(%d, %d)-(%d, %d)\n", + posx, + posy, + posx + view->index_xl, + posy + view->index_yl); /* we can only safely replace the palette if it's static *if it's not for some reason, we should die @@ -1793,7 +1786,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /* For SCI0, use special color mapping to copy the low ** nibble of the color index to the high - ** nibble. + ** nibble. */ if (sci1) { if (static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR) { @@ -1815,35 +1808,33 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE); if (flags & DRAWPIC01_FLAG_OVERLAID_PIC) - view_transparentize(view, pic->visual_map->index_data, - posx, sci_titlebar_size+posy, - view->index_xl, view->index_yl); - - _gfx_crossblit_simple(pic->visual_map->index_data+(sci_titlebar_size*320)+ - posy*320+posx, - view->index_data, - pic->visual_map->index_xl, view->index_xl, - view->index_xl, - view->index_yl, - 1); + view_transparentize(view, pic->visual_map->index_data, + posx, sci_titlebar_size + posy, + view->index_xl, view->index_yl); + + _gfx_crossblit_simple(pic->visual_map->index_data + (sci_titlebar_size*320) + + posy*320 + posx, + view->index_data, + pic->visual_map->index_xl, view->index_xl, + view->index_xl, + view->index_yl, + 1); gfx_free_mode(mode); gfx_free_pixmap(NULL, view); } goto end_op_loop; - case PIC_SCI0_OPX_SET_PRIORITY_TABLE: + case PIC_SCI0_OPX_SET_PRIORITY_TABLE: case PIC_SCI1_OPX_PRIORITY_TABLE_EXPLICIT: { int *pri_table; p0printf("Explicit priority table @%d\n", pos); - if (!pic->internal) - { - pic->internal = sci_malloc(16 * sizeof(int)); - } else - { - GFXERROR("pic->internal is not NULL (%08x); this only occurs with overlaid pics, otherwise it's a bug!\n", pic->internal); - } + if (!pic->internal) { + pic->internal = sci_malloc(16 * sizeof(int)); + } else { + GFXERROR("pic->internal is not NULL (%08x); this only occurs with overlaid pics, otherwise it's a bug!\n", pic->internal); + } pri_table = (int*)pic->internal; @@ -1853,32 +1844,30 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, for (int i = 1; i < 15; i++) pri_table[i] = resource[pos++]; } - goto end_op_loop; + goto end_op_loop; - case PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST: - { + case PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST: { int first = getInt16(resource + pos); int last = getInt16(resource + pos + 2); int nr; int *pri_table; - if (!pic->internal) - { - pic->internal = sci_malloc(16 * sizeof(int)); - } else - { - GFXERROR("pic->internal is not NULL (%08x); possible memory corruption!\n", pic->internal); - } + if (!pic->internal) { + pic->internal = sci_malloc(16 * sizeof(int)); + } else { + GFXERROR("pic->internal is not NULL (%08x); possible memory corruption!\n", pic->internal); + } pri_table = (int*)pic->internal; - + for (nr = 0; nr < 16; nr ++) - pri_table[nr] = SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr); + pri_table[nr] = SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr); pos += 4; goto end_op_loop; } - default: sciprintf("%s L%d: Warning: Unknown opx %02x\n", __FILE__, __LINE__, opx); + default: + sciprintf("%s L%d: Warning: Unknown opx %02x\n", __FILE__, __LINE__, opx); return; } goto end_op_loop; @@ -1889,11 +1878,11 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /* _gfxr_vismap_remove_artifacts(); */ return; - default: GFXWARN("Unknown op %02x\n", op); + default: + GFXWARN("Unknown op %02x\n", op); return; } -end_op_loop: - {} +end_op_loop: {} } GFXWARN("Reached end of pic resource %04x\n", resid); @@ -1901,9 +1890,8 @@ end_op_loop: void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, - byte *resource, gfxr_pic0_params_t *style, int resid, - gfx_pixmap_color_t *static_pal, int static_pal_nr) -{ + byte *resource, gfxr_pic0_params_t *style, int resid, + gfx_pixmap_color_t *static_pal, int static_pal_nr) { int has_bitmap = getUInt16(resource + 4); int vector_data_ptr = getUInt16(resource + 16); int palette_data_ptr = getUInt16(resource + 28); @@ -1913,58 +1901,55 @@ gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, gfx_pixmap_t *view = NULL; /* Set up mode structure for resizing the view */ mode = gfx_new_mode( - pic->visual_map->index_xl/320, - pic->visual_map->index_yl/200, - 1, /* 1bpp, which handles masks and the rest for us */ - 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); + pic->visual_map->index_xl / 320, + pic->visual_map->index_yl / 200, + 1, /* 1bpp, which handles masks and the rest for us */ + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); pic->visual_map->colors = gfxr_read_pal11(-1, &(pic->visual_map->colors_nr), resource + palette_data_ptr, 1284); if (has_bitmap) view = gfxr_draw_cel11(-1, 0, 0, 0, resource, resource + bitmap_data_ptr, size - bitmap_data_ptr, NULL); - if (view) - { + if (view) { view->colors = pic->visual_map->colors; view->colors_nr = pic->visual_map->colors_nr; - + gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE); - + if (flags & DRAWPIC01_FLAG_OVERLAID_PIC) - view_transparentize(view, pic->visual_map->index_data, - 0, 0, - view->index_xl, view->index_yl); - + view_transparentize(view, pic->visual_map->index_data, + 0, 0, + view->index_xl, view->index_yl); + /* Hack to prevent overflowing the visual map buffer. Yes, this does happen otherwise. */ if (view->index_yl + sci_titlebar_size > 200) sci_titlebar_size = 0; - _gfx_crossblit_simple(pic->visual_map->index_data+sci_titlebar_size*view->index_xl, - view->index_data, - pic->visual_map->index_xl, view->index_xl, - view->index_xl, - view->index_yl, - 1); - } else - { + _gfx_crossblit_simple(pic->visual_map->index_data + sci_titlebar_size*view->index_xl, + view->index_data, + pic->visual_map->index_xl, view->index_xl, + view->index_xl, + view->index_yl, + 1); + } else { GFXWARN("No view was contained in SCI1.1 pic resource"); } - + gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, - resource + vector_data_ptr, style, resid, 1, - static_pal, static_pal_nr); + resource + vector_data_ptr, style, resid, 1, + static_pal, static_pal_nr); } void -gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) -{ +gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) { int xl = pic->visual_map->index_xl; int yl = pic->visual_map->index_yl; - int xfrob_max = (pattern == GFXR_DITHER_PATTERN_1)? 1 : pic->mode->xfact; - int yfrob_max = (pattern == GFXR_DITHER_PATTERN_1)? 1 : pic->mode->yfact; + int xfrob_max = (pattern == GFXR_DITHER_PATTERN_1) ? 1 : pic->mode->xfact; + int yfrob_max = (pattern == GFXR_DITHER_PATTERN_1) ? 1 : pic->mode->yfact; int xfrobc = 0, yfrobc = 0; int selection = 0; int x, y; diff --git a/engines/sci/gfx/resource/sci_picfill.cpp b/engines/sci/gfx/resource/sci_picfill.cpp index e791231589..d72d6d2f88 100644 --- a/engines/sci/gfx/resource/sci_picfill.cpp +++ b/engines/sci/gfx/resource/sci_picfill.cpp @@ -56,9 +56,8 @@ static void FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, byte *bounds, - int legalcolor, int legalmask, int color, int priority, int drawenable, - int sci_titlebar_size) -{ + int legalcolor, int legalmask, int color, int priority, int drawenable, + int sci_titlebar_size) { int linewidth = pic->mode->xfact * 320; int miny = pic->mode->yfact * sci_titlebar_size; int maxy = pic->mode->yfact * 200; @@ -83,7 +82,8 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, #ifdef FILL_RECURSIVE_DEBUG if (!fillc) return; - else if (!fillmagc) { --fillc; + else if (!fillmagc) { + --fillc; } #endif /* defined(FILL_RECURSIVE_DEBUG) */ @@ -100,13 +100,13 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, proj_x = old_xl / pic->mode->xfact; proj_xl_bound = proj_x; - if (SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)){ + if (SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { while (proj_xl_bound - && pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT) + && pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT) --proj_xl_bound; } else { while (proj_xl_bound < 319 - && !(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT)) + && !(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT)) ++proj_xl_bound; if (proj_xl_bound < 319) @@ -114,19 +114,19 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, } if (proj_xl_bound == 319 - && !(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { + && !(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { PRINT_DEBUG0("ABRT because proj_xl_bound couldn't be found\n"); return; } - proj_xr_bound = (proj_xl_bound > proj_x)? proj_xl_bound : proj_x; + proj_xr_bound = (proj_xl_bound > proj_x) ? proj_xl_bound : proj_x; while ((proj_xr_bound < 319) - && pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT) + && pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT) ++proj_xr_bound; #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - fprintf(stderr,"l%d: {%d,%d} | ", proj_y, proj_xl_bound, proj_xr_bound); + fprintf(stderr, "l%d: {%d,%d} | ", proj_y, proj_xl_bound, proj_xr_bound); pic->aux_map[proj_y*320 + proj_xl_bound] |= 0x2; pic->aux_map[proj_y*320 + proj_xr_bound] |= 0x2; } @@ -139,7 +139,7 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, if (proj_xr_bound < 319) ++proj_xr_bound; proj_xr_bound *= pic->mode->xfact; - proj_xr_bound += pic->mode->xfact -1; + proj_xr_bound += pic->mode->xfact - 1; old_proj_y = proj_y; } @@ -150,30 +150,30 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, /* Now we have the projected limits, get the real ones: */ - xl = (old_xl > proj_xl_bound)? old_xl : proj_xl_bound; - if (!IS_BOUNDARY(xl, y+1, bounds[ytotal + xl])) { /* go left as far as possible */ - while (xl > proj_xl_bound && (!IS_BOUNDARY(xl-1, y+1, bounds[ytotal + xl - 1]))) + xl = (old_xl > proj_xl_bound) ? old_xl : proj_xl_bound; + if (!IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) { /* go left as far as possible */ + while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y + 1, bounds[ytotal + xl - 1]))) --xl; } else /* go right until the fillable area starts */ - while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y+1, bounds[ytotal + xl]))) + while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl]))) ++xl; PRINT_DEBUG1("<%d,", xl); if ((xl > proj_xr_bound) - || (xl > old_xr)) { + || (xl > old_xr)) { PRINT_DEBUG0("ABRT because xl > xr_bound\n"); return; } - xr = (xl > old_xl)? xl : old_xl; - while (xr < proj_xr_bound && (!IS_BOUNDARY(xr+1, y+1, bounds[ytotal + xr + 1]))) + xr = (xl > old_xl) ? xl : old_xl; + while (xr < proj_xr_bound && (!IS_BOUNDARY(xr + 1, y + 1, bounds[ytotal + xr + 1]))) ++xr; PRINT_DEBUG1("%d> -> ", xr); - if (IS_BOUNDARY(xl, y+1, bounds[ytotal + xl])) { + if (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) { PRINT_DEBUG0("ABRT because xl illegal\n"); return; } @@ -203,14 +203,14 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, state = 0; xcont = xr + 1; while (xcont <= old_xr) { - if (IS_BOUNDARY(xcont, y+1, bounds[ytotal + xcont])) + if (IS_BOUNDARY(xcont, y + 1, bounds[ytotal + xcont])) state = xcont; else if (state) { /* recurse */ PRINT_DEBUG4("[%d[%d,%d],%d]: ", old_xl, xl, xr, old_xr); PRINT_DEBUG4("rec BRANCH %d [%d,%d] l%d\n", dy, state, xcont, y - dy); FILL_FUNCTION_RECURSIVE(pic, state, xcont, y - dy, dy, bounds, legalcolor, - legalmask, color, priority, drawenable, sci_titlebar_size); + legalmask, color, priority, drawenable, sci_titlebar_size); state = 0; } ++xcont; @@ -220,7 +220,7 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, /* left */ if (xl < old_xl - 1) { state = 0; - for (xcont = old_xl-1; xcont >= xl; xcont--) { + for (xcont = old_xl - 1; xcont >= xl; xcont--) { if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont])) state = xcont; else if (state) { /* recurse */ @@ -228,8 +228,8 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, PRINT_DEBUG4("rec BACK-LEFT %d [%d,%d] l%d\n", -dy, state, xcont, y); FILL_FUNCTION_RECURSIVE(pic, xcont, state, y, -dy, bounds, - legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); + legalcolor, legalmask, color, priority, drawenable, + sci_titlebar_size); state = 0; } } @@ -246,8 +246,8 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, PRINT_DEBUG4("rec BACK-RIGHT %d [%d,%d] l%d\n", -dy, state, xcont, y); FILL_FUNCTION_RECURSIVE(pic, state, xcont, y, -dy, bounds, - legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); + legalcolor, legalmask, color, priority, drawenable, + sci_titlebar_size); state = 0; } } @@ -263,8 +263,7 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, static void FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, int control, int drawenable, - int sci_titlebar_size) -{ + int sci_titlebar_size) { int linewidth = pic->mode->xfact * 320; int x, y; int xl, xr; @@ -291,8 +290,8 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in } AUXBUF_FILL(pic, x_320, y_200, original_drawenable, - (drawenable & GFX_MASK_CONTROL)? control : 0, - sci_titlebar_size); + (drawenable & GFX_MASK_CONTROL) ? control : 0, + sci_titlebar_size); #ifdef DRAW_SCALED _gfxr_auxbuf_spread(pic, &min_x, &min_y, &max_x, &max_y); @@ -321,7 +320,7 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in if ((color & 0xf) == 0xf /* When dithering with white, do more ** conservative checks */ - || (color & 0xf0) == 0xf0) + || (color & 0xf0) == 0xf0) legalcolor = 0xff; else legalcolor = 0xf0; /* Only check the second color */ @@ -359,16 +358,16 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in proj_xl_bound = proj_x; if (SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { while (proj_xl_bound - && SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT)) + && SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT)) --proj_xl_bound; } else while (proj_xl_bound < 319 - && SCALED_CHECK(!(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT))) + && SCALED_CHECK(!(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT))) ++proj_xl_bound; - proj_xr_bound = (proj_xl_bound > proj_x)? proj_xl_bound : proj_x; + proj_xr_bound = (proj_xl_bound > proj_x) ? proj_xl_bound : proj_x; while ((proj_xr_bound < 319) && - SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT)) + SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT)) ++proj_xr_bound; proj_xl = proj_xl_bound; @@ -376,18 +375,18 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in proj_xl_bound *= pic->mode->xfact; if (proj_xl_bound) - proj_xl_bound -= pic->mode->xfact -1; + proj_xl_bound -= pic->mode->xfact - 1; if (proj_xr_bound < 319) ++proj_xr_bound; proj_xr_bound *= pic->mode->xfact; - proj_xr_bound += pic->mode->xfact -1; + proj_xr_bound += pic->mode->xfact - 1; #endif xl = x; - while (xl > proj_xl_bound && (!IS_BOUNDARY(xl-1, y, bounds[ytotal + xl -1]))) + while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y, bounds[ytotal + xl -1]))) --xl; - while (x < proj_xr_bound && (!IS_BOUNDARY(x+1, y, bounds[ytotal + x + 1]))) + while (x < proj_xr_bound && (!IS_BOUNDARY(x + 1, y, bounds[ytotal + x + 1]))) ++x; xr = x; @@ -398,18 +397,18 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1); FILL_FUNCTION_RECURSIVE(pic, xl, xr, y, -1, bounds, legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); - FILL_FUNCTION_RECURSIVE(pic, xl, xr, y, +1, bounds, legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); + sci_titlebar_size); + FILL_FUNCTION_RECURSIVE(pic, xl, xr, y, + 1, bounds, legalcolor, legalmask, color, priority, drawenable, + sci_titlebar_size); } /* Now finish the aux buffer */ bitmask = drawenable & - ( - ((color != 0xff)? 1 : 0) - | ((priority)? 2 : 0) - | ((control)? 4 : 0) - ); + ( + ((color != 0xff) ? 1 : 0) + | ((priority) ? 2 : 0) + | ((control) ? 4 : 0) + ); #ifdef DRAW_SCALED # ifdef FILL_RECURSIVE_DEBUG diff --git a/engines/sci/gfx/resource/sci_picfill_aux.cpp b/engines/sci/gfx/resource/sci_picfill_aux.cpp index 70d8a822da..5fd2f2dac9 100644 --- a/engines/sci/gfx/resource/sci_picfill_aux.cpp +++ b/engines/sci/gfx/resource/sci_picfill_aux.cpp @@ -34,8 +34,7 @@ static void AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, - int clipmask, int control, int sci_titlebar_size) -{ + int clipmask, int control, int sci_titlebar_size) { int xl, xr; int oldytotal = y * 320; #ifdef DRAW_SCALED @@ -65,7 +64,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, if (xl > old_xr) /* No fillable strip above the last one */ return; - if ((ytotal + xl) < 0) { fprintf(stderr,"AARGH-%d\n", __LINE__); BREAKPOINT(); } + if ((ytotal + xl) < 0) { fprintf(stderr, "AARGH-%d\n", __LINE__); BREAKPOINT(); } xr = xl; while (xr < 320 && !(pic->aux_map[ytotal + xr] & clipmask)) { @@ -73,8 +72,9 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, ++xr; } - if ((ytotal + xr) > 64000) { fprintf(stderr,"AARGH-%d\n", __LINE__); - BREAKPOINT(); + if ((ytotal + xr) > 64000) { + fprintf(stderr, "AARGH-%d\n", __LINE__); + BREAKPOINT(); } --xr; @@ -84,7 +84,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, /* Check whether we need to recurse on branches in the same direction */ if ((y > sci_titlebar_size && dy < 0) - || (y < 199 && dy > 0)) { + || (y < 199 && dy > 0)) { state = 0; xcont = xr + 1; @@ -94,7 +94,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, else if (!state) { /* recurse */ state = 1; AUXBUF_FILL_HELPER(pic, xcont, old_xr, - y - dy, dy, clipmask, control, sci_titlebar_size); + y - dy, dy, clipmask, control, sci_titlebar_size); } ++xcont; } @@ -109,7 +109,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, state = xcont; else if (state) { /* recurse */ AUXBUF_FILL_HELPER(pic, xcont, state, - y, -dy, clipmask, control, sci_titlebar_size); + y, -dy, clipmask, control, sci_titlebar_size); state = 0; } } @@ -123,17 +123,17 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, state = xcont; else if (state) { /* recurse */ AUXBUF_FILL_HELPER(pic, state, xcont, - y, -dy, clipmask, control, sci_titlebar_size); + y, -dy, clipmask, control, sci_titlebar_size); state = 0; } } } - if ((ytotal + xl) < 0) { fprintf(stderr,"AARGH-%d\n", __LINE__); BREAKPOINT() } - if ((ytotal + xr+1) > 64000) { fprintf(stderr,"AARGH-%d\n", __LINE__); BREAKPOINT(); } + if ((ytotal + xl) < 0) { fprintf(stderr, "AARGH-%d\n", __LINE__); BREAKPOINT() } + if ((ytotal + xr + 1) > 64000) { fprintf(stderr, "AARGH-%d\n", __LINE__); BREAKPOINT(); } if (control) - memset(pic->control_map->index_data + ytotal + xl, control, xr-xl+1); + memset(pic->control_map->index_data + ytotal + xl, control, xr - xl + 1); oldytotal = ytotal; old_xr = xr; @@ -144,8 +144,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, static void -AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_titlebar_size) -{ +AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_titlebar_size) { /* Fills the aux buffer and the control map (if control != 0) */ int xl, xr; int ytotal = y * 320; @@ -198,7 +197,7 @@ AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_ti AUXBUF_FILL_HELPER(pic, xl, xr, y, -1, clipmask, control, sci_titlebar_size); if (y < 199) - AUXBUF_FILL_HELPER(pic, xl, xr, y, +1, clipmask, control, sci_titlebar_size); + AUXBUF_FILL_HELPER(pic, xl, xr, y, + 1, clipmask, control, sci_titlebar_size); } diff --git a/engines/sci/gfx/resource/sci_resmgr.cpp b/engines/sci/gfx/resource/sci_resmgr.cpp index ad756afecd..5ecc05a7ed 100644 --- a/engines/sci/gfx/resource/sci_resmgr.cpp +++ b/engines/sci/gfx/resource/sci_resmgr.cpp @@ -33,9 +33,8 @@ int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, - gfx_options_t *options, - void *internal, int palette) -{ + gfx_options_t *options, + void *internal, int palette) { switch (type) { case GFX_RESOURCE_TYPE_VIEW: @@ -45,11 +44,11 @@ gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, if (version >= SCI_VERSION_01_VGA) return options->pic_port_bounds.y; else - return (options->pic0_unscaled)? 0x10000 : - (options->pic0_dither_mode << 12) - | (options->pic0_dither_pattern << 8) - | (options->pic0_brush_mode << 4) - | (options->pic0_line_mode); + return (options->pic0_unscaled) ? 0x10000 : + (options->pic0_dither_mode << 12) + | (options->pic0_dither_pattern << 8) + | (options->pic0_brush_mode << 4) + | (options->pic0_line_mode); case GFX_RESOURCE_TYPE_FONT: return 0; @@ -66,32 +65,29 @@ gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfxr_pic_t * -gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) -{ +gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) { return gfxr_init_pic(mode, ID, version >= SCI_VERSION_01_VGA); } void -gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) -{ +gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) { gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); } int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, - int flags, int default_palette, int nr, void *internal) -{ + int flags, int default_palette, int nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_pic, nr, 0); int need_unscaled = unscaled_pic != NULL; gfxr_pic0_params_t style, basic_style; - + basic_style.line_mode = GFX_LINE_MODE_CORRECT; basic_style.brush_mode = GFX_BRUSH_MODE_SCALED; basic_style.pic_port_bounds = state->options->pic_port_bounds; - + style.line_mode = state->options->pic0_line_mode; style.brush_mode = state->options->pic0_brush_mode; style.pic_port_bounds = state->options->pic_port_bounds; @@ -100,34 +96,33 @@ gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gf return GFX_ERROR; if (state->version >= SCI_VERSION_01_VGA) { - if (need_unscaled) - { + if (need_unscaled) { if (state->version == SCI_VERSION_1_1) gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); else gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, 1, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); } if (scaled_pic && scaled_pic->undithered_buffer) memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size); if (state->version == SCI_VERSION_1_1) gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); else gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, state->version, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); } else { if (need_unscaled) gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, 0, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); if (scaled_pic && scaled_pic->undithered_buffer) memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size); gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, 0, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); if (need_unscaled) gfxr_remove_artifacts_pic0(scaled_pic, unscaled_pic); @@ -151,27 +146,23 @@ gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gf void -gfxr_palettize_view(gfxr_view_t *view, gfx_pixmap_color_t *source, int source_entries) -{ - int i; - - for (i=0;icolors_nr,source_entries);i++) - { - if ((view->colors[i].r == 0) && - (view->colors[i].g == 0) && - (view->colors[i].b == 0)) - { - view->colors[i] = source[i]; +gfxr_palettize_view(gfxr_view_t *view, gfx_pixmap_color_t *source, int source_entries) { + int i; + + for (i = 0;i < MIN(view->colors_nr, source_entries);i++) { + if ((view->colors[i].r == 0) && + (view->colors[i].g == 0) && + (view->colors[i].b == 0)) { + view->colors[i] = source[i]; + } } - } } gfxr_view_t * gfxr_draw_view11(int id, byte *resource, int size); gfxr_view_t * -gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) -{ +gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_view, nr, 0); int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); @@ -180,43 +171,39 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal if (!res || !res->data) return NULL; - if (state->version < SCI_VERSION_01) palette=-1; + if (state->version < SCI_VERSION_01) palette = -1; - switch (state->version) - { + switch (state->version) { case SCI_VERSION_0: case SCI_VERSION_01: - result=gfxr_draw_view0(resid, res->data, res->size, palette); + result = gfxr_draw_view0(resid, res->data, res->size, palette); break; case SCI_VERSION_01_VGA: case SCI_VERSION_01_VGA_ODD: case SCI_VERSION_1_EARLY: case SCI_VERSION_1_LATE: - result=gfxr_draw_view1(resid, res->data, res->size, state->static_palette, state->static_palette_entries); + result = gfxr_draw_view1(resid, res->data, res->size, state->static_palette, state->static_palette_entries); break; case SCI_VERSION_1_1: case SCI_VERSION_32: - result=gfxr_draw_view11(resid, res->data, res->size); + result = gfxr_draw_view11(resid, res->data, res->size); break; } - if (state->version >= SCI_VERSION_01_VGA) - { - if (!result->colors) - { + if (state->version >= SCI_VERSION_01_VGA) { + if (!result->colors) { result->colors = (gfx_pixmap_color_t*)sci_malloc(sizeof(gfx_pixmap_color_t) * state->static_palette_entries); memset(result->colors, 0, sizeof(gfx_pixmap_color_t) * state->static_palette_entries); result->colors_nr = state->static_palette_entries; - } - gfxr_palettize_view(result, state->static_palette, state->static_palette_entries); + } + gfxr_palettize_view(result, state->static_palette, state->static_palette_entries); } return result; } gfx_bitmap_font_t * -gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) -{ +gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_font, nr, 0); if (!res || !res->data) @@ -227,8 +214,7 @@ gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) gfx_pixmap_t * -gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) -{ +gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_cursor, nr, 0); int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, nr); @@ -250,8 +236,7 @@ gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) int * gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, - int version, int *entries_nr, void *internal) -{ + int version, int *entries_nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; int restype; int *resources; @@ -260,16 +245,20 @@ gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, int i; switch (type) { - case GFX_RESOURCE_TYPE_VIEW: restype = sci_view; + case GFX_RESOURCE_TYPE_VIEW: + restype = sci_view; break; - case GFX_RESOURCE_TYPE_PIC: restype = sci_pic; + case GFX_RESOURCE_TYPE_PIC: + restype = sci_pic; break; - case GFX_RESOURCE_TYPE_CURSOR: restype = sci_cursor; + case GFX_RESOURCE_TYPE_CURSOR: + restype = sci_cursor; break; - case GFX_RESOURCE_TYPE_FONT: restype = sci_font; + case GFX_RESOURCE_TYPE_FONT: + restype = sci_font; break; default: @@ -290,8 +279,7 @@ gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, } gfx_pixmap_color_t * -gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) -{ +gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) { if (version >= SCI_VERSION_01_VGA) return gfxr_interpreter_get_palette(state, version, colors_nr, internal, 999); @@ -300,9 +288,8 @@ gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *col } gfx_pixmap_color_t * -gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, - void *internal, int nr) -{ +gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, + void *internal, int nr) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res; @@ -313,8 +300,7 @@ gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, if (!res || !res->data) return NULL; - switch (version) - { + switch (version) { case SCI_VERSION_01_VGA : case SCI_VERSION_01_VGA_ODD : case SCI_VERSION_1_EARLY : @@ -332,8 +318,7 @@ gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, } int -gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) -{ +gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) { return (version > SCI_VERSION_1); } diff --git a/engines/sci/gfx/resource/sci_view_0.cpp b/engines/sci/gfx/resource/sci_view_0.cpp index bea6377285..a89fbe8b17 100644 --- a/engines/sci/gfx/resource/sci_view_0.cpp +++ b/engines/sci/gfx/resource/sci_view_0.cpp @@ -38,15 +38,14 @@ gfx_pixmap_t * -gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored) -{ +gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored) { int xl = get_int_16(resource); int yl = get_int_16(resource + 2); int xhot = ((signed char *) resource)[4]; int yhot = ((signed char *) resource)[5]; int color_key = resource[6]; int pos = 7; - int writepos = mirrored? xl : 0; + int writepos = mirrored ? xl : 0; int pixmap_size = xl * yl; int line_base = 0; gfx_pixmap_t *retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, id, loop, cel)); @@ -54,15 +53,14 @@ gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t retval->color_key = 255; /* Pick something larger than 15 */ - retval->xoffset = mirrored? xhot : -xhot; + retval->xoffset = mirrored ? xhot : -xhot; retval->yoffset = -yhot; if (view) { retval->colors = view->colors; retval->colors_nr = view->colors_nr; retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; - } else - { + } else { retval->colors = gfx_sci0_image_colors[sci0_palette]; retval->colors_nr = GFX_SCI0_IMAGE_COLORS_NR; retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; @@ -131,8 +129,7 @@ gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t } static int -gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int offset, int size, gfxr_view_t *view, int mirrored) -{ +gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int offset, int size, gfxr_view_t *view, int mirrored) { int i; int cels_nr = get_int_16(resource + offset); @@ -179,8 +176,7 @@ gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int offset, #define V0_MIRROR_LIST_OFFSET 2 gfxr_view_t * -gfxr_draw_view0(int id, byte *resource, int size, int palette) -{ +gfxr_draw_view0(int id, byte *resource, int size, int palette) { int i; gfxr_view_t *view; int mirror_bitpos = 1; @@ -202,8 +198,7 @@ gfxr_draw_view0(int id, byte *resource, int size, int palette) view->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; view->colors = gfx_sci0_image_colors[sci0_palette]; - if ((palette_ofs)&&(palette>=0)) - { + if ((palette_ofs) && (palette >= 0)) { byte *paldata = resource + palette_ofs + (palette * GFX_SCI0_IMAGE_COLORS_NR); for (i = 0; i < GFX_SCI0_IMAGE_COLORS_NR; i++) @@ -218,7 +213,7 @@ gfxr_draw_view0(int id, byte *resource, int size, int palette) return NULL; } - view->loops = (gfxr_loop_t*)sci_malloc(sizeof (gfxr_loop_t) * ((view->loops_nr)? view->loops_nr : 1)); /* Alloc 1 if no loop */ + view->loops = (gfxr_loop_t*)sci_malloc(sizeof(gfxr_loop_t) * ((view->loops_nr) ? view->loops_nr : 1)); /* Alloc 1 if no loop */ for (i = 0; i < view->loops_nr; i++) { int error_token = 0; diff --git a/engines/sci/gfx/resource/sci_view_1.cpp b/engines/sci/gfx/resource/sci_view_1.cpp index d0dd660f2f..4d2daa0462 100644 --- a/engines/sci/gfx/resource/sci_view_1.cpp +++ b/engines/sci/gfx/resource/sci_view_1.cpp @@ -42,18 +42,17 @@ #define NEXT_RUNLENGTH_BYTE(n) \ if (literal_pos == runlength_pos) \ literal_pos += n; \ - runlength_pos += n; + runlength_pos += n; #define NEXT_LITERAL_BYTE(n) \ if (literal_pos == runlength_pos) \ runlength_pos += n; \ - literal_pos += n; + literal_pos += n; static int -decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, - int runlength_pos, int literal_pos, int xl, int yl, int color_key) -{ - int writepos = mirrored? xl : 0; +decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, + int runlength_pos, int literal_pos, int xl, int yl, int color_key) { + int writepos = mirrored ? xl : 0; if (mirrored) { int linebase = 0; @@ -69,40 +68,36 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m if (op & V1_RLE) { bytes = op & 0x3f; op &= (V1_RLE | V1_RLE_BG); - readbytes = (op & V1_RLE_BG)? 0 : 1; + readbytes = (op & V1_RLE_BG) ? 0 : 1; } else { readbytes = bytes = op & 0x3f; op = 0; } - if (runlength_pos + readbytes > size) - { + if (runlength_pos + readbytes > size) { GFXWARN("View %02x:(%d/%d) requires %d bytes to be read when %d are available at pos %d\n", - id, loop, cel, readbytes, size - runlength_pos, runlength_pos-1); + id, loop, cel, readbytes, size - runlength_pos, runlength_pos - 1); return 1; } -/* - if (writepos - bytes < 0) { - GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", - id, loop, cel, writepos - bytes, pixmap_size, pos - 1); - bytes = pixmap_size - writepos; - } -*/ - if (op==V1_RLE) - { + /* + if (writepos - bytes < 0) { + GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", + id, loop, cel, writepos - bytes, pixmap_size, pos - 1); + bytes = pixmap_size - writepos; + } + */ + if (op == V1_RLE) { color = resource[literal_pos]; NEXT_LITERAL_BYTE(1); } - if (!op && literal_pos + bytes > size) - { + if (!op && literal_pos + bytes > size) { GFXWARN("View %02x:(%d/%d) requires %d bytes to be read when %d are available at pos %d\n", - id, loop, cel, bytes, size - literal_pos, literal_pos-1); + id, loop, cel, bytes, size - literal_pos, literal_pos - 1); return 1; } - while (bytes--) - { + while (bytes--) { if (op) { if (op & V1_RLE_BG) { writepos--; @@ -115,17 +110,15 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m writepos--; *(dest + writepos) = *(resource + literal_pos); NEXT_LITERAL_BYTE(1); - + } - if (writepos == linebase) - { - writepos+=2*xl; - linebase+=xl; + if (writepos == linebase) { + writepos += 2 * xl; + linebase += xl; } } } - } - else { + } else { while (writepos < pixmap_size && literal_pos < size && runlength_pos < size) { int op = resource[runlength_pos]; int bytes; @@ -136,7 +129,7 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m if (op & V1_RLE) { bytes = op & 0x3f; op &= (V1_RLE | V1_RLE_BG); - readbytes = (op & V1_RLE_BG)? 0 : 1; + readbytes = (op & V1_RLE_BG) ? 0 : 1; } else { readbytes = bytes = op & 0x3f; op = 0; @@ -148,22 +141,20 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m if (writepos + bytes > pixmap_size) { GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", - id, loop, cel, writepos-bytes, pixmap_size, runlength_pos - 1); + id, loop, cel, writepos - bytes, pixmap_size, runlength_pos - 1); bytes = pixmap_size - writepos; } - if (!op && literal_pos + bytes > size) - { + if (!op && literal_pos + bytes > size) { GFXWARN("View %02x:(%d/%d) requires %d bytes to be read when %d are available at pos %d\n", - id, loop, cel, bytes, size - literal_pos, literal_pos-1); + id, loop, cel, bytes, size - literal_pos, literal_pos - 1); return 1; } - if (writepos + bytes > pixmap_size) - { + if (writepos + bytes > pixmap_size) { GFXWARN("Writing out of bounds: %d bytes at %d > size %d\n", bytes, writepos, pixmap_size); } - + if (op) { if (op & V1_RLE_BG) memset(dest + writepos, color_key, bytes); @@ -187,10 +178,9 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m } static int -decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, - int pos, int xl, int yl, int color_key) -{ - int writepos = mirrored? xl - 1 : 0; +decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, + int pos, int xl, int yl, int color_key) { + int writepos = mirrored ? xl - 1 : 0; while (writepos < pixmap_size && pos < size) { int op = resource[pos++]; @@ -213,8 +203,7 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, /* Then move to the end of next line */ writepos += 2 * xl; - if (writepos >= pixmap_size && bytes) - { + if (writepos >= pixmap_size && bytes) { GFXWARN("View %02x:(%d/%d) writing out of bounds\n", id, loop, cel); break; } @@ -223,7 +212,7 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, } else { if (writepos + bytes > pixmap_size) { GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", - id, loop, cel, writepos-bytes, pixmap_size, pos - 1); + id, loop, cel, writepos - bytes, pixmap_size, pos - 1); bytes = pixmap_size - writepos; } memset(dest + writepos, color, bytes); @@ -232,16 +221,15 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, } if (writepos < pixmap_size) { - GFXWARN("View %02x:(%d/%d) not enough pixel data in view\n", id, loop, cel); - return 1; + GFXWARN("View %02x:(%d/%d) not enough pixel data in view\n", id, loop, cel); + return 1; } return 0; } gfx_pixmap_t * -gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game) -{ +gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game) { int xl = get_int_16(resource); int yl = get_int_16(resource + 2); int xhot = (gint8) resource[4]; @@ -253,14 +241,14 @@ gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size int decompress_failed; retval->color_key = resource[6]; - retval->xoffset = (mirrored)? xhot : -xhot; + retval->xoffset = (mirrored) ? xhot : -xhot; retval->yoffset = -yhot; if (view) { retval->colors = view->colors; retval->colors_nr = view->colors_nr; } - + retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; if (xl <= 0 || yl <= 0) { @@ -271,12 +259,12 @@ gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size if (amiga_game) decompress_failed = decompress_sci_view_amiga(id, loop, cel, - resource, dest, mirrored, pixmap_size, size, pos, - xl, yl, retval->color_key); + resource, dest, mirrored, pixmap_size, size, pos, + xl, yl, retval->color_key); else decompress_failed = decompress_sci_view(id, loop, cel, - resource, dest, mirrored, pixmap_size, size, pos, - pos, xl, yl, retval->color_key); + resource, dest, mirrored, pixmap_size, size, pos, + pos, xl, yl, retval->color_key); if (decompress_failed) { gfx_free_pixmap(NULL, retval); @@ -287,8 +275,7 @@ gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size } static int -gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resource, int offset, int size, gfxr_view_t *view, int amiga_game) -{ +gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resource, int offset, int size, gfxr_view_t *view, int amiga_game) { int i; int cels_nr = get_int_16(resource + offset); @@ -335,8 +322,7 @@ gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resourc gfxr_view_t * gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal, - int static_pal_nr) -{ + int static_pal_nr) { int i; int palette_offset; gfxr_view_t *view; @@ -362,29 +348,28 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal return NULL; } -/* fprintf(stderr, "View flags are 0x%02x\n", resource[3]);*/ + /* fprintf(stderr, "View flags are 0x%02x\n", resource[3]);*/ -/* - for (i = 0; i < V1_MAGICS_NR; i++) - if (resource[V1_FIRST_MAGIC + i] != view_magics[i]) { - GFXWARN("View %04x: View magic #%d should be %02x but is %02x\n", - id, i, view_magics[i], resource[V1_FIRST_MAGIC + i]); - } -*/ + /* + for (i = 0; i < V1_MAGICS_NR; i++) + if (resource[V1_FIRST_MAGIC + i] != view_magics[i]) { + GFXWARN("View %04x: View magic #%d should be %02x but is %02x\n", + id, i, view_magics[i], resource[V1_FIRST_MAGIC + i]); + } + */ - if (palette_offset > 0) - { - if (palette_offset > size) { - GFXERROR("Palette is outside of view %04x\n", id); - free(view); - return NULL; - } - if (!(view->colors = gfxr_read_pal1(id, &(view->colors_nr), - resource + palette_offset, size - palette_offset))) { - GFXERROR("view %04x: Palette reading failed. Aborting...\n", id); - free(view); - return NULL; - } + if (palette_offset > 0) { + if (palette_offset > size) { + GFXERROR("Palette is outside of view %04x\n", id); + free(view); + return NULL; + } + if (!(view->colors = gfxr_read_pal1(id, &(view->colors_nr), + resource + palette_offset, size - palette_offset))) { + GFXERROR("view %04x: Palette reading failed. Aborting...\n", id); + free(view); + return NULL; + } } else if (static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR) { /* Assume we're running an amiga game. */ amiga_game = 1; @@ -392,12 +377,12 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal view->colors_nr = static_pal_nr; view->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; } else { - GFXWARN("view %04x: Doesn't have a palette. Can FreeSCI handle this?\n", view->ID); - view->colors = NULL; - view->colors_nr = 0; + GFXWARN("view %04x: Doesn't have a palette. Can FreeSCI handle this?\n", view->ID); + view->colors = NULL; + view->colors_nr = 0; } - view->loops = (gfxr_loop_t*)sci_malloc(sizeof (gfxr_loop_t) * view->loops_nr); + view->loops = (gfxr_loop_t*)sci_malloc(sizeof(gfxr_loop_t) * view->loops_nr); for (i = 0; i < view->loops_nr; i++) { int error_token = 0; @@ -408,8 +393,8 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal error_token = 1; } - if (error_token || gfxr_draw_loop1(view->loops + i, id, i, mirror_mask & (1<loops + i, id, i, mirror_mask & (1 << i), + resource, loop_offset, size, view, amiga_game)) { /* An error occured */ view->loops_nr = i; gfxr_free_view(NULL, view); @@ -440,8 +425,7 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal #define V2_LITERAL_OFFSET 28 gfx_pixmap_t * -gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view) -{ +gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view) { int xl = get_uint_16(cel_base + V2_CEL_WIDTH); int yl = get_uint_16(cel_base + V2_CEL_HEIGHT); int xdisplace = get_uint_16(cel_base + V2_X_DISPLACEMENT); @@ -449,20 +433,20 @@ gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, by int runlength_offset = get_uint_16(cel_base + V2_RUNLENGTH_OFFSET); int literal_offset = get_uint_16(cel_base + V2_LITERAL_OFFSET); int pixmap_size = xl * yl; - + gfx_pixmap_t *retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, id, loop, cel)); byte *dest = retval->index_data; int decompress_failed; retval->color_key = cel_base[V2_COLOR_KEY]; - retval->xoffset = (mirrored)? xdisplace : -xdisplace; + retval->xoffset = (mirrored) ? xdisplace : -xdisplace; retval->yoffset = -ydisplace; if (view) { retval->colors = view->colors; retval->colors_nr = view->colors_nr; } - + retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; if (xl <= 0 || yl <= 0) { @@ -472,7 +456,7 @@ gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, by } decompress_failed = decompress_sci_view(id, loop, cel, resource_base, dest, mirrored, pixmap_size, size, - runlength_offset, literal_offset, xl, yl, retval->color_key); + runlength_offset, literal_offset, xl, yl, retval->color_key); if (decompress_failed) { gfx_free_pixmap(NULL, retval); @@ -484,17 +468,15 @@ gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, by gfxr_loop_t * gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_base, byte *loop_base, int size, int cels_nr, - gfxr_loop_t *result, gfxr_view_t *view, int bytes_per_cel) -{ + gfxr_loop_t *result, gfxr_view_t *view, int bytes_per_cel) { byte *seeker = loop_base; int i; result->cels_nr = cels_nr; result->cels = (gfx_pixmap_t **) - sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); + sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); - for (i = 0; i < cels_nr; i++) - { + for (i = 0; i < cels_nr; i++) { result->cels[i] = gfxr_draw_cel11(id, loop, i, mirrored, resource_base, seeker, size, view); seeker += bytes_per_cel; } @@ -503,10 +485,9 @@ gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_base, byte *loop } gfxr_view_t * -gfxr_draw_view11(int id, byte *resource, int size) -{ +gfxr_draw_view11(int id, byte *resource, int size) { gfxr_view_t *view; - int header_size = get_uint_16(resource + V2_HEADER_SIZE); + int header_size = get_uint_16(resource + V2_HEADER_SIZE); int palette_offset = get_uint_16(resource + V2_PALETTE_OFFSET); int bytes_per_loop = resource[V2_BYTES_PER_LOOP]; int loops_num = resource[V2_LOOPS_NUM]; @@ -524,11 +505,10 @@ gfxr_draw_view11(int id, byte *resource, int size) view->loops = (gfxr_loop_t *)calloc(view->loops_nr, sizeof(gfxr_loop_t)); /* There is no indication of size here, but this is certainly large enough */ - view->colors = gfxr_read_pal11(id, &view->colors_nr, resource + palette_offset, 1284); - + view->colors = gfxr_read_pal11(id, &view->colors_nr, resource + palette_offset, 1284); + seeker = resource + header_size; - for (i = 0; i < view->loops_nr; i++) - { + for (i = 0; i < view->loops_nr; i++) { int loop_offset = get_uint_16(seeker + V2_LOOP_OFFSET); int cels = seeker[V2_CELS_NUM]; int mirrored = seeker[V2_IS_MIRROR]; @@ -536,16 +516,16 @@ gfxr_draw_view11(int id, byte *resource, int size) printf("%d\n", mirrored); if (copy_entry == 255) - gfxr_draw_loop11(id, i, 0, resource, resource + loop_offset, size, cels, view->loops + i, - view, bytes_per_cel); else - { - byte *temp = resource + header_size + copy_entry * bytes_per_loop; - loop_offset = get_uint_16(temp + V2_LOOP_OFFSET); - cels = temp[V2_CELS_NUM]; - gfxr_draw_loop11(id, i, 1, resource, resource + loop_offset, size, cels, - view->loops + i, view, bytes_per_cel); - } - + gfxr_draw_loop11(id, i, 0, resource, resource + loop_offset, size, cels, view->loops + i, + view, bytes_per_cel); + else { + byte *temp = resource + header_size + copy_entry * bytes_per_loop; + loop_offset = get_uint_16(temp + V2_LOOP_OFFSET); + cels = temp[V2_CELS_NUM]; + gfxr_draw_loop11(id, i, 1, resource, resource + loop_offset, size, cels, + view->loops + i, view, bytes_per_cel); + } + seeker += bytes_per_loop; } diff --git a/engines/sci/gfx/sbtree.cpp b/engines/sci/gfx/sbtree.cpp index 3e0f7883ee..712fa3311d 100644 --- a/engines/sci/gfx/sbtree.cpp +++ b/engines/sci/gfx/sbtree.cpp @@ -40,15 +40,13 @@ typedef struct { } sbcell_t; int -int_compar(const void *a, const void *b) -{ - return (*((int *)a))-(*((int *)b)); +int_compar(const void *a, const void *b) { + return (*((int *)a)) - (*((int *)b)); } void -insert_interval(sbcell_t *data, int start, int stop, int *keys, int plus) -{ +insert_interval(sbcell_t *data, int start, int stop, int *keys, int plus) { int center = start + ((stop - start) >> 1); data->key = keys[center]; @@ -64,8 +62,7 @@ insert_interval(sbcell_t *data, int start, int stop, int *keys, int plus) } sbtree_t * -sbtree_new(int size, int *keys) -{ +sbtree_new(int size, int *keys) { int table_size = 2; int levels = 0; sbcell_t *table; @@ -88,26 +85,26 @@ sbtree_new(int size, int *keys) table[i].key = NOT_A_KEY; if (!table) { - fprintf(stderr,"SBTree: Out of memory: Could not allocate %d cells\n", table_size); + fprintf(stderr, "SBTree: Out of memory: Could not allocate %d cells\n", table_size); return NULL; } tree = (sbtree_t*)sci_malloc(sizeof(sbtree_t)); if (!tree) { - fprintf(stderr,"SBTree: Could not allocate tree structure\n"); + fprintf(stderr, "SBTree: Could not allocate tree structure\n"); free(table); return NULL; } qsort(keys, size, sizeof(int), int_compar); - insert_interval(table, 0, size-1, keys, 1); + insert_interval(table, 0, size - 1, keys, 1); tree->levels = levels; tree->entries_nr = size; if ((tree->min_entry = keys[0]) < 0) { - fprintf(stderr,"SBTree: Error: Using negative keys\n"); + fprintf(stderr, "SBTree: Error: Using negative keys\n"); free(table); free(tree); return NULL; @@ -120,10 +117,9 @@ sbtree_new(int size, int *keys) void -sbtree_free(sbtree_t *tree) -{ +sbtree_free(sbtree_t *tree) { if (!tree) { - fprintf(stderr,"SBTree: Attempt to free NULL sbtree\n"); + fprintf(stderr, "SBTree: Attempt to free NULL sbtree\n"); return; } @@ -134,8 +130,7 @@ sbtree_free(sbtree_t *tree) void sbtree_foreach(sbtree_t *tree, void *args, void *(*operation)(sbtree_t *, const int, - const void *, void *)) -{ + const void *, void *)) { int i; sbcell_t *cell = (sbcell_t *) tree->data; @@ -147,8 +142,7 @@ sbtree_foreach(sbtree_t *tree, void *args, void *(*operation)(sbtree_t *, const } sbcell_t * -locate(sbcell_t *start, int key, int level, int levels, int plus) -{ +locate(sbcell_t *start, int key, int level, int levels, int plus) { int comparison; if (level >= levels && (level != levels || start->key == NOT_A_KEY)) @@ -167,8 +161,7 @@ locate(sbcell_t *start, int key, int level, int levels, int plus) int -sbtree_set(sbtree_t *tree, int key, void *value) -{ +sbtree_set(sbtree_t *tree, int key, void *value) { sbcell_t *cell = locate((sbcell_t *) tree->data, key, 0, tree->levels, 1); if (cell) @@ -181,8 +174,7 @@ sbtree_set(sbtree_t *tree, int key, void *value) void * -sbtree_get(sbtree_t *tree, int key) -{ +sbtree_get(sbtree_t *tree, int key) { sbcell_t *cell = locate((sbcell_t *) tree->data, key, 0, tree->levels, 1); if (cell) @@ -193,29 +185,28 @@ sbtree_get(sbtree_t *tree, int key) #if 0 static void -sbtree_print(sbtree_t *tree) -{ +sbtree_print(sbtree_t *tree) { int l, i; sbcell_t *cells = (sbcell_t *) tree->data; - fprintf(stderr,"\tTree:\n"); + fprintf(stderr, "\tTree:\n"); for (l = 0; l <= tree->levels; l++) { - fprintf(stderr,"\t "); + fprintf(stderr, "\t "); for (i = 0; i < (1 << l); i++) { if (cells->key == NOT_A_KEY) - fprintf(stderr,"-- "); + fprintf(stderr, "-- "); else { if (cells->value) - fprintf(stderr,"%d+ ", cells->key); + fprintf(stderr, "%d+ ", cells->key); else - fprintf(stderr,"%d ", cells->key); + fprintf(stderr, "%d ", cells->key); } cells = cells + 1; } - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); } - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); } #endif @@ -229,20 +220,18 @@ static int any_error; void * -foreach_double_func(sbtree_t *tree, const int key, const void *value, void *args) -{ +foreach_double_func(sbtree_t *tree, const int key, const void *value, void *args) { int *real_value = (int *) value; if (!real_value) - fprintf(stderr,"foreach_double_func(): key %d mapped to non-value!\n", key); + fprintf(stderr, "foreach_double_func(): key %d mapped to non-value!\n", key); else *real_value *= 2; return real_value; } int * -generate_linear_forward(int numbers) -{ +generate_linear_forward(int numbers) { int i; int *data = sci_malloc(sizeof(int) * numbers); for (i = 0; i < numbers; i++) @@ -252,8 +241,7 @@ generate_linear_forward(int numbers) } int * -generate_linear_backward(int numbers) -{ +generate_linear_backward(int numbers) { int i; int *data = sci_malloc(sizeof(int) * numbers); for (i = 0; i < numbers; i++) @@ -263,21 +251,19 @@ generate_linear_backward(int numbers) } int * -generate_random(int numbers, int max) -{ +generate_random(int numbers, int max) { int i; int *data = sci_malloc(sizeof(int) * numbers); for (i = 0; i < numbers; i++) - data[i] = 1 + (int) ((rand() * 1.0 * max) / (RAND_MAX + 1.0)); + data[i] = 1 + (int)((rand() * 1.0 * max) / (RAND_MAX + 1.0)); return data; } void -insert_values(sbtree_t *tree, int nr, int *data) -{ +insert_values(sbtree_t *tree, int nr, int *data) { int i; for (i = 0; i < nr; i++) @@ -294,16 +280,15 @@ insert_values(sbtree_t *tree, int nr, int *data) #define MODE_LINEAR_DOUBLE 3 void -test_value(sbtree_t *tree, int times, int max, int numbers, int *data, int mode) -{ +test_value(sbtree_t *tree, int times, int max, int numbers, int *data, int mode) { int i; int failed = 0; for (i = 0; i < times; i++) { - int key = (mode == MODE_LINEAR || mode == MODE_LINEAR_DOUBLE)? i : - (mode == MODE_LINEAR_MAP)? data[i % numbers] : - (int) ((rand() * 1.0 * max) / (RAND_MAX + 1.0)); - int *value = (int *) sbtree_get(tree, (mode == MODE_LINEAR_DOUBLE)? key >> 1 : key); + int key = (mode == MODE_LINEAR || mode == MODE_LINEAR_DOUBLE) ? i : + (mode == MODE_LINEAR_MAP) ? data[i % numbers] : + (int)((rand() * 1.0 * max) / (RAND_MAX + 1.0)); + int *value = (int *) sbtree_get(tree, (mode == MODE_LINEAR_DOUBLE) ? key >> 1 : key); int found = 0; int j; @@ -314,8 +299,7 @@ test_value(sbtree_t *tree, int times, int max, int numbers, int *data, int mode) if (found && !value) { fprintf(stderr, "!%d ", key); ++failed; - } - else if (!found && found) { + } else if (!found && found) { fprintf(stderr, "?[%d]=%d ", key, *value); ++failed; } @@ -329,8 +313,7 @@ test_value(sbtree_t *tree, int times, int max, int numbers, int *data, int mode) void -test_boundary(sbtree_t *tree, int max, int random) -{ +test_boundary(sbtree_t *tree, int max, int random) { int *value_too_low = sbtree_get(tree, 0); int *value_too_high = sbtree_get(tree, max + 1); int *value_low = sbtree_get(tree, 1); @@ -360,13 +343,12 @@ test_boundary(sbtree_t *tree, int max, int random) void -test_empty(sbtree_t *tree, int count, int max) -{ +test_empty(sbtree_t *tree, int count, int max) { int i; int errors = 0; for (i = 0; i < count; i++) { - int key = 1 + (int) ((rand() * 1.0 * max) / (RAND_MAX + 1.0)); + int key = 1 + (int)((rand() * 1.0 * max) / (RAND_MAX + 1.0)); int *value; if ((value = (int *) sbtree_get(tree, key))) { @@ -376,14 +358,13 @@ test_empty(sbtree_t *tree, int count, int max) } if (errors) - fprintf(stderr," (%d/%d errors)\n", any_error = errors, count); + fprintf(stderr, " (%d/%d errors)\n", any_error = errors, count); else - fprintf(stderr,"OK\n"); + fprintf(stderr, "OK\n"); } void -run_test(sbtree_t *tree, int entries, int *data, int random, int max_value) -{ +run_test(sbtree_t *tree, int entries, int *data, int random, int max_value) { char *tests[] = {"\tLinear reference test: \t\t", "\tKey map reference test: \t", "\tRandom access test: \t\t"}; int i; @@ -405,7 +386,7 @@ run_test(sbtree_t *tree, int entries, int *data, int random, int max_value) sbtree_foreach(tree, NULL, foreach_double_func); fprintf(stderr, "\tForeach test: \t\t\t"); if (i * 2 != data[0]) { - fprintf(stderr,"Error: No effect: %d * 2 != %d\n", i, data[0]); + fprintf(stderr, "Error: No effect: %d * 2 != %d\n", i, data[0]); any_error = 1; } else test_value(tree, entries * 2, entries * 2, entries, data, MODE_LINEAR_DOUBLE); @@ -422,51 +403,50 @@ run_test(sbtree_t *tree, int entries, int *data, int random, int max_value) #define TESTS_NR 11 int -main(int argc, char **argv) -{ +main(int argc, char **argv) { int tests_nr = TESTS_NR; int test_sizes[TESTS_NR] = {1, 2, 3, 7, 8, 9, 1000, 16383, 16384, 16385, 1000000}; int i; fprintf(stderr, "sbtree.c Copyright (C) 2000 Christoph Reichenbach \n" - "This program is provided WITHOUT WARRANTY of any kind\n" - "Please refer to the file COPYING that should have come with this program\n"); + "This program is provided WITHOUT WARRANTY of any kind\n" + "Please refer to the file COPYING that should have come with this program\n"); fprintf(stderr, "Static Binary Tree testing facility\n"); free(malloc(42)); /* Make sure libefence's Copyright message is print here if we're using it */ - fprintf(stderr,"\nsbtree.c: Running %d tests.\n", tests_nr); + fprintf(stderr, "\nsbtree.c: Running %d tests.\n", tests_nr); for (i = 0; i < tests_nr; i++) { int entries = test_sizes[i]; sbtree_t *tree; int *data; - fprintf(stderr,"Test #%d: %d entries\n", i+1, entries); + fprintf(stderr, "Test #%d: %d entries\n", i + 1, entries); - fprintf(stderr,"\t%da: Linear values\n", i+1); + fprintf(stderr, "\t%da: Linear values\n", i + 1); data = generate_linear_forward(entries); tree = sbtree_new(entries, data); run_test(tree, entries, data, 0, entries); - fprintf(stderr,"\t%db: Reverse linear values\n", i+1); + fprintf(stderr, "\t%db: Reverse linear values\n", i + 1); data = generate_linear_backward(entries); tree = sbtree_new(entries, data); run_test(tree, entries, data, 0, entries); - fprintf(stderr,"\t%dc: Dense random values\n", i+1); + fprintf(stderr, "\t%dc: Dense random values\n", i + 1); data = generate_random(entries, 1 + (entries >> 2)); tree = sbtree_new(entries, data); run_test(tree, entries, data, 1, 1 + (entries >> 2)); - fprintf(stderr,"\t%dc: Sparse random values\n", i+1); + fprintf(stderr, "\t%dc: Sparse random values\n", i + 1); data = generate_random(entries, (entries << 2)); tree = sbtree_new(entries, data); run_test(tree, entries, data, 1, entries << 2); - fprintf(stderr,"Test #%d completed.\n\n", i+1); + fprintf(stderr, "Test #%d completed.\n\n", i + 1); } - fprintf(stderr,"Test suite completed.\n"); + fprintf(stderr, "Test suite completed.\n"); return 0; } diff --git a/engines/sci/gfx/sci_widgets.cpp b/engines/sci/gfx/sci_widgets.cpp index d840962503..8f47e4a97f 100644 --- a/engines/sci/gfx/sci_widgets.cpp +++ b/engines/sci/gfx/sci_widgets.cpp @@ -36,8 +36,7 @@ static void -clear_titlebar(gfxw_port_t *titlebar) -{ +clear_titlebar(gfxw_port_t *titlebar) { if (titlebar->contents) { titlebar->contents->widfree(titlebar->contents); titlebar->contents = NULL; @@ -46,8 +45,7 @@ clear_titlebar(gfxw_port_t *titlebar) } static gfxw_list_t * -make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) -{ +make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) { gfx_color_t color = status_bar->bgcolor; gfxw_list_t *list; gfxw_box_t *bgbox; @@ -55,7 +53,7 @@ make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) list = gfxw_new_list(status_bar->bounds, 0); bgbox = gfxw_new_box(s->gfx_state, gfx_rect(0, 0, status_bar->bounds.xl, status_bar->bounds.yl - 1), - color, color, GFX_BOX_SHADE_FLAT); + color, color, GFX_BOX_SHADE_FLAT); list->add((gfxw_container_t *) list, (gfxw_widget_t *) bgbox); @@ -63,22 +61,20 @@ make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) } static gfxw_list_t * -finish_titlebar_list(state_t *s, gfxw_list_t *list, gfxw_port_t *status_bar) -{ +finish_titlebar_list(state_t *s, gfxw_list_t *list, gfxw_port_t *status_bar) { gfx_color_t black = s->ega_colors[0]; gfxw_primitive_t *line; line = gfxw_new_line(gfx_point(0, status_bar->bounds.yl - 1), - gfx_point(status_bar->bounds.xl, status_bar->bounds.yl - 1), - black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL); + gfx_point(status_bar->bounds.xl, status_bar->bounds.yl - 1), + black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL); list->add((gfxw_container_t *) list, (gfxw_widget_t *) line); return list; } void -sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor, int bgcolor) -{ +sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor, int bgcolor) { gfx_state_t *state; gfxw_list_t *list; gfx_color_t bg = status_bar->bgcolor; @@ -101,8 +97,8 @@ sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor if (text) { gfxw_text_t *textw = gfxw_new_text(state, gfx_rect(0, 0, status_bar->bounds.xl, status_bar->bounds.yl), - status_bar->font_nr, text, ALIGN_LEFT, ALIGN_CENTER, - fg, fg, bg, GFXR_FONT_FLAG_NO_NEWLINES); + status_bar->font_nr, text, ALIGN_LEFT, ALIGN_CENTER, + fg, fg, bg, GFXR_FONT_FLAG_NO_NEWLINES); list = make_titlebar_list(s, status_bar->bounds, status_bar); @@ -110,7 +106,7 @@ sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor } else { gfxw_box_t *bgbox = gfxw_new_box(state, gfx_rect(0, 0, status_bar->bounds.xl, status_bar->bounds.yl - 1), - black, black, GFX_BOX_SHADE_FLAT); + black, black, GFX_BOX_SHADE_FLAT); list = gfxw_new_list(status_bar->bounds, 0); @@ -125,23 +121,21 @@ sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor } static void -sciw_make_window_fit(rect_t *rect, gfxw_port_t *parent) -{ - /* This window is meant to cover the whole screen, so we allow it to go through. */ - if (rect->xl == 319 && rect->yl == 189) return; +sciw_make_window_fit(rect_t *rect, gfxw_port_t *parent) { + /* This window is meant to cover the whole screen, so we allow it to go through. */ + if (rect->xl == 319 && rect->yl == 189) return; - if (rect->x + rect->xl > parent->bounds.x + parent->bounds.xl) - rect->x -= (rect->x + rect->xl) - (parent->bounds.x + parent->bounds.xl) + 2; + if (rect->x + rect->xl > parent->bounds.x + parent->bounds.xl) + rect->x -= (rect->x + rect->xl) - (parent->bounds.x + parent->bounds.xl) + 2; - if (rect->y + rect->yl > parent->bounds.y + parent->bounds.yl) - rect->y -= (rect->y + rect->yl) - (parent->bounds.y + parent->bounds.yl) + 2; + if (rect->y + rect->yl > parent->bounds.y + parent->bounds.yl) + rect->y -= (rect->y + rect->yl) - (parent->bounds.y + parent->bounds.yl) + 2; } gfxw_port_t * sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_t bgcolor, - int title_font, gfx_color_t title_color, gfx_color_t title_bgcolor, - const char *title, int flags) -{ + int title_font, gfx_color_t title_color, gfx_color_t title_bgcolor, + const char *title, int flags) { gfxw_visual_t *visual = s->visual; gfx_state_t *state = s->gfx_state; int shadow_offset = 2; @@ -152,8 +146,7 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ // int xextra = !(flags & WINDOW_FLAG_NOFRAME) ? 1 : 0; // int yextra = !(flags & WINDOW_FLAG_NOFRAME) ? 2 : 0; - if (area.xl == 319 && area.yl == 189) - { + if (area.xl == 319 && area.yl == 189) { flags |= WINDOW_FLAG_NOFRAME; /* The below line makes the points bar in QfG2 work, but breaks the one in QfG1. Hm. */ @@ -195,22 +188,22 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ return win; /* Fully transparent window */ if (flags & WINDOW_FLAG_TITLE) - frame = gfx_rect(area.x-1, area.y-10, area.xl + 2, area.yl + 11); + frame = gfx_rect(area.x - 1, area.y - 10, area.xl + 2, area.yl + 11); else - frame = gfx_rect(area.x-1, area.y-1, area.xl + 2, area.yl + 2); + frame = gfx_rect(area.x - 1, area.y - 1, area.xl + 2, area.yl + 2); /* Set visible window boundaries */ win->bounds = gfx_rect(frame.x, frame.y, frame.xl + shadow_offset, frame.yl + shadow_offset); decorations = gfxw_new_list(gfx_rect(frame.x, frame.y, - frame.xl + 1 + shadow_offset, frame.yl + 1 + shadow_offset), 0); + frame.xl + 1 + shadow_offset, frame.yl + 1 + shadow_offset), 0); if (!(flags & WINDOW_FLAG_TRANSPARENT)) { /* Draw window background */ - win->port_bg = (gfxw_widget_t *) gfxw_new_box (state, - gfx_rect(1, (flags & WINDOW_FLAG_TITLE)? 10 : 1, - area.xl, area.yl), - bgcolor, bgcolor, GFX_BOX_SHADE_FLAT); + win->port_bg = (gfxw_widget_t *) gfxw_new_box(state, + gfx_rect(1, (flags & WINDOW_FLAG_TITLE) ? 10 : 1, + area.xl, area.yl), + bgcolor, bgcolor, GFX_BOX_SHADE_FLAT); decorations->add((gfxw_container_t *) decorations, win->port_bg); win->flags |= GFXW_FLAG_OPAQUE; } @@ -220,12 +213,12 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ rect_t title_rect = gfx_rect(1, 1, area.xl, 8); decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_box(state, title_rect, title_bgcolor, title_bgcolor, GFX_BOX_SHADE_FLAT)); + gfxw_new_box(state, title_rect, title_bgcolor, title_bgcolor, GFX_BOX_SHADE_FLAT)); decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_text(state, title_rect, title_font, title, - ALIGN_CENTER, ALIGN_CENTER, title_color, title_color, - title_bgcolor, GFXR_FONT_FLAG_NO_NEWLINES)); + gfxw_new_text(state, title_rect, title_font, title, + ALIGN_CENTER, ALIGN_CENTER, title_color, title_color, + title_bgcolor, GFXR_FONT_FLAG_NO_NEWLINES)); } if (!(flags & WINDOW_FLAG_NOFRAME)) { @@ -238,14 +231,14 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ } decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_box(state, gfx_rect(shadow_offset + 1, frame.yl - 1, - frame.xl - 4, shadow_offset), - black, black, GFX_BOX_SHADE_FLAT)); + gfxw_new_box(state, gfx_rect(shadow_offset + 1, frame.yl - 1, + frame.xl - 4, shadow_offset), + black, black, GFX_BOX_SHADE_FLAT)); decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_box(state, gfx_rect(frame.xl - 1, shadow_offset + 1, - shadow_offset, frame.yl - 2), - black, black, GFX_BOX_SHADE_FLAT)); + gfxw_new_box(state, gfx_rect(frame.xl - 1, shadow_offset + 1, + shadow_offset, frame.yl - 2), + black, black, GFX_BOX_SHADE_FLAT)); } /* Draw frame */ @@ -258,18 +251,18 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ if (!(flags & WINDOW_FLAG_NO_DROP_SHADOW)) { decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_rect(gfx_rect(0, 0, frame.xl-1, frame.yl-1), - black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); + gfxw_new_rect(gfx_rect(0, 0, frame.xl - 1, frame.yl - 1), + black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); if (flags & WINDOW_FLAG_TITLE) decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_line(gfx_point(1, 9), - gfx_point(frame.xl - 2, 9), - black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL)); + gfxw_new_line(gfx_point(1, 9), + gfx_point(frame.xl - 2, 9), + black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL)); } else { decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_rect(gfx_rect(0, 0, frame.xl, frame.yl), - black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); + gfxw_new_rect(gfx_rect(0, 0, frame.xl, frame.yl), + black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); } } @@ -286,17 +279,15 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ /**** Controls ****/ /*----------------*/ static inline rect_t -_move_and_extend_rect(rect_t rect, point_t point, int yplus) -{ +_move_and_extend_rect(rect_t rect, point_t point, int yplus) { return gfx_rect(rect.x + point.x, rect.y + point.y, rect.xl + 1, rect.yl + yplus); } gfxw_list_t * _sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t zone, char *text, - int font, gfx_alignment_t align, char framed, char inverse, int flags, - char gray_text) -{ + int font, gfx_alignment_t align, char framed, char inverse, int flags, + char gray_text) { gfx_color_t *color1, *color2, *bgcolor; if (inverse) { @@ -311,8 +302,8 @@ _sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t zone, char * } list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, zone, - font, text, align, ALIGN_TOP, - *color1, *color2, *bgcolor, flags))); + font, text, align, ALIGN_TOP, + *color1, *color2, *bgcolor, flags))); zone.xl--; @@ -320,17 +311,16 @@ _sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t zone, char * if (framed) { list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, *color2, GFX_LINE_MODE_CORRECT, - GFX_LINE_STYLE_STIPPLED))); + GFXW(gfxw_new_rect(zone, *color2, GFX_LINE_MODE_CORRECT, + GFX_LINE_STYLE_STIPPLED))); } return list; } gfxw_list_t * -sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, char selected, char inverse, char grayed_out) -{ - gfx_color_t *frame_col = (inverse)? &(port->bgcolor) : &(port->color); +sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, char selected, char inverse, char grayed_out) { + gfx_color_t *frame_col = (inverse) ? &(port->bgcolor) : &(port->color); gfxw_list_t *list; zone.x--; @@ -346,25 +336,25 @@ sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, in zone.y = 0; if (inverse) - list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.xl + 1, zone.yl + 1), - port->color, port->color, GFX_BOX_SHADE_FLAT))); + list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.xl + 1, zone.yl + 1), + port->color, port->color, GFX_BOX_SHADE_FLAT))); if (!inverse) list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.xl - 1, zone.yl), - text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); + text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); if (!inverse) list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(zone, *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); if (inverse) list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.xl - 1, zone.yl), - text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); + text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); - if (selected) - list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x + 1, zone.y + 1, zone.xl - 2, zone.yl - 2), - *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + if (selected) + list->add(GFXWC(list), + GFXW(gfxw_new_rect(gfx_rect(zone.x + 1, zone.y + 1, zone.xl - 2, zone.yl - 2), + *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); return list; } @@ -372,8 +362,7 @@ sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, in gfxw_list_t * sciw_new_text_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, - gfx_alignment_t align, char framed, char inverse) -{ + gfx_alignment_t align, char framed, char inverse) { gfxw_list_t *list = gfxw_new_list(_move_and_extend_rect(zone, gfx_point(port->zone.x, port->zone.y), 2), 0); gfxw_set_id(GFXW(list), ID.segment, ID.offset); @@ -387,8 +376,7 @@ sciw_new_text_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int gfxw_list_t * sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, unsigned int cursor, - char inverse) -{ + char inverse) { gfxw_text_t *text_handle; long draw_cursor; long foo; @@ -411,8 +399,8 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int if (!draw_cursor) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, text, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + font, text, ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); } else { @@ -425,8 +413,8 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int if (cursor > 0) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, textdup, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + font, textdup, ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; @@ -436,32 +424,32 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int textdup[0] = text[cursor]; textdup[1] = 0; text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, textdup, ALIGN_LEFT, ALIGN_TOP, - port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES); + font, textdup, ALIGN_LEFT, ALIGN_TOP, + port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; }; - if (cursor+1 < strlen(text)) { + if (cursor + 1 < strlen(text)) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, text + cursor + 1, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + font, text + cursor + 1, ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; }; if (cursor == strlen(text)) list->add(GFXWC(list), GFXW(gfxw_new_line(gfx_point(zone.x, zone.y), - gfx_point(zone.x, zone.y + cursor_height - 1), - port->color, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL))); + gfx_point(zone.x, zone.y + cursor_height - 1), + port->color, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL))); free(textdup); } zone.x = zone.y = 0; - list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + list->add(GFXWC(list), + GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); return list; } @@ -469,8 +457,7 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int gfxw_list_t * sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int view, int loop, int cel, - char frame, char inverse) -{ + char frame, char inverse) { gfxw_list_t *list = gfxw_new_list(_move_and_extend_rect(zone, gfx_point(port->zone.x, port->zone.y), 1), 0); gfxw_widget_t *icon; gfxw_set_id(GFXW(list), ID.segment, ID.offset); @@ -484,7 +471,7 @@ sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int view, int lo zone.y = 0; icon = GFXW(gfxw_new_view(port->visual->gfx_state, gfx_point(zone.x, zone.y), view, loop, cel, 0, -1, -1, - ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET)); + ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET)); if (!icon) { GFXERROR("Attempt to create icon control with cel %d/%d/%d (invalid)\n", view, loop, cel); @@ -501,8 +488,7 @@ sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int view, int lo gfxw_list_t * sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, char **entries_list, - int entries_nr, int list_top, int selection, char inverse) -{ + int entries_nr, int list_top, int selection, char inverse) { gfxw_list_t *list; char arr_up[2], arr_down[2]; @@ -544,16 +530,16 @@ sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, cha if (i != selection) list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), - font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), + font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); else { list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 1, font_height), - port->color, port->color, GFX_BOX_SHADE_FLAT))); + port->color, port->color, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), - font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, - port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), + font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, + port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES))); } zone.y += font_height; @@ -566,33 +552,33 @@ sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, cha /* Add up arrow */ list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, 0, zone.xl-2, 8), - port->font_nr, arr_up, ALIGN_CENTER, ALIGN_CENTER, - port->color, port->color, port->bgcolor, 0))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, 0, zone.xl - 2, 8), + port->font_nr, arr_up, ALIGN_CENTER, ALIGN_CENTER, + port->color, port->color, port->bgcolor, 0))); /* Add down arrow */ list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, zone.yl-9, zone.xl-2, 8), - port->font_nr, arr_down, ALIGN_CENTER, ALIGN_CENTER, - port->color, port->color, port->bgcolor, 0))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, zone.yl - 9, zone.xl - 2, 8), + port->font_nr, arr_down, ALIGN_CENTER, ALIGN_CENTER, + port->color, port->color, port->bgcolor, 0))); if (list_top & 1) { /* Hack to work around aggressive caching */ list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 20), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 20), + port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); } else { list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y, zone.xl, zone.yl - 10), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y, zone.xl, zone.yl - 10), + port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 10), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 10), + port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); } return list; @@ -600,8 +586,7 @@ sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, cha void -sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) -{ +sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) { gfxw_list_t *list = make_titlebar_list(s, status_bar->bounds, status_bar); int offset = MENU_LEFT_BORDER; int i; @@ -614,16 +599,16 @@ sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int se if (i == selection) { list->add(GFXWC(list), GFXW(gfxw_new_box(status_bar->visual->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), - status_bar->color, status_bar->color, GFX_BOX_SHADE_FLAT))); + status_bar->color, status_bar->color, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), - GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), - status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, - status_bar->bgcolor, status_bar->bgcolor, status_bar->color, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), + status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, + status_bar->bgcolor, status_bar->bgcolor, status_bar->color, GFXR_FONT_FLAG_NO_NEWLINES))); } else list->add(GFXWC(list), - GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), - status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, - status_bar->color, status_bar->color, status_bar->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), + status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, + status_bar->color, status_bar->color, status_bar->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); offset += width; } @@ -633,8 +618,7 @@ sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int se } gfxw_port_t * -sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) -{ +sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) { gfxw_port_t *retval; menu_t *menu = menubar->menus + selection; rect_t area = gfx_rect(MENU_LEFT_BORDER, 10, 0, 0); @@ -655,8 +639,8 @@ sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selec area.yl = menu->items_nr * 10; retval = sciw_new_window(s, area, status_bar->font_nr, status_bar->color, status_bar->bgcolor, - 0, status_bar->color, status_bar->bgcolor, - NULL, WINDOW_FLAG_NO_DROP_SHADOW | WINDOW_FLAG_TRANSPARENT); + 0, status_bar->color, status_bar->bgcolor, + NULL, WINDOW_FLAG_NO_DROP_SHADOW | WINDOW_FLAG_TRANSPARENT); retval->set_visual(GFXW(retval), s->visual); @@ -669,8 +653,7 @@ sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selec #define MAGIC_ID_OFFSET 0x2000 static inline gfx_color_t -un_prioritize(gfx_color_t col) -{ +un_prioritize(gfx_color_t col) { col.priority = -1; col.mask &= ~GFX_MASK_PRIORITY; @@ -678,8 +661,7 @@ un_prioritize(gfx_color_t col) } gfxw_widget_t * -_make_menu_entry(menu_item_t *item, int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID, int gray) -{ +_make_menu_entry(menu_item_t *item, int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID, int gray) { rect_t area = gfx_rect(MENU_BOX_LEFT_PADDING, 0, width - MENU_BOX_LEFT_PADDING, 10); rect_t list_area = gfx_rect(port->zone.x, area.y + offset + port->zone.y, width, area.yl); gfxw_list_t *list = (gfxw_list_t *) gfxw_set_id(GFXW(gfxw_new_list(list_area, 0)), ID, GFXW_NO_ID); @@ -688,24 +670,23 @@ _make_menu_entry(menu_item_t *item, int offset, int width, gfxw_port_t *port, gf color = un_prioritize(color); bgcolor = un_prioritize(bgcolor); - xcolor = gray? color : bgcolor; + xcolor = gray ? color : bgcolor; list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, area, port->font_nr, item->text, ALIGN_LEFT, ALIGN_CENTER, - color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); if (item->keytext) { area.xl -= MENU_BOX_RIGHT_PADDING; list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, area, port->font_nr, item->keytext, ALIGN_RIGHT, ALIGN_CENTER, - color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); } return GFXW(list); } gfxw_widget_t * -_make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID) -{ +_make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID) { rect_t area = gfx_rect(0, 0, width, 10); rect_t list_area = gfx_rect(area.x + port->zone.x, area.y + offset + port->zone.y, area.xl, area.yl); gfxw_list_t *list = (gfxw_list_t *) gfxw_set_id(GFXW(gfxw_new_list(list_area, 0)), ID, GFXW_NO_ID); @@ -715,16 +696,15 @@ _make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_line(gfx_point(0, 5), - gfx_point(width, 5), - color, - GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED))); + gfx_point(width, 5), + color, + GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED))); return GFXW(list); } gfxw_port_t * -sciw_unselect_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) -{ +sciw_unselect_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) { menu_item_t *item = menu->items + selection; if (selection < 0 || selection >= menu->items_nr) @@ -732,20 +712,19 @@ sciw_unselect_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selecti if (item->type == MENU_TYPE_NORMAL) menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->color, - menu_port->bgcolor, selection + MAGIC_ID_OFFSET, - item->enabled))); + menu_port, menu_port->color, + menu_port->bgcolor, selection + MAGIC_ID_OFFSET, + item->enabled))); else menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->color, - menu_port->bgcolor, selection + MAGIC_ID_OFFSET))); + menu_port, menu_port->color, + menu_port->bgcolor, selection + MAGIC_ID_OFFSET))); return menu_port; } gfxw_port_t * -sciw_select_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) -{ +sciw_select_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) { menu_item_t *item = menu->items + selection; if (selection < 0 || selection >= menu->items_nr) @@ -753,13 +732,13 @@ sciw_select_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection if (item->type == MENU_TYPE_NORMAL) menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->bgcolor, - menu_port->color, selection + MAGIC_ID_OFFSET, - item->enabled))); + menu_port, menu_port->bgcolor, + menu_port->color, selection + MAGIC_ID_OFFSET, + item->enabled))); else menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->bgcolor, - menu_port->color, selection + MAGIC_ID_OFFSET))); + menu_port, menu_port->bgcolor, + menu_port->color, selection + MAGIC_ID_OFFSET))); return menu_port; } diff --git a/engines/sci/gfx/widgets.cpp b/engines/sci/gfx/widgets.cpp index 778a0eb5ae..c805a9aee8 100644 --- a/engines/sci/gfx/widgets.cpp +++ b/engines/sci/gfx/widgets.cpp @@ -47,8 +47,7 @@ gfxw_widget_t *debug_widgets[GFXW_DEBUG_WIDGETS]; int debug_widget_pos = 0; static void -_gfxw_debug_add_widget(gfxw_widget_t *widget) -{ +_gfxw_debug_add_widget(gfxw_widget_t *widget) { if (debug_widget_pos == GFXW_DEBUG_WIDGETS) { GFXERROR("WIDGET DEBUG: Allocated the maximum number of %d widgets- Aborting!\n", GFXW_DEBUG_WIDGETS); BREAKPOINT(); @@ -63,7 +62,7 @@ _gfxw_debug_remove_widget(gfxw_widget_t *widget) { for (i = 0; i < debug_widget_pos; i++) { if (debug_widgets[i] == widget) { memmove(debug_widgets + i, debug_widgets + i + 1, - (sizeof (gfxw_widget_t *)) * (debug_widget_pos - i - 1)); + (sizeof(gfxw_widget_t *)) * (debug_widget_pos - i - 1)); debug_widgets[debug_widget_pos--] = NULL; found++; } @@ -86,16 +85,14 @@ _gfxw_debug_remove_widget(gfxw_widget_t *widget) { static inline void -indent(int indentation) -{ +indent(int indentation) { int i; for (i = 0; i < indentation; i++) sciprintf(" "); } static void -_gfxw_print_widget(gfxw_widget_t *widget, int indentation) -{ +_gfxw_print_widget(gfxw_widget_t *widget, int indentation) { unsigned int i; char flags_list[] = "VOCDTMI"; @@ -130,8 +127,7 @@ _gfxw_print_widget(gfxw_widget_t *widget, int indentation) } static int -_gfxwop_print_empty(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_print_empty(gfxw_widget_t *widget, int indentation) { _gfxw_print_widget(widget, indentation); sciprintf("", widget->type); @@ -140,8 +136,7 @@ _gfxwop_print_empty(gfxw_widget_t *widget, int indentation) gfxw_widget_t * -_gfxw_new_widget(int size, gfxw_widget_type_t type) -{ +_gfxw_new_widget(int size, gfxw_widget_type_t type) { gfxw_widget_t *widget = (gfxw_widget_t*)sci_malloc(size); #ifdef SATISFY_PURIFY memset(widget, 0, size); @@ -175,8 +170,7 @@ _gfxw_new_widget(int size, gfxw_widget_type_t type) static inline int -verify_widget(gfxw_widget_t *widget) -{ +verify_widget(gfxw_widget_t *widget) { if (!widget) { GFXERROR("Attempt to use NULL widget\n"); #ifdef GFXW_DEBUG_WIDGETS @@ -201,8 +195,7 @@ verify_widget(gfxw_widget_t *widget) if (verify_widget((gfxw_widget_t *)(w))) { GFXERROR("Error occured while validating widget\n"); } static void -_gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) -{ +_gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { if (GFXW_IS_TEXT(widget)) { gfxw_text_t *text = (gfxw_text_t *) widget; @@ -271,16 +264,15 @@ _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) static inline int -_color_equals(gfx_color_t a, gfx_color_t b) -{ +_color_equals(gfx_color_t a, gfx_color_t b) { if (a.mask != b.mask) return 0; if (a.mask & GFX_MASK_VISUAL) { if (a.visual.r != b.visual.r - || a.visual.g != b.visual.g - || a.visual.b != b.visual.b - || a.alpha != b.alpha) + || a.visual.g != b.visual.g + || a.visual.b != b.visual.b + || a.alpha != b.alpha) return 0; } @@ -296,12 +288,11 @@ _color_equals(gfx_color_t a, gfx_color_t b) } static int -_gfxwop_basic_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) -{ +_gfxwop_basic_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) { widget->visual = visual; if (widget->parent) { - DDIRTY(stderr,"basic_set_visual: DOWNWARDS rel(%d,%d,%d,%d, 1)\n", + DDIRTY(stderr, "basic_set_visual: DOWNWARDS rel(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->bounds)); widget->parent->add_dirty_rel(widget->parent, widget->bounds, 1); } @@ -311,15 +302,13 @@ _gfxwop_basic_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) static int -_gfxwop_basic_should_replace(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_basic_should_replace(gfxw_widget_t *widget, gfxw_widget_t *other) { return 0; } static inline void _gfxw_set_ops(gfxw_widget_t *widget, gfxw_point_op *draw, gfxw_op *free, gfxw_op *tag, gfxw_op_int *print, - gfxw_bin_op *compare_to, gfxw_bin_op *equals, gfxw_bin_op *superarea_of) -{ + gfxw_bin_op *compare_to, gfxw_bin_op *equals, gfxw_bin_op *superarea_of) { widget->draw = draw; widget->widfree = free; widget->tag = tag; @@ -333,8 +322,7 @@ _gfxw_set_ops(gfxw_widget_t *widget, gfxw_point_op *draw, gfxw_op *free, gfxw_op } void -gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *widget) -{ +gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *widget) { gfxw_widget_t **seekerp; if (!container) { @@ -345,7 +333,7 @@ gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *wi seekerp = &(container->contents); if (GFXW_IS_LIST(widget) && GFXW_IS_PORT(container)) { - gfxw_port_t *port = (gfxw_port_t *) container; + gfxw_port_t *port = (gfxw_port_t *) container; if (port->decorations == (gfxw_list_t *) widget) { port->decorations = NULL; return; @@ -374,10 +362,9 @@ gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *wi } static int -_gfxwop_basic_free(gfxw_widget_t *widget) -{ +_gfxwop_basic_free(gfxw_widget_t *widget) { gfxw_visual_t *visual = widget->visual; - gfx_state_t *state = (visual)? visual->gfx_state : NULL; + gfx_state_t *state = (visual) ? visual->gfx_state : NULL; DDIRTY(stderr, "BASIC-FREE: SomeAddDirty\n"); @@ -398,8 +385,7 @@ _gfxwop_basic_free(gfxw_widget_t *widget) static int -_gfxwop_basic_tag(gfxw_widget_t *widget) -{ +_gfxwop_basic_tag(gfxw_widget_t *widget) { widget->flags |= GFXW_FLAG_TAGGED; return 0; @@ -407,22 +393,19 @@ _gfxwop_basic_tag(gfxw_widget_t *widget) static int -_gfxwop_basic_compare_to(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_basic_compare_to(gfxw_widget_t *widget, gfxw_widget_t *other) { return 1; } static int -_gfxwop_basic_equals(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_basic_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { return 0; } static int -_gfxwop_basic_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_basic_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) { return (widget == other); } @@ -431,14 +414,12 @@ _gfxwop_basic_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) /*-------------*/ static inline rect_t -_move_rect(rect_t rect, point_t point) -{ +_move_rect(rect_t rect, point_t point) { return gfx_rect(rect.x + point.x, rect.y + point.y, rect.xl, rect.yl); } static inline void -_split_rect(rect_t rect, point_t *p1, point_t *p2) -{ +_split_rect(rect_t rect, point_t *p1, point_t *p2) { p1->x = rect.x; p1->y = rect.y; p2->x = rect.x + rect.xl; @@ -446,33 +427,29 @@ _split_rect(rect_t rect, point_t *p1, point_t *p2) } static inline point_t -_move_point(rect_t rect, point_t point) -{ +_move_point(rect_t rect, point_t point) { return gfx_point(rect.x + point.x, rect.y + point.y); } static int -_gfxwop_box_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_box_draw(gfxw_widget_t *widget, point_t pos) { gfxw_box_t *box = (gfxw_box_t *) widget; DRAW_ASSERT(widget, GFXW_BOX); GFX_ASSERT(gfxop_draw_box(box->visual->gfx_state, _move_rect(box->bounds, pos), box->color1, - box->color2, box->shade_type)); + box->color2, box->shade_type)); return 0; } static int -_gfxwop_box_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_box_print(gfxw_widget_t *widget, int indentation) { _gfxw_print_widget(widget, indentation); sciprintf("BOX"); return 0; } static int -_gfxwop_box_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_box_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_box_t *box = (gfxw_box_t *) widget; if (box->color1.alpha) @@ -488,8 +465,7 @@ _gfxwop_box_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) } static int -_gfxwop_box_equals(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_box_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_box_t *wbox = (gfxw_box_t *) widget, *obox; if (other->type != GFXW_BOX) return 0; @@ -506,33 +482,30 @@ _gfxwop_box_equals(gfxw_widget_t *widget, gfxw_widget_t *other) return 0; if (wbox->shade_type != GFX_BOX_SHADE_FLAT - && _color_equals(wbox->color2, obox->color2)) + && _color_equals(wbox->color2, obox->color2)) return 0; return 1; } void -_gfxw_set_ops_BOX(gfxw_widget_t *widget) -{ +_gfxw_set_ops_BOX(gfxw_widget_t *widget) { _gfxw_set_ops(GFXW(widget), _gfxwop_box_draw, - _gfxwop_basic_free, - _gfxwop_basic_tag, - _gfxwop_box_print, - _gfxwop_basic_compare_to, - _gfxwop_box_equals, - _gfxwop_box_superarea_of); + _gfxwop_basic_free, + _gfxwop_basic_tag, + _gfxwop_box_print, + _gfxwop_basic_compare_to, + _gfxwop_box_equals, + _gfxwop_box_superarea_of); } static inline int -_gfxw_color_get_priority(gfx_color_t color) -{ - return (color.mask & GFX_MASK_PRIORITY)? color.priority : -1; +_gfxw_color_get_priority(gfx_color_t color) { + return (color.mask & GFX_MASK_PRIORITY) ? color.priority : -1; } gfxw_box_t * -gfxw_new_box(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) -{ +gfxw_new_box(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) { gfxw_box_t *widget = (gfxw_box_t *) _gfxw_new_widget(sizeof(gfxw_box_t), GFXW_BOX); widget->widget_priority = _gfxw_color_get_priority(color1); @@ -544,8 +517,8 @@ gfxw_new_box(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t co widget->flags |= GFXW_FLAG_VISIBLE; if ((color1.mask & GFX_MASK_VISUAL) - && ((state && (state->driver->mode->palette)) - || (!color1.alpha && !color2.alpha))) + && ((state && (state->driver->mode->palette)) + || (!color1.alpha && !color2.alpha))) widget->flags |= GFXW_FLAG_OPAQUE; _gfxw_set_ops_BOX(GFXW(widget)); @@ -556,8 +529,7 @@ gfxw_new_box(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t co static inline gfxw_primitive_t * _gfxw_new_primitive(rect_t area, gfx_color_t color, gfx_line_mode_t mode, - gfx_line_style_t style, gfxw_widget_type_t type) -{ + gfx_line_style_t style, gfxw_widget_type_t type) { gfxw_primitive_t *widget = (gfxw_primitive_t *) _gfxw_new_widget(sizeof(gfxw_primitive_t), type); widget->widget_priority = _gfxw_color_get_priority(color); @@ -575,8 +547,7 @@ _gfxw_new_primitive(rect_t area, gfx_color_t color, gfx_line_mode_t mode, /*------------------*/ static int -_gfxwop_primitive_equals(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_primitive_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_primitive_t *wprim = (gfxw_primitive_t *) widget, *oprim; if (widget->type != other->type) return 0; @@ -599,22 +570,20 @@ _gfxwop_primitive_equals(gfxw_widget_t *widget, gfxw_widget_t *other) } static int -_gfxwop_rect_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_rect_draw(gfxw_widget_t *widget, point_t pos) { gfxw_primitive_t *rect = (gfxw_primitive_t *) widget; DRAW_ASSERT(widget, GFXW_RECT); GFX_ASSERT(gfxop_draw_rectangle(rect->visual->gfx_state, - gfx_rect(rect->bounds.x + pos.x, rect->bounds.y + pos.y, - rect->bounds.xl - 1, rect->bounds.yl - 1), - rect->color, rect->line_mode, rect->line_style)); + gfx_rect(rect->bounds.x + pos.x, rect->bounds.y + pos.y, + rect->bounds.xl - 1, rect->bounds.yl - 1), + rect->color, rect->line_mode, rect->line_style)); return 0; } static int -_gfxwop_rect_print(gfxw_widget_t *rect, int indentation) -{ +_gfxwop_rect_print(gfxw_widget_t *rect, int indentation) { _gfxw_print_widget(GFXW(rect), indentation); sciprintf("RECT"); return 0; @@ -622,20 +591,18 @@ _gfxwop_rect_print(gfxw_widget_t *rect, int indentation) void -_gfxw_set_ops_RECT(gfxw_widget_t *prim) -{ +_gfxw_set_ops_RECT(gfxw_widget_t *prim) { _gfxw_set_ops(GFXW(prim), _gfxwop_rect_draw, - _gfxwop_basic_free, - _gfxwop_basic_tag, - _gfxwop_rect_print, - _gfxwop_basic_compare_to, - _gfxwop_primitive_equals, - _gfxwop_basic_superarea_of); + _gfxwop_basic_free, + _gfxwop_basic_tag, + _gfxwop_rect_print, + _gfxwop_basic_compare_to, + _gfxwop_primitive_equals, + _gfxwop_basic_superarea_of); } gfxw_primitive_t * -gfxw_new_rect(rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) -{ +gfxw_new_rect(rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { gfxw_primitive_t *prim = _gfxw_new_primitive(rect, color, line_mode, line_style, GFXW_RECT); prim->bounds.xl++; prim->bounds.yl++; /* Since it is actually one pixel bigger in each direction */ @@ -651,8 +618,7 @@ gfxw_new_rect(rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_lin /*-------------*/ static int -_gfxwop_line_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_line_draw(gfxw_widget_t *widget, point_t pos) { gfxw_primitive_t *line = (gfxw_primitive_t *) widget; rect_t linepos = widget->bounds; point_t p1, p2; @@ -670,14 +636,13 @@ _gfxwop_line_draw(gfxw_widget_t *widget, point_t pos) _split_rect(_move_rect(linepos, pos), &p1, &p2); GFX_ASSERT(gfxop_draw_line(line->visual->gfx_state, p1, p2, - line->color, line->line_mode, line->line_style)); + line->color, line->line_mode, line->line_style)); return 0; } static int -_gfxwop_line_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_line_print(gfxw_widget_t *widget, int indentation) { _gfxw_print_widget(widget, indentation); if (widget->type == GFXW_INVERSE_LINE) sciprintf("INVERSE-LINE"); @@ -687,24 +652,22 @@ _gfxwop_line_print(gfxw_widget_t *widget, int indentation) } void -_gfxw_set_ops_LINE(gfxw_widget_t *prim) -{ +_gfxw_set_ops_LINE(gfxw_widget_t *prim) { _gfxw_set_ops(GFXW(prim), _gfxwop_line_draw, - _gfxwop_basic_free, - _gfxwop_basic_tag, - _gfxwop_line_print, - _gfxwop_basic_compare_to, - _gfxwop_primitive_equals, - _gfxwop_basic_superarea_of); + _gfxwop_basic_free, + _gfxwop_basic_tag, + _gfxwop_line_print, + _gfxwop_basic_compare_to, + _gfxwop_primitive_equals, + _gfxwop_basic_superarea_of); } gfxw_primitive_t * -gfxw_new_line(point_t start, point_t end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) -{ +gfxw_new_line(point_t start, point_t end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { gfxw_primitive_t *prim; /* Encode into internal representation */ - rect_t line = gfx_rect (start.x, start.y, end.x - start.x, end.y - start.y); + rect_t line = gfx_rect(start.x, start.y, end.x - start.x, end.y - start.y); byte inverse = 0; @@ -724,7 +687,7 @@ gfxw_new_line(point_t start, point_t end, gfx_color_t color, gfx_line_mode_t lin line.xl++; line.yl++; - prim = _gfxw_new_primitive(line, color, line_mode, line_style, inverse? GFXW_INVERSE_LINE : GFXW_LINE); + prim = _gfxw_new_primitive(line, color, line_mode, line_style, inverse ? GFXW_INVERSE_LINE : GFXW_LINE); _gfxw_set_ops_LINE(GFXW(prim)); @@ -738,8 +701,7 @@ gfxw_new_line(point_t start, point_t end, gfx_color_t color, gfx_line_mode_t lin gfxw_view_t * _gfxw_new_simple_view(gfx_state_t *state, point_t pos, int view, int loop, int cel, int palette, int priority, int control, - gfx_alignment_t halign, gfx_alignment_t valign, int size, gfxw_widget_type_t type) -{ + gfx_alignment_t halign, gfx_alignment_t valign, int size, gfxw_widget_type_t type) { gfxw_view_t *widget; int width, height; point_t offset; @@ -751,7 +713,7 @@ _gfxw_new_simple_view(gfx_state_t *state, point_t pos, int view, int loop, int c if (gfxop_get_cel_parameters(state, view, loop, cel, &width, &height, &offset)) { GFXERROR("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)\n", - view, cel, loop); + view, cel, loop); return NULL; } @@ -760,15 +722,15 @@ _gfxw_new_simple_view(gfx_state_t *state, point_t pos, int view, int loop, int c widget->widget_priority = priority; widget->pos = pos; widget->color.mask = - ((priority < 0)? 0 : GFX_MASK_PRIORITY) - | ((control < 0)? 0 : GFX_MASK_CONTROL); + ((priority < 0) ? 0 : GFX_MASK_PRIORITY) + | ((control < 0) ? 0 : GFX_MASK_CONTROL); widget->color.priority = priority; widget->color.control = control; widget->view = view; widget->loop = loop; widget->cel = cel; widget->palette = palette; - + if (halign == ALIGN_CENTER) widget->pos.x -= width >> 1; else if (halign == ALIGN_RIGHT) @@ -787,73 +749,66 @@ _gfxw_new_simple_view(gfx_state_t *state, point_t pos, int view, int loop, int c } int -_gfxwop_view_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_view_draw(gfxw_widget_t *widget, point_t pos) { gfxw_view_t *view = (gfxw_view_t *) widget; DRAW_ASSERT(widget, GFXW_VIEW); GFX_ASSERT(gfxop_draw_cel(view->visual->gfx_state, view->view, view->loop, - view->cel, gfx_point(view->pos.x + pos.x, view->pos.y + pos.y), - view->color, view->palette)); + view->cel, gfx_point(view->pos.x + pos.x, view->pos.y + pos.y), + view->color, view->palette)); return 0; } static int -_gfxwop_static_view_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_static_view_draw(gfxw_widget_t *widget, point_t pos) { gfxw_view_t *view = (gfxw_view_t *) widget; DRAW_ASSERT(widget, GFXW_VIEW); GFX_ASSERT(gfxop_draw_cel_static(view->visual->gfx_state, view->view, view->loop, - view->cel, _move_point(view->bounds, pos), - view->color, view->palette)); + view->cel, _move_point(view->bounds, pos), + view->color, view->palette)); return 0; } static int -_w_gfxwop_view_print(gfxw_widget_t *widget, const char *name, int indentation) -{ +_w_gfxwop_view_print(gfxw_widget_t *widget, const char *name, int indentation) { gfxw_view_t *view = (gfxw_view_t *) widget; _gfxw_print_widget(widget, indentation); sciprintf(name); sciprintf("(%d/%d/%d)@(%d,%d)[p:%d,c:%d]", view->view, view->loop, view->cel, view->pos.x, view->pos.y, - (view->color.mask & GFX_MASK_PRIORITY)? view->color.priority : -1, - (view->color.mask & GFX_MASK_CONTROL)? view->color.control : -1); + (view->color.mask & GFX_MASK_PRIORITY) ? view->color.priority : -1, + (view->color.mask & GFX_MASK_CONTROL) ? view->color.control : -1); return 0; } static int -_gfxwop_view_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_view_print(gfxw_widget_t *widget, int indentation) { return _w_gfxwop_view_print(widget, "VIEW", indentation); } static int -_gfxwop_static_view_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_static_view_print(gfxw_widget_t *widget, int indentation) { return _w_gfxwop_view_print(widget, "PICVIEW", indentation); } void -_gfxw_set_ops_VIEW(gfxw_widget_t *view, char stat) -{ +_gfxw_set_ops_VIEW(gfxw_widget_t *view, char stat) { _gfxw_set_ops(GFXW(view), (stat) ? _gfxwop_static_view_draw : _gfxwop_view_draw, - _gfxwop_basic_free, - _gfxwop_basic_tag, - (stat) ? _gfxwop_static_view_print : _gfxwop_view_print, - _gfxwop_basic_compare_to, - _gfxwop_basic_equals, - _gfxwop_basic_superarea_of); + _gfxwop_basic_free, + _gfxwop_basic_tag, + (stat) ? _gfxwop_static_view_print : _gfxwop_view_print, + _gfxwop_basic_compare_to, + _gfxwop_basic_equals, + _gfxwop_basic_superarea_of); } gfxw_view_t * gfxw_new_view(gfx_state_t *state, point_t pos, int view_nr, int loop, int cel, int palette, int priority, int control, - gfx_alignment_t halign, gfx_alignment_t valign, int flags) -{ + gfx_alignment_t halign, gfx_alignment_t valign, int flags) { gfxw_view_t *view; if (flags & GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET) { @@ -865,7 +820,7 @@ gfxw_new_view(gfx_state_t *state, point_t pos, int view_nr, int loop, int cel, i } view = _gfxw_new_simple_view(state, pos, view_nr, loop, cel, palette, priority, control, halign, valign, - sizeof(gfxw_view_t), (flags & GFXW_VIEW_FLAG_STATIC) ? GFXW_STATIC_VIEW : GFXW_VIEW); + sizeof(gfxw_view_t), (flags & GFXW_VIEW_FLAG_STATIC) ? GFXW_STATIC_VIEW : GFXW_VIEW); _gfxw_set_ops_VIEW(GFXW(view), (char)(flags & GFXW_VIEW_FLAG_STATIC)); @@ -877,14 +832,13 @@ gfxw_new_view(gfx_state_t *state, point_t pos, int view_nr, int loop, int cel, i /*---------------------*/ static int -_gfxwop_dyn_view_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_dyn_view_draw(gfxw_widget_t *widget, point_t pos) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) widget; DRAW_ASSERT(widget, GFXW_DYN_VIEW); GFX_ASSERT(gfxop_draw_cel(view->visual->gfx_state, view->view, view->loop, - view->cel, _move_point(view->draw_bounds, pos), - view->color, view->palette)); + view->cel, _move_point(view->draw_bounds, pos), + view->color, view->palette)); /* gfx_color_t red; red.visual.r = 0xff; red.visual.g = red.visual.b = 0; red.mask = GFX_MASK_VISUAL; @@ -900,30 +854,28 @@ _gfxwop_dyn_view_draw(gfxw_widget_t *widget, point_t pos) } static int -_gfxwop_draw_nop(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_draw_nop(gfxw_widget_t *widget, point_t pos) { return 0; } static int -_gfxwop_pic_view_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_pic_view_draw(gfxw_widget_t *widget, point_t pos) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) widget; DRAW_ASSERT(widget, GFXW_PIC_VIEW); GFX_ASSERT(gfxop_set_clip_zone(view->visual->gfx_state, view->parent->zone)); GFX_ASSERT(gfxop_draw_cel_static_clipped(view->visual->gfx_state, - view->view, view->loop, - view->cel, - _move_point(view->draw_bounds, pos), - view->color, view->palette)); + view->view, view->loop, + view->cel, + _move_point(view->draw_bounds, pos), + view->color, view->palette)); /* Draw again on the back buffer */ GFX_ASSERT(gfxop_draw_cel(view->visual->gfx_state, - view->view, view->loop, - view->cel, - _move_point(view->draw_bounds, pos), - view->color, view->palette)); + view->view, view->loop, + view->cel, + _move_point(view->draw_bounds, pos), + view->color, view->palette)); widget->draw = _gfxwop_draw_nop; /* No more drawing needs to be done */ @@ -933,38 +885,34 @@ _gfxwop_pic_view_draw(gfxw_widget_t *widget, point_t pos) } static int -_gfxwop_some_view_print(gfxw_widget_t *widget, int indentation, const char *type_string) -{ +_gfxwop_some_view_print(gfxw_widget_t *widget, int indentation, const char *type_string) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) widget; _gfxw_print_widget(widget, indentation); sciprintf(type_string); sciprintf(" SORT=%d z=%d seq=%d (%d/%d/%d)@(%d,%d)[p:%d,c:%d]; sig[%04x@%04x]", view->force_precedence, view->z, - view->sequence, view->view, view->loop, view->cel, view->pos.x, view->pos.y, - (view->color.mask & GFX_MASK_PRIORITY)? view->color.priority : -1, - (view->color.mask & GFX_MASK_CONTROL)? view->color.control : -1, - view->signal, view->signalp); + view->sequence, view->view, view->loop, view->cel, view->pos.x, view->pos.y, + (view->color.mask & GFX_MASK_PRIORITY) ? view->color.priority : -1, + (view->color.mask & GFX_MASK_CONTROL) ? view->color.control : -1, + view->signal, view->signalp); return 0; } static int -_gfxwop_dyn_view_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_dyn_view_print(gfxw_widget_t *widget, int indentation) { return _gfxwop_some_view_print(widget, indentation, "DYNVIEW"); } static int -_gfxwop_pic_view_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_pic_view_print(gfxw_widget_t *widget, int indentation) { return _gfxwop_some_view_print(widget, indentation, "PICVIEW"); } static int -_gfxwop_dyn_view_equals(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_dyn_view_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_dyn_view_t *wview = (gfxw_dyn_view_t *) widget, *oview; if (!GFXW_IS_DYN_VIEW(other)) return 0; @@ -972,13 +920,13 @@ _gfxwop_dyn_view_equals(gfxw_widget_t *widget, gfxw_widget_t *other) oview = (gfxw_dyn_view_t *) other; if (wview->pos.x != oview->pos.x - || wview->pos.y != oview->pos.y - || wview->z != oview->z) + || wview->pos.y != oview->pos.y + || wview->z != oview->z) return 0; if (wview->view != oview->view - || wview->loop != oview->loop - || wview->cel != oview->cel) + || wview->loop != oview->loop + || wview->cel != oview->cel) return 0; if (!_color_equals(wview->color, oview->color)) @@ -991,8 +939,7 @@ _gfxwop_dyn_view_equals(gfxw_widget_t *widget, gfxw_widget_t *other) } static int -_gfxwop_dyn_view_compare_to(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_dyn_view_compare_to(gfxw_widget_t *widget, gfxw_widget_t *other) { int retval; gfxw_dyn_view_t *wview = (gfxw_dyn_view_t *) widget, *oview; if (!GFXW_IS_DYN_VIEW(other)) @@ -1017,20 +964,18 @@ _gfxwop_dyn_view_compare_to(gfxw_widget_t *widget, gfxw_widget_t *other) void -_gfxw_set_ops_DYNVIEW(gfxw_widget_t *widget) -{ +_gfxw_set_ops_DYNVIEW(gfxw_widget_t *widget) { _gfxw_set_ops(GFXW(widget), _gfxwop_dyn_view_draw, - _gfxwop_basic_free, - _gfxwop_basic_tag, - _gfxwop_dyn_view_print, - _gfxwop_dyn_view_compare_to, - _gfxwop_dyn_view_equals, - _gfxwop_basic_superarea_of); + _gfxwop_basic_free, + _gfxwop_basic_tag, + _gfxwop_dyn_view_print, + _gfxwop_dyn_view_compare_to, + _gfxwop_dyn_view_equals, + _gfxwop_basic_superarea_of); } void -_gfxw_set_ops_PICVIEW(gfxw_widget_t *widget) -{ +_gfxw_set_ops_PICVIEW(gfxw_widget_t *widget) { _gfxw_set_ops_DYNVIEW(widget); widget->draw = _gfxwop_pic_view_draw; widget->print = _gfxwop_pic_view_print; @@ -1038,8 +983,7 @@ _gfxw_set_ops_PICVIEW(gfxw_widget_t *widget) gfxw_dyn_view_t * gfxw_new_dyn_view(gfx_state_t *state, point_t pos, int z, int view, int loop, int cel, int palette, int priority, int control, - gfx_alignment_t halign, gfx_alignment_t valign, int sequence) -{ + gfx_alignment_t halign, gfx_alignment_t valign, int sequence) { gfxw_dyn_view_t *widget; int width, height; int xalignmod, yalignmod; @@ -1052,7 +996,7 @@ gfxw_new_dyn_view(gfx_state_t *state, point_t pos, int z, int view, int loop, in if (gfxop_get_cel_parameters(state, view, loop, cel, &width, &height, &offset)) { GFXERROR("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)\n", - view, cel, loop); + view, cel, loop); return NULL; } @@ -1060,8 +1004,8 @@ gfxw_new_dyn_view(gfx_state_t *state, point_t pos, int z, int view, int loop, in widget->pos = pos; widget->color.mask = - ((priority < 0)? 0 : GFX_MASK_PRIORITY) - | ((control < 0)? 0 : GFX_MASK_CONTROL); + ((priority < 0) ? 0 : GFX_MASK_PRIORITY) + | ((control < 0) ? 0 : GFX_MASK_CONTROL); widget->widget_priority = priority; widget->color.priority = priority; widget->color.control = control; @@ -1094,9 +1038,9 @@ gfxw_new_dyn_view(gfx_state_t *state, point_t pos, int z, int view, int loop, in widget->z = z; widget->draw_bounds = gfx_rect(widget->pos.x - xalignmod, - widget->pos.y - yalignmod - z, width, height); + widget->pos.y - yalignmod - z, width, height); widget->bounds = gfx_rect(widget->pos.x - offset.x - xalignmod, - widget->pos.y - offset.y - yalignmod - z, width, height); + widget->pos.y - offset.y - yalignmod - z, width, height); widget->flags |= GFXW_FLAG_VISIBLE; @@ -1113,16 +1057,14 @@ gfxw_new_dyn_view(gfx_state_t *state, point_t pos, int z, int view, int loop, in /*------------*/ static int -_gfxwop_text_free(gfxw_widget_t *widget) -{ +_gfxwop_text_free(gfxw_widget_t *widget) { gfxw_text_t *text = (gfxw_text_t *) widget; free(text->text); return _gfxwop_basic_free(widget); } static int -_gfxwop_text_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_text_draw(gfxw_widget_t *widget, point_t pos) { gfxw_text_t *text = (gfxw_text_t *) widget; DRAW_ASSERT(widget, GFXW_TEXT); @@ -1132,15 +1074,14 @@ _gfxwop_text_draw(gfxw_widget_t *widget, point_t pos) } static int -_gfxwop_text_alloc_and_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_text_alloc_and_draw(gfxw_widget_t *widget, point_t pos) { gfxw_text_t *text = (gfxw_text_t *) widget; DRAW_ASSERT(widget, GFXW_TEXT); text->text_handle = - gfxop_new_text(widget->visual->gfx_state, text->font_nr, text->text, text->bounds.xl, - text->halign, text->valign, text->color1, - text->color2, text->bgcolor, text->text_flags); + gfxop_new_text(widget->visual->gfx_state, text->font_nr, text->text, text->bounds.xl, + text->halign, text->valign, text->color1, + text->color2, text->bgcolor, text->text_flags); text->draw = _gfxwop_text_draw; @@ -1149,8 +1090,7 @@ _gfxwop_text_alloc_and_draw(gfxw_widget_t *widget, point_t pos) static int -_gfxwop_text_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_text_print(gfxw_widget_t *widget, int indentation) { _gfxw_print_widget(widget, indentation); sciprintf("TEXT:'%s'", ((gfxw_text_t *)widget)->text); return 0; @@ -1158,8 +1098,7 @@ _gfxwop_text_print(gfxw_widget_t *widget, int indentation) static int -_gfxwop_text_equals(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_text_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_text_t *wtext = (gfxw_text_t *) widget, *otext; if (other->type != GFXW_TEXT) return 0; @@ -1167,11 +1106,11 @@ _gfxwop_text_equals(gfxw_widget_t *widget, gfxw_widget_t *other) otext = (gfxw_text_t *) other; if ((wtext->bounds.x != otext->bounds.x) - || (wtext->bounds.y != otext->bounds.y)) + || (wtext->bounds.y != otext->bounds.y)) return 0; if (wtext->halign != otext->halign - || wtext->valign != otext->valign) + || wtext->valign != otext->valign) return 0; if (wtext->text_flags != otext->text_flags) @@ -1189,8 +1128,7 @@ _gfxwop_text_equals(gfxw_widget_t *widget, gfxw_widget_t *other) } static int -_gfxwop_text_should_replace(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_text_should_replace(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_text_t *wtext = (gfxw_text_t *) widget, *otext; if (other->type != GFXW_TEXT) @@ -1203,32 +1141,29 @@ _gfxwop_text_should_replace(gfxw_widget_t *widget, gfxw_widget_t *other) static int -_gfxwop_text_compare_to(gfxw_widget_t *widget, gfxw_widget_t *other) -{ +_gfxwop_text_compare_to(gfxw_widget_t *widget, gfxw_widget_t *other) { return 1; } void -_gfxw_set_ops_TEXT(gfxw_widget_t *widget) -{ +_gfxw_set_ops_TEXT(gfxw_widget_t *widget) { _gfxw_set_ops(GFXW(widget), _gfxwop_text_alloc_and_draw, - _gfxwop_text_free, - _gfxwop_basic_tag, - _gfxwop_text_print, - _gfxwop_text_compare_to, - _gfxwop_text_equals, - _gfxwop_basic_superarea_of); + _gfxwop_text_free, + _gfxwop_basic_tag, + _gfxwop_text_print, + _gfxwop_text_compare_to, + _gfxwop_text_equals, + _gfxwop_basic_superarea_of); widget->should_replace = _gfxwop_text_should_replace; } gfxw_text_t * gfxw_new_text(gfx_state_t *state, rect_t area, int font, const char *text, gfx_alignment_t halign, - gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, - gfx_color_t bgcolor, int text_flags) -{ + gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, + gfx_color_t bgcolor, int text_flags) { gfxw_text_t *widget = (gfxw_text_t *) - _gfxw_new_widget(sizeof(gfxw_text_t), GFXW_TEXT); + _gfxw_new_widget(sizeof(gfxw_text_t), GFXW_TEXT); widget->widget_priority = _gfxw_color_get_priority(color1); widget->font_nr = font; @@ -1244,9 +1179,9 @@ gfxw_new_text(gfx_state_t *state, rect_t area, int font, const char *text, gfx_a strcpy(widget->text, text); gfxop_get_text_params(state, font, text, area.xl, &(widget->width), - &(widget->height), text_flags, - &(widget->lines_nr), &(widget->lineheight), - &(widget->lastline_width)); + &(widget->height), text_flags, + &(widget->lines_nr), &(widget->lineheight), + &(widget->lastline_width)); /* FIXME: Window is too big area.x += _calc_needmove(halign, area.xl, widget->width); @@ -1270,8 +1205,7 @@ gfxw_new_text(gfx_state_t *state, rect_t area, int font, const char *text, gfx_a void gfxw_text_info(gfx_state_t *state, gfxw_text_t *text, int *lines, - int *lineheight, int *offset) -{ + int *lineheight, int *offset) { if (lines) *lines = text->lines_nr; if (lineheight) @@ -1286,27 +1220,25 @@ gfxw_text_info(gfx_state_t *state, gfxw_text_t *text, int *lines, /***********************/ static int -_gfxwop_container_add_dirty_rel(gfxw_container_t *cont, rect_t rect, int propagate) -{ +_gfxwop_container_add_dirty_rel(gfxw_container_t *cont, rect_t rect, int propagate) { DDIRTY(stderr, "->container_add_dirty_rel(%d,%d,%d,%d, %d)\n", GFX_PRINT_RECT(rect), propagate); return cont->add_dirty_abs(cont, _move_rect(rect, gfx_point(cont->zone.x, cont->zone.y)), propagate); } static inline void _gfxw_set_container_ops(gfxw_container_t *container, gfxw_point_op *draw, gfxw_op *free, gfxw_op *tag, - gfxw_op_int *print, gfxw_bin_op *compare_to, gfxw_bin_op *equals, - gfxw_bin_op *superarea_of, gfxw_visual_op *set_visual, - gfxw_unary_container_op *free_tagged, gfxw_unary_container_op *free_contents, - gfxw_rect_op *add_dirty, gfxw_container_op *add) -{ + gfxw_op_int *print, gfxw_bin_op *compare_to, gfxw_bin_op *equals, + gfxw_bin_op *superarea_of, gfxw_visual_op *set_visual, + gfxw_unary_container_op *free_tagged, gfxw_unary_container_op *free_contents, + gfxw_rect_op *add_dirty, gfxw_container_op *add) { _gfxw_set_ops(GFXW(container), - draw, - free, - tag, - print, - compare_to, - equals, - superarea_of); + draw, + free, + tag, + print, + compare_to, + equals, + superarea_of); container->free_tagged = free_tagged; container->free_contents = free_contents; @@ -1317,8 +1249,7 @@ _gfxw_set_container_ops(gfxw_container_t *container, gfxw_point_op *draw, gfxw_o } static int -_w_gfxwop_container_print_contents(const char *name, gfxw_widget_t *widget, int indentation) -{ +_w_gfxwop_container_print_contents(const char *name, gfxw_widget_t *widget, int indentation) { gfxw_widget_t *seeker = widget; indent(indentation); @@ -1335,8 +1266,7 @@ _w_gfxwop_container_print_contents(const char *name, gfxw_widget_t *widget, int } static int -_w_gfxwop_container_print(gfxw_widget_t *widget, int indentation) -{ +_w_gfxwop_container_print(gfxw_widget_t *widget, int indentation) { gfx_dirty_rect_t *dirty; gfxw_container_t *container = (gfxw_container_t *) widget; if (!GFXW_IS_CONTAINER(widget)) { @@ -1345,7 +1275,7 @@ _w_gfxwop_container_print(gfxw_widget_t *widget, int indentation) } sciprintf(" viszone=((%d,%d),(%dx%d))\n", container->zone.x, container->zone.y, - container->zone.xl, container->zone.yl); + container->zone.xl, container->zone.yl); indent(indentation); sciprintf("--dirty:\n"); @@ -1354,7 +1284,7 @@ _w_gfxwop_container_print(gfxw_widget_t *widget, int indentation) while (dirty) { indent(indentation + 1); sciprintf("dirty(%d,%d, (%dx%d))\n", - dirty->rect.x, dirty->rect.y, dirty->rect.xl, dirty->rect.yl); + dirty->rect.x, dirty->rect.y, dirty->rect.xl, dirty->rect.yl); dirty = dirty->next; } @@ -1366,10 +1296,9 @@ _w_gfxwop_container_print(gfxw_widget_t *widget, int indentation) gfxw_container_t * -_gfxw_new_container_widget(rect_t area, int size, gfxw_widget_type_t type) -{ +_gfxw_new_container_widget(rect_t area, int size, gfxw_widget_type_t type) { gfxw_container_t *widget = (gfxw_container_t *) - _gfxw_new_widget(size, type); + _gfxw_new_widget(size, type); widget->bounds = widget->zone = area; widget->contents = NULL; @@ -1383,8 +1312,7 @@ _gfxw_new_container_widget(rect_t area, int size, gfxw_widget_type_t type) static void -recursively_free_dirty_rects(gfx_dirty_rect_t *dirty) -{ +recursively_free_dirty_rects(gfx_dirty_rect_t *dirty) { if (dirty) { recursively_free_dirty_rects(dirty->next); free(dirty); @@ -1395,21 +1323,19 @@ recursively_free_dirty_rects(gfx_dirty_rect_t *dirty) int ti = 0; static inline int -_gfxw_dirty_rect_overlaps_normal_rect(rect_t port_zone, rect_t bounds, rect_t dirty) -{ +_gfxw_dirty_rect_overlaps_normal_rect(rect_t port_zone, rect_t bounds, rect_t dirty) { bounds.x += port_zone.x; bounds.y += port_zone.y; return gfx_rects_overlap(bounds, dirty); } static int -_gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t *contents) -{ +_gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t *contents) { gfxw_container_t *container = (gfxw_container_t *) widget; gfx_dirty_rect_t *dirty = container->dirty; - gfx_state_t *gfx_state = (widget->visual)? widget->visual->gfx_state : ((gfxw_visual_t *) widget)->gfx_state; + gfx_state_t *gfx_state = (widget->visual) ? widget->visual->gfx_state : ((gfxw_visual_t *) widget)->gfx_state; int draw_ports; - rect_t nullzone = {0,0,0,0}; + rect_t nullzone = {0, 0, 0, 0}; if (!contents) return 0; @@ -1418,12 +1344,12 @@ _gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t *contents) gfxw_widget_t *seeker = contents; while (seeker) { - if (_gfxw_dirty_rect_overlaps_normal_rect(GFXW_IS_CONTAINER(seeker)? nullzone : container->zone, - /* Containers have absolute coordinates, reflect this. */ - seeker->bounds, dirty->rect)) { + if (_gfxw_dirty_rect_overlaps_normal_rect(GFXW_IS_CONTAINER(seeker) ? nullzone : container->zone, + /* Containers have absolute coordinates, reflect this. */ + seeker->bounds, dirty->rect)) { if (GFXW_IS_CONTAINER(seeker)) {/* Propagate dirty rectangles /upwards/ */ - DDIRTY(stderr,"container_draw_contents: propagate upwards (%d,%d,%d,%d ,0)\n", GFX_PRINT_RECT(dirty->rect)); + DDIRTY(stderr, "container_draw_contents: propagate upwards (%d,%d,%d,%d ,0)\n", GFX_PRINT_RECT(dirty->rect)); ((gfxw_container_t *)seeker)->add_dirty_abs((gfxw_container_t *)seeker, dirty->rect, 0); } @@ -1456,9 +1382,9 @@ _gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t *contents) if (!GFXW_IS_CONTAINER(seeker) && draw_noncontainers) { GFX_ASSERT(gfxop_set_clip_zone(gfx_state, small_rect)); } - /* Clip zone must be reset after each element, because we might - ** descend into containers. - ** Doing this is relatively cheap, though. */ + /* Clip zone must be reset after each element, because we might + ** descend into containers. + ** Doing this is relatively cheap, though. */ if (draw_noncontainers || GFXW_IS_CONTAINER(seeker)) seeker->draw(seeker, gfx_point(container->zone.x, container->zone.y)); @@ -1477,8 +1403,7 @@ _gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t *contents) } static int -_gfxwop_container_free(gfxw_widget_t *widget) -{ +_gfxwop_container_free(gfxw_widget_t *widget) { gfxw_container_t *container = (gfxw_container_t *) widget; gfxw_widget_t *seeker = container->contents; @@ -1495,8 +1420,7 @@ _gfxwop_container_free(gfxw_widget_t *widget) } static int -_gfxwop_container_tag(gfxw_widget_t *widget) -{ +_gfxwop_container_tag(gfxw_widget_t *widget) { gfxw_container_t *container = (gfxw_container_t *) widget; gfxw_widget_t *seeker = container->contents; @@ -1509,8 +1433,7 @@ _gfxwop_container_tag(gfxw_widget_t *widget) static int -_w_gfxwop_container_set_visual_contents(gfxw_widget_t *contents, gfxw_visual_t *visual) -{ +_w_gfxwop_container_set_visual_contents(gfxw_widget_t *contents, gfxw_visual_t *visual) { while (contents) { contents->set_visual(contents, visual); contents = contents->next; @@ -1519,14 +1442,13 @@ _w_gfxwop_container_set_visual_contents(gfxw_widget_t *contents, gfxw_visual_t * } static int -_gfxwop_container_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) -{ +_gfxwop_container_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) { gfxw_container_t *container = (gfxw_container_t *) widget; container->visual = visual; if (widget->parent) { if (!(GFXW_IS_LIST(widget) && !GFXWC(widget)->contents)) { - DDIRTY(stderr,"set_visual::DOWNWARDS abs(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->bounds)); + DDIRTY(stderr, "set_visual::DOWNWARDS abs(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->bounds)); widget->parent->add_dirty_abs(widget->parent, widget->bounds, 1); } } @@ -1535,8 +1457,7 @@ _gfxwop_container_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) } static int -_gfxwop_container_free_tagged(gfxw_container_t *container) -{ +_gfxwop_container_free_tagged(gfxw_container_t *container) { gfxw_widget_t *seekerp = (container->contents); while (seekerp) { @@ -1552,8 +1473,7 @@ _gfxwop_container_free_tagged(gfxw_container_t *container) } static int -_gfxwop_container_free_contents(gfxw_container_t *container) -{ +_gfxwop_container_free_contents(gfxw_container_t *container) { gfxw_widget_t *seeker = container->contents; while (seeker) { @@ -1565,8 +1485,7 @@ _gfxwop_container_free_contents(gfxw_container_t *container) } static void -_gfxw_dirtify_container(gfxw_container_t *container, gfxw_widget_t *widget) -{ +_gfxw_dirtify_container(gfxw_container_t *container, gfxw_widget_t *widget) { if (GFXW_IS_CONTAINER(widget)) container->add_dirty_abs(GFXWC(container), widget->bounds, 1); else @@ -1574,8 +1493,7 @@ _gfxw_dirtify_container(gfxw_container_t *container, gfxw_widget_t *widget) } static int -_parentize_widget(gfxw_container_t *container, gfxw_widget_t *widget) -{ +_parentize_widget(gfxw_container_t *container, gfxw_widget_t *widget) { if (widget->parent) { GFXERROR("_gfxwop_container_add(): Attempt to give second parent node to widget!\nWidget:"); widget->print(GFXW(widget), 3); @@ -1596,8 +1514,7 @@ _parentize_widget(gfxw_container_t *container, gfxw_widget_t *widget) } static int -_gfxw_container_id_equals(gfxw_container_t *container, gfxw_widget_t *widget) -{ +_gfxw_container_id_equals(gfxw_container_t *container, gfxw_widget_t *widget) { gfxw_widget_t **seekerp = &(container->contents); if (GFXW_IS_PORT(widget)) @@ -1607,15 +1524,15 @@ _gfxw_container_id_equals(gfxw_container_t *container, gfxw_widget_t *widget) return 0; while (*seekerp - && ((*seekerp)->ID != widget->ID - || (*seekerp)->subID != widget->subID)) + && ((*seekerp)->ID != widget->ID + || (*seekerp)->subID != widget->subID)) seekerp = &((*seekerp)->next); if (!*seekerp) return 0; if ((*seekerp)->equals(*seekerp, widget) - && !(*seekerp)->should_replace(*seekerp, widget)) { + && !(*seekerp)->should_replace(*seekerp, widget)) { widget->widfree(widget); (*seekerp)->flags &= ~GFXW_FLAG_TAGGED; return 1; @@ -1628,8 +1545,7 @@ _gfxw_container_id_equals(gfxw_container_t *container, gfxw_widget_t *widget) static int -_gfxwop_container_add_dirty(gfxw_container_t *container, rect_t dirty, int propagate) -{ +_gfxwop_container_add_dirty(gfxw_container_t *container, rect_t dirty, int propagate) { #if 0 /* This code has been disabled because containers may contain sub-containers with ** bounds greater than their own. */ @@ -1644,8 +1560,7 @@ _gfxwop_container_add_dirty(gfxw_container_t *container, rect_t dirty, int propa static int -_gfxwop_container_add(gfxw_container_t *container, gfxw_widget_t *widget) -{ +_gfxwop_container_add(gfxw_container_t *container, gfxw_widget_t *widget) { if (_gfxw_container_id_equals(container, widget)) return 0; @@ -1668,8 +1583,7 @@ _gfxwop_container_add(gfxw_container_t *container, gfxw_widget_t *widget) /*------------------------------*/ static int -_gfxwop_list_draw(gfxw_widget_t *list, point_t pos) -{ +_gfxwop_list_draw(gfxw_widget_t *list, point_t pos) { DRAW_ASSERT(list, GFXW_LIST); _gfxwop_container_draw_contents(list, ((gfxw_list_t *)list)->contents); @@ -1680,8 +1594,7 @@ _gfxwop_list_draw(gfxw_widget_t *list, point_t pos) } static int -_gfxwop_sorted_list_draw(gfxw_widget_t *list, point_t pos) -{ +_gfxwop_sorted_list_draw(gfxw_widget_t *list, point_t pos) { DRAW_ASSERT(list, GFXW_SORTED_LIST); _gfxwop_container_draw_contents(list, ((gfxw_list_t *)list)->contents); @@ -1691,22 +1604,19 @@ _gfxwop_sorted_list_draw(gfxw_widget_t *list, point_t pos) } static inline int -_w_gfxwop_list_print(gfxw_widget_t *list, const char *name, int indentation) -{ +_w_gfxwop_list_print(gfxw_widget_t *list, const char *name, int indentation) { _gfxw_print_widget(list, indentation); sciprintf(name); return _w_gfxwop_container_print(list, indentation); } static int -_gfxwop_list_print(gfxw_widget_t *list, int indentation) -{ +_gfxwop_list_print(gfxw_widget_t *list, int indentation) { return _w_gfxwop_list_print(list, "LIST", indentation); } static int -_gfxwop_sorted_list_print(gfxw_widget_t *list, int indentation) -{ +_gfxwop_sorted_list_print(gfxw_widget_t *list, int indentation) { return _w_gfxwop_list_print(list, "SORTED_LIST", indentation); } @@ -1718,8 +1628,7 @@ struct gfxw_widget_list { }; static struct gfxw_widtet_list * -_gfxw_make_widget_list_recursive(gfxw_widget_t *widget) -{ + _gfxw_make_widget_list_recursive(gfxw_widget_t *widget) { gfxw_widget_list *node; if (!widget) @@ -1733,8 +1642,7 @@ _gfxw_make_widget_list_recursive(gfxw_widget_t *widget) } static struct gfxw_widget_list * -_gfxw_make_widget_list(gfxw_container_t *container) -{ + _gfxw_make_widget_list(gfxw_container_t *container) { return _gfxw_make_widget_list_recursive(container->contents); } #endif @@ -1743,7 +1651,7 @@ _gfxw_make_widget_list(gfxw_container_t *container) static int _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) - /* Requires identical order of list elements. */ +/* Requires identical order of list elements. */ { gfxw_list_t *wlist, *olist; @@ -1768,7 +1676,7 @@ _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) while (widget && other) { - if (!(widget->equals(widget, other) && !widget->should_replace(widget,other))) + if (!(widget->equals(widget, other) && !widget->should_replace(widget, other))) return 0; widget = widget->next; @@ -1779,13 +1687,12 @@ _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) } static int -_gfxwop_list_add_dirty(gfxw_container_t *container, rect_t dirty, int propagate) -{ +_gfxwop_list_add_dirty(gfxw_container_t *container, rect_t dirty, int propagate) { /* Lists add dirty boxes to both themselves and their parenting port/visual */ container->flags |= GFXW_FLAG_DIRTY; - DDIRTY(stderr,"list_add_dirty %d,%d,%d,%d %d\n", GFX_PRINT_RECT(dirty), propagate); + DDIRTY(stderr, "list_add_dirty %d,%d,%d,%d %d\n", GFX_PRINT_RECT(dirty), propagate); if (propagate) if (container->parent) { DDIRTY(stderr, "->PROPAGATING\n"); @@ -1795,9 +1702,10 @@ _gfxwop_list_add_dirty(gfxw_container_t *container, rect_t dirty, int propagate) return _gfxwop_container_add_dirty(container, dirty, propagate); } -/* static inline */ int +/* static inline */ +int _gfxwop_ordered_add(gfxw_container_t *container, gfxw_widget_t *widget, int compare_all) - /* O(n) */ +/* O(n) */ { gfxw_widget_t **seekerp = &(container->contents); @@ -1844,34 +1752,32 @@ _gfxwop_ordered_add(gfxw_container_t *container, gfxw_widget_t *widget, int comp static int _gfxwop_sorted_list_add(gfxw_container_t *container, gfxw_widget_t *widget) - /* O(n) */ +/* O(n) */ { return _gfxwop_ordered_add(container, widget, 0); } void -_gfxw_set_ops_LIST(gfxw_container_t *list, char sorted) -{ +_gfxw_set_ops_LIST(gfxw_container_t *list, char sorted) { _gfxw_set_container_ops((gfxw_container_t *) list, - sorted? _gfxwop_sorted_list_draw : _gfxwop_list_draw, - _gfxwop_container_free, - _gfxwop_container_tag, - sorted? _gfxwop_sorted_list_print : _gfxwop_list_print, - _gfxwop_basic_compare_to, - sorted? _gfxwop_basic_equals : _gfxwop_list_equals, - _gfxwop_basic_superarea_of, - _gfxwop_container_set_visual, - _gfxwop_container_free_tagged, - _gfxwop_container_free_contents, - _gfxwop_list_add_dirty, - sorted? _gfxwop_sorted_list_add : _gfxwop_container_add); + sorted ? _gfxwop_sorted_list_draw : _gfxwop_list_draw, + _gfxwop_container_free, + _gfxwop_container_tag, + sorted ? _gfxwop_sorted_list_print : _gfxwop_list_print, + _gfxwop_basic_compare_to, + sorted ? _gfxwop_basic_equals : _gfxwop_list_equals, + _gfxwop_basic_superarea_of, + _gfxwop_container_set_visual, + _gfxwop_container_free_tagged, + _gfxwop_container_free_contents, + _gfxwop_list_add_dirty, + sorted ? _gfxwop_sorted_list_add : _gfxwop_container_add); } gfxw_list_t * -gfxw_new_list(rect_t area, int sorted) -{ +gfxw_new_list(rect_t area, int sorted) { gfxw_list_t *list = (gfxw_list_t *) _gfxw_new_container_widget(area, sizeof(gfxw_list_t), - sorted? GFXW_SORTED_LIST : GFXW_LIST); + sorted ? GFXW_SORTED_LIST : GFXW_LIST); _gfxw_set_ops_LIST(GFXWC(list), (char)sorted); @@ -1884,8 +1790,7 @@ gfxw_new_list(rect_t area, int sorted) /*---------------*/ static int -_gfxwop_visual_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_visual_draw(gfxw_widget_t *widget, point_t pos) { gfxw_visual_t *visual = (gfxw_visual_t *) widget; gfx_dirty_rect_t *dirty = visual->dirty; DRAW_ASSERT(widget, GFXW_VISUAL); @@ -1895,7 +1800,7 @@ _gfxwop_visual_draw(gfxw_widget_t *widget, point_t pos) if (err) { GFXERROR("Error while clearing dirty rect (%d,%d,(%dx%d))\n", dirty->rect.x, - dirty->rect.y, dirty->rect.xl, dirty->rect.yl); + dirty->rect.y, dirty->rect.xl, dirty->rect.yl); if (err == GFX_FATAL) return err; } @@ -1913,11 +1818,10 @@ _gfxwop_visual_draw(gfxw_widget_t *widget, point_t pos) } static int -_gfxwop_visual_free(gfxw_widget_t *widget) -{ +_gfxwop_visual_free(gfxw_widget_t *widget) { gfxw_visual_t *visual = (gfxw_visual_t *) widget; - gfxw_port_t **portrefs; - int retval; + gfxw_port_t **portrefs; + int retval; if (!GFXW_IS_VISUAL(visual)) { GFXERROR("_gfxwop_visual_free() called on non-visual!Widget was: "); @@ -1925,17 +1829,16 @@ _gfxwop_visual_free(gfxw_widget_t *widget) return 1; } - portrefs = visual->port_refs; + portrefs = visual->port_refs; retval = _gfxwop_container_free(widget); free(portrefs); - return 0; + return 0; } static int -_gfxwop_visual_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_visual_print(gfxw_widget_t *widget, int indentation) { int i; int comma = 0; gfxw_visual_t *visual = (gfxw_visual_t *) widget; @@ -1963,8 +1866,7 @@ _gfxwop_visual_print(gfxw_widget_t *widget, int indentation) } static int -_gfxwop_visual_set_visual(gfxw_widget_t *self, gfxw_visual_t *visual) -{ +_gfxwop_visual_set_visual(gfxw_widget_t *self, gfxw_visual_t *visual) { if (self != GFXW(visual)) { GFXWARN("Attempt to set a visual's parent visual to something else!\n"); } else { @@ -1974,26 +1876,24 @@ _gfxwop_visual_set_visual(gfxw_widget_t *self, gfxw_visual_t *visual) } void -_gfxw_set_ops_VISUAL(gfxw_container_t *visual) -{ +_gfxw_set_ops_VISUAL(gfxw_container_t *visual) { _gfxw_set_container_ops((gfxw_container_t *) visual, - _gfxwop_visual_draw, - _gfxwop_visual_free, - _gfxwop_container_tag, - _gfxwop_visual_print, - _gfxwop_basic_compare_to, - _gfxwop_basic_equals, - _gfxwop_basic_superarea_of, - _gfxwop_visual_set_visual, - _gfxwop_container_free_tagged, - _gfxwop_container_free_contents, - _gfxwop_container_add_dirty, - _gfxwop_container_add); + _gfxwop_visual_draw, + _gfxwop_visual_free, + _gfxwop_container_tag, + _gfxwop_visual_print, + _gfxwop_basic_compare_to, + _gfxwop_basic_equals, + _gfxwop_basic_superarea_of, + _gfxwop_visual_set_visual, + _gfxwop_container_free_tagged, + _gfxwop_container_free_contents, + _gfxwop_container_add_dirty, + _gfxwop_container_add); } gfxw_visual_t * -gfxw_new_visual(gfx_state_t *state, int font) -{ +gfxw_new_visual(gfx_state_t *state, int font) { gfxw_visual_t *visual = (gfxw_visual_t *) _gfxw_new_container_widget(gfx_rect(0, 0, 320, 200), sizeof(gfxw_visual_t), GFXW_VISUAL); visual->font_nr = font; @@ -2008,8 +1908,7 @@ gfxw_new_visual(gfx_state_t *state, int font) static int -_visual_find_free_ID(gfxw_visual_t *visual) -{ +_visual_find_free_ID(gfxw_visual_t *visual) { int id = 0; int newports = 16; @@ -2025,8 +1924,7 @@ _visual_find_free_ID(gfxw_visual_t *visual) } static int -_gfxwop_add_dirty_rects(gfxw_container_t *dest, gfx_dirty_rect_t *src) -{ +_gfxwop_add_dirty_rects(gfxw_container_t *dest, gfx_dirty_rect_t *src) { DDIRTY(stderr, "Adding multiple dirty to #%d\n", dest->ID); if (src) { dest->dirty = gfxdr_add_dirty(dest->dirty, src->rect, GFXW_DIRTY_STRATEGY); @@ -2040,8 +1938,7 @@ _gfxwop_add_dirty_rects(gfxw_container_t *dest, gfx_dirty_rect_t *src) /*-------------*/ static int -_gfxwop_port_draw(gfxw_widget_t *widget, point_t pos) -{ +_gfxwop_port_draw(gfxw_widget_t *widget, point_t pos) { gfxw_port_t *port = (gfxw_port_t *) widget; DRAW_ASSERT(widget, GFXW_PORT); @@ -2064,8 +1961,7 @@ _gfxwop_port_draw(gfxw_widget_t *widget, point_t pos) } static int -_gfxwop_port_free(gfxw_widget_t *widget) -{ +_gfxwop_port_free(gfxw_widget_t *widget) { gfxw_port_t *port = (gfxw_port_t *) widget; if (port->visual) { @@ -2079,7 +1975,7 @@ _gfxwop_port_free(gfxw_widget_t *widget) if (visual->port_refs[ID] != port) { GFXWARN("While freeing port %d: Port is at %p, but port list indicates %p!\n", - ID, port, visual->port_refs[ID]); + ID, port, visual->port_refs[ID]); } else visual->port_refs[ID] = NULL; } @@ -2091,8 +1987,7 @@ _gfxwop_port_free(gfxw_widget_t *widget) } static int -_gfxwop_port_print(gfxw_widget_t *widget, int indentation) -{ +_gfxwop_port_print(gfxw_widget_t *widget, int indentation) { gfxw_port_t *port = (gfxw_port_t *) widget; _gfxw_print_widget(widget, indentation); @@ -2106,8 +2001,7 @@ _gfxwop_port_print(gfxw_widget_t *widget, int indentation) } static int -_gfxwop_port_superarea_of(gfxw_widget_t *self, gfxw_widget_t *other) -{ +_gfxwop_port_superarea_of(gfxw_widget_t *self, gfxw_widget_t *other) { gfxw_port_t *port = (gfxw_port_t *) self; if (!port->port_bg) @@ -2117,8 +2011,7 @@ _gfxwop_port_superarea_of(gfxw_widget_t *self, gfxw_widget_t *other) } static int -_gfxwop_port_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) -{ +_gfxwop_port_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) { gfxw_list_t *decorations = ((gfxw_port_t *) widget)->decorations; widget->visual = visual; @@ -2133,17 +2026,16 @@ _gfxwop_port_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) } static int -_gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int propagate) -{ +_gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int propagate) { gfxw_port_t *self = (gfxw_port_t *) widget; self->flags |= GFXW_FLAG_DIRTY; _gfxwop_container_add_dirty(widget, dirty, propagate); - DDIRTY(stderr,"Added dirty to ID %d\n", widget->ID); + DDIRTY(stderr, "Added dirty to ID %d\n", widget->ID); DDIRTY(stderr, "dirty= (%d,%d,%d,%d) bounds (%d,%d,%d,%d)\n", dirty.x, dirty.x, dirty.xl, dirty.yl, - widget->bounds.x, widget->bounds.y, widget->bounds.xl, widget->bounds.yl); + widget->bounds.x, widget->bounds.y, widget->bounds.xl, widget->bounds.yl); #if 0 /* FIXME: This is a worthwhile optimization */ if (self->port_bg) { @@ -2155,7 +2047,7 @@ _gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int propagate) if (self->port_bg->superarea_of(self->port_bg, &foo)) { gfxw_container_t *parent = self->parent; while (parent) { - fprintf(stderr,"Dirtifying parent id %d\n", parent->ID); + fprintf(stderr, "Dirtifying parent id %d\n", parent->ID); parent->flags |= GFXW_FLAG_DIRTY; parent = parent->parent; } @@ -2175,34 +2067,32 @@ _gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int propagate) static int _gfxwop_port_add(gfxw_container_t *container, gfxw_widget_t *widget) - /* O(n) */ +/* O(n) */ { return _gfxwop_ordered_add(container, widget, 1); } void -_gfxw_set_ops_PORT(gfxw_container_t *widget) -{ +_gfxw_set_ops_PORT(gfxw_container_t *widget) { _gfxw_set_container_ops((gfxw_container_t *) widget, - _gfxwop_port_draw, - _gfxwop_port_free, - _gfxwop_container_tag, - _gfxwop_port_print, - _gfxwop_basic_compare_to, - _gfxwop_basic_equals, - _gfxwop_port_superarea_of, - _gfxwop_port_set_visual, - _gfxwop_container_free_tagged, - _gfxwop_container_free_contents, - _gfxwop_port_add_dirty, - _gfxwop_port_add); + _gfxwop_port_draw, + _gfxwop_port_free, + _gfxwop_container_tag, + _gfxwop_port_print, + _gfxwop_basic_compare_to, + _gfxwop_basic_equals, + _gfxwop_port_superarea_of, + _gfxwop_port_set_visual, + _gfxwop_container_free_tagged, + _gfxwop_container_free_contents, + _gfxwop_port_add_dirty, + _gfxwop_port_add); } gfxw_port_t * -gfxw_new_port(gfxw_visual_t *visual, gfxw_port_t *predecessor, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor) -{ +gfxw_new_port(gfxw_visual_t *visual, gfxw_port_t *predecessor, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor) { gfxw_port_t *widget = (gfxw_port_t *) - _gfxw_new_container_widget(area, sizeof(gfxw_port_t), GFXW_PORT); + _gfxw_new_container_widget(area, sizeof(gfxw_port_t), GFXW_PORT); VERIFY_WIDGET(visual); @@ -2224,15 +2114,13 @@ gfxw_new_port(gfxw_visual_t *visual, gfxw_port_t *predecessor, rect_t area, gfx_ return widget; } -void gfxw_port_auto_restore_background(gfxw_visual_t *visual, gfxw_port_t *window, rect_t auto_rect) -{ +void gfxw_port_auto_restore_background(gfxw_visual_t *visual, gfxw_port_t *window, rect_t auto_rect) { window->port_flags |= WINDOW_FLAG_AUTO_RESTORE; window->restore_snap = gfxw_make_snapshot(visual, auto_rect); } gfxw_port_t * -gfxw_remove_port(gfxw_visual_t *visual, gfxw_port_t *port) -{ +gfxw_remove_port(gfxw_visual_t *visual, gfxw_port_t *port) { gfxw_port_t *parent; VERIFY_WIDGET(visual); VERIFY_WIDGET(port); @@ -2257,8 +2145,7 @@ gfxw_remove_port(gfxw_visual_t *visual, gfxw_port_t *port) gfxw_port_t * -gfxw_find_port(gfxw_visual_t *visual, int ID) -{ +gfxw_find_port(gfxw_visual_t *visual, int ID) { if (ID < 0 || ID >= visual->port_refs_nr) return NULL; @@ -2267,8 +2154,7 @@ gfxw_find_port(gfxw_visual_t *visual, int ID) gfxw_port_t * -gfxw_find_default_port(gfxw_visual_t *visual) -{ +gfxw_find_default_port(gfxw_visual_t *visual) { int id = visual->port_refs_nr; while (id--) { @@ -2285,8 +2171,7 @@ gfxw_find_default_port(gfxw_visual_t *visual) /*** - other functions - ***/ gfxw_widget_t * -gfxw_set_id(gfxw_widget_t *widget, int ID, int subID) -{ +gfxw_set_id(gfxw_widget_t *widget, int ID, int subID) { if (widget) { widget->ID = ID; widget->subID = subID; @@ -2297,8 +2182,7 @@ gfxw_set_id(gfxw_widget_t *widget, int ID, int subID) gfxw_dyn_view_t * gfxw_dyn_view_set_params(gfxw_dyn_view_t *widget, int under_bits, void *under_bitsp, - int signal, void *signalp) -{ + int signal, void *signalp) { if (!widget) return NULL; @@ -2311,14 +2195,13 @@ gfxw_dyn_view_set_params(gfxw_dyn_view_t *widget, int under_bits, void *under_bi } gfxw_widget_t * -gfxw_remove_id(gfxw_container_t *container, int ID, int subID) -{ +gfxw_remove_id(gfxw_container_t *container, int ID, int subID) { gfxw_widget_t **wp = &(container->contents); while (*wp) { if ((*wp)->ID == ID - && (subID == GFXW_NO_ID - || (*wp)->subID == subID)) { + && (subID == GFXW_NO_ID + || (*wp)->subID == subID)) { gfxw_widget_t *widget = *wp; *wp = (*wp)->next; @@ -2337,8 +2220,7 @@ gfxw_remove_id(gfxw_container_t *container, int ID, int subID) gfxw_widget_t * -gfxw_hide_widget(gfxw_widget_t *widget) -{ +gfxw_hide_widget(gfxw_widget_t *widget) { if (widget->flags & GFXW_FLAG_VISIBLE) { widget->flags &= ~GFXW_FLAG_VISIBLE; @@ -2350,8 +2232,7 @@ gfxw_hide_widget(gfxw_widget_t *widget) } gfxw_widget_t * -gfxw_show_widget(gfxw_widget_t *widget) -{ +gfxw_show_widget(gfxw_widget_t *widget) { if (!(widget->flags & GFXW_FLAG_VISIBLE)) { widget->flags |= GFXW_FLAG_VISIBLE; @@ -2364,8 +2245,7 @@ gfxw_show_widget(gfxw_widget_t *widget) gfxw_snapshot_t * -gfxw_make_snapshot(gfxw_visual_t *visual, rect_t area) -{ +gfxw_make_snapshot(gfxw_visual_t *visual, rect_t area) { gfxw_snapshot_t *retval = (gfxw_snapshot_t*)sci_malloc(sizeof(gfxw_snapshot_t)); retval->serial = widget_serial_number_counter++; @@ -2381,9 +2261,8 @@ gfxw_make_snapshot(gfxw_visual_t *visual, rect_t area) int -gfxw_widget_matches_snapshot(gfxw_snapshot_t *snapshot, gfxw_widget_t *widget) -{ - int free_below = (snapshot->serial < widget_serial_number_counter)? 0: widget_serial_number_counter; +gfxw_widget_matches_snapshot(gfxw_snapshot_t *snapshot, gfxw_widget_t *widget) { + int free_below = (snapshot->serial < widget_serial_number_counter) ? 0 : widget_serial_number_counter; int free_above_eq = snapshot->serial; rect_t bounds = widget->bounds; @@ -2393,22 +2272,21 @@ gfxw_widget_matches_snapshot(gfxw_snapshot_t *snapshot, gfxw_widget_t *widget) } return ((widget->serial >= free_above_eq - || widget->serial < free_below) - && gfx_rect_subset(bounds, snapshot->area)); + || widget->serial < free_below) + && gfx_rect_subset(bounds, snapshot->area)); } #define MAGIC_FREE_NUMBER -42 void -_gfxw_free_contents_appropriately(gfxw_container_t *container, gfxw_snapshot_t *snapshot, int priority) -{ +_gfxw_free_contents_appropriately(gfxw_container_t *container, gfxw_snapshot_t *snapshot, int priority) { gfxw_widget_t *widget = container->contents; while (widget) { gfxw_widget_t *next = widget->next; if (gfxw_widget_matches_snapshot(snapshot, widget) && !(widget->flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) - && (priority == MAGIC_FREE_NUMBER || priority <= widget->widget_priority || widget->widget_priority == -1)) { + && (priority == MAGIC_FREE_NUMBER || priority <= widget->widget_priority || widget->widget_priority == -1)) { widget->widfree(widget); } else { if (GFXW_IS_CONTAINER(widget)) @@ -2420,16 +2298,14 @@ _gfxw_free_contents_appropriately(gfxw_container_t *container, gfxw_snapshot_t * } gfxw_snapshot_t * -gfxw_restore_snapshot(gfxw_visual_t *visual, gfxw_snapshot_t *snapshot) -{ +gfxw_restore_snapshot(gfxw_visual_t *visual, gfxw_snapshot_t *snapshot) { _gfxw_free_contents_appropriately(GFXWC(visual), snapshot, MAGIC_FREE_NUMBER); return snapshot; } void -gfxw_annihilate(gfxw_widget_t *widget) -{ +gfxw_annihilate(gfxw_widget_t *widget) { gfxw_visual_t *visual = widget->visual; int widget_priority = 0; int free_overdrawn = 0; @@ -2453,8 +2329,7 @@ gfxw_annihilate(gfxw_widget_t *widget) gfxw_dyn_view_t * -gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview) -{ +gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview) { dynview->type = GFXW_PIC_VIEW; dynview->flags |= GFXW_FLAG_DIRTY; @@ -2469,28 +2344,24 @@ gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview) /* Chrono-Ports (tm) */ gfxw_port_t * -gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags) -{ +gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags) { gfxw_port_t *result = NULL; gfx_color_t transparent = {{0, 0, 0, 0}, 0, 0, 0, 0}; int id = 0; - if (!(flags & GFXW_CHRONO_NON_TOPMOST)) - { + if (!(flags & GFXW_CHRONO_NON_TOPMOST)) { result = gfxw_find_default_port(visual); - } else - { + } else { id = visual->port_refs_nr; while (id >= 0 && (!visual->port_refs[id] || - !visual->port_refs[id]->chrono_port)) + !visual->port_refs[id]->chrono_port)) id--; if (id >= 0) result = visual->port_refs[id]; } - - if (!result || !result->chrono_port) - { + + if (!result || !result->chrono_port) { if (flags & GFXW_CHRONO_NO_CREATE) return NULL; result = gfxw_new_port(visual, NULL, gfx_rect(0, 0, 320, 200), transparent, transparent); *temp_widgets_list = gfxw_new_list(gfx_rect(0, 0, 320, 200), 1); @@ -2507,13 +2378,11 @@ gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int } static int -gfxw_check_chrono_overlaps(gfxw_port_t *chrono, gfxw_widget_t *widget) -{ +gfxw_check_chrono_overlaps(gfxw_port_t *chrono, gfxw_widget_t *widget) { gfxw_widget_t *seeker = GFXWC(chrono->contents)->contents; while (seeker) { - if (gfx_rect_equals(seeker->bounds, widget->bounds)) - { + if (gfx_rect_equals(seeker->bounds, widget->bounds)) { gfxw_annihilate(GFXW(seeker)); return 1; } @@ -2525,26 +2394,23 @@ gfxw_check_chrono_overlaps(gfxw_port_t *chrono, gfxw_widget_t *widget) } void -gfxw_add_to_chrono(gfxw_visual_t *visual, gfxw_widget_t *widget) -{ +gfxw_add_to_chrono(gfxw_visual_t *visual, gfxw_widget_t *widget) { gfxw_list_t *tw; - gfxw_port_t *chrono = - gfxw_get_chrono_port(visual, &tw, 0); + gfxw_port_t *chrono = + gfxw_get_chrono_port(visual, &tw, 0); gfxw_check_chrono_overlaps(chrono, widget); chrono->add(GFXWC(chrono), widget); } static gfxw_widget_t * -gfxw_widget_intersects_chrono(gfxw_list_t *tw, gfxw_widget_t *widget) -{ +gfxw_widget_intersects_chrono(gfxw_list_t *tw, gfxw_widget_t *widget) { gfxw_widget_t *seeker; assert(tw->type == GFXW_SORTED_LIST); seeker = tw->contents; - while (seeker) - { + while (seeker) { point_t origin; rect_t bounds = widget->bounds; @@ -2563,8 +2429,7 @@ gfxw_widget_intersects_chrono(gfxw_list_t *tw, gfxw_widget_t *widget) } void -gfxw_widget_reparent_chrono(gfxw_visual_t *visual, gfxw_widget_t *view, gfxw_list_t *target) -{ +gfxw_widget_reparent_chrono(gfxw_visual_t *visual, gfxw_widget_t *view, gfxw_list_t *target) { gfxw_list_t *tw; gfxw_port_t *chrono; gfxw_widget_t *intersector; @@ -2573,10 +2438,9 @@ gfxw_widget_reparent_chrono(gfxw_visual_t *visual, gfxw_widget_t *view, gfxw_lis if (chrono == NULL) return; intersector = gfxw_widget_intersects_chrono(tw, view); - if (intersector) - { - point_t origin = gfx_point(intersector->parent->zone.x, - intersector->parent->zone.y); + if (intersector) { + point_t origin = gfx_point(intersector->parent->zone.x, + intersector->parent->zone.y); gfxw_remove_widget_from_container(GFXWC(chrono), GFXW(tw)); gfxw_remove_widget_from_container(GFXWC(chrono->parent), GFXW(chrono)); @@ -2588,12 +2452,10 @@ gfxw_widget_reparent_chrono(gfxw_visual_t *visual, gfxw_widget_t *view, gfxw_lis } void -gfxw_widget_kill_chrono(gfxw_visual_t *visual, int window) -{ +gfxw_widget_kill_chrono(gfxw_visual_t *visual, int window) { int i; - for (i=window; i < visual->port_refs_nr ; i++) - { + for (i = window; i < visual->port_refs_nr ; i++) { if (visual->port_refs[i] && visual->port_refs[i]->chrono_port) gfxw_annihilate(GFXW(visual->port_refs[i])); } -- cgit v1.2.3