summaryrefslogtreecommitdiff
path: root/dviware/dvi2pcl/firstpar.c
blob: 2c2c79adf6e2d98aee839460d95b1487b0541d33 (plain)
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
/* $Log:	firstpar.c,v $
 * Revision 0.8  92/11/23  19:46:45  19:46:45  bt (Bo Thide')
 * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
 * 
 * Revision 0.7  92/11/13  02:41:29  02:41:29  bt (Bo Thide')
 * More bug fixes and improvements. Support for PaintJet XL
 * 
 * Revision 0.6  92/11/10  21:47:45  21:47:45  bt (Bo Thide')
 * Bug fixes. Added -R option. Better font handling.
 * 
 * Revision 0.5  92/11/09  16:25:32  16:25:32  bt (Bo Thide')
 * Rewrite of dospecial.c. Extended \special support
 * 
 * Revision 0.4  92/11/08  02:45:48  02:45:48  bt (Bo Thide')
 * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
 * 
 * Revision 0.3  92/08/24  12:45:40  12:45:40  bt (Bo Thide')
 * Fixed 8 bit (dc font) support.
 * 
 * Revision 0.2  92/08/23  17:28:57  17:28:57  bt (Bo Thide')
 * Source cleaned up.  Changed certain function calls.  Removed globals.
 * 
 * Revision 0.1  92/08/22  23:58:47  23:58:47  bt (Bo Thide')
 * First Release.
 *  */

#include <stdio.h>
#include "dvi.h"
#include "globals.h"
#include "macros.h"

static char rcsid[] = "$Header: firstpar.c,v 0.8 92/11/23 19:46:45 bt Exp $";

/*
 * This routine computes the first parameter of each dvi opcode.
 */
long firstpar(dvifile, k)
FILE	*dvifile;
int	k;
{
	switch (k)
	{ 
	case DVI_SET1:
	case DVI_PUT1:
	case DVI_FNT1:
	case DVI_XXX1:
	case DVI_FNT_DEF1:
		return((long)getubyte(dvifile));
		break;
	case DVI_SET2:
	case DVI_PUT2:
	case DVI_FNT2:
	case DVI_XXX2:
	case DVI_FNT_DEF2:
		return((long)getupair(dvifile));
		break;
	case DVI_SET3:
	case DVI_PUT3:
	case DVI_FNT3:
	case DVI_XXX3:
	case DVI_FNT_DEF3:
		return((long)getutrio(dvifile));
		break;
	case DVI_RIGHT1:
	case DVI_W1:
	case DVI_X1:
	case DVI_DOWN1:
	case DVI_Y1:
	case DVI_Z1:
		return((long)getsbyte(dvifile));
		break;
	case DVI_RIGHT2:
	case DVI_W2:
	case DVI_X2:
	case DVI_DOWN2:
	case DVI_Y2:
	case DVI_Z2:
		return((long)getspair(dvifile));
		break;
	case DVI_RIGHT3:
	case DVI_W3:
	case DVI_X3:
	case DVI_DOWN3:
	case DVI_Y3:
	case DVI_Z3:
		return((long)getstrio(dvifile));
		break;
	case DVI_SET4:
	case DVI_SET_RULE:
	case DVI_PUT4:
	case DVI_PUT_RULE:
	case DVI_RIGHT4:
	case DVI_W4:
	case DVI_X4:
	case DVI_DOWN4:
	case DVI_Y4:
	case DVI_Z4:
	case DVI_FNT4:
	case DVI_XXX4:
	case DVI_FNT_DEF4:
		return((long)getsquad(dvifile));
		break;
	case DVI_NOP:
	case DVI_BOP:
	case DVI_EOP:
	case DVI_PUSH:
	case DVI_POP:
	case DVI_PRE:
	case DVI_POST:
	case DVI_POSTPOST:
	case DVI_UNDEF0:
	case DVI_UNDEF1:
	case DVI_UNDEF2:
	case DVI_UNDEF3:
	case DVI_UNDEF4:
	case DVI_UNDEF5:
		return(0);
		break;
	case DVI_W0:
		return(w);
		break;
	case DVI_X0:
		return(x);
		break;
	case DVI_Y0:
		return(y);
		break;
	case DVI_Z0:
		return(z);
		break;
	default:
		if((k >= DVI_FNT_NUM_0) && (k <= DVI_FNT_NUM_63))
			return((long)(k - DVI_FNT_NUM_0));
		break;
	}
}