Ticket #8184: skypatch2.diff
File skypatch2.diff, 35.5 KB (added by , 22 years ago) |
---|
-
common/engine.cpp
diff -urN scummvm/common/engine.cpp scummvm-bass/common/engine.cpp
old new 87 87 } else if (detector->_gameId >= GID_SCUMM_FIRST && detector->_gameId <= GID_SCUMM_LAST) { 88 88 // Some kind of Scumm game 89 89 engine = Engine_SCUMM_create(detector, syst); 90 } else if (detector->_gameId >= GID_SKY_FIRST && detector->_gameId <= GID_SKY_LAST) { 91 // Beneath a Steel Sky 92 engine = Engine_SKY_create(detector, syst); 90 93 } else { 91 94 // Unknown game 92 95 } -
common/engine.h
diff -urN scummvm/common/engine.h scummvm-bass/common/engine.h
old new 78 78 // 2) Faster (compiler doesn't have to parse lengthy header files) 79 79 extern Engine *Engine_SIMON_create(GameDetector *detector, OSystem *syst); 80 80 extern Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst); 81 extern Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst); 81 82 82 83 extern const VersionSettings *Engine_SIMON_targetList(); 83 84 extern const VersionSettings *Engine_SCUMM_targetList(); 85 extern const VersionSettings *Engine_SKY_targetList(); 84 86 85 87 #endif 86 88 -
common/gameDetector.cpp
diff -urN scummvm/common/gameDetector.cpp scummvm-bass/common/gameDetector.cpp
old new 191 191 // Gather & combine the target lists from the modules 192 192 const VersionSettings *scummVersions = Engine_SCUMM_targetList(); 193 193 const VersionSettings *simonVersions = Engine_SIMON_targetList(); 194 const VersionSettings *skyVersions = Engine_SKY_targetList(); 195 194 196 int scummCount = countVersions(scummVersions); 195 197 int simonCount = countVersions(simonVersions); 198 int skyCount = countVersions(skyVersions); 196 199 197 VersionSettings *v = (VersionSettings *)calloc(scummCount + simonCount + 1, sizeof(VersionSettings));200 VersionSettings *v = (VersionSettings *)calloc(scummCount + simonCount + skyCount + 1, sizeof(VersionSettings)); 198 201 memcpy(v, scummVersions, scummCount * sizeof(VersionSettings)); 199 202 memcpy(v+scummCount, simonVersions, simonCount * sizeof(VersionSettings)); 203 memcpy(v+skyCount, skyVersions, skyCount * sizeof(VersionSettings)); 200 204 version_settings = v; 201 205 } 202 206 } -
common/gameDetector.h
diff -urN scummvm/common/gameDetector.h scummvm-bass/common/gameDetector.h
old new 40 40 41 41 // Simon the Sorcerer 42 42 GID_SIMON_FIRST, 43 GID_SIMON_LAST = GID_SIMON_FIRST + 99 43 GID_SIMON_LAST = GID_SIMON_FIRST + 99, 44 45 // Beneath a Steel Sky 46 GID_SKY_FIRST, 47 GID_SKY_LAST = GID_SKY_FIRST + 99 44 48 }; 45 49 46 50 // TODO: the GameFeatures really should be moved to scumm/scumm.h, too -
Makefile
diff -urN scummvm/Makefile scummvm-bass/Makefile
old new 32 32 ####################################################################### 33 33 34 34 # Uncomment this to activate the MAD lib for compressed sound files 35 DEFINES += -DUSE_MAD36 LIBS += -lmad35 #DEFINES += -DUSE_MAD 36 #LIBS += -lmad 37 37 38 38 # Uncomment this to activate the Ogg Vorbis lib for compressed sound files 39 39 # DEFINES += -DUSE_VORBIS -
Makefile.common
diff -urN scummvm/Makefile.common scummvm-bass/Makefile.common
old new 23 23 # module.mk of their parents. In fact the only reason they are listed here is to ensure the 24 24 # DEPDIRS directive works correctly. 25 25 MODULES += \ 26 scumm common simon gui backends sound \26 scumm common simon sky gui backends sound \ 27 27 scumm/smush backends/fs/posix backends/fs/morphos backends/fs/windows backends/midi 28 28 29 29 # Include the build instructions for all modules -
sky/disk.cpp
diff -urN scummvm/sky/disk.cpp scummvm-bass/sky/disk.cpp
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #include "common/scummsys.h" 21 #include "common/engine.h" 22 #include "common/file.h" 23 #include "sky/skydefs.h" 24 #include "sky/skymain.h" 25 26 #define no_of_files_hd 1600 27 #define no_of_files_cd 5200 28 #define max_files_in_list 60 29 30 extern uint16 UnpackM1(void *, void *, uint16); 31 32 const char *data_file_name = "sky.dsk"; 33 const char *dinner_file_name = "sky.dnr"; 34 uint8 *dinner_table_area, *fixed_dest, *file_dest, *comp_dest; 35 uint32 dinner_table_size, file_flags, file_offset, file_size, decomp_size, comp_file; 36 uint16 build_list[max_files_in_list]; 37 uint32 loaded_file_list[max_files_in_list]; 38 39 File *data_disk_handle = new File(); 40 File *dnr_handle = new File(); 41 42 void SkyState::initialise_disk() 43 { 44 uint32 entries_read; 45 46 dnr_handle->open(dinner_file_name, _gameDataPath); 47 if (dnr_handle->isOpen() == false) 48 error("Could not open %s%s!\n", _gameDataPath, dinner_file_name); 49 50 if (!(dinner_table_size = dnr_handle->readUint32LE())) 51 error("Error reading from sky.dnr!\n"); //even though it was opened correctly?! 52 53 debug(1, "Entries in dinner table: %d", dinner_table_size); 54 55 dinner_table_area = (uint8 *)malloc(dinner_table_size*8); 56 entries_read = dnr_handle->read(dinner_table_area, 8*dinner_table_size) / 8; 57 58 if (entries_read != dinner_table_size) 59 warning("bytes_read != dinner_table_entries. [%d/%d]\n", entries_read, dinner_table_size); 60 61 data_disk_handle->open(data_file_name, _gameDataPath); 62 if (data_disk_handle->isOpen() == false) 63 error("Error opening %s%s!\n", _gameDataPath, data_file_name); 64 } 65 66 //load in file file_nr to address dest 67 //if dest == NULL, then allocate memory for this file 68 uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest) 69 { 70 uint8 cflag; 71 uint32 eax, ecx; 72 int32 bytes_read; 73 uint8 *file_ptr, *esiptr, *ediptr; 74 s file_header; 75 76 #ifdef file_order_chk 77 warning("File order checking not implemented yet!\n"); 78 #endif 79 80 comp_file = file_nr; 81 debug(1, "load file %d,%d (%d)", (file_nr>>11), (file_nr&2047), file_nr); 82 83 84 file_ptr = (uint8 *)get_file_info(file_nr); 85 if (file_ptr == NULL) { 86 printf("File %d not found!\n", file_nr); 87 return NULL; 88 } 89 90 eax = READ_LE_UINT32((file_ptr+5)); 91 file_flags = eax; 92 eax &= 0x03fffff; 93 file_size = eax; 94 95 ecx = READ_LE_UINT32((file_ptr+2)); 96 ecx &= 0x0ffffff; 97 98 cflag = (uint8)((ecx >> (23)) & 0x1); 99 ecx = (((1 << (23)) ^ 0xFFFFFFFF) & ecx); 100 101 if (cflag) 102 ecx = ecx << 4; 103 104 file_offset = ecx; 105 fixed_dest = dest; 106 file_dest = dest; 107 comp_dest = dest; 108 109 if (dest == NULL) //we need to allocate memory for this file 110 file_dest = (uint8 *)malloc(eax); 111 112 data_disk_handle->seek(file_offset, SEEK_SET); 113 114 #ifdef file_order_chk 115 warning("File order checking not implemented yet!\n"); 116 #endif 117 118 //now read in the data 119 bytes_read = data_disk_handle->read(file_dest, 1*file_size); 120 121 if (bytes_read != (int32)file_size) 122 printf("ERROR: Unable to read %d bytes from datadisk (%d bytes read)\n", file_size, bytes_read); 123 124 cflag = (uint8)((file_flags >> (23)) & 0x1); 125 126 //if cflag == 0 then file is compressed, 1 == uncompressed 127 128 if (!cflag) 129 { 130 debug(1, "File is compressed..."); 131 132 memcpy(&file_header, file_dest, sizeof(struct s)); 133 if ( (uint8)((file_header.flag >> (7)) & 0x1) ) { 134 debug(1, "with RNC!"); 135 136 eax = file_header.flag; 137 eax &= 0xFFFFFF00; //clear al 138 eax = eax << 8; 139 eax |= (uint16)file_header.s_tot_size; 140 141 decomp_size = eax; 142 143 if (fixed_dest == NULL) // is this valid? 144 comp_dest = (uint8 *)malloc(eax); 145 146 esiptr = file_dest; 147 ediptr = comp_dest; 148 149 if ( (uint8)(file_flags >> (22) & 0x1) ) //do we include the header? 150 esiptr += sizeof(struct s); 151 else { 152 memcpy(ediptr, esiptr, sizeof(struct s)); 153 esiptr += sizeof(struct s); 154 ediptr += sizeof(struct s); 155 } 156 157 eax = UnpackM1(esiptr, ediptr, 0); 158 159 debug(2, "UnpackM1 returned: %d", eax); 160 161 if (eax == 0) { //Unpack returned 0: file was probably not packed. 162 if (fixed_dest == NULL) 163 free(comp_dest); 164 165 return (uint16 *)file_dest; 166 } 167 168 if (! (uint8)(file_flags >> (22) & 0x1) ) { //include header? 169 eax += sizeof(struct s); 170 171 if (eax != decomp_size) 172 { 173 debug(1, "ERROR: invalid decomp size! (was: %d, should be: %d)", eax, decomp_size); 174 } 175 } 176 177 if (fixed_dest == NULL) 178 free(file_dest); 179 180 } 181 else 182 debug(1, "but not with RNC! (?!)"); 183 184 } 185 else 186 return (uint16 *)file_dest; 187 188 return (uint16 *)comp_dest; 189 } 190 191 uint16 *SkyState::get_file_info(uint16 file_nr) 192 { 193 uint16 i; 194 uint16 *dnr_tbl_16_ptr = (uint16 *)dinner_table_area; 195 196 for (i = 0; i < dinner_table_size/2; i++) 197 { 198 if (READ_LE_UINT16(dnr_tbl_16_ptr+(i*4)) == file_nr) 199 { 200 debug(1, "file %d found!", file_nr); 201 return (dnr_tbl_16_ptr+(i*4)); 202 } 203 } 204 205 //if file is speech file then return NULL if not found 206 printf("get_file_info() - speech file support not implemented yet!\n"); 207 return (uint16 *)NULL; 208 } 209 -
sky/intro.cpp
diff -urN scummvm/sky/intro.cpp scummvm-bass/sky/intro.cpp
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #include <string.h> 21 #include "common/scummsys.h" 22 #include "sky/skydefs.h" 23 #include "sky/skymain.h" 24 25 #define intro_text_width 128 26 27 #define fn_a_pal 60080 28 #define fn_1a_log 60081 29 #define fn_1a 60082 30 #define fn_1b 60083 31 #define fn_1c 60084 32 #define fn_1d 60085 33 #define fn_1e 60086 34 #define fn_4a 60087 35 #define fn_4b_log 60088 36 #define fn_4b 60089 37 #define fn_4c_log 60090 38 #define fn_4c 60091 39 #define fn_5_pal 60092 40 #define fn_5_log 60093 41 #define fn_5 60094 42 #define fn_6_pal 60095 43 #define fn_6_log 60096 44 #define fn_6a 60097 45 #define fn_6b 60098 46 47 #ifdef short_intro_start 48 #define virgin_time_1 3 49 #define viring_time_2 3 50 #define rev_time 8 51 #define gibb_time 6 52 #else 53 #define virgin_time_1 (3*50) 54 #define virgin_time_2 ((3*50)+8) 55 #define rev_time ((8*50)+8) 56 #define gibb_time ((6*50)+8) 57 #endif 58 59 void prepare_text(void); 60 void show_intro_text(void); 61 void remove_text(void); 62 void intro_fx(void); 63 void intro_vol(void); 64 65 uint8 *seq1a_data; 66 uint8 *seq1b_data; 67 uint8 *seq1c_data; 68 uint8 *seq1d_data; 69 uint8 *seq1e_data; 70 uint8 *seq4a_data; 71 uint8 *seq4b_data; 72 uint8 *seq4c_data; 73 uint8 *seq5_data; 74 uint8 *seq6a_data; 75 uint8 *seq6b_data; 76 77 78 uint8 *vga_data; 79 uint8 *diff_data; 80 81 uint8 *work_base; 82 uint8 *work_screen; 83 uint8 *work_screen_end; 84 85 uint8 *intro_text_space; //space for storing text messages 86 uint8 *intro_text_save; //save screen data here 87 88 uint8 *vga_pointer; 89 uint8 *diff_pointer; 90 91 uint32 no_frames; //number of frames in scrolling intro 92 uint32 frame_counter; 93 94 #define ic_prepare_text 0 95 #define ic_show_text 1 96 #define ic_remove_text 2 97 #define ic_make_sound 3 98 #define ic_fx_volume 4 99 100 101 typedef void (*pfc)(void); 102 pfc command_routines[] = { &prepare_text, &show_intro_text, &remove_text, &intro_fx, &intro_vol }; 103 104 uint32 cockpit_commands[] = 105 { 106 1000, //do straight away 107 ic_prepare_text, 108 77, 109 220, 110 ic_show_text, //radar detects jamming signal 111 20, 112 160, 113 105, 114 ic_remove_text, 115 81, 116 105, 117 ic_show_text, //well switch to override you fool 118 170, 119 86, 120 35, 121 ic_remove_text, 122 35, 123 ic_prepare_text, 124 477, 125 35, 126 ic_show_text, 127 30, 128 160, 129 3, 130 ic_remove_text 131 }; 132 133 uint32 zero_commands[] = { 0 }; 134 135 uint32 anim5_commands[] = 136 { 137 31, 138 ic_make_sound, 139 2, 140 127, 141 0 142 }; 143 144 uint32 anim4a_commands[] = 145 { 146 136, 147 ic_make_sound, 148 1, 149 70, 150 90, 151 ic_fx_volume, 152 80, 153 50, 154 ic_fx_volume, 155 90, 156 5, 157 ic_fx_volume, 158 100, 159 0 160 }; 161 162 uint32 anim4c_commands[] = 163 { 164 1000, 165 ic_fx_volume, 166 100, 167 25, 168 ic_fx_volume, 169 110, 170 15, 171 ic_fx_volume, 172 120, 173 4, 174 ic_fx_volume, 175 127, 176 0 177 }; 178 179 uint32 anim6a_commands[] = 180 { 181 1000, 182 ic_prepare_text, 183 478, 184 13, 185 ic_show_text, 186 175, 187 155, 188 0 189 }; 190 191 uint32 anim6b_commands[] = 192 { 193 131, 194 ic_remove_text, 195 131, 196 ic_prepare_text, 197 479, 198 74, 199 ic_show_text, 200 175, 201 155, 202 45, 203 ic_remove_text, 204 45, 205 ic_prepare_text, 206 162, 207 44, 208 ic_show_text, 209 175, 210 155, 211 4, 212 ic_remove_text, 213 0 214 }; 215 216 uint32 *command_pointer = (uint32 *)zero_commands; 217 218 219 void SkyState::init_virgin() 220 { 221 _temp_pal = (uint8 *)load_file(60111, NULL); 222 if (_temp_pal != NULL) 223 set_palette(_temp_pal); 224 225 _work_screen = (uint8 *)load_file(60110, NULL); 226 227 if (_work_screen != NULL) 228 show_screen(); 229 230 //free the memory that was malloc'ed indirectly via load_file 231 free (_work_screen); 232 free (_temp_pal); 233 } 234 235 void SkyState::show_screen(void) 236 { 237 _system->copy_rect(_work_screen, 320, 0, 0, 320, 200); 238 _system->update_screen(); 239 } 240 241 void prepare_text(void) 242 { 243 244 } 245 246 void show_intro_text(void) 247 { 248 249 } 250 251 void remove_text(void) 252 { 253 254 } 255 256 void intro_fx(void) 257 { 258 259 } 260 261 void intro_vol(void) 262 { 263 264 } -
sky/module.mk
diff -urN scummvm/sky/module.mk scummvm-bass/sky/module.mk
old new 1 MODULE := sky 2 3 MODULE_OBJS = \ 4 sky/skymain.o \ 5 sky/disk.o \ 6 sky/screen.o \ 7 sky/intro.o \ 8 sky/rnc_deco.o \ 9 10 # Include common rules 11 include common.rules -
sky/rnc_deco.cpp
diff -urN scummvm/sky/rnc_deco.cpp scummvm-bass/sky/rnc_deco.cpp
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #include <string.h> 21 #include "common/scummsys.h" 22 23 #define ROL(x, n) (((x) << (n)) | ((x) >> (16-(n)))) 24 #define ROR(x, n) (((x) << (16-(n))) | ((x) >> (n))) 25 #define XCHG(a, b) (a ^=b, b ^= a, a ^= b) 26 27 //conditional flags 28 #define CHECKSUMS 1 29 #define PROTECTED 0 30 31 //return codes 32 #define NOT_PACKED 0 33 #define PACKED_CRC -1 34 #define UNPACKED_CRC -2 35 36 //other defines 37 #define TABLE_SIZE (16*8) 38 #define MIN_LENGTH 2 39 #define HEADER_LEN 18 40 41 uint16 raw_table[TABLE_SIZE/2]; 42 uint16 pos_table[TABLE_SIZE/2]; 43 uint16 len_table[TABLE_SIZE/2]; 44 45 #ifdef CHECKSUMS 46 uint16 crc_table[0x100]; 47 #endif 48 49 uint32 unpack_len = 0; 50 uint32 pack_len = 0; 51 uint16 pack_paras = 0; 52 uint16 counts = 0; 53 uint16 bit_buffl = 0; 54 uint16 bit_buffh = 0; 55 uint8 blocks = 0; 56 uint8 bit_count = 0; 57 58 #ifdef CHECKSUMS 59 uint16 crc_u = 0; 60 uint16 crc_p = 0; 61 #endif 62 63 64 uint8 *esiptr, *ediptr; //these need to be global because input_bits() uses them 65 66 void init_crc(void) 67 { 68 uint16 cnt=0; 69 uint16 tmp1=0; 70 uint16 tmp2=0; 71 72 for (tmp2 = 0; tmp2 < 0x100; tmp2++) { 73 tmp1 = tmp2; 74 for (cnt = 8; cnt > 0; cnt--) { 75 if (tmp1 % 2) { 76 tmp1 /= 2; 77 tmp1 ^= 0x0a001; 78 } 79 else 80 tmp1 /= 2; 81 } 82 crc_table[tmp2] = tmp1; 83 } 84 } 85 86 //calculate 16 bit crc of a block of memory 87 uint16 crc_block(uint8 *block, uint32 size) 88 { 89 uint16 crc=0; 90 uint8 *crcTable8 = (uint8 *)crc_table; //make a uint8* to crc_table 91 uint8 tmp; 92 uint32 i; 93 94 for (i = 0; i < size; i++) { 95 tmp = *block++; 96 crc ^= tmp; 97 tmp = (uint8)((crc>>8)&0x00FF); 98 crc &= 0x00FF; 99 crc = crc << 1; 100 crc = *(uint16 *)&crcTable8[crc]; 101 crc ^= tmp; 102 } 103 104 return crc; 105 } 106 107 uint16 input_bits(uint8 amount) 108 { 109 uint16 newBitBuffh = bit_buffh; 110 uint16 newBitBuffl = bit_buffl; 111 int16 newBitCount = bit_count; 112 uint16 remBits, returnVal; 113 114 returnVal = ((1 << amount) - 1) & newBitBuffl; 115 newBitCount -= amount; 116 117 if (newBitCount < 0) { 118 newBitCount += amount; 119 XCHG(newBitCount, amount); 120 remBits = ROR((uint16)(((1 << amount) - 1) & newBitBuffh), amount); 121 newBitBuffh >>= amount; 122 newBitBuffl >>= amount; 123 newBitBuffl |= remBits; 124 esiptr += 2; 125 newBitBuffh = READ_LE_UINT16(esiptr); 126 XCHG(newBitCount, amount); 127 amount -= newBitCount; 128 newBitCount = 16 - amount; 129 } 130 remBits = ROR((uint16)(((1 << amount) - 1) & newBitBuffh), amount); 131 bit_buffh = newBitBuffh >> amount; 132 bit_buffl = (newBitBuffl >> amount) | remBits; 133 bit_count = newBitCount; 134 135 return returnVal; 136 137 } 138 139 // RCL/RCR functions..operate on 16 bit ints only 140 uint16 rcl(uint16 reg, uint16 *cflag) 141 { 142 uint16 lsb = *cflag; 143 *cflag = reg >> 15; 144 return (reg << 1) | lsb; 145 } 146 147 uint16 rcr(uint16 reg, uint16 *cflag) 148 { 149 uint16 msb = *cflag << 15; 150 *cflag = reg & 1; 151 return (reg >> 1) | msb; 152 } 153 154 155 156 void make_huftable(uint16 *table) 157 { 158 uint16 bitLength, i, j; 159 uint16 numCodes = input_bits(5); 160 161 if (!numCodes) 162 return; 163 164 uint8 huffLength[16]; 165 for (i = 0; i < numCodes; i++) 166 huffLength[i] = (uint8)(input_bits(4) & 0x00FF); 167 168 uint16 huffCode = 0; 169 170 for (bitLength = 1; bitLength < 17; bitLength++) { 171 for (i = 0; i < numCodes; i++) { 172 if (huffLength[i] == bitLength) { 173 *table++ = (1 << bitLength) - 1; 174 175 uint16 b = huffCode >> (16 - bitLength); 176 uint16 a = 0; 177 uint16 carry = 0; 178 179 for (j = 0; j < bitLength; j++) { 180 b = rcr(b, &carry); 181 a = rcl(a, &carry); 182 183 } 184 *table++ = a; 185 186 *(table+0x1e) = (huffLength[i]<<8)|(i & 0x00FF); 187 huffCode += 1 << (16 - bitLength); 188 } 189 } 190 } 191 } 192 193 194 uint16 input_value(uint16 *table) 195 { 196 uint16 valOne, valTwo, value = bit_buffl; 197 198 do { 199 valTwo = (*table++) & value; 200 valOne = *table++; 201 202 } while (valOne != valTwo); 203 204 value = *(table+0x1e); 205 input_bits((uint8)((value>>8)&0x00FF)); 206 value &= 0x00FF; 207 208 if (value >= 2) { 209 value--; 210 valOne = input_bits((uint8)value&0x00FF); 211 valOne |= (1 << value); 212 value = valOne; 213 } 214 215 return value; 216 } 217 218 int UnpackM1(void *input, void *output, uint16 key) 219 { 220 uint8 cl; 221 uint8 *inputHigh, *outputLow; 222 uint32 eax, ebx, ecx, edx; 223 uint8 *inputptr = (uint8 *)input; 224 225 if (CHECKSUMS) 226 init_crc(); 227 228 //Check for "RNC " 229 if (READ_BE_UINT32(inputptr) != 0x524e4301) 230 return NOT_PACKED; 231 232 inputptr += 4; 233 234 // read unpacked/packed file length 235 unpack_len = READ_BE_UINT32(inputptr); inputptr += 4; 236 pack_len = READ_BE_UINT32(inputptr); inputptr += 4; 237 238 blocks = *(inputptr+5); 239 240 if (CHECKSUMS) { 241 //read CRC's 242 crc_u = READ_BE_UINT16(inputptr); inputptr += 2; 243 crc_p = READ_BE_UINT16(inputptr); inputptr += 2; 244 245 inputptr = (inputptr+HEADER_LEN-16); 246 247 if (crc_block(inputptr, pack_len) != crc_p) 248 return PACKED_CRC; 249 250 inputptr = (((uint8 *)input)+HEADER_LEN); 251 esiptr = inputptr; 252 253 } 254 255 inputHigh = ((uint8 *)input) + pack_len + HEADER_LEN;; 256 outputLow = (uint8 *)output; 257 258 eax = *(((uint8 *)input)+16) + unpack_len; 259 260 if (! ((inputHigh <= outputLow ) || ((outputLow+eax) <= inputHigh )) ) { 261 esiptr = inputHigh; 262 ediptr = (outputLow+eax); 263 memcpy((ediptr-pack_len), (esiptr-pack_len), pack_len); 264 esiptr = (ediptr-pack_len); 265 } 266 267 268 //unpack3: 269 ediptr = (uint8 *)output; 270 bit_count = 0; 271 272 bit_buffl = READ_LE_UINT16(esiptr); 273 /*eax =*/ input_bits(2); 274 275 276 //Argh! Labels!! 277 unpack4: 278 make_huftable(raw_table); 279 make_huftable(pos_table); 280 make_huftable(len_table); 281 282 counts = input_bits(16); 283 284 goto unpack6; 285 286 unpack5: 287 288 eax = input_value(pos_table) + 1; //input offset 289 ecx = input_value(len_table) + MIN_LENGTH; //input length 290 291 inputHigh = esiptr; 292 esiptr = (ediptr-eax); 293 294 //Don't use memcpy here! because input and output overlap 295 while (ecx) { 296 *ediptr++ = *esiptr++; ecx--; 297 } 298 299 esiptr = inputHigh; 300 301 unpack6: 302 303 ecx = input_value(raw_table); 304 305 if (ecx == 0) 306 goto unpack7; 307 308 memcpy(ediptr, esiptr, ecx); //memcpy is allowed here 309 ediptr += ecx; 310 esiptr += ecx; 311 cl = bit_count; 312 eax = READ_LE_UINT16(esiptr); 313 ebx = eax; 314 eax = ROL((uint16)eax, cl); 315 edx = ((1 << cl) - 1) & 0x0000FFFF; //make sure we only get 16bits 316 bit_buffl &= (uint16)edx; 317 edx &= eax; 318 319 eax = READ_LE_UINT16((esiptr+2)); 320 ebx = (ebx << cl)&0x0000FFFF; 321 eax = (eax << cl)&0x0000FFFF; 322 eax |= edx; 323 bit_buffl |= (uint16)ebx; 324 bit_buffh = (uint16)eax; 325 326 unpack7: 327 328 counts--; 329 if (counts) 330 goto unpack5; 331 332 blocks--; 333 if (blocks) 334 goto unpack4; 335 336 if (CHECKSUMS) { 337 if (crc_block((uint8 *)output, unpack_len) != crc_u) 338 return UNPACKED_CRC; 339 } 340 341 // all is done..return the amount of unpacked bytes 342 return unpack_len; 343 } -
sky/screen.cpp
diff -urN scummvm/sky/screen.cpp scummvm-bass/sky/screen.cpp
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #include <string.h> 21 #include "common/scummsys.h" 22 #include "sky/skydefs.h" 23 #include "sky/skymain.h" 24 25 #define fade_jump 2 26 #define scroll_jump 16 27 28 #define vga_colours 256 29 #define game_colours 240 30 31 uint8 top_16_colours[] = 32 { 33 0, 0, 0, 34 38, 38, 38, 35 63, 63, 63, 36 0, 0, 0, 37 0, 0, 0, 38 0, 0, 0, 39 0, 0, 0, 40 54, 54, 54, 41 45, 47, 49, 42 32, 31, 41, 43 29, 23, 37, 44 23, 18, 30, 45 49, 11, 11, 46 39, 5, 5, 47 29, 1, 1, 48 63, 63, 63 49 }; 50 51 void SkyState::initialise_screen(void) 52 { 53 int i; 54 uint8 tmp_pal[1024]; 55 56 _system->init_size(full_screen_width, full_screen_height); 57 _backscreen = (uint8 *)malloc(full_screen_width*full_screen_height); 58 _game_grid = (uint8 *)malloc(GRID_X*GRID_Y*2); 59 _work_palette = (uint8 *)malloc(vga_colours*3); 60 61 //blank the first 240 colors of the palette 62 bzero(tmp_pal, game_colours*4); 63 64 //set the remaining colors 65 for (i=0; i<(vga_colours-game_colours); i++) { 66 tmp_pal[game_colours+i*4] = (top_16_colours[i*3] << 2) + (top_16_colours[i*3] & 3); 67 tmp_pal[game_colours+i*4+1] = (top_16_colours[i*3+1] << 2) + (top_16_colours[i*3+1] & 3); 68 tmp_pal[game_colours+i*4+2] = (top_16_colours[i*3+2] << 2) + (top_16_colours[i*3+2] & 3); 69 tmp_pal[game_colours+i*4+3] = 0x00; 70 } 71 72 //set the palette 73 _system->set_palette(tmp_pal, 0, 256); 74 75 } 76 77 //set a new palette, pal is a pointer to dos vga rgb components 0..63 78 void SkyState::set_palette(uint8 *pal) 79 { 80 convert_palette(pal, _palette); 81 _system->set_palette(_palette, 0, 256); 82 } 83 84 void SkyState::convert_palette(uint8 *inpal, uint8* outpal) //convert 3 byte 0..63 rgb to 4byte 0..255 rgbx 85 { 86 int i; 87 88 for (i = 0; i < vga_colours; i++) { 89 outpal[4*i] = (inpal[3*i] << 2) + (inpal[3*i] & 3); 90 outpal[4*i+1] = (inpal[3*i+1] << 2) + (inpal[3*i+1] & 3); 91 outpal[4*i+2] = (inpal[3*i+2] << 2) + (inpal[3*i+2] & 3); 92 outpal[4*i+3] = 0x00; 93 } 94 } -
sky/skydefs.h
diff -urN scummvm/sky/skydefs.h scummvm-bass/sky/skydefs.h
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #include "struc.h" 21 22 //This file is incomplete, several flags still missing. 23 24 #define key_buffer_size 80 25 #define sequence_count 3 26 27 //screen/grid defines 28 #define game_screen_width 320 29 #define game_screen_height 192 30 #define full_screen_width 320 31 #define full_screen_height 200 32 33 #define tot_no_grids 70 34 35 #define grid_size 120 36 37 #define GRID_X 20 38 #define GRID_Y 24 39 #define GRID_W 16 40 #define GRID_H 8 41 42 #define GRID_W_SHIFT 4 43 #define GRID_H_SHIFT 3 44 45 #define top_left_x 128 46 #define top_left_y 136 47 48 //item list defines 49 #define section_0_item 119 50 51 #define c_base_mode 0 52 #define c_base_mode56 56 53 #define c_action_mode 4 54 #define c_sp_colour 90 55 #define c_mega_set 112 56 #define c_grid_width 114 57 58 //#define next_mega_set 59 60 #define send_sync -1 61 #define lf_start_fx -2 62 #define safe_start_screen 0 63 64 //autoroute defines 65 #define upy 0 66 #define downy 1 67 #define lefty 2 68 #define righty 3 69 70 #define route_space 64 71 72 #define l_script 1 73 #define l_ar 2 74 #define l_ar_anim 3 75 #define l_ar_turning 4 76 #define l_alt 5 77 #define l_mod_animate 6 78 #define l_turning 7 79 #define l_cursor 8 80 #define l_talk 9 81 #define l_listen 10 82 #define l_stopped 11 83 #define l_choose 12 84 #define l_frames 13 85 #define l_pause 14 86 #define l_wait_synch 15 87 #define l_simple_mod 16 88 -
sky/skymain.cpp
diff -urN scummvm/sky/skymain.cpp scummvm-bass/sky/skymain.cpp
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #include "sky/skymain.h" 21 #include "sky/skydefs.h" //game specific defines 22 #include "common/file.h" 23 #include "common/gameDetector.h" 24 #include <errno.h> 25 #include <time.h> 26 27 #ifdef _WIN32_WCE 28 29 extern bool toolbar_drawn; 30 extern bool draw_keyboard; 31 32 #endif 33 34 static const VersionSettings sky_settings[] = { 35 /* Beneath a Steel Sky */ 36 {"sky", "Beneath a Steel Sky", GID_SKY_FIRST, 99, 99, 99, 0, "sky.dsk" }, 37 {NULL, NULL, 0, 0, 0, 0, 0, NULL} 38 }; 39 40 const VersionSettings *Engine_SKY_targetList() 41 { 42 return sky_settings; 43 } 44 45 Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst) 46 { 47 return new SkyState(detector, syst); 48 } 49 50 SkyState::SkyState(GameDetector *detector, OSystem *syst) 51 : Engine(detector, syst) 52 { 53 _game = detector->_gameId; 54 55 _debugMode = detector->_debugMode; 56 _debugLevel = detector->_debugLevel; 57 _language = detector->_language; 58 } 59 60 SkyState::~SkyState() 61 { 62 63 } 64 65 void SkyState::pollMouseXY() 66 { 67 _mouse_x = _sdl_mouse_x; 68 _mouse_y = _sdl_mouse_y; 69 } 70 71 void SkyState::go() 72 { 73 if (!_dump_file) 74 _dump_file = stdout; 75 76 initialise(); 77 78 while (1) { 79 delay(100); 80 } 81 } 82 83 void SkyState::initialise(void) 84 { 85 //initialise_memory(); 86 //init_timer(); 87 //init_music(); 88 initialise_disk(); 89 initialise_screen(); 90 init_virgin(); 91 92 } 93 94 void SkyState::delay(uint amount) //copied and mutilated from Simon.cpp 95 { 96 OSystem::Event event; 97 98 uint32 start = _system->get_msecs(); 99 uint32 cur = start; 100 101 _rnd.getRandomNumber(2); 102 103 do { 104 while (_system->poll_event(&event)) { 105 switch (event.event_code) { 106 case OSystem::EVENT_KEYDOWN: 107 // Make sure backspace works right (this fixes a small issue on OS X) 108 if (event.kbd.keycode == 8) 109 _key_pressed = 8; 110 else 111 _key_pressed = (byte)event.kbd.ascii; 112 break; 113 114 case OSystem::EVENT_MOUSEMOVE: 115 _sdl_mouse_x = event.mouse.x; 116 _sdl_mouse_y = event.mouse.y; 117 _mouse_pos_changed = true; 118 break; 119 120 case OSystem::EVENT_LBUTTONDOWN: 121 _left_button_down++; 122 #ifdef _WIN32_WCE 123 _sdl_mouse_x = event.mouse.x; 124 _sdl_mouse_y = event.mouse.y; 125 #endif 126 break; 127 128 case OSystem::EVENT_RBUTTONDOWN: 129 130 break; 131 } 132 } 133 134 if (amount == 0) 135 break; 136 137 { 138 uint this_delay = 20; // 1? 139 if (this_delay > amount) 140 this_delay = amount; 141 _system->delay_msecs(this_delay); 142 } 143 cur = _system->get_msecs(); 144 } while (cur < start + amount); 145 } 146 -
sky/skymain.h
diff -urN scummvm/sky/skymain.h scummvm-bass/sky/skymain.h
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #ifndef SKYMAIN_H 21 #define SKYMAIN_H 22 23 #include <stdio.h> 24 #include "common/engine.h" 25 #include "common/util.h" 26 27 class SkyState : public Engine { 28 public: 29 30 byte _game; 31 byte _key_pressed; 32 33 uint16 _debugMode; 34 uint16 _debugLevel; 35 uint16 _language; 36 uint _mouse_x, _mouse_y; 37 uint _mouse_x_old, _mouse_y_old; 38 bool _mouse_pos_changed; 39 uint _left_button_down; 40 41 uint8 _palette[1024]; 42 43 int _num_screen_updates; 44 45 // int _timer_id; 46 47 FILE *_dump_file; 48 49 int _number_of_savegames; 50 51 int _sdl_mouse_x, _sdl_mouse_y; 52 53 byte *_work_screen; 54 byte *_backscreen; 55 byte *_temp_pal; 56 byte *_work_palette; 57 byte *_half_palette; 58 59 byte *_game_grid; 60 61 SkyState(GameDetector *detector, OSystem *syst); 62 virtual ~SkyState(); 63 64 void delay(uint amount); 65 void pollMouseXY(); 66 void go(); 67 void convert_palette(uint8 *inpal, uint8* outpal); 68 69 void initialise(); 70 void initialise_disk(); 71 void initialise_screen(); 72 void set_palette(uint8 *pal); 73 uint16 *load_file(uint16 file_nr, uint8 *dest); 74 uint16 *get_file_info(uint16 file_nr); 75 void init_virgin(); 76 void show_screen(); 77 78 static int CDECL game_thread_proc(void *param); 79 80 void shutdown(); 81 82 RandomSource _rnd; 83 84 85 }; 86 87 #endif -
sky/struc.h
diff -urN scummvm/sky/struc.h scummvm-bass/sky/struc.h
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 typedef struct s 21 { 22 uint16 flag; // bit 0: set for colour data, clear for not 23 // bit 1: set for compressed, clear for uncompressed 24 // bit 2: set for 32 colours, clear for 16 colours 25 uint16 s_x; 26 uint16 s_y; 27 uint16 s_width; 28 uint16 s_height; 29 uint16 s_sp_size; 30 uint16 s_tot_size; 31 uint16 s_n_sprites; 32 uint16 s_offset_x; 33 uint16 s_offset_y; 34 uint16 s_compressed_size; 35 }s; 36