gxsetup_ex.s
20.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
/*---------------------------------------------------------------------*
Copyright (C) 1997, Nintendo.
File gxsetup_ex.s
Coded by Yoshitaka Yasumoto. Dec 5, 1997.
$Id: gxsetup_ex.s,v 1.1.1.1 2002/05/02 03:29:11 blythe Exp $
*---------------------------------------------------------------------*/
#!Reserved (0,11,12,22,23,24,25,26,27,31)
#!Reserved (v0,v1,v29,v30,v31)
#ifdef QUAD
#---------------------------------------------------------------------
# caseEX_G_QUAD
#
# 4 角形を 2 つの 3 角形に分割してを描画する. このとき RDRAM
# へのアクセスがなるべく減るように分割方向を変更する.
# GBI には 2TRI とコンパチの形式で頂点が設定されているため
# そのまま 2TRI として描画が可能. この場合対角線 0-2 で切れる
# +------------+------------+------------+------------+
# | G_QUAD | v0*2 | v1*2 | v2*2 |
# +------------+------------+------------+------------+
# | | v0*2 | v2*2 | v3*2 |
# +------------+------------+------------+------------+
#---------------------------------------------------------------------
caseEX_G_QUAD:
FixedAssign(v1, 1)
FixedAssign(v2, 2)
FixedAssign(v3, 3)
FixedAssign(v0, 4) # Acts as flat
Assign(y0, 5)
Assign(y1, 6)
Assign(y2, 7)
Assign(y3, 8)
lbu v0, RSP_DLINPUT_BOTTOM-7(dinp)
lbu v2, RSP_DLINPUT_BOTTOM-5(dinp)
lbu v1, RSP_DLINPUT_BOTTOM-6(dinp)
lbu v3, RSP_DLINPUT_BOTTOM-1(dinp)
lhu v0, RSP_SUBMOD_POINTS(v0)
lhu v2, RSP_SUBMOD_POINTS(v2)
lhu v1, RSP_SUBMOD_POINTS(v1)
lhu v3, RSP_SUBMOD_POINTS(v3)
lh y0, oRSP_POINT_YS(v0)
lh y2, oRSP_POINT_YS(v2)
lh y1, oRSP_POINT_YS(v1)
lh y3, oRSP_POINT_YS(v3)
sub sys0, y0, y2
bgtz sys0, EXQUAD_0
sub sys1, y1, y3
sub sys0, zero, sys0
EXQUAD_0: bgtz sys1, EXQUAD_1
sb gfx1, RSP_DLINPUT_BOTTOM-5(dinp)
sub sys1, zero, sys1
EXQUAD_1: sub sys0, sys0, sys1
blez sys0, caseEX_G_TRI2 # 対角線0-2 が短いならJump
EndAssign(y0, 5)
EndAssign(y1, 6)
EndAssign(y2, 7)
EndAssign(y3, 8)
FixedAssign(vptr, v2)
FixedAssign(quart, v3)
FixedAssign(vtx1, v4)
#------ 0-1-3, 1-2-3 で分割 ------
mtc2 v1, vptr[10] # Delay
lw gfx0, RSP_DLINPUT_BOTTOM-8(dinp) # 0-1-3
mtc2 v2, vtx1[12] vor quart, vzero, _0x4000
mtc2 v3, vptr[14]
j Setup_EX_Clipped
_li (return, caseEX_G_TRI1)
EndAssign(v1, 1)
EndAssign(v2, 2)
EndAssign(v3, 3)
EndAssign(v0, 4)
EndAssign(vptr, v2)
EndAssign(quart, v3)
EndAssign(vtx1, v4)
#else
.symbol caseEX_G_QUAD, caseEX_G_TRI2
#endif
#---------------------------------------------------------------------
# caseEX_G_TRI[1/2]
#
# 2 つの 3 角形を描画する. もし 1 つしか描画する必要がないなら
# gfx1(w0,w1,w2) に 0 を代入する.
# +------------+------------+------------+------------+
# | G_TRI | v0*2 | v1*2 | v2*2 |
# +------------+------------+------------+------------+
# | | w0*2 | w1*2 | w2*2 |
# +------------+------------+------------+------------+
#
#---------------------------------------------------------------------
FixedAssign(clipbuf, 18) /* Clipping 処理時に使用する */
FixedAssign(obufp, 21) /* Clipping 処理時に使用する */
FixedAssign(return_save, 30) /* Clipping 処理時に使用する */
caseEX_G_TRI2:
jal Setup_EX
sw gfx1, 4(outp)
caseEX_G_TRI1:
_li (return, GfxDone)
sw gfx0, 4(outp)
#---------------------------------------------------------------------
# 頂点キャッシュへのポインタの取得
#---------------------------------------------------------------------
# アトリビュートデータの小数部の初期化
# [0]〜[3]=0x8000 を代入
#---------------------------------------------------------------------
Setup_EX:
FixedAssign(vptr, v2) # gxclip_ex.s で共用
lpv vptr[0], 0(outp)
FixedAssign(v0, 1)
lbu v0, 5(outp)
FixedAssign(v1, 2)
FixedAssign(quart, v3) # gxclip_ex.s で共用
lbu v1, 6(outp)
FixedAssign(v2, 3)
FixedAssign(vtx1, v4) # gxclip_ex.s で共用
lbu v2, 7(outp) vor quart, vzero, _0x4000
FixedAssign(flat, 4)
lhu v0, RSP_SUBMOD_POINTS(v0) vmudn vtx1, vone, _TopOfPoints
lhu v1, RSP_SUBMOD_POINTS(v1) vmadl vptr, vptr, _0x1400
Assign(aminf, v5)
lhu v2, RSP_SUBMOD_POINTS(v2) vmadn vtx1, vzero, _0x0000
_mov (flat, v0) /*Resv*/
#---------------------------------------------------------------------
# Clip Code の取得 Reject/Clip 判定
# 3 頂点が画面外にあることが確定したら終了
# 3 頂点の 1 つがクリップボックス外なら CLIP 処理へ
#---------------------------------------------------------------------
# 外積値の計算による裏表判定
# CULL フラグと考え合わせ, CULLing する.
#---------------------------------------------------------------------
# y ソート
# 3 頂点を y 座標をキーにしてソートする
#---------------------------------------------------------------------
Assign(vtx0, v6)
Assign(amidf, v7)
Setup_EX_Clipped:
/*Resv*/ vnxor aminf, vzero, _0x7fff
llv vtx0[0], oRSP_POINT_XS(v0) vnxor amidf, vzero, _0x7fff
llv vtx1[0], oRSP_POINT_XS(v1) vmov vtx0[6], vptr[5]
Assign(vtx2, v8)
Assign(amaxf, v9)
llv vtx2[0], oRSP_POINT_XS(v2) vnxor amaxf, vzero, _0x7fff
Assign(cc0, 5)
lw cc0, oRSP_POINT_CC(v0) vmov vtx2[6], vptr[7]
EndAssign(vptr, v2)
Assign(ymax, v2)
Assign(cc1, 6)
lw cc1, oRSP_POINT_CC(v1) vadd ymax, vzero, vtx0[1]
Assign(cc2, 7)
Assign(v01, v10)
lw cc2, oRSP_POINT_CC(v2) vsub v01, vtx0, vtx1
Assign(v10, v11)
#ifdef NEARCLIP_OFF
andi sys0, cc0, 0x70b0 vsub v10, vtx1, vtx0
#else
andi sys0, cc0, 0x7070 vsub v10, vtx1, vtx0
#endif
Assign(v02, v12)
and sys0, cc1, sys0 vsub v02, vtx0, vtx2
Assign(ymin, v13)
and sys0, cc2, sys0 vlt ymin, ymax, vtx1[1]
Assign(vmin, v14)
vmrg vmin, vtx0, vtx1 bne sys0, zero, ReturnToR31 # Reject 処理
/* Delay */ lbu sys0, RSP_LSTAT_RENDER+2(zero)
# CLIPTEST の値は gxclip_ex で書換えられる
vmudh vtmp, v01, v02[1] lw sys1, RSP_SUBMOD_EX_CLIPTEST(zero) # 0x30304040
EndAssign(v01, v10)
vmadh vtmp, v02, v10[1] or cc0, cc0, cc1
EndAssign(cc1, 6)
EndAssign(v10, v11)
EndAssign(v02, v12)
vge ymax, ymax, vtx1[1] or cc0, cc0, cc2
EndAssign(cc2, 7)
Assign(vmax, v10)
vmrg vmax, vtx0, vtx1 lw sys0, RSP_SUBMOD_EX_CULL(sys0) # CULL 判定値取得
EndAssign(vtx0, v6)
Assign(ymid, v6)
Assign(flag, 6)
vge ymid, ymin, vtx2[1] mfc2 flag, vtmp[0] # sign の値は -0x8000〜+0x7fff
EndAssign(ymin, v13)
vmrg vtx1, vmin, vtx2 and cc0, cc0, sys1
vmrg vmin, vtx2, vmin bne cc0, zero, caseEX_Clipping # Clip 処理
EndAssign(cc0, 5)
EndAssign(vtx2, v8)
/* Delay */ add sys0, flag, sys0
vlt ymid, ymid, ymax bgez sys0, ReturnToR31 # CULL 処理
EndAssign(ymid, v6)
EndAssign(ymax, v2)
Assign(vmid, v2)
vmrg vmid, vtx1, vmax /* Delay */
vmrg vmax, vmax, vtx1 mfc2 v0, vmin[12]
EndAssign(vtx1, v4)
Assign(yf, v4)
vmudn yf, vmin, _0x4000 beq flag, zero, ReturnToR31 # 外積値=0
/*Any*/ /* Delay */
#---------------------------------------------------------------------
# y ソート結果取得
# 頂点キャッシュへのポインタを再設定
#---------------------------------------------------------------------
# 外積値 r の再計算
# r[1] = vHx*vMy - vMx*vHy = vHx*vMy + vHx*vMy_r
#---------------------------------------------------------------------
# 1/r の値を Newton 法で求める (1)
# vrcph/l で求めるのは 1/2X の値. (R=1/X)
# 1/X = R*(2-R*X) = R/2*(4+R/2*X*(-4))
#---------------------------------------------------------------------
# Flat Shading と Smooth Shading の処理を行なう.
# Flat のときは RGBA 値に同じ値を代入する.
# Flat を使用しても FOG が使用できるようにするため,
# A 値は別に代入する.
#---------------------------------------------------------------------
Assign(vM, v6)
vsub vM, vmid, vmin mfc2 v1, vmid[12]
Assign(vH, v8)
vsub vH, vmax, vmin mfc2 v2, vmax[12]
Assign(vMr, v11)
vsub vMr, vmin, vmid lw flag, RSP_LSTAT_RENDER(zero)
Assign(vHr, v12)
Assign(invWi, v13)
vsub vHr, vmin, vmax llv invWi[0], oRSP_POINT_INVWI(v0)
Assign(vL, v15)
vsub vL, vmax, vmid llv invWi[8], oRSP_POINT_INVWI(v1)
Assign(rf, v16)
vmudh rf, vM, vH[0] llv invWi[12],oRSP_POINT_INVWI(v2)
vmadh rf, vH, vMr[0] sll sys0, flag, 10 # G_SHADING_SMOOTH=0x00200000
Assign(ri, v17)
vsar ri, ri, ri[0] bgez sys0, setupEX_flat
vsar rf, rf, rf[1] /* Delay */
# Smooth Shading
Assign(amin, v18)
lpv amin[0], oRSP_POINT_R(v0) vmov vL[2], vM[0]
Assign(amid, v19)
Assign(invDyf, v20)
lpv amid[0], oRSP_POINT_R(v1) vrcp invDyf[0], vL[1]
Assign(amax, v21)
Assign(invDyi, v22)
lpv amax[0], oRSP_POINT_R(v2) vrcph invDyi[0], ri[1]
Assign(invrf, v23)
vrcpl invrf[1], rf[1] j setupEX_1
Assign(invri, v24)
vrcph invri[1], _0x0000 /* Delay */
# Flat Shading
setupEX_flat:
#ifndef FOG_COMPATIBLE
lpv amin[0], oRSP_POINT_R(flat) vrcp invDyf[0], vL[1]
lbv amin[6], oRSP_POINT_A(v0) vrcph invDyi[0], ri[1]
lpv amid[0], oRSP_POINT_R(flat) vrcpl invrf[1], rf[1]
lbv amid[6], oRSP_POINT_A(v1) vrcph invri[1], _0x0000
lpv amax[0], oRSP_POINT_R(flat) vmov vL[2], vM[0]
lbv amax[6], oRSP_POINT_A(v2) /*Resvd */
#else
lpv amin[0], oRSP_POINT_R(flat) vrcp invDyf[0], vL[1]
lpv amid[0], oRSP_POINT_R(flat) vrcph invDyi[0], ri[1]
lpv amax[0], oRSP_POINT_R(flat) vrcpl invrf[1], rf[1]
/*S*/ vrcph invri[1], _0x0000
/*S*/ vmov vL[2], vM[0]
/*S*/ /*Resvd*/
#endif
#---------------------------------------------------------------------
# W 値の最小値を求める Texture の補正処理に使用する
#---------------------------------------------------------------------
# 1/dy を計算し, dx/dy を求める (1)
#---------------------------------------------------------------------
setupEX_1:
vrcp invDyf[2], vM[1] /*Resvd*/
Assign(iw0, 5)
vrcph invDyi[2], vM[1] lw iw0, oRSP_POINT_INVWI(v0)
Assign(iw1, 7)
vrcp invDyf[3], vH[1] lw iw1, oRSP_POINT_INVWI(v1)
Assign(iw2, 8)
vrcph invDyi[3], vH[1] lw iw2, oRSP_POINT_INVWI(v2)
Assign(txflag, 9)
vmudl amin, amin, _0x0100 lbu txflag, RSP_LSTAT_TEX_ENABLE(zero)
vmudl amid, amid, _0x0100 sub sys0, iw0, iw1
EndAssign(iw1, 7)
vmudl amax, amax, _0x0100 sra sys1, sys0, 31
vmov vL[3], vH[0] and sys0, sys0, sys1
#define DEBUG_207
#ifdef DEBUG_207
vmudl vtmp, invDyf, _0x0020 sub iw0, iw0, sys0
vmadm invDyi, invDyi, _0x0020 sub sys0, iw0, iw2
#else
vmudl vtmp, invDyf, _0x0008 sub iw0, iw0, sys0
vmadm invDyi, invDyi, _0x0008 sub sys0, iw0, iw2
#endif
EndAssign(iw2, 8)
vmadn invDyf, vzero, _0x0000 sra sys1, sys0, 31
Assign(Dxi, v25)
#ifdef DEBUG_207
vmudm Dxi, vL, _0x1000 and sys0, sys0, sys1
#else
vmudm Dxi, vL, _0x4000 and sys0, sys0, sys1
#endif
EndAssign(vL, v15)
Assign(Dxf, v15)
vmadn Dxf, vzero, _0x0000 sub iw0, iw0, sys0
#---------------------------------------------------------------------
# サブピクセル値を計算する
#---------------------------------------------------------------------
vsubc yf, vzero, yf sw iw0, 16(outp)
EndAssign(iw0, 5)
Assign(yi, v26)
Assign(nearWi, v27)
vsub yi, vzero, vzero llv nearWi[0], 16(outp)
#---------------------------------------------------------------------
# 1/dy を計算し, dx/dy を求める (2)
#---------------------------------------------------------------------
Assign(major, 5)
vmudm vtmp, Dxi, invDyf mfc2 major, ri[1] /*L/R major判定用*/
Assign(tile, 7)
vmadl vtmp, Dxf, invDyf lbu tile, RSP_LSTAT_TEX_TILE(zero)
EndAssign(invDyf, v20)
Assign(DxDyf, v20)
vmadn DxDyf, Dxf, invDyi lsv amid[14], oRSP_POINT_ZS(v1)
EndAssign(Dxf, v15)
Assign(DxDyi, v15)
vmadh DxDyi, Dxi, invDyi /*[0|2|3]=[L|M|H]*/ lsv amax[14], oRSP_POINT_ZS(v2)
EndAssign(Dxi, v25)
EndAssign(invDyi, v22)
#---------------------------------------------------------------------
# 1/r の値を Newton 法で求める (2)
#---------------------------------------------------------------------
vmudl vtmp, invrf, rf lsv amidf[14], oRSP_POINT_ZSF(v1)
vmadm vtmp, invri, rf lsv amaxf[14], oRSP_POINT_ZSF(v2)
vmadn rf, invrf, ri ori sys0, flag, G_TRI_FILL
vmadh ri, invri, ri or sys0, sys0, txflag
#ifdef DEBUG_207
Assign(tDxDyf, v22)
vand tDxDyf, DxDyf, _0xfff8 /*S*/
vcr DxDyi, DxDyi, _0x0100 /*必要?*/ sb sys0, 0(outp)
#else
vcr DxDyi, DxDyi, _0x01cc /*必要?*/ sb sys0, 0(outp)
#endif
vmudh vtmp, vone, _0x0010 ssv vmax[2], 2(outp)
EndAssign(vmax, v10)
vmadn rf, rf, _0xfff0 ssv vmid[2], 4(outp)
EndAssign(vmid, v2)
vmadh ri, ri, _0xfff0 ssv vmin[2], 6(outp)
#---------------------------------------------------------------------
# XM,XH のサブピクセル計算
#---------------------------------------------------------------------
vmudn vtmp, quart, vmin[0] andi sys1, major, 0x80
EndAssign(major, 5)
EndAssign(vmin, v14)
EndAssign(quart, v3)
#ifdef DEBUG_207
vmadl vtmp, tDxDyf, yf[1] or sys1, sys1, tile
EndAssign(tile, 7)
vmadm vtmp, DxDyi, yf[1] sb sys1, 1(outp)
Assign(xf, v2)
vmadn xf, tDxDyf, yi[1] beq txflag, zero, setupEX_noTxtr
EndAssign(tDxDyf, v22)
#else
vmadl vtmp, DxDyf, yf[1] or sys1, sys1, tile
EndAssign(tile, 7)
vmadm vtmp, DxDyi, yf[1] sb sys1, 1(outp)
Assign(xf, v2)
vmadn xf, DxDyf, yi[1] beq txflag, zero, setupEX_noTxtr
#endif
Assign(xi, v3)
vmadh xi, DxDyi, yi[1] /* Delay */
#---------------------------------------------------------------------
# Texture On 時の処理
#---------------------------------------------------------------------
vrcph vtmp[0], nearWi[0]
Assign(nearWf, v10)
vrcpl nearWf[0], nearWi[1]
Assign(invWf, v14)
vadd invWf, vzero, invWi[1q]
vrcph nearWi[0], _0x0000
Assign(stw01i, v22)
vor stw01i, vzero, _0x7fff
vmudm vtmp, invWi, nearWf[0]
vmadl vtmp, invWf, nearWf[0] llv stw01i[0], oRSP_POINT_S(v0)
EndAssign(nearWf, v10)
vmadn invWf, invWf, nearWi[0] llv stw01i[8], oRSP_POINT_S(v1)
vmadh invWi, invWi, nearWi[0]
EndAssign(nearWi, v27)
Assign(stw2_i, v10)
vor stw2_i, vzero, _0x7fff
vge vtmp, vconst1,vconst1[7] /*[4|5|6]移動*/ llv stw2_i[8], oRSP_POINT_S(v2)
EndAssign(v2, 3)
vmudm vtmp, stw01i, invWf[0h]
vmadh stw01i, stw01i, invWi[0h]
Assign(stw01f, v25)
vmadn stw01f, vzero, _0x0000
vmudm vtmp, stw2_i, invWf[6]
EndAssign(invWf, v14)
vmadh stw2_i, stw2_i, invWi[6]
EndAssign(invWi, v13)
Assign(stw2_f, v13)
vmadn stw2_f, vzero, _0x0000 sdv stw01i[0], 32+0(outp)
vmrg amid, amid, stw01i /*S で置換可*/ sdv stw01f[0], 32+8(outp)
EndAssign(stw01i, v22)
vmrg amidf, amidf, stw01f ldv amin[8], 32+0(outp)
EndAssign(stw01f, v25)
vmrg amax, amax, stw2_i ldv aminf[8], 32+8(outp)
EndAssign(stw2_i, v10)
vmrg amaxf, amaxf, stw2_f
EndAssign(stw2_f, v13)
#---------------------------------------------------------------------
# 1/r の値を Newton 法で求める (3)
#---------------------------------------------------------------------
setupEX_noTxtr:
vmudl vtmp, rf, invrf lsv aminf[14], oRSP_POINT_ZSF(v0)
vmadm vtmp, ri, invrf lsv amin[14], oRSP_POINT_ZS(v0)
EndAssign(v0, 1)
Assign(xL, 1)
vmadn invrf, rf, invri lh xL, oRSP_POINT_XS(v1) # xL
EndAssign(v1, 2)
EndAssign(rf, v16)
Assign(soutp, 2)
vmadh invri, ri, invri addiu soutp, outp, 32
EndAssign(ri, v17)
#---------------------------------------------------------------------
# DaH,DaM を求める
#---------------------------------------------------------------------
Assign(shflag, 3)
Assign(DaHf, v10)
vsubc DaHf, amaxf, aminf andi shflag, flag, G_RDP_TRI_SHADE_MASK
EndAssign(amaxf, v9)
Assign(DaHi, v9)
vsub DaHi, amax, amin sll xL, xL, 14
EndAssign(amax, v21)
Assign(DaMf, v13)
vsubc DaMf, amidf, aminf sw xL, 8(outp)
EndAssign(amidf, v7)
EndAssign(xL, 1)
Assign(DaMi, v7)
vsub DaMi, amid, amin ssv xi[6], 16(outp) # xH
EndAssign(amid, v19)
#---------------------------------------------------------------------
# DaDx を求める (1)
# DaDx = DyM * DaH - DyH * DaM
#---------------------------------------------------------------------
vmudn vtmp, DaHf, vM[1] ssv xf[6], 18(outp) # xH.frac
vmadh vtmp, DaHi, vM[1] ssv xi[4], 24(outp) # xM
EndAssign(vM, v6)
EndAssign(xi, v3)
vmadn vtmp, DaMf, vHr[1] ssv xf[4], 26(outp) # xM.frac
EndAssign(xf, v2)
vmadh vtmp, DaMi, vHr[1] ssv DxDyi[0], 12(outp)
EndAssign(vHr, v12)
Assign(DaDxf, v2)
vsar DaDxf, DaDxf, DaDxf[1] ssv DxDyf[0], 14(outp)
Assign(DaDxi, v3)
vsar DaDxi, DaDxi, DaDxi[0] ssv DxDyi[6], 20(outp)
#---------------------------------------------------------------------
# DaDy を求める (1)
# DaDy = DxH * DaM - DxM * DaH
#---------------------------------------------------------------------
vmudn vtmp, DaMf, vH[0] ssv DxDyf[6], 22(outp)
EndAssign(DaMf, v13)
vmadh vtmp, DaMi, vH[0] ssv DxDyi[4], 28(outp)
EndAssign(DaMi, v7)
EndAssign(vH, v8)
vmadn vtmp, DaHf, vMr[0] ssv DxDyf[4], 30(outp)
EndAssign(DaHf, v10)
vmadh vtmp, DaHi, vMr[0] sll sys0, shflag, 4
EndAssign(DaHi, v9)
EndAssign(shflag, 3)
EndAssign(vMr, v11)
Assign(toutp, 1)
Assign(DaDyf, v6)
vsar DaDyf, DaDyf, DaDyf[1] add toutp, soutp, sys0
Assign(DaDyi, v7)
vsar DaDyi, DaDyi, DaDyi[0] sll sys0, txflag, 5
EndAssign(txflag, 9)
#---------------------------------------------------------------------
# DaDx を求める (2)
# DaDx = DaDx / r
#---------------------------------------------------------------------
vmudl vtmp, DaDxf, invrf[1] add outp, toutp, sys0
vmadm vtmp, DaDxi, invrf[1] andi flag, flag, G_RDP_TRI_ZBUFF_MASK
vmadn DaDxf, DaDxf, invri[1] sll sys0, flag, 4
vmadh DaDxi, DaDxi, invri[1] add outp, outp, sys0
#---------------------------------------------------------------------
# DaDy を求める (2)
# DaDy = DaDy / r
#---------------------------------------------------------------------
vmudl vtmp, DaDyf, invrf[1]
vmadm vtmp, DaDyi, invrf[1]
EndAssign(invrf, v23)
vmadn DaDyf, DaDyf, invri[1] sdv DaDxf[0], 24(soutp)
vmadh DaDyi, DaDyi, invri[1] sdv DaDxi[0], 8(soutp)
EndAssign(invri, v24)
#---------------------------------------------------------------------
# DaDe を求める
# DaDe = DaDy + DaDx * DxDyH (ACC = DaDy)
#---------------------------------------------------------------------
vmadl vtmp, DaDxf, DxDyf[3] sdv DaDxf[8], 24(toutp)
vmadm vtmp, DaDxi, DxDyf[3] sdv DaDxi[8], 8(toutp)
EndAssign(DxDyf, v20)
Assign(DaDef, v8)
vmadn DaDef, DaDxf, DxDyi[3] sdv DaDyf[0], 56(soutp)
Assign(DaDei, v9)
vmadh DaDei, DaDxi, DxDyi[3] sdv DaDyi[0], 40(soutp)
EndAssign(DxDyi, v15)
#---------------------------------------------------------------------
# Attr 値のサブピクセル計算
# a = a - (DaDe * yf)
#---------------------------------------------------------------------
vmudn vtmp, aminf, _0x0001 sdv DaDyf[8], 56(toutp)
vmadh vtmp, amin, _0x0001 sdv DaDyi[8], 40(toutp)
vmadl vtmp, DaDef, yf[1] sdv DaDef[0], 48(soutp)
vmadm vtmp, DaDei, yf[1] sdv DaDei[0], 32(soutp)
vmadn aminf, DaDef, yi[1] sdv DaDef[8], 48(toutp)
vmadh amin, DaDei, yi[1] sdv DaDei[8], 32(toutp)
EndAssign(yi, v26)
Assign(aminff, v10)
#---------------------------------------------------------------------
# Z 値のスケーリング
#---------------------------------------------------------------------
vmudn aminff,DaDef, yf[1] beq flag, zero, setupEX_nonZ
EndAssign(yf, v4)
EndAssign(flag, 6)
vmudn DaDef, DaDef, _0x0020 /* Delay */
vmadh DaDei, DaDei, _0x0020 sdv aminf[0], 16(soutp)
vmudn DaDxf, DaDxf, _0x0020 sdv amin[0], 0(soutp)
vmadh DaDxi, DaDxi, _0x0020 sdv aminf[8], 16(toutp)
vmudn DaDyf, DaDyf, _0x0020 sdv amin[8], 0(toutp)
vmadh DaDyi, DaDyi, _0x0020 ssv DaDef[14], 10-16(outp)
EndAssign(DaDef, v8)
vmudl vtmp, aminff,_0x0020 ssv DaDei[14], 8-16(outp)
EndAssign(aminff, v10)
EndAssign(DaDei, v9)
vmadn aminf, aminf, _0x0020 ssv DaDxf[14], 6-16(outp)
EndAssign(DaDxf, v2)
vmadh amin, amin, _0x0020 ssv DaDxi[14], 4-16(outp)
EndAssign(DaDxi, v3)
ssv DaDyf[14], 14-16(outp)
EndAssign(DaDyf, v6)
ssv DaDyi[14], 12-16(outp)
EndAssign(DaDyi, v7)
ssv aminf[14], 2-16(outp)
j OutputClose
ssv amin[14], 0-16(outp)
setupEX_nonZ: sdv aminf[0], 16(soutp)
sdv amin[0], 0(soutp)
EndAssign(soutp, 2)
sdv aminf[8], 16(toutp)
EndAssign(aminf, v5)
j OutputClose
sdv amin[8], 0(toutp)
EndAssign(toutp, 1)
EndAssign(amin, v18)
EndAssign(clipbuf, 18) /* Clipping 処理時に使用する */
EndAssign(obufp, 21) /* Clipping 処理時に使用する */
EndAssign(return_save, 30) /* Clipping 処理時に使用する */
EndAssign(flat, 4)
#---------------------------------------------------------------------
# caseEX_G_LINE3D
# 実装しない
#---------------------------------------------------------------------
.symbol caseEX_G_LINE3D, GfxDone
/*======== End of gxsetup_ex.s ========*/