mirror of
https://github.com/rvtr/ntr_bootrom.git
synced 2025-10-31 07:11:11 -04:00
129 lines
4.7 KiB
C
129 lines
4.7 KiB
C
//======================================================================
|
||
// IrisSinTable.h
|
||
// Sinテーブル関連
|
||
//
|
||
// Copyright (C) 2002-2003 NINTENDO Co.,Ltd.
|
||
//======================================================================
|
||
#ifndef _IRIS_SIN_TABLE_H
|
||
#define _IRIS_SIN_TABLE_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
|
||
#include <IrisTarget.h>
|
||
#include <IrisTypes.h>
|
||
#include <IrisDefine.h>
|
||
|
||
|
||
|
||
#define SIN_NDIV_DEFAULT 256 // デフォルトSinテーブルの分割数
|
||
|
||
#define SINCOS256TBL_ON_TCM // TCM上に配置するのに適した256段階のSinCosテーブルを選択
|
||
#define SINCOS1024TBL_ON_TCM // TCM上に配置するのに適した1024段階のSinCosテーブルを選択
|
||
#define SINCOS4096TBL_ON_TCM // TCM上に配置するのに適した4096段階のSinCosテーブルを選択
|
||
|
||
|
||
// デフォルトSinテーブル(シフト調整有り)
|
||
|
||
#define SinTbl(theta) TrigonTblPriv(Sin, SIN_NDIV_DEFAULT, theta)
|
||
#define CosTbl(theta) TrigonTblPriv(Cos, SIN_NDIV_DEFAULT, theta)
|
||
|
||
|
||
// 回転角精度別Sinテーブル(シフト調整有り)
|
||
|
||
#ifdef SINCOS256TBL_ON_TCM
|
||
#define Sin256Tbl(theta) (sin256_tbl[ ((u16 )((theta) )) >>8])
|
||
#define Cos256Tbl(theta) (sin256_tbl[ ((u16 )((theta)+0x10000/4)) >>8])
|
||
#else
|
||
#define Sin256Tbl(theta) (sincos256_tbl[ (((u16 )((theta) )) >>8) * 2 ])
|
||
#define Cos256Tbl(theta) (sincos256_tbl[ (((u16 )((theta) )) >>8) * 2 + 1])
|
||
#endif
|
||
|
||
#ifdef SINCOS1024TBL_ON_TCM
|
||
#define Sin1024Tbl(theta) (sin1024_tbl[ ((u16 )((theta) )) >>6])
|
||
#define Cos1024Tbl(theta) (sin1024_tbl[ ((u16 )((theta)+0x10000/4)) >>6])
|
||
#else
|
||
#define Sin1024Tbl(theta) (sincos1024_tbl[(((u16 )((theta) )) >>6) * 2 ])
|
||
#define Cos1024Tbl(theta) (sincos1024_tbl[(((u16 )((theta) )) >>6) * 2 + 1])
|
||
#endif
|
||
|
||
#ifdef SINCOS4096TBL_ON_TCM
|
||
#define Sin4096Tbl(theta) (sin4096_tbl[ ((u16 )((theta) )) >>4])
|
||
#define Cos4096Tbl(theta) (sin4096_tbl[ ((u16 )((theta)+0x10000/4)) >>4])
|
||
#else
|
||
#define Sin4096Tbl(theta) (sincos4096_tbl[(((u16 )((theta) )) >>4) * 2 ])
|
||
#define Cos4096Tbl(theta) (sincos4096_tbl[(((u16 )((theta) )) >>4) * 2 + 1])
|
||
#endif
|
||
|
||
|
||
// デフォルトSinテーブル(シフト調整無し)
|
||
|
||
#define SinTblImm(theta) TrigonTblImmPriv(Sin, SIN_NDIV_DEFAULT, theta)
|
||
#define CosTblImm(theta) TrigonTblImmPriv(Cos, SIN_NDIV_DEFAULT, theta)
|
||
|
||
|
||
// 回転角精度別Sinテーブル(シフト調整無し)
|
||
|
||
#ifdef SINCOS256TBL_ON_TCM
|
||
#define Sin256TblImm(theta) (sin256_tbl[ (u8 )((theta) )])
|
||
#define Cos256TblImm(theta) (sin256_tbl[ (u8 )((theta)+0x100/4 )])
|
||
#else
|
||
#define Sin256TblImm(theta) (sincos256_tbl[ (u8 )((theta) ) * 2 ])
|
||
#define Cos256TblImm(theta) (sincos256_tbl[ (u8 )((theta) ) * 2 + 1])
|
||
#endif
|
||
|
||
#ifdef SINCOS1024TBL_ON_TCM
|
||
#define Sin1024TblImm(theta) (sin1024_tbl[ (u16 )((theta) )])
|
||
#define Cos1024TblImm(theta) (sin1024_tbl[ (u16 )((theta)+0x400/4 )])
|
||
#else
|
||
#define Sin1024TblImm(theta) (sincos1024_tbl[(u16 )(theta) )) * 2 ])
|
||
#define Cos1024TblImm(theta) (sincos1024_tbl[(u16 )(theta) )) * 2 + 1])
|
||
#endif
|
||
|
||
#ifdef SINCOS4096TBL_ON_TCM
|
||
#define Sin4096TblImm(theta) (sin4096_tbl[ (u16 )((theta) )])
|
||
#define Cos4096TblImm(theta) (sin4096_tbl[ (u16 )((theta)+0x1000/4)])
|
||
#else
|
||
#define Sin4096TblImm(theta) (sincos4096_tbl[(u16 )((theta) ) * 2 ])
|
||
#define Cos4096TblImm(theta) (sincos4096_tbl[(u16 )((theta) ) * 2 + 1])
|
||
#endif
|
||
|
||
|
||
// ArcCosテーブル
|
||
|
||
#define ArcCosTbl(cos) ((cos) >= V_ONE ? 0 \
|
||
: arcCos256_tbl[-(cos) >= V_ONE ? 0 \
|
||
: ((cos)>>(V_SFT - 8)) + 0])
|
||
|
||
|
||
// 中間マクロ(下記のマクロは直接使用しないで下さい)
|
||
|
||
#define TrigonTblPriv( trigon, ndiv, theta) TrigonNDivTbl( trigon, ndiv, theta)
|
||
#define TrigonNDivTbl( trigon, ndiv, theta) trigon##ndiv##Tbl( theta)
|
||
|
||
#define TrigonTblImmPriv(trigon, ndiv, theta) TrigonNDivTblImm(trigon, ndiv, theta)
|
||
#define TrigonNDivTblImm(trigon, ndiv, theta) trigon##ndiv##TblImm( theta)
|
||
|
||
extern const s16 sin256_tbl[];
|
||
extern const s16 sin1024_tbl[];
|
||
extern const s16 sin4096_tbl[];
|
||
extern const s16 sincos256_tbl[];
|
||
extern const s16 sincos1024_tbl[];
|
||
extern const s16 sincos4096_tbl[];
|
||
|
||
extern const u16 arcCos256_tbl[];
|
||
|
||
#define ArcTanTbl(tan) (arcTan256_tbl[((tan)>>(9-7)) + 128])
|
||
|
||
extern const s16 arcTan256_tbl[];
|
||
|
||
|
||
|
||
#ifdef __cplusplus
|
||
} // extern "C"
|
||
#endif
|
||
|
||
#endif // _IRIS_SIN_TABLE_H
|