1 /* wvWare
2  * Copyright (C) Caolan McNamara, Dom Lachowicz, and others
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
17  * 02111-1307, USA.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include "wv.h"
28 
29 void
wvGetSHD_internal(SHD * item,wvStream * fd,U8 * pointer)30 wvGetSHD_internal (SHD * item, wvStream * fd, U8 * pointer)
31 {
32     U16 temp16;
33 #ifdef PURIFY
34     wvInitSHD (item);
35 #endif
36     temp16 = dread_16ubit (fd, &pointer);
37     item->icoFore = temp16 & 0x001F;
38     item->icoBack = (temp16 & 0x03E0) >> 5;
39     item->ipat = (temp16 & 0xFC00) >> 10;
40 }
41 
42 void
wvGetSHD(SHD * item,wvStream * fd)43 wvGetSHD (SHD * item, wvStream * fd)
44 {
45     wvGetSHD_internal (item, fd, NULL);
46 }
47 
48 void
wvGetSHDFromBucket(SHD * item,U8 * pointer)49 wvGetSHDFromBucket (SHD * item, U8 * pointer)
50 {
51     wvGetSHD_internal (item, NULL, pointer);
52 }
53 
54 void
wvInitSHD(SHD * item)55 wvInitSHD (SHD * item)
56 {
57     item->icoFore = 0;
58     item->icoBack = 0;
59     item->ipat = 0;
60 }
61 
62 void
wvCopySHD(SHD * dest,SHD * src)63 wvCopySHD (SHD * dest, SHD * src)
64 {
65     memcpy (dest, src, sizeof (SHD));
66 }
67