diff ps2util.c @ 95:b0249b856488

change_ps2util
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 26 May 2011 18:13:40 +0900
parents cb6c6de125dc
children 0b65ca27f113
line wrap: on
line diff
--- a/ps2util.c	Thu May 26 15:04:10 2011 +0900
+++ b/ps2util.c	Thu May 26 18:13:40 2011 +0900
@@ -53,9 +53,14 @@
 
 
 
-void ps2util_tex_Set(TEXTURE* tex)
+int ps2util_tex_Set(TEXTURE* tex)
 {
-  //none
+  return -1;
+}
+
+int ps2util_sprite_Create(ps2utilSprite sp, TEXTURE *sprite_tex)
+{
+  return -1;
 }
 
 
@@ -64,26 +69,51 @@
   //none
 }
 
-void ps2_vu0_unit_matrix(FMATRIX rot)
+void ps2_vu0_unit_matrix(FMATRIX m)
 {
-  //none
+  m[0][1] = m[0][2] = m[0][3] = 0;
+  m[1][0] = m[1][2] = m[1][3] = 0;
+  m[2][0] = m[2][1] = m[2][3] = 0;
+  m[3][0] = m[3][1] = m[3][2] = 0;
+  m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0;
 }
 
-void ps2_vu0_rot_matrix_y(FMATRIX rot1, FMATRIX rot2, float radian)
+void ps2_vu0_rot_matrix_y(FMATRIX result, FMATRIX m, float radian)
 {
-  //none
+  FMATRIX rot;
+  m[0][1] = m[0][2] = m[0][3] = 0;
+  m[1][0] = m[1][2] = m[1][3] = 0;
+  m[2][0] = m[2][1] = m[2][3] = 0;
+  m[3][0] = m[3][1] = m[3][2] = 0;
+  m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0;
+
+  m[0][0] = fsign(radian);
+  m[2][2] = fsign(radian);
+  m[0][2] = -fcos(radian);
+  m[2][0] = fcos(radian);
+
+  FMATRIX m1 = m;
+
+  ps2_vu0_mul_matrix(result, m1, m);
+  
 }
 
 
-void ps2_vu0_apply_matrix(FVECTOR direction, FMATRIX rot, FVECTOR v)
+void ps2_vu0_apply_matrix(FVECTOR result, FMATRIX m, FVECTOR v)
 {
-  //none
+  result[0] = m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2] + m[0][3] * v[3] ;
+  result[1] = m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2] + m[1][3] * v[3] ;
+  result[2] = m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2] + m[2][3] * v[3] ;
+  result[3] = m[3][0] * v[0] + m[3][1] * v[1] + m[3][2] * v[2] + m[3][3] * v[3] ;
 }
 
 
 void ps2_vu0_scale_vector(FVECTOR mov, FVECTOR car_direction, float car_speed)
 {
-  //none
+  mov[0] = car_direction[0] * car_speed ;
+  mov[1] = car_direction[1] * car_speed ;
+  mov[2] = car_direction[2] * car_speed ;
+  mov[3] = car_direction[3];
 }
 
 void ps2_vu0_add_vector(FVECTOR car_location1, FVECTOR car_location2,FVECTOR mov)
@@ -92,16 +122,18 @@
 }
 
 
-void ps2_vu0_outer_product(FVECTOR rotaxis, FVECTOR car_vertical, FVECTOR yd)
+void ps2_vu0_outer_product(FVECTOR result, FVECTOR v0, FVECTOR v1)
 {
-  //none
+  result[0] = v0[1] * v1[2] - v0[2] * v1[1] ;
+  result[1] = v0[0] * v1[2] - v0[2] * v1[0] ;
+  result[2] = v0[0] * v1[1] - v0[1] * v1[0] ;
+  result[3] = 1;
 }
 
 
-float ps2_vu0_inner_product(FVECTOR yd, FVECTOR car_vertical)
+float ps2_vu0_inner_product(FVECTOR v0, FVECTOR v1)
 {
-  float ret;
-  return ret;
+  return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2];
 }
 
 
@@ -110,9 +142,9 @@
   //none
 }
 
-void ps2_vu0_copy_matrix(FMATRIX car_body_transfer, FMATRIX pose)
+void ps2_vu0_copy_matrix(FMATRIX from, FMATRIX to)
 {
-  //none
+  to = from;
 }
 
 
@@ -121,9 +153,9 @@
   //none
 }
 
-void ps2util_obj_Free(OBJECT* p_body)
+void ps2util_obj_Free(OBJECT* obj)
 {
-  //none
+  free(obj);
 }
 
 
@@ -136,9 +168,13 @@
 
 
 
-void ps2_vu0_normalize(FVECTOR colface_normal1, FVECTOR colface_normal2)
+void ps2_vu0_normalize(FVECTOR result, FVECTOR v)
 {
-  //none
+  float d = fsqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
+  result[0] = v[0] / d;
+  result[1] = v[1] / d;
+  result[2] = v[2] / d;
+  result[3] = 1;
 }
 
 
@@ -168,6 +204,51 @@
 
 
 
+void ps2util_sprite_Set_basicAttribute(ps2utilSprite *p,
+	unsigned short x, unsigned short y,
+	unsigned short sptable_tw1, unsigned short sptable_th1,
+	unsigned short sptable_tx, unsigned short sptable_ty,
+	unsigned short sptable_tw2, unsigned short sptable_th2,
+	int sprite_prio_foreground)
+{
+  //none
+}
+
+void ps2util_sprite_Request(ps2utilSprite *p)
+{
+  //none
+}
+
+
+void ps2util_sprite_Unuse_alpha(ps2utilSprite *sp)
+{
+  //none
+}
+
+void ps2util_graphic_Init()
+{
+  //none
+}
+
+
+/*
+  ps2 依存関係の sprite.c より引用。
+*/
+inline void
+sprite_disappear( SPRITE* sprite )
+{
+  
+  int i;
+  GsSpritePacket* packet = sprite->gs_packet;
+  for (i=0; i<SPRITE_HAS_4VERTEXIS; i++)
+    packet->primData[i].xyz_addr = PS2_GS_XYZ3;
+  
+}
+
+
+
+
+
 
 
 
@@ -223,6 +304,7 @@
 /*
   ps2 依存関係内の、texture.c から拝借
   この malloc によるメモリ取得をあちこちで行っているっぽい
+  cerium にある。
 */
 int malloc_align16(void *free, void *aligned, int size)
 {