1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 /*
20  * $Source: n:/project/lib/src/2d/RCS/chain.h $
21  * $Revision: 1.8 $
22  * $Author: baf $
23  * $Date: 1993/12/08 19:14:57 $
24  *
25  * Prototypes and macros for function chaining.
26  *
27  * This file is part of the 2D library.
28  *
29  * $Log: chain.h $
30  * Revision 1.8  1993/12/08  19:14:57  baf
31  * Fixed bug in gr_toggle_generic
32  *
33  * Revision 1.7  1993/12/07  11:46:34  baf
34  * Renamed gr_chain_add
35  *
36  * Revision 1.6  1993/12/02  13:44:45  baf
37  * Added the ability to unchain and rechain.
38  *
39  * Revision 1.5  1993/11/30  20:47:24  baf
40  * Chainged generic mode stuff so it can
41  * be done at any time.
42  *
43  * Revision 1.4  1993/11/30  19:31:22  baf
44  * Added more macros for manipulating
45  * chaining and generic mode
46  *
47  * Revision 1.3  1993/11/16  23:06:58  baf
48  * Added the ability to chain void functions
49  * after the primitive.
50  *
51  * Revision 1.2  1993/11/15  03:28:49  baf
52  * Added gr_chain_add_void, as well as
53  * support for forcing generic mode and
54  * turning chaining off.
55  *
56  * Revision 1.1  1993/11/12  09:30:18  baf
57  * Initial revision
58  *
59  */
60 
61 #ifndef __CHAIN
62 #define __CHAIN
63 
64 #include "grs.h"
65 #include "icanvas.h"
66 
67 
68 typedef struct iaaiiaia{
69    void (*f)();
70    struct iaaiiaia *next;
71    uchar flags;
72 } grs_func_chain;
73 
74 extern short grd_pixel_index;
75 extern short grd_canvas_index;
76 
77 extern uchar chn_flags;
78 #define CHN_ON 1
79 #define CHN_GEN 2
80 
81 extern grs_func_chain *gr_chain_add_over(int n, void (*f)());
82 extern grs_func_chain *gr_chain_add_before(int n, void (*f)(void));
83 extern grs_func_chain *gr_chain_add_after(int n, void (*f)(void));
84 extern void (*chain_rest())();
85 
86 extern void gr_unchain(int n);
87 extern void gr_rechain(int n);
88 extern void gr_unchain_all();
89 extern void gr_rechain_all();
90 
91 #define gr_do_chain (chain_rest())
92 #define gr_chaining_on() (chn_flags |= CHN_ON)
93 #define gr_chaining_off() (chn_flags &= ~CHN_ON)
94 #define gr_chaining_toggle() (chn_flags ^= CHN_ON)
95 
96 #define gr_generic (chn_flags & CHN_GEN)
97 extern void gr_force_generic();
98 extern void gr_unforce_generic();
99 #define gr_toggle_generic() (gr_generic? gr_unforce_generic() : gr_force_generic())
100 
101 #define gr_start_frame ((void (*)())grd_canvas_table[START_FRAME])
102 #define gr_end_frame ((void (*)())grd_canvas_table[END_FRAME])
103 
104 #endif
105