-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphe.c
137 lines (116 loc) · 3.47 KB
/
phe.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* wvWare
* Copyright (C) Caolan McNamara, Dom Lachowicz, and others
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include "wv.h"
void
wvGetPHE6 (PHE * dest, U8 * page, U16 * pos)
{
U8 temp8;
#ifdef PURIFY
wvInitPHE (dest, 0);
#endif
temp8 = bread_8ubit (&(page[*pos]), pos);
dest->var1.fSpare = temp8 & 0x01;
dest->var1.fUnk = (temp8 & 0x02) >> 1;
dest->var1.fDiffLines = (temp8 & 0x04) >> 2;
dest->var1.reserved1 = (temp8 & 0xf8) >> 3;
dest->var1.clMac = bread_8ubit (&(page[*pos]), pos);
dest->var1.dxaCol = (S16) bread_16ubit (&(page[*pos]), pos);
dest->var1.dymHeight = (S32) bread_16ubit (&(page[*pos]), pos);
}
void
wvGetPHE (PHE * dest, int which, U8 * page, U16 * pos)
{
U8 temp8;
U32 temp32;
#ifdef PURIFY
wvInitPHE (dest, which);
#endif
if (which)
{
temp32 = bread_32ubit (&(page[*pos]), pos);
dest->var2.fSpare = temp32 & 0x0001;
dest->var2.fUnk = (temp32 & 0x0002) >> 1;
dest->var2.dcpTtpNext = (temp32 & 0xfffffffc) >> 2;
dest->var2.dxaCol = (S32) bread_32ubit (&(page[*pos]), pos);
dest->var2.dymHeight = (S32) bread_32ubit (&(page[*pos]), pos);
}
else
{
temp8 = bread_8ubit (&(page[*pos]), pos);
dest->var1.fSpare = temp8 & 0x01;
dest->var1.fUnk = (temp8 & 0x02) >> 1;
dest->var1.fDiffLines = (temp8 & 0x04) >> 2;
dest->var1.reserved1 = (temp8 & 0xf8) >> 3;
dest->var1.clMac = bread_8ubit (&(page[*pos]), pos);
dest->var1.reserved2 = bread_16ubit (&(page[*pos]), pos);
dest->var1.dxaCol = (S32) bread_32ubit (&(page[*pos]), pos);
dest->var1.dymHeight = (S32) bread_32ubit (&(page[*pos]), pos);
}
}
void
wvCopyPHE (PHE * dest, PHE * src, int which)
{
if (which)
{
dest->var2.fSpare = src->var2.fSpare;
dest->var2.fUnk = src->var2.fUnk;
dest->var2.dcpTtpNext = src->var2.dcpTtpNext;
dest->var2.dxaCol = src->var2.dxaCol;
dest->var2.dymHeight = src->var2.dymHeight;
}
else
{
dest->var1.fSpare = src->var1.fSpare;
dest->var1.fUnk = src->var1.fUnk;
dest->var1.fDiffLines = src->var1.fDiffLines;
dest->var1.reserved1 = src->var1.reserved1;
dest->var1.clMac = src->var1.clMac;
dest->var1.reserved2 = src->var1.reserved2;
dest->var1.dxaCol = src->var1.dxaCol;
dest->var1.dymHeight = src->var1.dymHeight;
}
}
void
wvInitPHE (PHE * item, int which)
{
if (which)
{
item->var2.fSpare = 0;
item->var2.fUnk = 0;
item->var2.dcpTtpNext = 0;
item->var2.dxaCol = 0;
item->var2.dymHeight = 0;
}
else
{
item->var1.fSpare = 0;
item->var1.fUnk = 0;
item->var1.fDiffLines = 0;
item->var1.reserved1 = 0;
item->var1.clMac = 0;
item->var1.reserved2 = 0;
item->var1.dxaCol = 0;
item->var1.dymHeight = 0;
}
}