-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2dres.h
106 lines (88 loc) · 3.4 KB
/
2dres.h
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
/*
@Copyright Looking Glass Studios, Inc.
1996,1997,1998,1999,2000 Unpublished Work.
*/
/*
* $Header: r:/prj/lib/src/h/rcs/2dres.h 1.9 1995/02/06 12:21:04 buzzard Exp $
*
* Macros to use 2d calls with resources
*
* $Log: 2dres.h $
* Revision 1.9 1995/02/06 12:21:04 buzzard
* Moved data structures out to fdesc.h
*
* Revision 1.8 1995/01/25 18:11:51 jak
* And finally more casts on all the calls to ResGet.
*
* Revision 1.7 1995/01/25 17:48:04 jak
* Added casts to make C++ happy
*
* Revision 1.6 1994/07/06 18:38:48 jaemz
* Added fields to cylbm frame
*
* Revision 1.5 1994/06/15 11:51:49 jaemz
* Added cylindrical bitmap object data types
*
* Revision 1.4 1994/01/27 13:21:19 eric
* Added gr_cpy_pal_image to copy image pallette from
* REFerence to a pallette in memory.
*
* Revision 1.3 1993/09/28 01:12:21 kaboom
* Converted #include "xxx" to #include <xxx> for watcom.
*
* Revision 1.2 1993/08/24 20:04:52 rex
* Turned framedesc's updateArea into union of updateArea, anchorArea, anchorPt
*
* Revision 1.1 1993/04/27 12:06:52 rex
* Initial revision
*/
#ifndef _2DRES_H
#define _2DRES_H
// include 2d and special 2d-oriented
// resource types (e.g. FrameDesc)
#include <fdesc.h>
#include <res.h>
// These are the ref-based 2d macros. They have the goofy do/while(0)
// so that you may use them in an if statement without C whining.
// Draw a bitmap, given its ref (unclipped)
#define gr_ubitmap_ref(ref,x,y) do { \
FrameDesc *pfd = (FrameDesc*)RefGet(ref); \
pfd->bm.bits = (uchar *)(pfd + 1); \
gr_ubitmap(&pfd->bm, x, y); \
} while (0)
// Draw a bitmap, given its ref (clipped)
#define gr_bitmap_ref(ref,x,y) do { \
FrameDesc *pfd = (FrameDesc*)RefGet(ref); \
pfd->bm.bits = (uchar *)(pfd + 1); \
gr_bitmap(&pfd->bm, x, y); \
} while(0)
// Draw a scaled bitmap, given its ref (unclipped)
#define gr_scale_ubitmap_ref(ref,x,y,w,h) do { \
FrameDesc *pfd = (FrameDesc*)RefGet(ref); \
pfd->bm.bits = (uchar *)(pfd + 1); \
gr_scale_ubitmap(&pfd->bm, x, y, w, h); \
} while(0)
// Draw a scaled bitmap, given its ref (clipped)
#define gr_scale_bitmap_ref(ref,x,y,w,h) do { \
FrameDesc *pfd = (FrameDesc*)RefGet(ref); \
pfd->bm.bits = (uchar *)(pfd + 1); \
gr_scale_bitmap(&pfd->bm, x, y, w, h); \
} while(0)
// Set an image's associated (partial) palette, if any
#define gr_set_pal_imgref(ref) do { \
FrameDesc *pfd = (FrameDesc*)RefGet(ref); \
if (pfd->pallOff) { \
short *p = (short *)((uchar *) ResGet(REFID(ref)) + pfd->pallOff); \
gr_set_pal(*p, *(p+1), (uchar *)(p+2)); \
} \
} while(0)
// Copy an image's associated (partial) palette to memory
// (palp is a pointer to start of destination pallette)
#define gr_cpy_pal_imgref(ref, palp) do { \
FrameDesc *pfd = (FrameDesc*)RefGet(ref); \
if (pfd->pallOff) { \
short *p = (short *)((uchar *) ResGet(REFID(ref)) + pfd->pallOff); \
memcpy((uchar *)(palp + (*p * 3)), (uchar *)(p+2), *(p+1) * 3 ); \
} \
} while(0)
#endif