Ticket #9091: descumm_2870543_incl_287369.diff
File descumm_2870543_incl_287369.diff, 9.4 KB (added by , 15 years ago) |
---|
-
.cpp
old new 94 94 #define ASTARTCOMMA (1<<28) 95 95 #define AVARSTORE (1<<27) 96 96 #define ANOENDSEMICOLON (1<<26) 97 #define ATOWITHLASTPAREN (1<<25) 97 98 98 99 99 100 100 void emit_if(char *buf, char *condition); 101 101 102 102 … … 564 564 565 565 char *putascii(char *buf, int i) { 566 566 if (i > 31 && i < 128) { 567 // non-printable chars are escaped by backslashes as so: "\x00" 568 // backslashes and quote marks are escaped like so: "\\" "\"" 569 if (i == '\\' || i == '"') { 570 buf[0] = '\\'; 571 buf++; 572 } 567 573 buf[0] = i; 568 574 buf[1] = 0; 569 575 return buf + 1; 570 576 } 571 return buf + sprintf(buf, " ^%d", i);577 return buf + sprintf(buf, "\\x%.2X", i); 572 578 } 573 579 574 580 char *get_ascii(char *buf) { … … 661 667 662 668 if (args & ATO) { 663 669 char tmp[256]; 670 if (args & ATOWITHLASTPAREN) { 671 buf = strecpy(buf, ")"); 672 } 664 673 strcpy(tmp, buforg); 665 674 emit_if(buforg, tmp); 666 675 } else { … … 684 693 c &= 0x7f; 685 694 686 695 if (c < 8) { 687 buf += sprintf(buf, " ^%d", (int)c);696 buf += sprintf(buf, "\\x%.2X", (int)c); 688 697 if (c > 3) { 689 buf += sprintf(buf, " ^%d", (int)get_byte());698 buf += sprintf(buf, "\\x%.2X", (int)get_byte()); 690 699 } 691 } else 700 } else { 701 if (c == '\\' || c == '"') // backslash is the escape character 702 *buf++ = '\\'; 703 } 692 704 *buf++ = c; 693 705 if (flag) 694 706 *buf++ = ' '; … … 802 814 case 0x0E: 803 815 buf = do_tok(buf, "InitAnimNr", ((opcode & 0x80) ? A1V : A1B) | ANOENDSEMICOLON); 804 816 break; 805 // 817 // case 0x0F: buf=do_tok(buf, "PaletteList", A1LIST); break; 806 818 case 0x10: 807 819 buf = do_tok(buf, "Width", ((opcode & 0x80) ? A1V : A1B) | ANOENDSEMICOLON); 808 820 break; … … 1048 1060 break; 1049 1061 1050 1062 case 0x22 + 1: 1051 do_tok(buf, "setCDVolume ?", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B));1063 do_tok(buf, "setCDVolume", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B)); 1052 1064 break; 1053 1065 case 0x23 + 1: 1054 1066 do_tok(buf, "setSoundLoudness", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B) | A3B); … … 1091 1103 1092 1104 switch (opcode & 0x1F) { 1093 1105 case 0x01: 1094 do_tok(buf, "RoomScroll", ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2W) | ANOENDSEMICOLON);1106 do_tok(buf, "RoomScroll", ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2W)); 1095 1107 break; 1096 1108 case 0x02: 1097 do_tok(buf, "RoomColor", ANOENDSEMICOLON);1109 do_tok(buf, "RoomColor", 0); 1098 1110 break; 1099 1111 case 0x03: 1100 do_tok(buf, "SetScreen", ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2W) | ANOENDSEMICOLON);1112 do_tok(buf, "SetScreen", ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2W)); 1101 1113 break; 1102 1114 case 0x04: 1103 1115 buf = … … 1105 1117 ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2W) | 1106 1118 ((opcode & 0x20) ? A3V : A3W) | ANOLASTPAREN | ANOENDSEMICOLON); 1107 1119 opcode = get_byte(); 1108 buf = do_tok(buf, NULL, ASTARTCOMMA | ANOFIRSTPAREN | ANOENDSEMICOLON |((opcode & 0x80) ? A1V : A1B));1120 buf = do_tok(buf, NULL, ASTARTCOMMA | ANOFIRSTPAREN | ((opcode & 0x80) ? A1V : A1B)); 1109 1121 break; 1110 1122 case 0x05: 1111 do_tok(buf, "ShakeOn", ANOENDSEMICOLON);1123 do_tok(buf, "ShakeOn", 0); 1112 1124 break; 1113 1125 case 0x06: 1114 do_tok(buf, "ShakeOff", ANOENDSEMICOLON);1126 do_tok(buf, "ShakeOff", 0); 1115 1127 break; 1116 1128 case 0x07: 1117 do_tok(buf, "Unused", ANOENDSEMICOLON); 1129 // Possibly unused, but changed to match ScummVM anyway 1130 //do_tok(buf, "Unused", 0); 1131 buf = do_tok(buf, "SetRoomScale", 1132 ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B) | 1133 ANOLASTPAREN | ANOENDSEMICOLON); 1134 opcode = get_byte(); 1135 buf = do_tok(buf, NULL, 1136 ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B) | 1137 ASTARTCOMMA | ANOFIRSTPAREN | ANOLASTPAREN | ANOENDSEMICOLON); 1138 opcode = get_byte(); 1139 buf = do_tok(buf, NULL, 1140 ((opcode & 0x40) ? A2V : A2B) | // apparently it uses the param 2 bit 1141 ASTARTCOMMA | ANOFIRSTPAREN); 1118 1142 break; 1119 1143 case 0x08: 1120 1144 buf = 1121 1145 do_tok(buf, "RoomIntensity", 1122 1146 ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B) | 1123 ((opcode & 0x20) ? A3V : A3B) | ANOENDSEMICOLON);1147 ((opcode & 0x20) ? A3V : A3B)); 1124 1148 break; 1125 1149 case 0x09: 1126 buf = do_tok(buf, "saveLoad", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B) | ANOENDSEMICOLON);1150 buf = do_tok(buf, "saveLoad", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B)); 1127 1151 break; 1128 1152 case 0x0A: 1129 buf = do_tok(buf, "screenEffect", ((opcode & 0x80) ? A1V : A1W) | ANOENDSEMICOLON);1153 buf = do_tok(buf, "screenEffect", ((opcode & 0x80) ? A1V : A1W)); 1130 1154 break; 1131 1155 case 0x0B: 1132 1156 buf = … … 1137 1161 opcode = get_byte(); 1138 1162 buf = 1139 1163 do_tok(buf, NULL, 1140 ASTARTCOMMA | ANOFIRSTPAREN | ANOENDSEMICOLON |((opcode & 0x80) ? A1V : A1B) |1164 ASTARTCOMMA | ANOFIRSTPAREN | ((opcode & 0x80) ? A1V : A1B) | 1141 1165 ((opcode & 0x40) ? A2V : A2B)); 1142 1166 break; 1143 1167 … … 1150 1174 opcode = get_byte(); 1151 1175 buf = 1152 1176 do_tok(buf, NULL, 1153 ASTARTCOMMA | ANOFIRSTPAREN | ANOENDSEMICOLON |((opcode & 0x80) ? A1V : A1B) |1177 ASTARTCOMMA | ANOFIRSTPAREN | ((opcode & 0x80) ? A1V : A1B) | 1154 1178 ((opcode & 0x40) ? A2V : A2B)); 1155 1179 break; 1156 1180 1157 1181 case 0x0D: 1158 do_tok(buf, "saveString", ((opcode & 0x80) ? A1V : A1B) | A2ASCII | ANOENDSEMICOLON);1182 do_tok(buf, "saveString", ((opcode & 0x80) ? A1V : A1B) | A2ASCII); 1159 1183 break; 1160 1184 case 0x0E: 1161 do_tok(buf, "loadString", ((opcode & 0x80) ? A1V : A1B) | A2ASCII | ANOENDSEMICOLON);1185 do_tok(buf, "loadString", ((opcode & 0x80) ? A1V : A1B) | A2ASCII); 1162 1186 break; 1163 1187 1164 1188 case 0x0F: … … 1174 1198 break; 1175 1199 1176 1200 case 0x10: 1177 do_tok(buf, "colorCycleDelay", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B) | ANOENDSEMICOLON);1201 do_tok(buf, "colorCycleDelay", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B)); 1178 1202 break; 1179 1203 1180 1204 default: 1181 1205 strcpy(buf, "Unknown??"); 1182 1206 } 1183 1184 strcat(buf, ");");1185 1207 } 1186 1208 1187 1209 void do_room_ops_old(char *buf, byte opcode) { … … 1957 1979 case 0xB5: 1958 1980 case 0xF5: 1959 1981 do_tok(buf, "findObject", 1960 AVARSTORE | ((opcode & 0x80) ? A1V : A1 W) | ((opcode & 0x40) ? A2V : A2W));1982 AVARSTORE | ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B)); 1961 1983 break; 1962 1984 case 0x71: 1963 1985 case 0xF1: … … 2035 2057 case 0x9D: 2036 2058 case 0xDD: 2037 2059 //ifClassOfIs 2038 do_tok(buf, "classOfIs", ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2B) | ATO );2060 do_tok(buf, "classOfIs", ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2B) | ATO | ATOWITHLASTPAREN); 2039 2061 break; 2040 2062 2041 2063 case 0x3F: … … 2119 2141 //loadRoomWithEgo 2120 2142 buf = 2121 2143 do_tok(buf, "loadRoomWithEgo", 2122 ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2B) | ANOLASTPAREN );2144 ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2B) | ANOLASTPAREN | ANOENDSEMICOLON); 2123 2145 do_tok(buf, NULL, A1B | A2B | ANOFIRSTPAREN | ASTARTCOMMA); 2124 2146 break; 2125 2147 … … 2973 2995 opcode = get_byte(); 2974 2996 switch (opcode & 0x1F) { 2975 2997 case 1: 2976 do_tok(buf, " , setXY(",2977 A NOLASTPAREN | ANOFIRSTPAREN| ANOENDSEMICOLON | ((opcode & 0x80) ? A1V : A1W) |2998 do_tok(buf, "setXY", 2999 ASTARTCOMMA | ANOENDSEMICOLON | ((opcode & 0x80) ? A1V : A1W) | 2978 3000 ((opcode & 0x40) ? A2V : A2W)); 2979 3001 break; 2980 3002 case 2: 2981 do_tok(buf, " , setImage(", ANOLASTPAREN | ANOFIRSTPAREN| ANOENDSEMICOLON | ((opcode & 0x80) ? A1V : A1W));3003 do_tok(buf, "setImage", ASTARTCOMMA | ANOENDSEMICOLON | ((opcode & 0x80) ? A1V : A1W)); 2982 3004 break; 2983 3005 } 2984 strcat(buf, ") );");3006 strcat(buf, ");"); 2985 3007 2986 3008 } else { 2987 3009 buf = do_tok(buf, "drawObject", … … 3032 3054 case 0xCA: 3033 3055 case 0x6A: 3034 3056 case 0xEA: 3035 do_tok(buf, "startScript", ((opcode & 0x80) ? A1V : A1B) | A2LIST); 3057 buf = do_tok(buf, "startScript", ((opcode & 0x80) ? A1V : A1B) | A2LIST | ANOLASTPAREN | ANOENDSEMICOLON); 3058 if (opcode & 0x20) { // freeze resistant 3059 buf += sprintf(buf, ",F"); 3060 } 3061 if (opcode & 0x40) { // recursive 3062 buf += sprintf(buf, ",R"); 3063 } 3064 buf += sprintf(buf, ");"); 3036 3065 break; 3037 3066 3038 3039 3067 case 0x0B: 3040 3068 case 0x4B: 3041 3069 case 0x8B: … … 3109 3137 3110 3138 case 0x1D: 3111 3139 case 0x9D: 3112 do_tok(buf, "classOfIs", ((opcode & 0x80) ? A1V : A1W) | A2LIST | ATO );3140 do_tok(buf, "classOfIs", ((opcode & 0x80) ? A1V : A1W) | A2LIST | ATO | ATOWITHLASTPAREN); 3113 3141 break; /* arg1=object; vararg=classes to test; arg3=jumpoffs */ 3114 3142 3115 3143 case 0x1E: … … 3131 3159 case 0xE4: 3132 3160 buf = 3133 3161 do_tok(buf, "loadRoomWithEgo", 3134 ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2B) | ANOLASTPAREN );3162 ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ? A2V : A2B) | ANOLASTPAREN | ANOENDSEMICOLON); 3135 3163 do_tok(buf, NULL, A1W | A2W | ANOFIRSTPAREN | ASTARTCOMMA); 3136 3164 break; 3137 3165 … … 3465 3493 case 0xB5: 3466 3494 case 0xF5: 3467 3495 do_tok(buf, "findObject", 3468 AVARSTORE | ((opcode & 0x80) ? A1V : A1 W) | ((opcode & 0x40) ? A2V : A2W));3496 AVARSTORE | ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B)); 3469 3497 break; 3470 3498 3471 3499 case 0x26: … … 3658 3686 break; 3659 3687 3660 3688 case 0x6B: 3661 do_tok(buf, "debug ?", ((opcode & 0x80) ? A1V : A1W));3689 do_tok(buf, "debug", ((opcode & 0x80) ? A1V : A1W)); 3662 3690 break; 3663 3691 3664 3692 default: