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 <stdio.h>
25 #include <stdlib.h>
26 #include <ctype.h>
27 #include <string.h>
28 #include <errno.h>
29 #include "wv.h"
30 
31 U32
twvGetFOPTE(FOPTE * afopte,wvStream * infd)32 twvGetFOPTE (FOPTE * afopte, wvStream * infd)
33 {
34     U32 ret = 0;
35     U16 dtemp;
36     dtemp = read_16ubit (infd);
37 #ifdef PURIFY
38     afopte->pid = 0;
39     afopte->fBid = 0;
40     afopte->fComplex = 0;
41 #endif
42     afopte->pid = (dtemp & 0x3fff);
43     afopte->fBid = ((dtemp & 0x4000) >> 14);
44     afopte->fComplex = ((dtemp & 0x8000) >> 15);
45     afopte->op = read_32ubit (infd);
46 
47     if (afopte->fComplex)
48       {
49 	  wvTrace (("1 complex len is %d (%x)\n", afopte->op, afopte->op));
50 	  ret = afopte->op;
51       }
52 #if 0
53     else if (afopte->fBid)
54 	wvTrace (
55 		 ("great including graphic number %d %d\n", afopte->op,
56 		  afopte->op));
57 #endif
58     wvTrace (
59 	     ("orig %x,pid is %x, val is %x\n", dtemp, afopte->pid,
60 	      afopte->op));
61     return (ret);
62 }
63 
64 fbse_list *
wvGetSPID(U32 spid,fsp_list * afsp_list,fbse_list * afbse_list)65 wvGetSPID (U32 spid, fsp_list * afsp_list, fbse_list * afbse_list)
66 {
67     fopte_list *temp;
68     U32 i;
69 
70     while (afsp_list != NULL)
71       {
72 	  if (afsp_list->afsp.spid == spid)
73 	    {
74 		wvTrace (("found the correct spid\n"));
75 		temp = afsp_list->afopte_list;
76 		while (temp != NULL)
77 		  {
78 		      if ((temp->afopte.fBid) && (!(temp->afopte.fComplex)))
79 			{
80 			    wvTrace (
81 				     ("found a graphic to go with the spid, no %d\n",
82 				      temp->afopte.op));
83 			    for (i = 1; i < temp->afopte.op; i++)
84 				afbse_list = afbse_list->next;
85 			    return (afbse_list);
86 			    break;
87 			}
88 		      temp = temp->next;
89 		  }
90 		break;
91 	    }
92 	  afsp_list = afsp_list->next;
93       }
94 
95     return (NULL);
96 }
97 
98 
99 U32
wvGetSPIDfromCP(U32 cp,textportions * portions)100 wvGetSPIDfromCP (U32 cp, textportions * portions)
101 {
102     U32 i;
103     for (i = 0; i < portions->noofficedraw; i++)
104 	if (cp == portions->officedrawcps[i])
105 	    return (portions->fspas[i].spid);
106     return (0xffffffffL);
107 }
108 
109 void
wvGetBITMAP(BITMAP * bmp,wvStream * infd)110 wvGetBITMAP (BITMAP * bmp, wvStream * infd)
111 {
112     int i;
113     for (i = 0; i < 14; i++)
114 	bmp->bm[i] = read_8ubit (infd);
115 }
116 
117 void
wvGetrc(rc * arc,wvStream * infd)118 wvGetrc (rc * arc, wvStream * infd)
119 {
120     int i;
121     for (i = 0; i < 14; i++)
122 	arc->bm[i] = read_8ubit (infd);
123 }
124 
125 
126 U32
twvGetFBSE(FBSE * afbse,wvStream * infd)127 twvGetFBSE (FBSE * afbse, wvStream * infd)
128 {
129     int i;
130     afbse->btWin32 = read_8ubit (infd);
131     afbse->btMacOS = read_8ubit (infd);
132     for (i = 0; i < 16; i++)
133 	afbse->rgbUid[i] = read_8ubit (infd);
134     afbse->tag = read_16ubit (infd);
135     afbse->size = read_32ubit (infd);
136     afbse->cRef = read_32ubit (infd);
137     afbse->foDelay = read_32ubit (infd);
138     afbse->usage = read_8ubit (infd);
139     afbse->cbName = read_8ubit (infd);
140     afbse->unused2 = read_8ubit (infd);
141     afbse->unused3 = read_8ubit (infd);
142     return (36);
143 }
144