-
Notifications
You must be signed in to change notification settings - Fork 2
/
raster.c
125 lines (109 loc) · 2.86 KB
/
raster.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
#include <stddef.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <fcntl.h>
#include <conio.h>
#include <dos.h>
#include "config.h"
#include "debug.h"
#include "idatypes.h"
#include "lottypes.h"
#include "lotcalls.h"
#include "bundle.h"
#include "lmbcs.h"
#include "attr.h"
#include "caca.h"
#include "draw.h"
#include "raster.h"
static const char far *raster_op_name(unsigned op)
{
char far *raster_op_names[] = {
"Jump",
"Nop",
"SetLineColor",
"SetLinePattern",
"SetLineWidth",
"SetFillColor",
"SetFillPatten",
"undefined",
"SetTextSize",
"SetTextAlign",
"SetTextAngle",
"SetTextStyle",
"SetMarkerSize",
"SetMarkerSymbol",
"ClearRectangle",
"DrawSingleLine",
"DrawRectangleEdges",
"DrawRectangleInterior",
"DrawRactangle",
"DrawSliceEdges",
"DrawSliceInterior",
"DrawSlice",
"DrawArc",
"DrawPolyLine",
"DrawPolygonInterior",
"DrawPolygon",
"DrawText",
"DrawMarker",
};
if (op < RASTER_OP_NUMOPS) {
return raster_op_names[op];
}
return NULL;
}
int decode_raster_ops(char far *startaddr, char far *endaddr)
{
int opcnt;
int oplen;
char type;
char opcode;
char param;
char far *addr;
char far *rasterop;
trace("decode_raster_ops");
traceptr(startaddr);
traceptr(endaddr);
for (opcnt = 0, rasterop = startaddr; rasterop != endaddr; opcnt++) {
traceptr(rasterop);
tracebuf(rasterop, 16);
type = *rasterop++;
opcode = (char)((type & 0x7f) - 1);
param = *rasterop++;
addr = *(char far **) rasterop; // Only used for JMP?
oplen = 0;
traceint(type);
traceint(opcode);
traceint(param);
traceptr(addr);
logmsg("opcode %02x %s@", opcode, raster_op_name(opcode));
if (opcode == RASTER_OP_DRAWTEXT) {
struct DRAWTEXT *label = (void far *) rasterop;
traceptr(label);
traceval("%u", label->xpos);
traceval("%u", label->ypos);
traceint(label->len);
traceptr(label->str);
tracestrlen(label->str, label->len);
}
// This is a jmp to a far pointer.
if (param < 0 && opcode == RASTER_OP_JMP) {
traceptr(addr);
tracebuf(addr, 32);
rasterop = addr;
continue;
}
if (type < 0) {
// The top bit indicates the instruction is variable width.
oplen = param & 0x1f;
// If the 1-byte length is zero, then it's a 2-byte width.
if (oplen == 0) {
oplen = *(int *) rasterop;
}
rasterop += oplen;
}
}
return opcnt;
}