1 //**************************************************************************
2 //**
3 //**	##   ##    ##    ##   ##   ####     ####   ###     ###
4 //**	##   ##  ##  ##  ##   ##  ##  ##   ##  ##  ####   ####
5 //**	 ## ##  ##    ##  ## ##  ##    ## ##    ## ## ## ## ##
6 //**	 ## ##  ########  ## ##  ##    ## ##    ## ##  ###  ##
7 //**	  ###   ##    ##   ###    ##  ##   ##  ##  ##       ##
8 //**	   #    ##    ##    #      ####     ####   ##       ##
9 //**
10 //**	$Id: progs.h 4201 2010-04-03 14:20:46Z dj_jl $
11 //**
12 //**	Copyright (C) 1999-2006 Jānis Legzdiņš
13 //**
14 //**	This program is free software; you can redistribute it and/or
15 //**  modify it under the terms of the GNU General Public License
16 //**  as published by the Free Software Foundation; either version 2
17 //**  of the License, or (at your option) any later version.
18 //**
19 //**	This program is distributed in the hope that it will be useful,
20 //**  but WITHOUT ANY WARRANTY; without even the implied warranty of
21 //**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 //**  GNU General Public License for more details.
23 //**
24 //**************************************************************************
25 
26 // HEADER FILES ------------------------------------------------------------
27 
28 // MACROS ------------------------------------------------------------------
29 
30 // TYPES -------------------------------------------------------------------
31 
32 struct dprograms_t;
33 
34 union VStack
35 {
36 	vint32	i;
37 	float	f;
38 	void*	p;
39 };
40 
41 // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
42 
43 void PR_Init();
44 void PR_OnAbort();
45 
46 // PUBLIC DATA DECLARATIONS ------------------------------------------------
47 
48 extern VStack*			pr_stackPtr;
49 
50 //**************************************************************************
51 //
52 //	Stack routines
53 //
54 //**************************************************************************
55 
PR_Push(int value)56 inline void PR_Push(int value)
57 {
58 	pr_stackPtr->i = value;
59 	pr_stackPtr++;
60 }
61 
PR_Pop()62 inline int PR_Pop()
63 {
64 	--pr_stackPtr;
65 	return pr_stackPtr->i;
66 }
67 
PR_Pushf(float value)68 inline void PR_Pushf(float value)
69 {
70 	pr_stackPtr->f = value;
71 	pr_stackPtr++;
72 }
73 
PR_Popf()74 inline float PR_Popf()
75 {
76 	--pr_stackPtr;
77 	return pr_stackPtr->f;
78 }
79 
PR_Pushv(const TVec & v)80 inline void PR_Pushv(const TVec &v)
81 {
82 	PR_Pushf(v.x);
83 	PR_Pushf(v.y);
84 	PR_Pushf(v.z);
85 }
86 
PR_Pushav(const TAVec & v)87 inline void PR_Pushav(const TAVec &v)
88 {
89 	PR_Pushf(v.pitch);
90 	PR_Pushf(v.yaw);
91 	PR_Pushf(v.roll);
92 }
93 
PR_Popv()94 inline TVec PR_Popv()
95 {
96 	TVec v;
97 	v.z = PR_Popf();
98 	v.y = PR_Popf();
99 	v.x = PR_Popf();
100 	return v;
101 }
102 
PR_Popav()103 inline TAVec PR_Popav()
104 {
105 	TAVec v;
106 	v.roll = PR_Popf();
107 	v.yaw = PR_Popf();
108 	v.pitch = PR_Popf();
109 	return v;
110 }
111 
PR_PushName(VName value)112 inline void PR_PushName(VName value)
113 {
114 	pr_stackPtr->i = value.GetIndex();
115 	pr_stackPtr++;
116 }
117 
PR_PopName()118 inline VName PR_PopName()
119 {
120 	--pr_stackPtr;
121 	return *(VName*)&pr_stackPtr->i;
122 }
123 
PR_PushPtr(void * value)124 inline void PR_PushPtr(void* value)
125 {
126 	pr_stackPtr->p = value;
127 	pr_stackPtr++;
128 }
129 
PR_PopPtr()130 inline void* PR_PopPtr()
131 {
132 	--pr_stackPtr;
133 	return pr_stackPtr->p;
134 }
135 
136 void PR_PushStr(const VStr& value);
137 VStr PR_PopStr();
138 
139 VStr PF_FormatString();
140