2
* OpenTyrian: A modern cross-platform port of Tyrian
3
* Copyright (C) 2007-2009 The OpenTyrian Development Team
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
void JE_loadPic(SDL_Surface *screen, JE_byte PCXnumber, JE_boolean storepal )
32
FILE *f = dir_fopen_die(data_dir(), "tyrian.pic", "rb");
34
static bool first = true;
40
efread(&temp, sizeof(Uint16), 1, f);
41
for (int i = 0; i < PCX_NUM; i++)
43
efread(&pcxpos[i], sizeof(JE_longint), 1, f);
46
pcxpos[PCX_NUM] = ftell_eof(f);
49
unsigned int size = pcxpos[PCXnumber + 1] - pcxpos[PCXnumber];
50
Uint8 *buffer = malloc(size);
52
fseek(f, pcxpos[PCXnumber], SEEK_SET);
53
efread(buffer, sizeof(Uint8), size, f);
57
Uint8 *s; /* screen pointer, 8-bit specific */
59
s = (Uint8 *)screen->pixels;
61
for (int i = 0; i < 320 * 200; )
63
if ((*p & 0xc0) == 0xc0)
66
memset(s, *(p + 1), (*p & 0x3f));
67
s += (*p & 0x3f); p += 2;
73
if (i && (i % 320 == 0))
75
s += screen->pitch - 320;
81
memcpy(colors, palettes[pcxpal[PCXnumber]], sizeof(colors));
84
set_palette(colors, 0, 255);