017f19f2b273a1990750c6f08620d84767eb6397
[jump.git] / minidol / esrc / Square.c
1 #include <stdio.h>
2 #include "Square.h"
3
4 #include "../shared.h"
5 extern shm_t shm;
6
7 void Square_delay(void)
8 {
9         for(volatile int a = 0; a < 25; a++)
10                 for(volatile int b = 0; b < 25; b++)
11                         ;
12 }
13
14 void Square_init(DOLProcess *p) {
15         ((Square_State*)p->local)->index = 0;
16 }
17
18 int Square_fire(DOLProcess *p) {
19         float i;
20
21         if (((Square_State*)p->local)->index < LENGTH) {
22                 DOL_read(PORT_INPUT, &i, sizeof(float), p);
23                 i = i*i;
24                 DOL_write(PORT_OUTPUT, &i, sizeof(float), p);
25                 ((Square_State*)p->local)->index++;
26         } else {
27                 DOL_detach(p);
28         }
29
30         return 0;
31 }