glvtx.s 15.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577

#include "gfx_regs.h"

.name gmode,	$3	/* getScaleTrans で設定 */
.name v0,	$6
.name voutp,	$7
.name tmp,	$8	/* getScaleTrans で使用 */
.name i,	$9
.name clr2,	$14
.name clr3,	$15	/* doLight で設定 */
.name clr4,	$16	/* doLight で設定 */
.name lighton,	$13

.name flag12,	$10
.name flag34,	$12

/* $30,$20,$19,$18,$17,$21,$11 are used by overlay */	

#ifdef	DIRECTZCMP
.name	Wint2,	$2	/* W int 値の一時保存 */
.name	Wint3,	$4
.name	Wint4,	$5
#endif
	
.name mtx0,	$v8	/* getMatrix で設定 */
.name mtx1,	$v9
.name mtx2,	$v10
.name mtx3,	$v11
.name mtf0,	$v12
.name mtf1,	$v13
.name mtf2,	$v14
.name mtf3,	$v15
.name vpscale,	$v0	/* getScaleTrans で設定 */
.name vptrans,	$v1	/* getScaleTrans で設定 */
.name txtscale,	$v23
.name vtmp,	$v3	/* getScaleTrans/doLight で vtmp として使用 */

.name vtmpf,    $v20	/* doLight で使用 */

.name rej12,	$v19	/* getScaleTrans で使用 */
.name rej34,	$v29
.name st12,	$v24
.name vin12,	$v21
.name persp12i,	$v4	/* doLight で使用 */
.name persp12f,	$v5	/* doLight で使用 */
.name invWi,    $v6	/* doLight で使用 */
.name invWf,    $v7	/* doLight で使用 */
.name vout12i,	$v16	
.name vout12f,	$v17
		
.name st34,	$v18	/* doLight で設定 */
.name vin34,	$v22
.name persp34i,	$v2	/* doLight で使用 */
.name persp34f, $v26	/* doLight で使用 */
.name vout34i,	$v25
.name vout34f,	$v28

#if 0
#define	ISREJECT1	0x0707	/* Near Clip On  */
#define	ISREJECT2	0x7070
#else
#define	ISREJECT1	0x0703	/* Near Clip Off */
#define	ISREJECT2	0x7030
#endif
		
 #-YASU
 #  
 #  n は bit が余っているから Fast3D では n-1 の値を代入していたが F3DLP
 #  では n の値を入れているので -1 の処理は必要なし
 #
 #  また n の値を直後に i に代入しているので, わざわさ n に代入する必要なし
 #
 #  i は $9 でなければならない. なぜならこのコードは doClip から呼び出される
 #  ので, それとレジスタアサインが一致している必要があるから
 # 
 #-YASU
		lbu	i, (0-6)(dinp)	# n is really n
				
 #-YASU
 #  
 #  voutp に出力バッファへのポインタを代入する
 #  
 #  Clip なし: voutp = v0 * 16 + RSP_POINTS_OFFSET
 #  
 #-YASU
#ifndef DIRECTZCMP
# ifdef PERSPTXTR
		sll	tmp, $1, 2
		addu	tmp, $1, tmp
		sll	tmp, tmp, 1
# else
		sll	tmp, $1, 3
# endif
		addi	voutp, tmp, RSP_POINTS_OFFSET
#else
		lhu	voutp, RSP_VADDR_TABLE($1)
#endif
		srl	i, i, 2
	
 #-YASU
 #  
 #  4 つ分の頂点データ (x,y,z,flag) を vin12,vin34 に代入する
 #
 #  vin12[0|1|2|3] = [ x1 | y1 | z1 | flag1 ]
 #  vin12[4|5|6|7] = [ x2 | y2 | z2 | flag2 ]
 #  vin34[0|1|2|3] = [ x3 | y3 | z3 | flag3 ]
 #  vin34[4|5|6|7] = [ x4 | y4 | z4 | flag4 ]  
 #
 #-YASU
		ldv	vin12[0],  0(in_bufp)
		ldv	vin12[8], 16(in_bufp)
		ldv	vin34[0], 32(in_bufp)
		ldv	vin34[8], 48(in_bufp)

 #-YASU
 #  
 #  MP マトリクスをロードする
 #  getScaleTrans で vpscale,vptrans,wscl,gmode を取得する
 #  gSPTexture で指定された sc,tc の値を txtscale へ取得する
 #  txtscale[2] に wscl[0]($v19) の値を代入
 #  
 #-YASU
		jal	getScaleTrans
		llv	txtscale[0], RSP_STATE_TEX_SCALE_S(rsp_state)
		vmov	txtscale[2], $v19[0]
                jal	getMatrix
		llv	txtscale[8], RSP_STATE_TEX_SCALE_S(rsp_state)
	
xfm_loop:
 #-YASU
 #  
 #  MP 行列を頂点座標に乗ずる
 #
 #    vout12[0|1|2|3] = [ X1 | Y1 | Z1 | W1 ]
 #                    = [ x1*mt00 + y1*mt10 + z1*mt20 + 1.0*mt30 |
 #                        x1*mt01 + y1*mt11 + z1*mt21 + 1.0*mt31 |
 #                        x1*mt02 + y1*mt12 + z1*mt22 + 1.0*mt32 |
 #                        x1*mt03 + y1*mt13 + z1*mt23 + 1.0*mt33 ]
 #  
 #    vout12[4|5|6|7] = [ X2 | Y2 | Z2 | W2 ]
 #    vout34[0|1|2|3] = [ X3 | Y3 | Z3 | W3 ]
 #    vout34[4|5|6|7] = [ X4 | Y4 | Z4 | W4 ]
 #  
 #-YASU
		vmudn	vout12f, mtf0, vin12[0h]
	addi	in_bufp, in_bufp, 64
		vmadh	vout12f, mtx0, vin12[0h]
	llv	st34[0], ( 0+8-64)(in_bufp)
		vmadn	vout12f, mtf1, vin12[1h]
	llv	st34[8], (16+8-64)(in_bufp)
		vmadh	vout12f, mtx1, vin12[1h]
	lw	clr3,    ( 0+12-64)(in_bufp)
		vmadh	vout12f, mtx2, vin12[2h]
	lw	clr4,    (16+12-64)(in_bufp)
		vmadn	vout12f, mtf2, vin12[2h]
 	andi	lighton, gmode,(G_LIGHTING_H)
		vmadn	vout12f, mtf3, vconst[1]
 	bne	lighton, zero,  doLight
		vmadh	vout12i, mtx3, vconst[1]
lightReturn:
	bltz	lighton, lightReturn2
	sub	lighton, zero, lighton		# 2 度目を意味する
		vadd	st12, st34, vconst[0]
		vmudn	vout34f, mtf0, vin34[0h]
	addi	clr2, clr4, 0
		vmadh	vout34f, mtx0, vin34[0h]
	sw	clr3, (0*RSP_PTS_LEN+RSP_PTS_R_NX)(voutp)
		vmadn	vout34f, mtf1, vin34[1h]
	llv	st34[0], ( 0+ 8-32)(in_bufp)
		vmadh	vout34f, mtx1, vin34[1h]
	llv	st34[8], (16+ 8-32)(in_bufp)
		vmadn	vout34f, mtf2, vin34[2h]
	lw	clr3,    ( 0+12-32)(in_bufp)
		vmadh	vout34f, mtx2, vin34[2h]
	lw	clr4,    (16+12-32)(in_bufp)
		vmadn	vout34f, mtf3, vconst[1]
 	bne	lighton, zero, doLight
		vmadh	vout34i, mtx3, vconst[1]
lightReturn2:
	
 #-YASU
 #  
 #  W(s15.16)に PerspNorm=txtscale[2](u.16) を乗じ値を小さくし, 
 #  その逆数を Newton 法で計算する
 #
 #  Turbo の場合 テーブル引きで OK なのだが, どうしても Z 値の
 #  誤差が大きくなり Blockmonkey の動作に支障がでるので Newton 
 #  法を採用する.
 #  このため少しストールが生じるので何とかする必要がある.
 #
 #    invW[3|7|1|5] = [ 1/(W1*txtscale[2]) | 1/(W2*txtscale[2])]
 #	            = [ 1/WP1 | 1/WP2 ] 
 #  
 #-YASU
		vmudl   persp12f, vout12f, txtscale[2]
	addi	i, i, -2
                vmadm   persp12i, vout12i, txtscale[2]
	addi	voutp,  voutp, RSP_PTS_LEN*4
                vmadn   persp12f, vconst, vconst[0]

		vmudl   persp34f, vout34f, txtscale[2]
                vmadm   persp34i, vout34i, txtscale[2]
                vmadn   persp34f, vconst, vconst[0]
#ifdef	DIRECTZCMP
	mfc2	Wint2, vout12i[14]
#endif
		vrcph	invWi[3], persp12i[3]
#ifdef	DIRECTZCMP
	mfc2	Wint3, vout34i[6]
#endif
		vrcpl	invWf[3], persp12f[3]
#ifdef	DIRECTZCMP
	mfc2	Wint4, vout34i[14]
#endif
		vrcph	invWi[3], persp12i[7]
		vrcpl	invWf[7], persp12f[7]
		vrcph	invWi[7], persp34i[3]
		vrcpl	invWf[2], persp34f[3]
			#  リジェクトボックス取得
			lsv	rej34[0], (CLIP_SELECT+6)(zero)
		vrcph	invWi[2], persp34i[7]
			lsv	rej34[2], (CLIP_SELECT+6)(zero)
		vrcpl	invWf[6], persp34f[7]
			lsv	rej34[4], (VCONST_OFFSET+2)(zero)
		vrcph	invWi[6], vconst[0]
			lsv	rej34[8], (CLIP_SELECT+6)(zero)

		vmov	persp12i[2], persp34i[3]
			lsv	rej34[10], (CLIP_SELECT+6)(zero)
		vmov	persp12f[2], persp34f[3]
			lsv	rej34[12], (VCONST_OFFSET+2)(zero)
		vmov	persp12i[6], persp34i[7]
		vmov	persp12f[6], persp34f[7]
		
		vmudn	invWf, invWf, vconst[2]
		vmadh	invWi, invWi, vconst[2]
		vmadn	invWf, vconst, vconst[0]
		
		lqv	vtmp[0], VNEWT_OFFSET(zero)
		vxor	vtmpf, vconst, vconst	
	#  テクスチャ座標系をスケーリングする
	vmudm	st12, st12, txtscale
	vmudm	st34, st34, txtscale
		vmudl	persp34f, invWf, persp12f
		vmadm	persp34f, invWi, persp12f
#ifdef	DIRECTZCMP
	ssv	vout12i[6], (-4*RSP_PTS_LEN+RSP_PTS_W_INT)(voutp)
#endif
		vmadn	persp34f, invWf, persp12i
	slv	st12[0], (-4*RSP_PTS_LEN+RSP_PTS_S)(voutp)
		vmadh	persp34i, invWi, persp12i
			#  リジェクションを行なうための W の値を取得する
			#  通常は  [X,Y,Z] = (nW, nW, W) を使用するが倍精度
			#  の掛け算をすると 3 命令必要なので, 単精度の掛け算
			#  をし, X,Y については n>=2 なので小数部をケアしなく
			#  でも問題ないと考える. これで 1 命令ですむ
			vmudh	rej12, rej34, vout12i[3h]
			vmudh	rej34, rej34, vout34i[3h]
		vsubc	persp34f, vtmpf, persp34f
		vsub	persp34i, vtmp,  persp34i
			vch	vtmp, vout12i, rej12
			vcl	vtmp, vout12f, vout12f[3h]	# W の小数部
		vmudl	vtmp,  invWf, persp34f
			cfc2	flag12, $vcc
		vmadm	vtmp,  invWi, persp34f
		vmadn	invWf, invWf, persp34i
		vmadh	invWi, invWi, persp34i
			vch	vtmp, vout34i, rej34
			andi	tmp, flag12, ISREJECT1	# e0-e2 XYZ
			vcl	vtmp, vout34f, vout34f[3h]	# W の小数部
			sltiu	tmp, tmp, 1	

 #-YASU
 #  
 #  vout12[ X1 | Y1 | Z1 ] の値に 1/WP1 を掛ける
 #  vout12[ X2 | Y2 | Z2 ] の値に 1/WP2 を掛ける
 #
 #  persp12[0|1|2|3] = [ X1/WP1 | Y1/WP1 | Z1/WP1 | 1/P ]
 #  persp12[4|5|6|7] = [ X2/WP2 | Y2/WP2 | Z2/WP2 | 1/P ]
 #  
 #-YASU
		vmudl	persp12f, vout12f, invWf[3h]
			sll	tmp, tmp, 1
		vmadm	persp12f, vout12i, invWf[3h]
					cfc2	flag34, $vcc
		vmadn	persp12f, vout12f, invWi[3h]
			llv	rej12[0], REJECT_FLAG(tmp)
		vmadh	persp12i, vout12i, invWi[3h]
			andi	tmp, flag12, ISREJECT2	# e4-e6 XYZ
		vmudl	persp34f, vout34f, invWf[2h]
			sltiu	tmp, tmp, 1
		vmadm	persp34f, vout34i, invWf[2h]
			sll	tmp, tmp, 1	
		vmadn	persp34f, vout34f, invWi[2h]
			llv	rej12[8], REJECT_FLAG(tmp)
		vmadh	persp34i, vout34i, invWi[2h]
	
.unname vtmpf

 #-YASU
 #  
 #  PerspNorm を掛けて座標値を得る.
 #
 #  persp12[0|1|2|4|5|6] = [ X1/W1 | Y1/W1 | Z1/W1 | X2/W2 | Y2/W2 | Z2/W2 ]
 #  
 #  スクリーン座標クランプ用のデータをロードする.
 #
 #-YASU
			andi	tmp, flag34, ISREJECT1	# e0-e2 XYZ
		vmudl   persp12f, persp12f, txtscale[2]
			sltiu	tmp, tmp, 1	
                vmadm   persp12i, persp12i, txtscale[2]
			sll	tmp, tmp, 1	
                vmadn   persp12f, vconst, vconst[0]
			llv	rej12[4], REJECT_FLAG(tmp)
		vmudl   persp34f, persp34f, txtscale[2]
			andi	tmp, flag34, ISREJECT2	# e4-e6 XYZ
	        vmadm   persp34i, persp34i, txtscale[2]
			sltiu	tmp, tmp, 1	
                vmadn   persp34f, vconst, vconst[0]
.unname	flag12
.unname	flag34
.unname	vout12i
.unname	vout12f
.unname	vout34i
.unname	vout34f

 #-YASU
 #  
 #  vin12, vin34 に次の頂点データ v0-v3 を先読みする
 #  
 #  スクリーン座標系への変換 (スケーリング + トランスフォーム)
 #     scrn12 = vptrans + persp12 * vpscale 
 #
 #  scrn12[0|1|2] = [ Tx+Sx*X1/W1 | Ty-Sy*Y1/W1 | Tz-Sz*Z1/W1 ] = [XS1|YS1|ZS1]
 #  scrn12[4|5|6] = [ Tx+Sx*X2/W2 | Ty-Sy*Y2/W2 | Tz-Sz*Z2/W2 ] = [XS2|YS2|ZS2]
 #  
 #  カウンタを減らす. 
 #  
 #-YASU
.name scrn12i,	$v27
.name scrn12f,	$v20
.name scrn34i,	$v17
.name scrn34f,	$v28
.name yscr12i,	$v16
.name yscr34i,	$v25

			sll	tmp, tmp, 1
		vmudh	scrn12f, vptrans, vconst[1]	# use accumulator
			llv	rej12[12], REJECT_FLAG(tmp)
		vmadn	scrn12f, persp12f, vpscale	# adds to translate
	andi	tmp, gmode, (G_FOG_H)
		vmadh	scrn12i, persp12i, vpscale
	lqv	vtmp[0], RSP_FOG_FACTOR(zero)
		vmadn	scrn12f, vconst,  vconst[0]	
#ifdef	PERSPTXTR
	ssv	invWf[6], (-4*RSP_PTS_LEN+RSP_PTS_INVW_FRAC)(voutp)
#endif
		vmudh	scrn34f, vptrans, vconst[1]	# use accumulator
	ldv	vin12[0], 0(in_bufp)		# load first vert to transform
		vmadn	scrn34f, persp34f, vpscale	# adds to translate
	ldv	vin12[8], 16(in_bufp)		# load 2nd vert to transform
		vmadh	scrn34i, persp34i, vpscale
	ldv	vin34[0], 32(in_bufp)		# load first vert to transform
		vmadn	scrn34f, vconst, vconst[0]
	ldv	vin34[8], 48(in_bufp)		# load 2nd vert to transform

 #-YASU
 #  
 #  頂点が画面外なら XS,ZS に 0x7fff を代入する
 #
 #  スクリーン座標値を一番近いピクセルに一致させる. 
 #  これによって 精度の劣る 3 角形セットアップにおける( 3 角形の)壊れを
 #  防止することに役立つ. 
 #  
 #  [XS1|YS1|ZS1] = [ (XS1+2)&0xfffc | (YS1+2)&0xfffc | (YS1+2)&0xfffc ]
 #  [XS2|YS2|ZS2] = [ (XS2+2)&0xfffc | (YS2+2)&0xfffc | (YS2+2)&0xfffc ]
 #
 #-YASU
.name	voutp2,	$10
		vadd	yscr12i, scrn12i,  vconst[2]
#if	(defined(PERSPTXTR) && !defined(DIRECTZCMP))
	addi	voutp2, voutp, -RSP_PTS_LEN	# RSP_PTS_LEN の 8 の非倍数対策
						# Offset が 64 を超えないよう
#endif
	vge	scrn12i, scrn12i, rej12[0h]
#ifdef	PERSPTXTR
		ssv	invWi[6], (-4*RSP_PTS_LEN+RSP_PTS_INVW_INT)(voutp)
#endif
		vadd	yscr34i, scrn34i,  vconst[2]
		beq	tmp, zero, roundVertex
	vge	scrn34i, scrn34i, rej12[2h]
		
 #-YASU
 #
 #  フォグ計算を行なう
 #
 #-YASU
	vmudn	persp12f, persp12f, vtmp[0]
	vmadh	persp12i, persp12i, vtmp[0]
	vmudn	persp34f, persp34f, vtmp[0]
	vmadh	persp34i, persp34i, vtmp[0]
	/* Delay-V */
	vadd	persp12i, persp12i, vtmp[1]
	vadd	persp34i, persp34i, vtmp[1]
	/* Delay-V */
	/* Delay-V */
	vge	persp12i, persp12i, vconst[0]	
	vge	persp34i, persp34i, vconst[0]	
	/* Delay-V */
	/* Delay-V */
	vlt	persp12i, persp12i, vtmp[2]
	sw	clr2, (-4*RSP_PTS_LEN+RSP_PTS_XS+0)(voutp)
	vlt	persp34i, persp34i, vtmp[2]
	sw	clr3, (-4*RSP_PTS_LEN+RSP_PTS_XS+4)(voutp)
	/* Delay-V */
	/* Delay-V */
#ifndef	DIRECTZCMP
#ifdef	PERSPTXTR
	# LX_REJ の場合 -4*RSP_PTS_LEN+RSP = -80 < -64 となるので問題
	sbv	persp12i[5], (-3*RSP_PTS_LEN+RSP_PTS_R_NX+3)(voutp2)
	sbv	persp12i[13],(-3*RSP_PTS_LEN+RSP_PTS_XS+3)(voutp2)
	sbv	persp34i[5], (-3*RSP_PTS_LEN+RSP_PTS_XS+7)(voutp2)
#else
	sbv	persp12i[5], (-4*RSP_PTS_LEN+RSP_PTS_R_NX+3)(voutp)
	sbv	persp12i[13],(-4*RSP_PTS_LEN+RSP_PTS_XS+3)(voutp)
	sbv	persp34i[5], (-4*RSP_PTS_LEN+RSP_PTS_XS+7)(voutp)
#endif
#else
	addi	voutp2, voutp, -RSP_PTS_LEN*4
	sbv	persp12i[5], (RSP_PTS_R_NX+3)(voutp2)
	sbv	persp12i[13],(RSP_PTS_XS+3)(voutp2)
	sbv	persp34i[5], (RSP_PTS_XS+7)(voutp2)	
#endif
	lw	clr2, (-4*RSP_PTS_LEN+RSP_PTS_XS+0)(voutp)
	sw	clr4, (-4*RSP_PTS_LEN+RSP_PTS_XS+0)(voutp)
	lw	clr3, (-4*RSP_PTS_LEN+RSP_PTS_XS+4)(voutp)
#ifndef	DIRECTZCMP
# ifdef	PERSPTXTR
	sbv	persp34i[13],(-3*RSP_PTS_LEN+RSP_PTS_XS+3)(voutp2)
# else
	sbv	persp34i[13],(-4*RSP_PTS_LEN+RSP_PTS_XS+3)(voutp)
# endif
#else
	sbv	persp34i[13],(RSP_PTS_XS+3)(voutp2)
#endif
	lw	clr4, (-4*RSP_PTS_LEN+RSP_PTS_XS+0)(voutp)
roundVertex:	
		vand	yscr12i, yscr12i, vconst1[5]
		vand	yscr34i, yscr34i, vconst1[5]
	
 #-YASU
 #  
 # 座標データを頂点バッファへ出力する
 #
 #  voutp[0..7] = [ XS1 | YS1 | ZS1 | ZSF1 ] 
 #  voutp[0..7] = [ XS2 | YS2 | ZS2 | ZSF2 ]
 #  
 #-YASU
	# 頂点 1
 	sdv	scrn12i[0],  (-4*RSP_PTS_LEN+RSP_PTS_XS  )(voutp)
 	ssv	scrn12f[4],  (-4*RSP_PTS_LEN+RSP_PTS_ZSF )(voutp)
	bltz	i, xfm_done
  	ssv	yscr12i[2],  (-4*RSP_PTS_LEN+RSP_PTS_YS  )(voutp)
		
	# 頂点 2
	slv	st12[8],     (-3*RSP_PTS_LEN+RSP_PTS_S   )(voutp)
#if	(defined(PERSPTXTR)&&!defined(DIRECTZCMP))
 	sdv	scrn12i[8],  (-2*RSP_PTS_LEN+RSP_PTS_XS  )(voutp2) # 注意
#else
 	sdv	scrn12i[8],  (-3*RSP_PTS_LEN+RSP_PTS_XS  )(voutp)
#endif
#ifdef DIRECTZCMP
	sh	Wint2,       (-3*RSP_PTS_LEN+RSP_PTS_W_INT)(voutp)
#endif
#ifdef	PERSPTXTR
	ssv	invWi[14],   (-3*RSP_PTS_LEN+RSP_PTS_INVW_INT)(voutp)
	ssv	invWf[14],   (-3*RSP_PTS_LEN+RSP_PTS_INVW_FRAC)(voutp)
#endif
 	ssv	scrn12f[12], (-3*RSP_PTS_LEN+RSP_PTS_ZSF )(voutp)
	ssv	yscr12i[10], (-3*RSP_PTS_LEN+RSP_PTS_YS  )(voutp)
	blez	i, xfm_done
	sw	clr2,        (-3*RSP_PTS_LEN+RSP_PTS_R_NX)(voutp)
	addi	i, i, -2

	# 頂点 3
	slv	st34[0],     (-2*RSP_PTS_LEN+RSP_PTS_S   )(voutp)
 	sdv	scrn34i[0],  (-2*RSP_PTS_LEN+RSP_PTS_XS  )(voutp)
#ifdef	PERSPTXTR
	ssv	invWi[4],    (-2*RSP_PTS_LEN+RSP_PTS_INVW_INT)(voutp)
	ssv	invWf[4],    (-2*RSP_PTS_LEN+RSP_PTS_INVW_FRAC)(voutp)
#endif
#ifdef	DIRECTZCMP
	sh	Wint3,       (-2*RSP_PTS_LEN+RSP_PTS_W_INT)(voutp)
#endif
 	ssv	scrn34f[4],  (-2*RSP_PTS_LEN+RSP_PTS_ZSF )(voutp)
	ssv	yscr34i[2],  (-2*RSP_PTS_LEN+RSP_PTS_YS  )(voutp)
	bltz	i, xfm_done
	sw	clr3,        (-2*RSP_PTS_LEN+RSP_PTS_R_NX)(voutp)
	
	# 頂点 4
	slv	st34[8],     (-1*RSP_PTS_LEN+RSP_PTS_S   )(voutp)
#if	(defined(PERSPTXTR)&&!defined(DIRECTZCMP))
 	sdv	scrn34i[8],  ( 0*RSP_PTS_LEN+RSP_PTS_XS  )(voutp2) # 注意
#else
	sdv	scrn34i[8],  (-1*RSP_PTS_LEN+RSP_PTS_XS  )(voutp)
#endif
#ifdef	PERSPTXTR
	ssv	invWi[12],   (-1*RSP_PTS_LEN+RSP_PTS_INVW_INT)(voutp)
	ssv	invWf[12],   (-1*RSP_PTS_LEN+RSP_PTS_INVW_FRAC)(voutp)
#endif
#ifdef	DIRECTZCMP
	sh	Wint4,       (-1*RSP_PTS_LEN+RSP_PTS_W_INT)(voutp)
#endif
 	ssv	scrn34f[12], (-1*RSP_PTS_LEN+RSP_PTS_ZSF )(voutp)
	ssv	yscr34i[10], (-1*RSP_PTS_LEN+RSP_PTS_YS  )(voutp)
	bgtz	i, xfm_loop
	sw	clr4,        (-1*RSP_PTS_LEN+RSP_PTS_R_NX)(voutp)

	# transform normals and shade


.unname gmode

.unname v0
.unname voutp
.unname tmp
.unname lighton
.unname i
.unname clr2
.unname clr3
.unname clr4
.unname voutp2

#ifdef	DIRECTZCMP
.unname	Wint2
.unname	Wint3
.unname	Wint4
#endif
	
.unname mtx0
.unname mtx1
.unname mtx2
.unname mtx3
.unname mtf0
.unname mtf1
.unname mtf2
.unname mtf3
.unname vpscale
.unname vptrans
.unname txtscale
.unname vtmp

.unname rej12
.unname rej34
.unname st12
.unname vin12
.unname persp12i
.unname persp12f
.unname scrn12i
.unname scrn12f
.unname yscr12i
.unname yscr34i

.unname st34
.unname vin34
.unname persp34i
.unname persp34f
.unname scrn34i
.unname scrn34f
.unname	invWi
.unname	invWf

 #
 #
 #
 ############################################################################