comparison structs.h @ 0:76568becd6d6

Rhope Alpha 2a source import
author Mike Pavone <pavone@retrodev.com>
date Tue, 28 Apr 2009 23:06:07 +0000
parents
children 94c885692eb5
comparison
equal deleted inserted replaced
-1:000000000000 0:76568becd6d6
1 #ifndef _STRUCTS_H_
2 #define _STRUCTS_H_
3
4 #ifdef WIN32
5 #include <windows.h>
6 #endif
7
8 #ifndef BOOL
9 #define BOOL short
10 #define TRUE 1
11 #define FALSE 0
12 #endif
13
14 #ifndef DWORD
15 #define DWORD unsigned long
16 #endif
17
18 #ifndef WINAPI
19 #define WINAPI
20 #endif
21
22 #ifndef LPVOID
23 #define LPVOID void *
24 #endif
25 #ifndef NULL
26 #define NULL 0
27 #endif
28
29 //#include "interp.h"
30 #include "vis_threading.h"
31 #include "datum.h"
32 #define QUEUE_SIZE 512
33 #include <stdio.h>
34
35 #ifdef CPLUSPLUS
36 extern "C" {
37 #endif
38
39 typedef struct
40 {
41 int type;
42 int num_outputs;
43 int num_inputs;
44 char name[256];
45 int wire_up_lookup;
46 int wire_down_lookup;
47 void * value_index;//used to associate with a def
48 int io_num;
49 unsigned short magic_cache_type;
50 struct worker_def * magic_cache_implement;
51 VIS_CRITICAL_SECTION(lock)
52 BOOL null_input;
53 } worker;
54
55 typedef struct
56 {
57 int start_worker;
58 int end_worker;
59 int output_num;
60 int input_num;
61 } wire;
62
63
64 typedef struct
65 {
66 datum * value;
67 VIS_CRITICAL_SECTION(worker_lock)
68 int ready_count;
69 datum * params[32];
70 } worker_instance_data;
71
72
73 typedef struct
74 {
75 datum * data;
76 } wire_instance_data;
77
78 /*
79 Moved to datum.h for stupid reasons
80 typedef struct
81 {
82 char filename[512];
83 struct worker_def * deflist;
84 int num_defs;
85 int defs_storage;
86 struct company * companylist;
87 int num_companies;
88 int companies_storage;
89 } program;
90
91 */
92
93 /*typedef struct worker_def
94 {
95 worker_impl implement_func;
96 char name[256];
97 int num_outputs;
98 int num_inputs;
99 unsigned short input_types[32];
100 // unsigned short output_types[32];
101 // int parent_out_wires[32];
102 worker * workerlist;
103 int num_workers;
104 wire * wirelist;
105 int num_wires;
106 int * workers_to_wires_down;
107 int * workers_to_wires_up;
108 // struct worker_def * parent;
109 // int parent_attached_worker;
110 // int parent_attached_workerout;
111 // struct worker_def ** children;
112 // int num_children;
113 BOOL magic;
114 program program;
115 } worker_def;*/
116 /*
117 typedef struct worker_def_file
118 {
119 worker_impl implement_func;
120 char name[256];
121 int num_outputs;
122 int num_inputs;
123 unsigned short input_types[32];
124 // unsigned short output_types[32];
125 // int parent_out_wires[32];
126 worker * workerlist;
127 int num_workers;
128 wire * wirelist;
129 int num_wires;
130 int * workers_to_wires_down;
131 int * workers_to_wires_up;
132 // struct worker_def * parent;
133 // int parent_attached_worker;
134 // int parent_attached_workerout;
135 // struct worker_def ** children;
136 // int num_children;
137 BOOL magic;
138 } worker_def;*/
139
140 typedef struct
141 {
142 worker * workerlist;
143 int num_workers;
144 int worker_storage;
145 wire * wirelist;
146 int num_wires;
147 int wire_storage;
148 int * workers_to_wires_down;
149 int * workers_to_wires_up;
150 VIS_CRITICAL_SECTION(lock)
151 BOOL dirty;
152 } custom_worker;
153
154 #define TRANSACTION_WRITE 0x8000
155 #define TRANSACTION_TYPE_MASK 0xFF
156 #define TRANSACTION_RETRY 0
157 #define TRANSACTION_FORCE 1
158
159 typedef struct worker_def
160 {
161 custom_worker * implement_func; //points to either C function or "custom function struct"
162 char * name;
163 struct opt_entry * optimized;
164 int opt_count;
165 int num_stores;
166 char ** uses_stores;
167 unsigned short num_outputs;
168 unsigned short num_inputs;
169 unsigned short *input_types;
170 unsigned short *output_types;
171 unsigned short type; //Magic, Builtin, Custom
172 unsigned short transaction_flags;
173 #ifdef CPLUSPLUS
174 //ugly hack alert!
175 program * prog;
176 #else
177 program * program;
178 #endif
179 #ifdef USER_PROFILE
180 int count;
181 LARGE_INTEGER total;
182 LARGE_INTEGER worst;
183 VIS_CRITICAL_SECTION(lock)
184 #endif
185 } worker_def;
186
187 typedef struct defchunk
188 {
189 int num_defs;
190 int defs_storage;
191 struct defchunk * next;
192 worker_def deflist[1];
193 } defchunk;
194
195 typedef struct
196 {
197 datum * name;
198 datum * data;
199 //short inuse;
200 } global_store;
201
202 typedef struct
203 {
204 global_store * store;
205 datum * begin_data;
206 datum * instance_data;
207 VIS_CRITICAL_SECTION(lock)
208 } global_store_use;
209
210 typedef struct
211 {
212 int num_stores;
213 datum * params[32];
214 global_store_use stores[1];
215 } transaction;
216
217 typedef struct worker_instance
218 {
219 worker_def * def;
220 worker_instance_data * workerlist;
221 datum ** opt_results;
222 int num_workers;
223 wire_instance_data * wirelist;
224 int num_wires;
225 void (*callback)(struct worker_instance *, int, struct worker_instance *, void * data);
226 void * callback_data;
227 struct worker_instance * caller_instance;
228 int worker_in_caller;
229 int in_queue_count;
230 int in_progress_count;
231 int child_count;
232 transaction * trans;
233 #ifdef USER_PROFILE
234 LARGE_INTEGER start;
235 #endif // USER_PROFILE
236 VIS_CRITICAL_SECTION(counter_lock)
237 } worker_instance;
238
239 typedef void (*instance_callback)(worker_instance *, int, worker_instance *, void * data);
240
241 typedef struct
242 {
243 int worker_num;
244 worker_instance * instance;
245 } queue_entry;
246
247 typedef struct queue_section
248 {
249 queue_entry entries[QUEUE_SIZE];
250 struct queue_section * last;
251 struct queue_section * next;
252 } queue_section;
253
254 #define ROOM_NO_ACCESS 0
255 #define ROOM_BYTE 1
256 #define ROOM_SHORT 2
257 #define ROOM_LONG 3
258 #define ROOM_SINGLE 4
259 #define ROOM_DOUBLE 5
260 //The param must be set to the max string length for these
261 #define ROOM_CSTRING_STRUCT 6
262 #define ROOM_PSTRING_STRUCT 7
263 //Pointer types: For the following it's assumed that it's safe to free the current string
264 #define ROOM_CSTRING 8
265 #define ROOM_PSTRING 9
266 //Will copy the contents of a complex value to the destination offset, or the union contents otherwise
267 #define ROOM_VIS_OBJECT 10
268 //Pointer to datum
269 #define ROOM_VIS_REF 11
270 //Use a worker to set/get the room
271 #define ROOM_WORKER 12
272
273 #define PRIVATE_FLAG 0x8000
274 #define ROOM_TYPE_MASK 0xFF
275
276 typedef struct
277 {
278 char * name;
279 void * set_func;
280 void * get_func;
281 int param;
282 unsigned short set_func_type;
283 unsigned short get_func_type;
284 } company_room;
285
286 typedef struct company
287 {
288 char name[256];
289 worker_def ** methodlist;
290 int num_methods;
291 int method_storage;
292 company_room * room_list;
293 int num_rooms;
294 int room_storage;
295 int build_size;
296 unsigned short type_id;
297 VIS_CRITICAL_SECTION(lock)
298 } company;
299
300 typedef struct
301 {
302 int num_entries;
303 datum * entries[1];
304 } list_data;
305 /*
306 typedef struct ternary_node
307 {
308 struct ternary_node * left;
309 struct ternary_node * right;
310 struct ternary_node * next;
311 datum * payload;
312 char letter;
313 } ternary_node;
314 */
315
316 typedef struct ternary_node
317 {
318 int left;
319 int right;
320 int next;
321 datum * payload;
322 char letter;
323 } ternary_node;
324
325 typedef struct
326 {
327 int num_entries; //Number of entries currently in the dict
328 int num_nodes; //Number of ternary nodes in the dict
329 int node_storage; //Max number of nodes we can store in the dict
330 ternary_node nodes[1];
331 } dict_data;
332
333 typedef enum {FILE_NOSIZE, FILE_CLOSED, FILE_WRITE, FILE_READ, FILE_CANT_OPEN} file_status;
334 typedef struct
335 {
336 unsigned int size;
337 #ifndef SEGA
338 FILE * file;
339 #endif
340 VIS_CRITICAL_SECTION(lock)
341 int ref_count;
342 file_status status;
343 char name[1];
344 } shared_file;
345 typedef struct
346 {
347 unsigned int offset;
348 shared_file * shared;
349 } file_data;
350
351 typedef struct
352 {
353 datum * title;
354 double width;
355 double height;
356 datum * widget_dict;
357 datum * widget_xpos;
358 datum * widget_ypos;
359 datum * id_list;
360 } vis_window;
361
362 typedef struct
363 {
364 datum * label;
365 datum * value;
366 double width;
367 double height;
368 int flags;
369 datum * handler_dict;
370 int selected_index;
371 } vis_widget;
372
373 typedef struct
374 {
375 VIS_CRITICAL_SECTION(lock)
376 datum ** params;
377 BOOL done_flag;
378 } def_done;
379
380 typedef struct opt_entry
381 {
382 worker_def * def;
383 int original_pos;
384 int * input_data;
385 int null_inputs;
386 int branch1;
387 int branch2;
388 int * output_refs;
389 } opt_entry;
390
391 typedef struct
392 {
393 worker_def * def;
394 datum * params[32];
395 } worker_datum;
396 #define MIN_STACK_SIZE 512 //minimum stack size in longwords
397 typedef struct stack_segment
398 {
399 int size;
400 struct stack_segment *parent;
401 struct stack_segment *child;
402 unsigned long current_stack;//only used when stack is in the queue
403 unsigned int data[MIN_STACK_SIZE];
404 } stack_segment;
405
406 #define QUEUE_FUNC 0
407 #define QUEUE_BUILTIN 1
408 #define QUEUE_BLOCK 2
409 #define QUEUE_BLOCK_WAIT 3
410
411 typedef struct
412 {
413 unsigned long * address;
414 void * params;
415 stack_segment * stack;
416 char type;
417 } virt_queue_entry;
418
419 typedef struct virt_queue_segment
420 {
421 struct virt_queue_segment * next;
422 struct virt_queue_segment * last;
423 virt_queue_entry entries[QUEUE_SIZE];
424 } virt_queue_segment;
425
426 typedef int (*worker_impl)(datum **, queue_entry *);
427
428 //extern worker_def deflist[100];
429 //extern int num_defs;
430
431 //extern datum data[4096];
432 //extern int num_datum;
433
434 extern wire wirelist[2048];
435 extern int num_wires;
436
437 extern worker workerlist[1024];
438 extern int num_workers;
439
440 extern int workers_to_wires_down[2048];
441 extern int workers_to_wires_up[2048];
442
443 #ifdef CPLUSPLUS
444 }
445 #endif
446
447
448 #endif //_STRUCTS_H_
449
450
451
452
453
454
455
456
457