annotate test/putenemy.c @ 751:c921670e2ce8

i64 continue... 64bit register
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 14 Nov 2010 04:56:02 +0900
parents c2c709727221
children c55337499f96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
1 #include <math.h>
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
2
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
3 // for rand
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
4 #include <stdlib.h>
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
5
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
6 extern int printf(char *,...);
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
7 #define SANKAKU 100000
673
442e90958386 PS3 PPc almot done...
kono
parents: 558
diff changeset
8 #ifndef M_PI
442e90958386 PS3 PPc almot done...
kono
parents: 558
diff changeset
9 #define M_PI 3.1415962
442e90958386 PS3 PPc almot done...
kono
parents: 558
diff changeset
10 #endif
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
11
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
12 static const double pi2 = M_PI * 2.0;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
13
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
14 int mysin[181];
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
15 int mycos[181];
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
16
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
17 void sankakuf()
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
18 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
19 int i;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
20 for(i=0;i<181;i++)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
21 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
22 mysin[i]=sin(i /360.0*pi2)*SANKAKU;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
23 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
24 for(i=0;i<181;i++)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
25 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
26 mycos[i]=cos(i /360.0*pi2)*SANKAKU;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
27 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
28 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
29
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
30 int Mycos0(int c)
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
31 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
32 c%=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
33 if(c<0) c+=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
34 if((c<=180))
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
35 return(mycos[c]);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
36 if(c>180)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
37 return(mycos[180-(c-180)]);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
38 return(0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
39 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
40
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
41 int Mycos(int c) {
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 674
diff changeset
42 printf("#0041:Mycos %d=%d\n",c,Mycos0(c));
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
43 return Mycos0(c);
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
44 }
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
45
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
46 int Mysin0(int c)
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
47 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
48 c%=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
49 if(c<0) c+=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
50 if(c<=180)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
51 return(mysin[c]);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
52 if(c>180)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
53 return(mysin[180-(c-180)]*-1);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
54 return(0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
55 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
56
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
57 int Mysin(int c) {
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 674
diff changeset
58 printf("#0057:Mysin %d=%d\n",c,Mysin0(c));
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
59 return Mysin0(c);
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
60 }
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
61
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
62 void
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
63 Putenemy(int charno,float x,float y,float sx,float sy,int move) {
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
64 if(x)
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 674
diff changeset
65 printf("#0064:%d %f %f %f %f %d\n",charno,x,y,sx,sy,move);
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
66 else
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 674
diff changeset
67 printf("#0066:check\n");
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
68 }
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
69 int
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
70 main()
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
71 {
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
72 int ix=32,iy=32; float fx=32,fy=32;
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
73 srand(55555);
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
74 sankakuf();
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 674
diff changeset
75 printf("#0074:%d %d\n", Mysin(45),Mycos(-30));
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
76 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
77 float x=10,y=20;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
78 Putenemy(3,x,y,(float) Mysin(15)*2/SANKAKU,(float)Mycos(15)*2/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
79 //Putenemy(3,x,y,(float) Mysin(15)*2.0/SANKAKU,(float)Mycos(15)*2.0/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
80 Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2/SANKAKU,(float)Mycos(rand()%15*-1)*2/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
81 // Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2.0/SANKAKU,(float)Mycos(rand()%15*-1)*2.0/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
82 }
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
83 Putenemy(0,ix,iy,1,0,10);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
84 Putenemy(1,(float)ix,(float)iy,1,0,10);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
85 Putenemy(2,(float)ix,(float)iy,(float)ix,(float)iy,ix);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
86 Putenemy(3,(float)ix,(float)iy,(float)ix,0,ix);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
87 Putenemy(4,fx,fy,1,0,10);
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
88 return(0);
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
89 }
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
90