Mercurial > hg > CbC > CbC_gcc
comparison CbC-examples/tmpa.c @ 78:365b84b6fe04
more examples
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 20 Sep 2011 17:32:20 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
77:65b2ea5f1266 | 78:365b84b6fe04 |
---|---|
1 #define __environment _CbC_environment | |
2 #define __return _CbC_return | |
3 | |
4 #include <stdio.h> | |
5 | |
6 struct enemy{ | |
7 int charno; // image number | |
8 float x; // x location | |
9 float y; // y location | |
10 int ap; // armor point | |
11 }; | |
12 void | |
13 print_param(struct enemy *e) | |
14 { | |
15 printf("#0014:charno:%d x,y:%f,%f hp:%d\n", | |
16 e->charno,e->x,e->y,e->ap); | |
17 } | |
18 | |
19 typedef struct{ | |
20 char dest; | |
21 int VF01[4]; | |
22 __code (*ret)(); | |
23 void *env; | |
24 } interface; | |
25 | |
26 __code a0(interface a) { | |
27 printf("#0026:%d\n",a.dest); | |
28 goto a.ret(0,a.env); | |
29 } | |
30 | |
31 | |
32 int main(int argc,char *argv[]) | |
33 { | |
34 struct enemy e; | |
35 #if 0 | |
36 interface args = {15,{0,0,0,0},return,environment}; | |
37 #else | |
38 interface args = {15,{0,0,0,0},0,0}; | |
39 args.ret = __return; | |
40 args.env = __environment; | |
41 #endif | |
42 | |
43 e.charno=5; e.x=50.0; e.y=30.0; e.ap=100; | |
44 print_param(&e); | |
45 | |
46 printf("#0045:%d %d\n",args.VF01[2],args.VF01[1]); | |
47 goto a0(args); | |
48 } | |
49 |