Debian Codegraph @

port/sdl/hamfake.h

raw symbols SCIP
1 /*
2 * PROPRIETARY INFORMATION. This software is proprietary to POWDER
3 * Development, and is not to be reproduced, transmitted, or disclosed
4 * in any way without written permission.
5 *
6 * Produced by: Jeff Lait
7 *
8 * POWDER Development
9 *
10 * NAME: hamfake.h ( POWDER Library, C++ )
11 *
12 * COMMENTS:
13 */
14
15 #ifndef __hamfake__
16 #define __hamfake__
17
18 // These are the native res of the SDL screen.
19 // measured in tiles.
20 #ifdef USE_EXTENDED_HEIGHT
21 #define HAM_SCRW_T 32
22 #define HAM_SCRH_T 26
23 #else
24 #define HAM_SCRW_T 32
25 #define HAM_SCRH_T 24
26 #endif
27
28 //
29 // External Hooks
30 // These are HAMish functions that don't exist in the HAM library, as
31 // they are unneeded or non-existant on the GBA. They have blank
32 // functions if USING_SDL is not defined.
33 //
34 void hamfake_rebuildScreen();
35 void hamfake_awaitEvent();
36
37 u16 *hamfake_lockScreen();
38 void hamfake_unlockScreen(u16 *screen);
39
40 #ifdef USE_VIRTUAL_SCREEN
41
42 class SCREENDATA_REF;
43
44 class SCREENDATA
45 {
46 public:
47 SCREENDATA(u8 *data, int w, int h, int i);
48 SCREENDATA();
49 virtual ~SCREENDATA();
50 SCREENDATA(const SCREENDATA &data);
51 SCREENDATA &operator=(const SCREENDATA &data);
52
53 int width() const { return myWidth; }
54 int height() const { return myHeight; }
55
56 const u8 *data();
57 int id() const { return myId; }
58
59 protected:
60 SCREENDATA_REF *myRef;
61 int myWidth, myHeight;
62 int myId;
63 };
64
65 class INPUTDATA
66 {
67 public:
68 int myX, myY;
69 int myMaxLen;
70 char myText[256];
71 };
72
73 extern INPUTDATA glbInputData;
74
75 class EMAILDATA
76 {
77 public:
78 const char *myTo;
79 const char *mySubject;
80 const char *myBody;
81 };
82
83 extern EMAILDATA glbEmailData;
84 extern volatile bool glbCanSendEmail;
85
86 bool hamfake_isunlocked();
87 void hamfake_setunlocked(bool lockstate);
88 // The ability to unlock may be disabled.
89 bool hamfake_allowunlocks();
90 void hamfake_setallowunlocks(bool state);
91
92 bool hamfake_cansendemail();
93 void hamfake_sendemail(const char *to, const char *subject, const char *body);
94
95 void hamfake_getActualScreen(SCREENDATA &screen);
96 void hamfake_callThisFromVBL();
97 void hamfake_setstyluspos(bool state, int x, int y);
98 void hamfake_setdatapath(const char *path);
99
100 void hamfake_postaction(int action, int spell);
101
102 void hamfake_postdir(int dx, int dy);
103 void hamfake_flushdir();
104 bool hamfake_externaldir(int &dx, int &dy);
105 void hamfake_postorientation(bool isportrait);
106 void hamfake_revertdefault();
107 void hamfake_postshake(bool isshook);
108 // This is a latch, so reading resets.
109 bool hamfake_hasbeenshaken();
110 #endif
111 // REturns false if none pending.
112 bool hamfake_getbuttonreq(int &mode, int &type);
113
114 void hamfake_externalaction(int &action, int &spell);
115 void hamfake_enableexternalactions(bool allow);
116 bool hamfake_externalactionsenabled();
117 void hamfake_setinventorymode(bool inventory);
118 bool hamfake_isinventorymode();
119
120 // Moves files
121 void hamfake_move(const char *dst, const char *src);
122
123 char *hamfake_writeLockSRAM();
124 void hamfake_writeUnlockSRAM(char *);
125 char *hamfake_readLockSRAM();
126 void hamfake_readUnlockSRAM(char *);
127
128 // Flags that we are done writing to the SRAM. Allows us to only
129 // write to disk once.
130 void hamfake_endWritingSession();
131
132 void hamfake_softReset();
133 void hamfake_awaitResurrect();
134 void hamfake_postResurrect();
135
136 void hamfake_setFullScreen(bool fullscreen);
137 bool hamfake_isFullScreen();
138
139
140 //
141 // Type clones.
142 //
143 struct tile_info
144 {
145 // Private to hamfake:
146 int numtiles;
147
148 u8 **tiles;
149 u16 **tiles16;
150 };
151
152 typedef tile_info *tile_info_ptr;
153
154 struct map_info
155 {
156 // Private to hamfake
157 int width, height;
158 int *tiles;
159
160 };
161
162 typedef map_info *map_info_ptr;
163
164 struct bg_info
165 {
166 map_info_ptr mi;
167 tile_info_ptr ti;
168
169 int scrollx, scrolly;
170 };
171
172 extern bg_info ham_bg[];
173
174 #ifndef HAS_KEYBOARD
175
176 //
177 // Raw data accessors.
178 //
179
180 enum FAKE_BUTTONS
181 {
182 FAKE_BUTTON_UP,
183 FAKE_BUTTON_DOWN,
184 FAKE_BUTTON_LEFT,
185 FAKE_BUTTON_RIGHT,
186 FAKE_BUTTON_A,
187 FAKE_BUTTON_B,
188 FAKE_BUTTON_START,
189 FAKE_BUTTON_SELECT,
190 FAKE_BUTTON_R,
191 FAKE_BUTTON_L,
192 FAKE_BUTTON_X,
193 FAKE_BUTTON_Y,
194 FAKE_BUTTON_TOUCH,
195 FAKE_BUTTON_LID,
196 NUM_FAKE_BUTTONS
197 };
198
199 bool hamfake_isFakeButtonPressed(FAKE_BUTTONS button);
200 void hamfake_setFakeButtonState(FAKE_BUTTONS button, bool state);
201 int hamfake_isAnyPressed(); // Note bizarre return semantics!
202
203 void hamfake_setForceQuit();
204 void hamfake_clearForceQuit();
205
206 // These data accessors are left for historical reasons. We now
207 // never use our built in key matching tech.
208
209 #define F_CTRLINPUT_UP_PRESSED \
210 hamfake_isFakeButtonPressed(FAKE_BUTTON_UP)
211 #define F_CTRLINPUT_DOWN_PRESSED \
212 hamfake_isFakeButtonPressed(FAKE_BUTTON_DOWN)
213 #define F_CTRLINPUT_LEFT_PRESSED \
214 hamfake_isFakeButtonPressed(FAKE_BUTTON_LEFT)
215 #define F_CTRLINPUT_RIGHT_PRESSED \
216 hamfake_isFakeButtonPressed(FAKE_BUTTON_RIGHT)
217
218 #define F_CTRLINPUT_A_PRESSED \
219 hamfake_isFakeButtonPressed(FAKE_BUTTON_A)
220 #define F_CTRLINPUT_B_PRESSED \
221 hamfake_isFakeButtonPressed(FAKE_BUTTON_B)
222 #define F_CTRLINPUT_R_PRESSED \
223 hamfake_isFakeButtonPressed(FAKE_BUTTON_R)
224 #define F_CTRLINPUT_L_PRESSED \
225 hamfake_isFakeButtonPressed(FAKE_BUTTON_L)
226
227 #define F_CTRLINPUT_SELECT_PRESSED \
228 hamfake_isFakeButtonPressed(FAKE_BUTTON_SELECT)
229 #define F_CTRLINPUT_START_PRESSED \
230 hamfake_isFakeButtonPressed(FAKE_BUTTON_START)
231
232 #define R_CTRLINPUT \
233 hamfake_isAnyPressed()
234
235 #endif
236
237 // Gets a new keypress. Returns 0 if no keypress is ready.
238 // Clears key after getting it.
239 int hamfake_peekKeyPress();
240 int hamfake_getKeyPress(bool onlyascii);
241 void hamfake_clearKeyboardBuffer();
242 void hamfake_insertKeyPress(int key);
243
244 // Returns the union of all active modifiers.
245 int hamfake_getModifiers();
246
247 void hamfake_setScrollX(int layer, int scroll);
248 void hamfake_setScrollY(int layer, int scroll);
249
250 #define M_BG0SCRLX_SET(xoff) \
251 hamfake_setScrollX(0, xoff);
252 #define M_BG0SCRLY_SET(yoff) \
253 hamfake_setScrollY(0, yoff);
254 #define M_BG1SCRLX_SET(xoff) \
255 hamfake_setScrollX(1, xoff);
256 #define M_BG1SCRLY_SET(yoff) \
257 hamfake_setScrollY(1, yoff);
258 #define M_BG2SCRLX_SET(xoff) \
259 hamfake_setScrollX(2, xoff);
260 #define M_BG2SCRLY_SET(yoff) \
261 hamfake_setScrollY(2, yoff);
262 #define M_BG3SCRLX_SET(xoff) \
263 hamfake_setScrollX(3, xoff);
264 #define M_BG3SCRLY_SET(yoff) \
265 hamfake_setScrollY(3, yoff);
266
267 //
268 // Cloned Ham functions
269 //
270
271 void ham_Init();
272 void ham_StartIntHandler(u8 intno, void (*fp)());
273 void ham_SetBgMode(u8 mode);
274 void ham_LoadBGPal(void *vpal, int bytes);
275 map_info_ptr ham_InitMapEmptySet(u8 size, u8 );
276 tile_info_ptr ham_InitTileEmptySet(int entries, int , int);
277 void ham_InitBg(int layer, int foo, int bar, int baz);
278 void ham_CreateWin(int wid, int, int, int, int, int, int, int);
279 void ham_DeleteWin(int wid);
280 void ham_SetMapTile(int layer, int mx, int my, int tileidx);
281 void ham_ReloadTileGfx(tile_info_ptr tiledata, const u16 *data, int destidx,
282 int numtile);
283
284 #endif
285