gxsetup_ln.s 3.87 KB
 #----------------------------------------------------------------------#
 #	Copyright (C) 1998, Nintendo.
 #	
 #	File		gxline.s
 #	Coded    by	Yoshitaka Yasumoto.	Mar 10, 1998.
 #	
 #	$Id: gxsetup_ln.s,v 1.1.1.1 2002/05/02 03:29:11 blythe Exp $
 #----------------------------------------------------------------------#

	#---------------------------------------------------------------------
	#  caseLN_GL_TRI[12]
	#	+------------+------------+------------+------------+
	#	|  G_LINE3D  |    v0*2    |    v1*2    |    v2*2    |
	#	+------------+------------+------------+------------+
	#	|     w      |    w0*2    |    w1*2    |    w2*2    |
	#	+------------+------------+------------+------------+
	#---------------------------------------------------------------------
  FixedAssign(v1, 2)
  FixedAssign(v2, 3)
  FixedAssign(wd, 4)
  FixedAssign(flat, 5)
  FixedAssign(p0, 28)
  FixedAssign(p1, 29)
  FixedAssign(p2, 30)
caseLN_G_TRI2:	
	lbu	flat, RSP_DLINPUT_BOTTOM-3(dinp)
	lbu	p1,   RSP_DLINPUT_BOTTOM-2(dinp)
	lbu	p2,   RSP_DLINPUT_BOTTOM-1(dinp)	
	j	caseLN_G_TRI0
	_li	(gfx0, caseLN_G_TRI1)
caseLN_G_TRI1:	
	lbu	flat, RSP_DLINPUT_BOTTOM-7(dinp)
	lbu	p1,   RSP_DLINPUT_BOTTOM-6(dinp)
	lbu	p2,   RSP_DLINPUT_BOTTOM-5(dinp)
	_li	(gfx0, GfxDone)
caseLN_G_TRI0:
	lb	wd,   RSP_DLINPUT_BOTTOM-4(dinp)
	lhu	p0,   RSP_SUBMOD_POINTS(flat)
	lhu	p1,   RSP_SUBMOD_POINTS(p1)
	lhu	p2,   RSP_SUBMOD_POINTS(p2)
	lhu	flat, RSP_SUBMOD_POINTS(flat)
	addi	wd,   wd, 3
	_mov	(v1, p0)
	jal	caseLN_G_LINE3D_Main
	_mov	(v2, p1)
	_mov	(v1, p1)
	jal	caseLN_G_LINE3D_Main
	_mov	(v2, p2)
	_mov	(v1, p2)
	_mov	(v2, p0)
	j	caseLN_G_LINE3D_Main
	_mov	(return, gfx0)
	
	#---------------------------------------------------------------------
	#  caseLN_G_LINE3D
	#
	#	+------------+------------+------------+------------+
	#	|  G_LINE3D  |    v1*2    |    v2*2    |     w      |
	#	+------------+------------+------------+------------+
	#	|            |            |            |            |
	#	+------------+------------+------------+------------+
	#---------------------------------------------------------------------
caseLN_G_LINE3D:
	lb	wd,   RSP_DLINPUT_BOTTOM-5(dinp)
	lbu	flat, RSP_DLINPUT_BOTTOM-7(dinp)
	lbu	v2,   RSP_DLINPUT_BOTTOM-6(dinp)
	addi	wd,   wd,  3	
	lhu	v1,   RSP_SUBMOD_POINTS(flat)
	lhu	v2,   RSP_SUBMOD_POINTS(v2)
	lhu	flat, RSP_SUBMOD_POINTS(flat)
	_li	(return, GfxDone)

	# この間に命令を追加してはならん
	#---------------------------------------------------------------------
	#  CLIPPING つきのライン描画処理
	#---------------------------------------------------------------------
caseLN_G_LINE3D_Main:
	
	#---------------------------------------------------------------------
	#  クリップ判定
	#	2 点が画面外枠の同一方向にあるなら描画せずに終了.
	#	2 点がクリップボックス内にあるならクリップなしで描画へ
	#---------------------------------------------------------------------
  Assign(cc1, 6)
  Assign(cc2, 7)
	lw	cc1, oRSP_POINT_CC(v1)
	lw	cc2, oRSP_POINT_CC(v2)
	lw	sys1, RSP_SUBMOD_LN_CLIPTEST(zero)
#ifdef	NEARCLIP_OFF
	andi	sys0, cc1,  0x70b0
#else
	andi	sys0, cc1,  0x7070
#endif	
	and	sys0, sys0, cc2			# 画面外かどうかの判定
	bne	sys0, zero, ReturnToR31		# 終了
	or	sys0, cc1,  cc2
	and	sys0, sys0, sys1		# クリップ範囲内かどうかの判定
	beq	sys0, zero, caseLN_LineSetup	# ラインクリップへ
	sh	return, RSP_SUBMOD_LN_RETURN(zero)	# return を保存する
  EndAssign(cc1, 6)
  EndAssign(cc2, 7)
	#---------------------------------------------------------------------
	#  クリップ処理
	#---------------------------------------------------------------------
#include	"gxclip_ln.s"

	#---------------------------------------------------------------------
	#  Line 描画処理
	#---------------------------------------------------------------------
caseLN_LineSetup:
#include	"gxline_ln.s"
  EndAssign(v1, 2)
  EndAssign(v2, 3)
  EndAssign(wd, 4)
  EndAssign(flat, 5)
  EndAssign(p0, 28)
  EndAssign(p1, 29)
  EndAssign(p2, 30)
	
 #======== End of gxline.s ========#