view ps2util.c @ 93:3731dd016e1b

halfway_3
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 26 May 2011 15:01:13 +0900
parents cb6c6de125dc
children b0249b856488
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include "libps2.h"
#include "ps2util.h"


/*
  たぶん、本当は読み込んだ xml file から情報を取得するとかそんなんだと思う
  どんな処理か分からないので、とりあえず、初期化している。
*/

OBJECT *ps2util_obj_Create_fromXML(char *filename)
{
  OBJECT *body;
  /*
  body->xyz = {0,0,0,0};
  body->angle = {0,0,0,0};
  body->transfer = { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} };
  body->*name = filename;
  body->*free_me = NULL;
  */
  return body;
}



void ps2util_obj_Set_effect(OBJECT *body, int def)
{
  //none
}


void ps2_vu0_copy_vector(FVECTOR directionA, FVECTOR directionB)
{
  //none
}


void ps2util_obj_Renew_transMatrix(OBJECT *car){
  //none
}


/*
  ps2 内の texture.c から
*/
TEXTURE* read_png_file(char *texname)
{
  //とりあえず戻り値を返してエラーをどうにか
  TEXTURE* tex;
  return tex;
}



void ps2util_tex_Set(TEXTURE* tex)
{
  //none
}


void ps2util_obj_Set_texture(OBJECT* car_body, TEXTURE *tex)
{
  //none
}

void ps2_vu0_unit_matrix(FMATRIX rot)
{
  //none
}

void ps2_vu0_rot_matrix_y(FMATRIX rot1, FMATRIX rot2, float radian)
{
  //none
}


void ps2_vu0_apply_matrix(FVECTOR direction, FMATRIX rot, FVECTOR v)
{
  //none
}


void ps2_vu0_scale_vector(FVECTOR mov, FVECTOR car_direction, float car_speed)
{
  //none
}

void ps2_vu0_add_vector(FVECTOR car_location1, FVECTOR car_location2,FVECTOR mov)
{
  //none
}


void ps2_vu0_outer_product(FVECTOR rotaxis, FVECTOR car_vertical, FVECTOR yd)
{
  //none
}


float ps2_vu0_inner_product(FVECTOR yd, FVECTOR car_vertical)
{
  float ret;
  return ret;
}


void ps2_vu0_mul_matrix(FMATRIX pose1, FMATRIX yrot, FMATRIX pose2)
{
  //none
}

void ps2_vu0_copy_matrix(FMATRIX car_body_transfer, FMATRIX pose)
{
  //none
}


void ps2util_tex_Exclude(TEXTURE* t)
{
  //none
}

void ps2util_obj_Free(OBJECT* p_body)
{
  //none
}



void ps2_vu0_sub_vector(FVECTOR o0, FVECTOR p, FVECTOR p0)
{
  //none
}




void ps2_vu0_normalize(FVECTOR colface_normal1, FVECTOR colface_normal2)
{
  //none
}


void xml_free(PolygonInfo xml)
{
  //none
}


void ps2util_obj_Draw(OBJECT *object)
{
  //none
}


void gSprite_Init()
{
  //none
}


void  ps2util_sprite_Destroy(ps2utilSprite *title_sprite )
{
  //none
}







/*
  からの関数
  ps2 依存関係にあったけど、( name_dictionary.c ) の中のもの
  だけど、他にも持ってくるものが増えるので、とりあえず、からの関数に
*/
void delete_name_dictionary(const char *string)
{
  /*
  int number;
  NAME_DIC *dic_ptr;

  if (string == NULL) return;

  number = hash_func(string,NAME_HASH_SIZE);

  for (dic_ptr=name_hash+number;dic_ptr->name;dic_ptr=name_hash+number) {
    if (!strcmp(string,dic_ptr->name)) {
      dic_ptr->ref_num--;
      if (dic_ptr->ref_num == 0) {
	free(dic_ptr->name);
	dic_ptr->name = NULL;
      }
      return;
    } else {
      number += REHASH_NUM;
      if (number > NAME_HASH_SIZE) number -= NAME_HASH_SIZE;
    }
  }
  */
}
  


/*
  ps2 依存関係から持ってきた。
  テクスチャに割り振ったメモリの解放処理?
  元ファイル:texture.c
*/
void free_texture(TEXTURE *tex)
{
  if (tex == NULL) return;

  delete_name_dictionary(tex->name);
  free(tex->free_texenv);
  free(tex->free_image);
  free(tex);
}


/*
  ps2 依存関係内の、texture.c から拝借
  この malloc によるメモリ取得をあちこちで行っているっぽい
*/
int malloc_align16(void *free, void *aligned, int size)
{
  char *index;
  unsigned int *f=(unsigned int *)free,*a=(unsigned int *)aligned;

  if (free == NULL || aligned == NULL || size <= 0) return(-1);

  index = (char *)malloc(size + ALIGN_16BYTE);
  if (index == NULL) {
    return(-1);
  }

  *f = *a = (unsigned long int)index;
  if (((unsigned long int)index % ALIGN_16BYTE) != 0) {
    index += ALIGN_16BYTE - ((unsigned long int)index % ALIGN_16BYTE);
    *a = (unsigned long int)index;
  }

  return(0);
}