diff options
-rw-r--r-- | docs/Manual.txt | 1 | ||||
-rw-r--r-- | docs/OSX_where_did_the_package_go.txt | 6 | ||||
-rw-r--r-- | docs/Readme_Mandrake_Linux.txt | 6 | ||||
-rw-r--r-- | docs/Readme_Windows_MSVC6.0.txt | 4 | ||||
-rw-r--r-- | gfx.c | 43 | ||||
-rw-r--r-- | gfx.h | 2 | ||||
-rw-r--r-- | readme.txt | 16 | ||||
-rw-r--r-- | spritecache.c | 92 | ||||
-rw-r--r-- | table/palettes.h | 91 | ||||
-rw-r--r-- | ttd.c | 5 | ||||
-rw-r--r-- | variables.h | 2 |
11 files changed, 203 insertions, 65 deletions
diff --git a/docs/Manual.txt b/docs/Manual.txt index 30b938a09..7530691bf 100644 --- a/docs/Manual.txt +++ b/docs/Manual.txt @@ -24,6 +24,7 @@ On BeOS, run ./configure and then use jam. There are a variaty of options you ca On Windows, insert your "Transport Tycoon Deluxe for Windows 95" disk. You can use a DOS version, but your graphics will be purple. NB: Even if your version of Transport Tycoon Deluxe ran on Windows 95, it may still be the DOS version. Then run the OpenTTD installer. On UNIX platforms; decompress your OpenTTD archive, or otherwise run the installer. You should be left with an OpenTTD directory on your system. In this directory, make a subdirectory called 'data', and into this place the sample.cat file and all the .grf files from the install CD of 'Transport Tycoon Deluxe for Windows 95". +(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.) If you want MIDI music, copy the 'gm' folder from the original game directory/CD to the OpenTTD folder. diff --git a/docs/OSX_where_did_the_package_go.txt b/docs/OSX_where_did_the_package_go.txt index 7a175eebc..72c3e76d0 100644 --- a/docs/OSX_where_did_the_package_go.txt +++ b/docs/OSX_where_did_the_package_go.txt @@ -10,8 +10,8 @@ opntitle.dat signalsw.grf trkfoundw.grf -THE WINDOWS GRF FILES ARE STILL NEEDED! -they need to be inside a folder called "data" in the same folder as OpenTTD. Create it if you have none. It should contain: +THE TTD GRF FILES ARE STILL NEEDED! +They need to be inside a folder called "data" in the same folder as OpenTTD. Create it if you have none. It should contain: sample.cat trg1r.grf trgcr.grf @@ -19,4 +19,6 @@ trghr.grf trgir.grf trgtr.grf +(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.) + You should also use the data folder to add any custom grf files if you like
\ No newline at end of file diff --git a/docs/Readme_Mandrake_Linux.txt b/docs/Readme_Mandrake_Linux.txt index 6d9d94dd5..838b862c9 100644 --- a/docs/Readme_Mandrake_Linux.txt +++ b/docs/Readme_Mandrake_Linux.txt @@ -31,14 +31,16 @@ You can undo changes to a file with 3.) Required data files: -Copy the following files from the WINDOWS version of Transport Tycoon Deluxe to openttd/data/ +Copy the following files from Transport Tycoon Deluxe to openttd/data/ sample.cat trg1r.grf trgcr.grf trghr.grf trgir.grf trgtr.grf - + +(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.) + 4.) Compiling and running: diff --git a/docs/Readme_Windows_MSVC6.0.txt b/docs/Readme_Windows_MSVC6.0.txt index 6a7a98c0a..6321a15c8 100644 --- a/docs/Readme_Windows_MSVC6.0.txt +++ b/docs/Readme_Windows_MSVC6.0.txt @@ -58,7 +58,7 @@ b) libraru files (the lib dir, D:\Program Files\Microsoft Visual Studio\VC98\Dir Step 4
-----------------
-Copy the following files from the WINDOWS version of Transport Tycoon Deluxe to the data folder
+Copy the following files from Transport Tycoon Deluxe to the data folder
sample.cat
trg1r.grf
trgcr.grf
@@ -66,7 +66,7 @@ Copy the following files from the WINDOWS version of Transport Tycoon Deluxe to trgir.grf
trgtr.grf
-
+(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
Step 5
-----------------
@@ -1483,14 +1483,18 @@ static void GfxScalePalette(int pal, byte scaling) } while (--count); } +void DoPaletteAnimations(); + void GfxInitPalettes() { - memcpy(_cur_palette, _palettes[0], 256*3); + int pal = _use_dos_palette?1:0; + memcpy(_cur_palette, _palettes[pal], 256*3); + _pal_first_dirty = 0; _pal_last_dirty = 255; + DoPaletteAnimations(); } - #define EXTR(p,q) (((uint16)(_timer_counter * (p)) * (q)) >> 16) #define EXTR2(p,q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16) #define COPY_TRIPLET do {d[0]=s[0+j]; d[1]=s[1+j]; d[2]=s[2+j];d+=3;}while(0) @@ -1499,13 +1503,17 @@ void DoPaletteAnimations() { const byte *s; byte *d; + /* Amount of colors to be rotated. + * A few more for the DOS palette, because the water colors are + * 245-254 for DOS and 217-226 for Windows. */ + int c = _use_dos_palette?38:28; int j; int i; const ExtraPaletteValues *ev = &_extra_palette_values; - byte old_val[28*3]; + byte old_val[c*3]; d = _cur_palette + 217*3; - memcpy(old_val, d, 28*3); + memcpy(old_val, d, c*3); // Dark blue water s = ev->a; @@ -1574,9 +1582,32 @@ void DoPaletteAnimations() if (j == 3*4) j = 0; } - if (memcmp(old_val, _cur_palette + 217*3, 28*3)) { + // Animate water for old DOS graphics + if(_use_dos_palette) { + // Dark blue water DOS + s = ev->a; + if (_opt.landscape == LT_CANDY) s = ev->ac; + j = EXTR(320,5) * 3; + for(i=0; i!=5; i++) { + COPY_TRIPLET; + j+=3; + if (j == 15) j = 0; + } + + // Glittery water DOS + s = ev->b; + if (_opt.landscape == LT_CANDY) s = ev->bc; + j = EXTR(128, 15) * 3; + for(i=0; i!=5; i++) { + COPY_TRIPLET; + j += 9; + if (j >= 45) j -= 45; + } + } + + if (memcmp(old_val, _cur_palette + 217*3, c*3)) { if (_pal_first_dirty > 217) _pal_first_dirty = 217; - if (_pal_last_dirty < 217+29-1) _pal_last_dirty = 217+29-1; + if (_pal_last_dirty < 217+c) _pal_last_dirty = 217+c; } } @@ -100,6 +100,8 @@ VARDEF CursorVars _cursor; VARDEF int _pal_first_dirty; VARDEF int _pal_last_dirty; +VARDEF bool _use_dos_palette; + /* spritecache.c */ //enum { NUM_SPRITES = 0x1320 }; //enum { NUM_SPRITES = 0x1500 }; diff --git a/readme.txt b/readme.txt index 719c56880..ccab5bd91 100644 --- a/readme.txt +++ b/readme.txt @@ -80,11 +80,9 @@ are: ---- ---------------- Before you run OpenTTD, you need to put the game's datafiles into the data/ -subdirectory. You need the following files from the original Windows version +subdirectory. You need the following files from the original version of TTD as OpenTTD makes use of the original TTD artwork. -IMPORTANT! You need the files from the WINDOWS version of TTD. - List of the required files: sample.cat trg1r.grf @@ -93,9 +91,17 @@ trghr.grf trgir.grf trgtr.grf -If you want music you need to copy the gm/ folder from Windows TTD into your OpenTTD folder, not your data folder. +(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, +TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase +to be detected correctly. A few minor graphical glitches with the DOS +graphics remain. E.g. the autorail button in the rail toolbar doesn't look +as nice as with the Windows graphics.) + +If you want music you need to copy the gm/ folder from Windows TTD into your +OpenTTD folder, not your data folder. -You can change the data path (which contains savegames as well) in Makefile.config by setting DATA_DIR_PREFIX and USE_HOMEDIR. +You can change the data path (which contains savegames as well) in Makefile.config +by setting DATA_DIR_PREFIX and USE_HOMEDIR. 5.0) OpenTTD features: diff --git a/spritecache.c b/spritecache.c index a325f0c9b..5cbcc8c6e 100644 --- a/spritecache.c +++ b/spritecache.c @@ -55,22 +55,31 @@ static byte *_spritecache_ptr; static uint32 _spritecache_size; static int _compact_cache_counter; - -static const char * const _filename_list[] = { - "TRG1R.GRF", - "TRGIR.GRF", - "signalsw.grf", //0x1320 - 0x1405 inclusive -// "openttd.grf", //0x1406 - - NULL +typedef struct FileList { + const char * const basic[4]; // grf files that always have to be loaded + const char * const landscape[3]; // landscape specific grf files +} FileList; + +FileList files_dos = { + { "TRG1.GRF", + "TRGI.GRF", + "signalsw.grf", //0x1320 - 0x1405 inclusive + NULL }, + { "TRGC.GRF", + "TRGH.GRF", + "TRGT.GRF" }, }; -static const char * const _landscape_filenames[] = { - "TRGCR.GRF", - "TRGHR.GRF", - "TRGTR.GRF" +FileList files_win = { + { "TRG1R.GRF", + "TRGIR.GRF", + "signalsw.grf", //0x1320 - 0x1405 inclusive + NULL }, + { "TRGCR.GRF", + "TRGHR.GRF", + "TRGTR.GRF" }, }; - #include "table/landscape_sprite.h" static const uint16 * const _landscape_spriteindexes[] = { @@ -267,16 +276,6 @@ static void SkipSprites(int count) } } -// Checks, if trg1r.grf is the Windows version -static bool CheckGrfFile() -{ - byte check; - FioSeekToFile(38); // Byte 38 has the value 0x21 in Windows version, 0x07 in DOS - check = FioReadWord(); - FioSeekToFile(0); - return (check==0x21); -} - static int LoadGrfFile(const char *filename, int load_index, int file_index) { int load_index_org = load_index; @@ -290,10 +289,6 @@ static int LoadGrfFile(const char *filename, int load_index, int file_index) DEBUG(spritecache, 2) ("Reading grf-file ``%s''", filename); - if(file_index==0 && !_ignore_wrong_grf) - if(!CheckGrfFile()) - error("Wrong version of grf files!\nThe Windows 95 edition of Transport Tycoon Deluxe is required to play OTTD!\n(you can disable this message by starting with the \"-i\" switch."); - while (LoadNextSprite(load_index, file_index)) { load_index++; if (load_index >= NUM_SPRITES) { @@ -307,7 +302,7 @@ static int LoadGrfFile(const char *filename, int load_index, int file_index) static int LoadNewGrfFile(const char *filename, int load_index, int file_index) { int i; - + FioOpenFile(file_index, filename); _cur_grffile = filename; _skip_specials = 0; @@ -763,9 +758,35 @@ static const uint16 _openttd_grf_indexes[] = { 0xffff, }; + +/* Checks, if either the Windows files exist (TRG1R.GRF) or the DOS files (TRG1.GRF). + * _use_dos_palette is set accordingly + * WARNING! This is case-sensitive, therefore the file has to be uppercase for correct + * detection. If neither are found, Windows palette is assumed. */ +static void CheckGrfFile() +{ + FILE *f; + byte *s; + + s = str_fmt("%s%s", _path.data_dir, files_win.basic[0]); + f = fopen(s, "r"); + if (f != NULL) { + _use_dos_palette = false; + return; + } + + s = str_fmt("%s%s", _path.data_dir, files_dos.basic[0]); + f = fopen(s, "r"); + if (f != NULL) { + _use_dos_palette = true; + return; + } +} + static void LoadSpriteTables() { int i,j; + FileList *files; // list of grf files to be loaded. Either Windows files or DOS files _loading_stage = 1; @@ -780,6 +801,11 @@ static void LoadSpriteTables() * invest that further. --octo */ + // Check if we have the DOS or Windows version of the GRF files + CheckGrfFile(); + + files = _use_dos_palette?(&files_dos):(&files_win); + // Try to load the sprites from cache if (!HandleCachedSpriteHeaders(_cached_filenames[_opt.landscape], true)) { // We do not have the sprites in cache yet, or cache is disabled @@ -787,14 +813,14 @@ static void LoadSpriteTables() int load_index = 0; - for(i=0; _filename_list[i] != NULL; i++) { - load_index += LoadGrfFile(_filename_list[i], load_index, (byte)i); + for(i=0; files->basic[i] != NULL; i++) { + load_index += LoadGrfFile(files->basic[i], load_index, (byte)i); } LoadGrfIndexed("openttd.grf", _openttd_grf_indexes, i++); if (_sprite_page_to_load != 0) - LoadGrfIndexed(_landscape_filenames[_sprite_page_to_load-1], _landscape_spriteindexes[_sprite_page_to_load-1], i++); + LoadGrfIndexed(files->landscape[_sprite_page_to_load-1], _landscape_spriteindexes[_sprite_page_to_load-1], i++); LoadGrfIndexed("trkfoundw.grf", _slopes_spriteindexes[_opt.landscape], i++); @@ -832,13 +858,13 @@ static void LoadSpriteTables() // // NOTE: the order of the files must be identical as in the section above!! - for(i = 0; _filename_list[i] != NULL; i++) - FioOpenFile(i,_filename_list[i]); + for(i = 0; files->basic[i] != NULL; i++) + FioOpenFile(i,files->basic[i]); FioOpenFile(i++, "openttd.grf"); if (_sprite_page_to_load != 0) - FioOpenFile(i++, _landscape_filenames[_sprite_page_to_load-1]); + FioOpenFile(i++, files->landscape[_sprite_page_to_load-1]); FioOpenFile(i++, "trkfoundw.grf"); FioOpenFile(i++, "canalsw.grf"); diff --git a/table/palettes.h b/table/palettes.h index efee5f401..cacca03e2 100644 --- a/table/palettes.h +++ b/table/palettes.h @@ -1,7 +1,7 @@ byte _palettes[4][256 * 3] = { -/* palette 1 */ +/* palette 1 (TTD Windows) */ { -0, 0, 0, 212, 0, 212, 212, 0, 212, 212, 0, 212, + 0, 0, 0, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 168, 168, 168, 184, 184, 184, 200, 200, 200, 216, 216, 216, 232, 232, 232, 252, 252, 252, @@ -65,18 +65,89 @@ byte _palettes[4][256 * 3] = { 252, 228, 0, 148, 148, 148, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, 252, 252, 252, -}}; +}, + +/* palette 2 (mixed TTD DOS + TTD Windows palette */ +{ + 0, 0, 0, 16, 16, 16, 32, 32, 32, 48, 48, 48, + 65, 64, 65, 82, 80, 82, 98, 101, 98, 115, 117, 115, +131, 133, 131, 148, 149, 148, 168, 168, 168, 184, 184, 184, +200, 200, 200, 216, 216, 216, 232, 232, 232, 252, 252, 252, + 52, 60, 72, 68, 76, 92, 88, 96, 112, 108, 116, 132, +132, 140, 152, 156, 160, 172, 176, 184, 196, 204, 208, 220, + 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, +120, 120, 64, 148, 148, 100, 176, 176, 132, 204, 204, 168, + 72, 44, 4, 88, 60, 20, 104, 80, 44, 124, 104, 72, +152, 132, 92, 184, 160, 120, 212, 188, 148, 244, 220, 176, + 64, 0, 4, 88, 4, 16, 112, 16, 32, 136, 32, 52, +160, 56, 76, 188, 84, 108, 204, 104, 124, 220, 132, 144, +236, 156, 164, 252, 188, 192, 252, 212, 0, 252, 232, 60, +252, 248, 128, 76, 40, 0, 96, 60, 8, 116, 88, 28, +136, 116, 56, 156, 136, 80, 176, 156, 108, 196, 180, 136, + 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, +184, 120, 24, 212, 156, 32, 232, 184, 16, 252, 212, 0, +252, 248, 128, 252, 252, 192, 32, 4, 0, 64, 20, 8, + 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, +168, 92, 76, 184, 108, 88, 196, 128, 108, 212, 148, 128, + 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, + 64, 112, 12, 84, 132, 20, 104, 148, 28, 128, 168, 44, + 28, 52, 24, 44, 68, 32, 60, 88, 48, 80, 104, 60, +104, 124, 76, 128, 148, 92, 152, 176, 108, 180, 204, 124, + 16, 52, 24, 32, 72, 44, 56, 96, 72, 76, 116, 88, + 96, 136, 108, 120, 164, 136, 152, 192, 168, 184, 220, 200, + 32, 24, 0, 56, 28, 0, 72, 40, 0, 88, 52, 12, +104, 64, 24, 124, 84, 44, 140, 108, 64, 160, 128, 88, + 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, +164, 96, 64, 184, 112, 80, 204, 128, 96, 212, 148, 112, +224, 168, 128, 236, 188, 148, 80, 28, 4, 100, 40, 20, +120, 56, 40, 140, 76, 64, 160, 100, 96, 184, 136, 136, + 36, 40, 68, 48, 52, 84, 64, 64, 100, 80, 80, 116, +100, 100, 136, 132, 132, 164, 172, 172, 192, 212, 212, 224, + 40, 20, 112, 64, 44, 144, 88, 64, 172, 104, 76, 196, +120, 88, 224, 140, 104, 252, 160, 136, 252, 188, 168, 252, + 0, 24, 108, 0, 36, 132, 0, 52, 160, 0, 72, 184, + 0, 96, 212, 24, 120, 220, 56, 144, 232, 88, 168, 240, +128, 196, 252, 188, 224, 252, 16, 64, 96, 24, 80, 108, + 40, 96, 120, 52, 112, 132, 80, 140, 160, 116, 172, 192, +156, 204, 220, 204, 240, 252, 172, 52, 52, 212, 52, 52, +252, 52, 52, 252, 100, 88, 252, 144, 124, 252, 184, 160, +252, 216, 200, 252, 244, 236, 72, 20, 112, 92, 44, 140, +112, 68, 168, 140, 100, 196, 168, 136, 224, 204, 180, 252, +204, 180, 252, 232, 208, 252, 60, 0, 0, 92, 0, 0, +128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, +252, 0, 0, 252, 80, 0, 252, 108, 0, 252, 136, 0, +252, 164, 0, 252, 192, 0, 252, 220, 0, 252, 252, 0, +204, 136, 8, 228, 144, 4, 252, 156, 0, 252, 176, 48, +252, 196, 100, 252, 216, 152, 8, 24, 88, 12, 36, 104, + 20, 52, 124, 28, 68, 140, 40, 92, 164, 56, 120, 188, + 72, 152, 216, 100, 172, 224, 92, 156, 52, 108, 176, 64, +124, 200, 76, 144, 224, 92, 224, 244, 252, 204, 240, 252, +180, 220, 236, 132, 188, 216, 88, 152, 172, 16, 16, 16, + 32, 32, 32, 8, 92, 104, 16, 100, 112, 24, 108, 120, + 32, 116, 128, 44, 124, 140, 92, 164, 184, 116, 180, 196, +148, 200, 216, 180, 220, 232, 216, 244, 252, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +252, 60, 0, 252, 80, 0, 252, 104, 0, 252, 128, 0, +252, 148, 0, 252, 172, 0, 252, 196, 0, 252, 0, 0, +252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +252, 228, 0, 148, 148, 148, 16, 101, 115, 24, 109, 123, + 32, 117, 131, 41, 125, 139, 90, 165, 189, 115, 182, 197, +148, 202, 222, 180, 222, 238, 222, 246, 255, 252, 252, 252, +} + + +}; #define GET_PALETTE(x) _palettes[x] typedef struct { - byte a[15]; - byte ac[15]; - byte lighthouse[12]; - byte oil_ref[21]; - byte e[15]; - byte b[45]; - byte bc[45]; + byte a[15]; // dark blue water + byte ac[15]; // dark blue water Toyland + byte lighthouse[12]; // lighthouse & stadium + byte oil_ref[21]; // oil refinery + byte e[15]; // ??? + byte b[45]; // glittery water + byte bc[45]; // glittery water Toyland } ExtraPaletteValues; static const ExtraPaletteValues _extra_palette_values = { @@ -313,7 +313,7 @@ static void showhelp() " -G seed = Set random seed\n" " -n [ip#player:port] = Start networkgame\n" " -D = Start dedicated server\n" - " -i = Ignore wrong grf\n" + " -i = Force to use the DOS palette (use this if you see a lot of pink)\n" " -p #player = Player as #player (deprecated) (network only)\n" ); @@ -525,7 +525,6 @@ int ttd_main(int argc, char* argv[]) char musicdriver[16], sounddriver[16], videodriver[16]; int resolution[2] = {0,0}; uint startdate = -1; - _ignore_wrong_grf = false; musicdriver[0] = sounddriver[0] = videodriver[0] = 0; _game_mode = GM_MENU; @@ -570,7 +569,7 @@ int ttd_main(int argc, char* argv[]) SetDebugString(mgo.opt); } break; case 'e': _switch_mode = SM_EDITOR; break; - case 'i': _ignore_wrong_grf = true; break; + case 'i': _use_dos_palette = true; break; case 'g': if (mgo.opt) { strcpy(_file_to_saveload.name, mgo.opt); diff --git a/variables.h b/variables.h index ab84a427c..9756d5047 100644 --- a/variables.h +++ b/variables.h @@ -415,8 +415,6 @@ VARDEF byte _vehicle_design_names; VARDEF SignStruct _sign_list[40]; VARDEF SignStruct *_new_sign_struct; -VARDEF bool _ignore_wrong_grf; - /* tunnelbridge */ #define MAX_BRIDGES 13 |