Debian Codegraph @

src/picload.c

raw symbols SCIP
1 /*
2 * OpenTyrian: A modern cross-platform port of Tyrian
3 * Copyright (C) 2007-2009 The OpenTyrian Development Team
4 *
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.
9 *
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.
14 *
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.
18 */
19 #include "picload.h"cxx . . $ `<file>/src/picload.h`/
20
21 #include "file.h"cxx . . $ `<file>/src/file.h`/
22 #include "opentyr.h"cxx . . $ `<file>/src/opentyr.h`/
23 #include "palette.h"cxx . . $ `<file>/src/palette.h`/
24 #include "pcxmast.h"cxx . . $ `<file>/src/pcxmast.h`/
25 #include "video.h"cxx . . $ `<file>/src/video.h`/
26
27 #include <string.h>
28 #include <stdlib.h>
29
30 void JE_loadPiccxx . . $ JE_loadPic(4846ed2ea5b0a844).(SDL_Surfacecxx . . $ SDL_Surface# *screen, JE_bytecxx . . $ JE_byte# PCXnumber, JE_booleancxx . . $ JE_boolean# storepal)
31 {
32 PCXnumber--;
33
34 FILEcxx . . $ FILE# *f = dir_fopen_diecxx . . $ dir_fopen_die(2493aa730c89ee72).(data_dircxx . . $ data_dir(33a1f659e94feb42).(), "tyrian.pic", "rb");
35
36 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! first = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
37 if (first)
38 {
39 first = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
40
41 Uint16cxx . . $ Uint16# temp;
42 fread_u16_diecxx . . $ fread_u16_die(c6228d4965a46ad0).(&temp, 1, f);
43
44 fread_s32_diecxx . . $ fread_s32_die(4b35c8e6f923dc9d).(pcxposcxx . . $ pcxpos., PCX_NUMcxx . . $ `src/pcxmast.h:24:9`!, f);
45 pcxposcxx . . $ pcxpos.[PCX_NUMcxx . . $ `src/pcxmast.h:24:9`!] = ftell_eofcxx . . $ ftell_eof(1dcafcd8ef4c6e6c).(f);
46 }
47
48 unsigned int size = pcxposcxx . . $ pcxpos.[PCXnumber + 1] - pcxposcxx . . $ pcxpos.[PCXnumber];
49 Uint8cxx . . $ Uint8# *buffer = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(size);
50
51 fseekcxx . . $ fseek(543fae30d249f6b1).(f, pcxposcxx . . $ pcxpos.[PCXnumber], SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!);
52 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(buffer, size, f);
53 fclosecxx . . $ fclose(89bc1efcdac0ca22).(f);
54
55 Uint8cxx . . $ Uint8# *p = buffer;
56 Uint8cxx . . $ Uint8# *s; /* screen pointer, 8-bit specific */
57
58 s = (Uint8cxx . . $ Uint8# *)screen->pixelscxx . . $ SDL_Surface#pixels.;
59
60 for (int i = 0; i < 320 * 200; )
61 {
62 if ((*p & 0xc0) == 0xc0)
63 {
64 i += (*p & 0x3f);
65 memsetcxx . . $ memset(d1de1e4fb215f1c6).(s, *(p + 1), (*p & 0x3f));
66 s += (*p & 0x3f); p += 2;
67 }
68 else
69 {
70 i++;
71 *s = *p;
72 s++; p++;
73 }
74 if (i && (i % 320 == 0))
75 {
76 s += screen->pitchcxx . . $ SDL_Surface#pitch. - 320;
77 }
78 }
79
80 freecxx . . $ free(5d22bdacc48458e8).(buffer);
81
82 memcpycxx . . $ memcpy(cc817cb175f282d).(colorscxx . . $ colors., palettescxx . . $ palettes.[pcxpalcxx . . $ pcxpal.[PCXnumber]], sizeof(colorscxx . . $ colors.));
83
84 if (storepal)
85 set_palettecxx . . $ set_palette(e7c4d2139a064c7f).(colorscxx . . $ colors., 0, 255);
86 }