mtxf2l.s 1.89 KB
/************************************************************************
 Copyright (C) 1998,1999 NINTENDO CO,Ltd,
 Copyright (C) 1998,1999 MONEGI CORPORATION,
	All Rights Reserved
This program is a trade secret of NINTENDO CO,Ltd and MONEGI Corp. 
and it is not to be reproduced, published, disclosed to others, copied,
adapted, distributed, or displayed without the prior authorization of 
NINTENDO CO,Ltd. and MONEGI Corp. Licensee agrees to attach or embed 
this Notice on all copies of the program, including partial copies or 
modified versions thereof.
*************************************************************************/
/************************************************************************
 $Date: 2002/10/29 08:06:43 $
 $Revision: 1.1.1.1 $
 $Author: blythe $
************************************************************************/

#include	<asm.h>
#include	<regdef.h>

/*
 * void guMtxF2L(float mf[4][4], Mtx *m)
 *
 * 퐁卦
 *	float mf[4][4]
 * 싻卦
 *	Mtx *m
 */

#define	HALF_SIZE_MTX	32
#define	MASK_LOW	0x0000FFFF
#define	MASK_HIGH	0xFFFF0000
#define	MAGNIFICANT	65536.0	/* = 0x10000 */

#define	ptr_fl	a0	/* 과웃 */
#define	ptr_mtx	a1	/* 과웃 */
#define	end_mtx	t8
#define	mask_hi	t9
#define	magni	fv0

	.text	
	.align	5
LEAF( guMtxF2L )
	.set reorder

	li.s	magni, MAGNIFICANT
	li	mask_hi, MASK_HIGH
	addu	end_mtx, ptr_mtx, HALF_SIZE_MTX
label_loop:
	l.s	ft0, 0(ptr_fl)	/* FTOFIX32( ) */
	mul.s	ft1, ft0, magni
	trunc.w.s	ft2, ft1

	l.s	ft3, 4(ptr_fl)	/* FTOFIX32( ) */
	mul.s	ft4, ft3, magni
	trunc.w.s	ft5, ft4

	mfc1	t0, ft2	/* t0 <- FIXED */
	mfc1	t1, ft5	/* t1 <- FIXED */

	and	t2, t0, mask_hi	/* 육웃 */
	srl	t3, t1, 16
	or	t4, t2, t3
	sw	t4, 0(ptr_mtx)

	sll	t5, t0, 16	/* 쒸웃 */
	and	t6, t1, MASK_LOW
	or	t7, t5, t6
	sw	t7, HALF_SIZE_MTX(ptr_mtx)

	addu	ptr_mtx, ptr_mtx, 4
	addu	ptr_fl, ptr_fl, 8

	bne	ptr_mtx, end_mtx, label_loop
/* loop-end */

	j	ra
	END( guMtxF2L )

/* End of file */