642
|
1 #ifndef INLINE
|
|
2 #define INLINE
|
|
3 #endif
|
637
|
4
|
|
5 int printf(const char *,...);
|
646
|
6 void bzero(void *b, unsigned int len);
|
|
7
|
|
8
|
649
|
9 int align100 ;
|
|
10 int align101 __attribute__((aligned (16)));
|
|
11 int align102 __attribute__((aligned (8)));
|
|
12 char align103;
|
|
13 char align104;
|
|
14 int align105;
|
|
15 int align106 __attribute__((aligned (8)));
|
|
16
|
|
17 void *aligns[] = {
|
|
18 &align100,
|
|
19 &align101,
|
|
20 &align102,
|
|
21 &align103,
|
|
22 &align104,
|
|
23 &align105,
|
|
24 &align106,
|
|
25 };
|
|
26
|
|
27 void *aligns1[] = {
|
|
28 &align100,
|
|
29 &align101,
|
|
30 &align102,
|
|
31 &align103,
|
|
32 &align104,
|
|
33 &align105,
|
|
34 &align106
|
|
35 };
|
|
36
|
637
|
37
|
|
38 typedef float ps2_vu0_fmatrix[4][4] __attribute__((aligned (16)));
|
|
39 typedef ps2_vu0_fmatrix FMATRIX;
|
|
40
|
647
|
41 typedef float ps2_vu0_fmatrix1[4][4];
|
|
42 typedef ps2_vu0_fmatrix1 FMATRIX1;
|
|
43
|
646
|
44 typedef struct objNode {
|
|
45 void* object;
|
|
46 void (*mtd)(struct objNode*);
|
|
47 void (*draw)(struct objNode*, FMATRIX, FMATRIX);
|
|
48 struct objNode *next;
|
|
49 struct objNode *parent;
|
|
50 struct objNode *child;
|
|
51 } ObjNode, *ObjNodePtr;
|
637
|
52
|
646
|
53 INLINE void draw(ObjNode *this, FMATRIX m, FMATRIX n)
|
|
54 {
|
|
55 printf("work %g ",m[1][1]);
|
|
56 printf("base %g\n",n[1][1]);
|
|
57 m[1][1] += -0.7;
|
|
58 n[1][1] += 0.7;
|
|
59 }
|
|
60
|
|
61 ObjNode c = {
|
|
62 0, 0, draw, 0, 0, 0
|
|
63 };
|
|
64
|
|
65 ObjNode p = {
|
|
66 0, 0, draw, &c, 0, &c
|
|
67 };
|
|
68
|
|
69
|
|
70 INLINE void
|
|
71 graphic_ObjNode_draw( ObjNode *this, FMATRIX base )
|
|
72 {
|
|
73 FMATRIX work;
|
|
74 bzero(&work,sizeof(work)); work[1][1] = 0.33;
|
|
75
|
|
76 if(!this) return;
|
|
77 if(this->mtd) this->mtd( this );
|
|
78 if(this->draw) this->draw( this, work, base );
|
650
|
79 printf("offset draw %d\n",((char*)(&this->draw) - ((char*)&this->object)));
|
|
80 printf("offset next %d\n",((char*)(&this->next) - ((char*)&this->object)));
|
646
|
81
|
|
82 if(this->child) graphic_ObjNode_draw( this->child, work );
|
|
83 if(this->next) graphic_ObjNode_draw( this->next, base );
|
|
84 return;
|
|
85 }
|
637
|
86
|
|
87
|
642
|
88 INLINE void ps2_vu0_unit_matrix(ps2_vu0_fmatrix m)
|
637
|
89 {
|
|
90 printf("%g\n",m[1][1]);
|
638
|
91 m[1][1] = -0.5;
|
637
|
92 }
|
|
93
|
646
|
94
|
647
|
95 #define mod16(a) (((int)(&a))%16)
|
|
96
|
|
97 int
|
|
98 align16(int i, FMATRIX a, FMATRIX b) {
|
|
99 FMATRIX m;
|
|
100 FMATRIX n;
|
|
101 int k = i;
|
|
102 FMATRIX o;
|
|
103 if (i==0) return i;
|
|
104 #ifdef OFFSET
|
|
105 printf("offset %d\n",((char*)a) - ((char*)(&m)));
|
|
106 #endif
|
|
107 printf("%d %d %d\n",mod16(m),mod16(n),mod16(o));
|
|
108 align16(i-1,m,n);
|
|
109 return k;
|
|
110 }
|
|
111
|
|
112 int
|
|
113 align16_1(int i, FMATRIX1 a, FMATRIX1 b) {
|
|
114 FMATRIX1 m;
|
|
115 FMATRIX1 n;
|
|
116 int k = i;
|
|
117 FMATRIX1 o;
|
|
118 if (i==0) return i;
|
|
119 #ifdef OFFSET
|
|
120 printf("offset %d\n",((char*)a) - ((char*)(&m)));
|
|
121 #endif
|
|
122 printf("%d %d %d\n",mod16(m),mod16(n),mod16(o));
|
|
123 align16_1(i-1,m,n);
|
|
124 return k;
|
|
125 }
|
|
126
|
|
127
|
637
|
128 int
|
|
129 main(int ac, char *av[])
|
|
130 {
|
|
131 FMATRIX m;
|
649
|
132 int i;
|
648
|
133 int aligned = 10;
|
637
|
134
|
|
135 m[1][1] = 0.5;
|
|
136 ps2_vu0_unit_matrix(m);
|
648
|
137 printf("%g %d\n",m[1][1],aligned);
|
647
|
138 align16(2,m,m);
|
|
139 align16_1(2,m,m);
|
|
140 graphic_ObjNode_draw( &p, m);
|
649
|
141
|
|
142 printf("sizeof(aligns)==%d %d\n",
|
|
143 sizeof(aligns),sizeof(aligns1));
|
|
144 printf("sizeof(aligns)/sizeof(void *)==%d\n",
|
|
145 sizeof(aligns)/sizeof(void *));
|
|
146
|
|
147 for(i=0;i<sizeof(aligns)/sizeof(void *);i++) {
|
|
148 printf("align10%d %d\n",i,mod16(aligns[i]));
|
|
149 }
|
|
150
|
637
|
151 }
|
646
|
152
|
647
|
153
|
646
|
154 /* end */
|