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 "wv.h"
27
28 void
wvGetPHE6(PHE * dest,U8 * page,U16 * pos)29 wvGetPHE6 (PHE * dest, U8 * page, U16 * pos)
30 {
31 U8 temp8;
32
33 #ifdef PURIFY
34 wvInitPHE (dest, 0);
35 #endif
36
37 temp8 = bread_8ubit (&(page[*pos]), pos);
38 dest->var1.fSpare = temp8 & 0x01;
39 dest->var1.fUnk = (temp8 & 0x02) >> 1;
40
41 dest->var1.fDiffLines = (temp8 & 0x04) >> 2;
42 dest->var1.reserved1 = (temp8 & 0xf8) >> 3;
43
44 dest->var1.clMac = bread_8ubit (&(page[*pos]), pos);
45
46 dest->var1.dxaCol = (S16) bread_16ubit (&(page[*pos]), pos);
47 dest->var1.dymHeight = (S32) bread_16ubit (&(page[*pos]), pos);
48 }
49
50 void
wvGetPHE(PHE * dest,int which,U8 * page,U16 * pos)51 wvGetPHE (PHE * dest, int which, U8 * page, U16 * pos)
52 {
53 U8 temp8;
54 U32 temp32;
55
56 #ifdef PURIFY
57 wvInitPHE (dest, which);
58 #endif
59
60 if (which)
61 {
62 temp32 = bread_32ubit (&(page[*pos]), pos);
63 dest->var2.fSpare = temp32 & 0x0001;
64 dest->var2.fUnk = (temp32 & 0x0002) >> 1;
65 dest->var2.dcpTtpNext = (temp32 & 0xfffffffc) >> 2;
66 dest->var2.dxaCol = (S32) bread_32ubit (&(page[*pos]), pos);
67 dest->var2.dymHeight = (S32) bread_32ubit (&(page[*pos]), pos);
68 }
69 else
70 {
71 temp8 = bread_8ubit (&(page[*pos]), pos);
72 dest->var1.fSpare = temp8 & 0x01;
73 dest->var1.fUnk = (temp8 & 0x02) >> 1;
74
75 dest->var1.fDiffLines = (temp8 & 0x04) >> 2;
76 dest->var1.reserved1 = (temp8 & 0xf8) >> 3;
77
78 dest->var1.clMac = bread_8ubit (&(page[*pos]), pos);
79
80 dest->var1.reserved2 = bread_16ubit (&(page[*pos]), pos);
81
82 dest->var1.dxaCol = (S32) bread_32ubit (&(page[*pos]), pos);
83 dest->var1.dymHeight = (S32) bread_32ubit (&(page[*pos]), pos);
84 }
85 }
86
87 void
wvCopyPHE(PHE * dest,PHE * src,int which)88 wvCopyPHE (PHE * dest, PHE * src, int which)
89 {
90 if (which)
91 {
92 dest->var2.fSpare = src->var2.fSpare;
93 dest->var2.fUnk = src->var2.fUnk;
94 dest->var2.dcpTtpNext = src->var2.dcpTtpNext;
95 dest->var2.dxaCol = src->var2.dxaCol;
96 dest->var2.dymHeight = src->var2.dymHeight;
97 }
98 else
99 {
100 dest->var1.fSpare = src->var1.fSpare;
101 dest->var1.fUnk = src->var1.fUnk;
102
103 dest->var1.fDiffLines = src->var1.fDiffLines;
104 dest->var1.reserved1 = src->var1.reserved1;
105 dest->var1.clMac = src->var1.clMac;
106 dest->var1.reserved2 = src->var1.reserved2;
107
108 dest->var1.dxaCol = src->var1.dxaCol;
109 dest->var1.dymHeight = src->var1.dymHeight;
110 }
111 }
112
113 void
wvInitPHE(PHE * item,int which)114 wvInitPHE (PHE * item, int which)
115 {
116 if (which)
117 {
118 item->var2.fSpare = 0;
119 item->var2.fUnk = 0;
120 item->var2.dcpTtpNext = 0;
121 item->var2.dxaCol = 0;
122 item->var2.dymHeight = 0;
123 }
124 else
125 {
126 item->var1.fSpare = 0;
127 item->var1.fUnk = 0;
128
129 item->var1.fDiffLines = 0;
130 item->var1.reserved1 = 0;
131 item->var1.clMac = 0;
132 item->var1.reserved2 = 0;
133
134 item->var1.dxaCol = 0;
135 item->var1.dymHeight = 0;
136 }
137 }
138