view tmpa.c @ 2:35d6eabeadb0

modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Wed, 22 Oct 2014 02:06:29 +0900
parents bacef8675607
children 586096c45873
line wrap: on
line source

#ifdef GCC
#define __environment _CbC_environment
#define __return _CbC_return
#endif

#include <stdio.h>

struct enemy{
  int charno;                 // image number
  float x;                    // x location
  float y;                    // y location
  int ap;                     // armor point
};
void
print_param(struct enemy *e)
{
  printf("#0014:charno:%d   x,y:%f,%f   hp:%d\n",
         e->charno,e->x,e->y,e->ap);
}

typedef struct{
  char  dest;
  int VF01[4];
  __code (*ret)(int,void*);
  void *env;
} interface;

__code a0(interface a) {
  printf("#0026:%d\n",a.dest);
  goto a.ret(0,a.env);
}


int main(int argc,char *argv[])
{
  struct enemy e;
#if 0
  interface args = {15,{0,0,0,0},return,environment};
#else
  interface args = {15,{0,0,0,0},0,0};
  args.ret = __return;
  args.env = __environment;
#endif

  e.charno=5; e.x=50.0; e.y=30.0; e.ap=100;
  print_param(&e);

  printf("#0045:%d %d\n",args.VF01[2],args.VF01[1]);
  goto  a0(args);
}