gxsetup_exrej.s
20.1 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
/*---------------------------------------------------------------------*
Copyright (C) 1998, Nintendo.
File gxsetup_exrej.s
Coded by Yoshitaka Yasumoto. Dec 5, 1997.
$Id: gxsetup_exrej.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)
#---------------------------------------------------------------------
# caseEXRej_G_TRI1
#
# 1 つの 3 角形を描画する.
# 2 TRI の片方の三角形で同じ頂点を指定し, 外積=0 で Reject させる
# +------------+------------+------------+------------+
# | G_TRI1 | v0*2 | v1*2 | v2*2 |
# +------------+------------+------------+------------+
# | | 0 | 0 | 0 |
# +------------+------------+------------+------------+
#
#---------------------------------------------------------------------
caseEXRej_G_TRI1:
sw zero, (RSP_DLINPUT_BOTTOM-4)(dinp)
#---------------------------------------------------------------------
# caseEXRej_G_TRI2
#
# 2 つの 3 角形を描画する. もし 1 つしか描画する必要がないなら
# gfx1(w0,w1,w2) に 0 を代入する.
# +------------+------------+------------+------------+
# | G_TRI | v0*2 | v1*2 | v2*2 |
# +------------+------------+------------+------------+
# | | w0*2 | w1*2 | w2*2 |
# +------------+------------+------------+------------+
#
#---------------------------------------------------------------------
caseEXRej_G_TRI2:
#---------------------------------------------------------------------
# 頂点キャッシュへのポインタの取得
#---------------------------------------------------------------------
# アトリビュートデータの小数部の初期化
# [0]〜[3]=0x8000 を代入
#---------------------------------------------------------------------
# y ソート用データの作成
# vtx0=[v0x|v0y|v0p|-|w0x|w0y|w0p|-]
# vtx1=[v1x|v1y|v1p|-|w1x|w1y|w1p|-]
# vtx2=[v2x|v2y|v2p|-|w2x|w2y|w2p|-]
# ymax=[v0y|v0y|v0y|-|w0y|w0y|w0y|-]
#---------------------------------------------------------------------
Assign(v0, 1)
Assign(v1, 2)
Assign(v2, 3)
Assign(vflat, 4)
Assign(w0, 5)
Assign(w1, 6)
Assign(w2, 7)
Assign(wflat, 8)
Assign(cmask, 9)
Assign(vtx0, v2)
Assign(vtx1, v3)
Assign(vtx2, v4)
Assign(ymin, v5)
Assign(vMr, v6)
Assign(vM, v7)
Assign(aminf, v8)
Assign(amidf, v9)
Assign(amaxf, v10)
addiu sys0, dinp, RSP_DLINPUT_BOTTOM vnxor aminf, vzero, _0x7fff
luv vtx1[0], -8(sys0) vnxor amidf, vzero, _0x7fff
lbu v0, -7(sys0) vnxor amaxf, vzero, _0x7fff
lbu w0, -3(sys0) /*V*/
lbu v1, -6(sys0) vmudn vtx0, vone, _TopOfPoints
lbu w1, -2(sys0) vmadl vtx1, vtx1, _0x1400
lhu v0, RSP_SUBMOD_POINTS(v0) /*V*/
lhu w0, RSP_SUBMOD_POINTS(w0) /*V*/
lhu v1, RSP_SUBMOD_POINTS(v1) /*V*/
lhu w1, RSP_SUBMOD_POINTS(w1) vor vtx0, vzero, vtx1[1h]
llv vtx0[0], oRSP_POINT_XS(v0) vor vtx2, vzero, vtx1[3h]
llv vtx0[8], oRSP_POINT_XS(w0) /*V*/
llv vtx1[0], oRSP_POINT_XS(v1) /*V*/
llv vtx1[8], oRSP_POINT_XS(w1) /*V*/
_mov (vflat, v0) /*V*/
_mov (wflat, w0) vor ymin, vzero, vtx0[1h]
mfc2 v2, vtx2[6] /*V*/
mfc2 w2, vtx2[14] vsub vMr, vtx1, vtx0
lbu cmask, RSP_LSTAT_RENDER_CULL(zero) vsub vM, vtx0, vtx1
EndAssign(w0, 5)
EndAssign(w1, 6)
#---------------------------------------------------------------------
# Clip Code の取得 Reject 判定
# 3 頂点のどれら 1 つが RejectBox 外にあることが確定したら終了
#---------------------------------------------------------------------
# 外積値の計算による裏表判定
# CULL フラグと考え合わせ, CULLing する.
#---------------------------------------------------------------------
# y ソート
# 3 頂点を y 座標をキーにしてソートする
#---------------------------------------------------------------------
Assign(v2y, 5)
Assign(w2y, 6)
Assign(isrej, 10)
Assign(isbak, 13)
Assign(zoutp, 14)
Assign(ymid, v11)
Assign(ymax, v12)
Assign(vH, v13)
Assign(vL, v14)
Assign(vmin, v15)
Assign(vmid, v16)
Assign(vmax, v17)
Assign(vmaxT, v18)
/*Resv*/ vge ymax, ymin, vtx1[1h]
llv vtx2[0], oRSP_POINT_XS(v2) /*Resv*/
llv vtx2[8], oRSP_POINT_XS(w2) vlt ymin, ymin, vtx1[1h]
lh v2y, oRSP_POINT_YS(v2) vmrg vmin, vtx0, vtx1
_mov (zoutp, outp) vmrg vmaxT, vtx1, vtx0
lh w2y, oRSP_POINT_YS(w2) vlt vtmp, ymax, _0x7ffc
cfc2 isrej, $vcc vsub vH, vtx0, vtx2
lhu cmask, RSP_SUBMOD_LXRej_CULLMASK(cmask) vge ymid, ymin, vtx2[1h]
slti v2y, v2y, 0x7ffc vmrg vmid, vmin, vtx2
sll v2y, v2y, 1 vmrg vmin, vtx2, vmin
slti w2y, w2y, 0x7ffc vmudh vtmp, vMr, vH[0h]
sll w2y, w2y, 5 vmadh vM, vH, vM[0h]
or v2y, v2y, w2y vge ymax, ymax, ymid
and isrej, isrej, v2y vmrg vmax, vmaxT, vmid
sll v2y, isrej, 8 vmrg vmid, vmid, vmaxT
or isrej, isrej, v2y vch vM, vM, _0x0001
cfc2 isbak, $vcc vadd vM, vzero, vzero # Clear VCO
mfc2 v0, vmin[4] vsub vH, vmax, vmin
and cmask, cmask, isrej vsub vM, vmid, vmin
and isrej, isbak, cmask vsub vMr, vmin, vmid
/*Resv*/ vsub vL, vmax, vmid
beq isrej, zero, GfxDone /*Resv*/
EndAssign(v2y, 5)
EndAssign(w2y, 6)
EndAssign(w2, 7)
EndAssign(isbak, 13)
EndAssign(cmask, 9)
EndAssign(vmaxT, v18)
EndAssign(ymax, v12)
EndAssign(ymid, v11)
EndAssign(ymin, v5)
EndAssign(vtx0, v2)
EndAssign(vtx1, v3)
EndAssign(vtx2, v4)
#---------------------------------------------------------------------
# y ソート結果取得
# 頂点キャッシュへのポインタを再設定
#---------------------------------------------------------------------
# 外積値 r の再計算
# r[1] = vHx*vMy - vMx*vHy = vHx*vMy + vHx*vMy_r
#---------------------------------------------------------------------
# 1/r, 1/Dx の値をテーブルで求める
# vrcph/l で求めるのは 1/2X の値. (R=1/X)
#---------------------------------------------------------------------
Assign(flag, 5)
Assign(rf, v2)
Assign(ri, v3)
mfc2 v1, vmid[4] /*Delay*/
mfc2 v2, vmax[4] vmudh vtmp, vM, vH[0h]
lw flag, RSP_LSTAT_RENDER(zero) vmadh vtmp, vH, vMr[0h]
andi sys0, isrej, 0x0202 vsar ri, ri, ri[0]
/*Resv*/ vsar rf, rf, rf[1]
beq sys0, zero, setupEXRej_ExchgTri /*Resv*/
#---------------------------------------------------------------------
# TRI 描画ループ地点
# ここ以降で必要な値
# vmin[1|5], vmid[1|5], vmax[1|5]
# v0, v1, v2, vflat, wflat
# vL[0|1|4|5], vM[0|1|4|5], vL[0|1|4|5], vMr[0|4]
# ri[1|5], rf[1|5]
# isrej, flag
#---------------------------------------------------------------------
setupEXRej_TriStart:
Assign(invDyf, v4)
Assign(invDyi, v5)
Assign(vHr, v11)
/*Delay*/ vsub vHr, vmin, vmax
sll sys0, flag, 10 vrcp invDyf[0], vL[1]
/*Resv*/ vrcph invDyi[0], _0x0000
bgez sys0, setupEXRej_flat /*Resv*/
/*Delay*/ vrcp invDyf[2], vM[1]
#---------------------------------------------------------------------
# Smooth Shading
# RGBA を取得する.
#---------------------------------------------------------------------
Assign(amin, v12)
Assign(amid, v18)
Assign(amax, v19)
Assign(invrf, v20)
Assign(invri, v21)
lpv amin[0], oRSP_POINT_R(v0) vrcph invDyi[2], _0x0000
lpv amid[0], oRSP_POINT_R(v1) vrcp invDyf[3], vH[1]
lpv amax[0], oRSP_POINT_R(v2) vrcph invDyi[3], ri[1]
/*Resv*/ vrcpl invrf[1], rf[1]
j setupEXRej_1 /*Resv*/
/*Delay*/ vrcph invri[1], _0x0000
#---------------------------------------------------------------------
# Flat Shading
# Flat のときは RGBA 値に同じ値を代入する.
# Flat を使用しても FOG が使用できるようにするため,
# A 値は別に代入する.
#---------------------------------------------------------------------
setupEXRej_flat:
#ifndef COMPATIBLE
lpv amin[0], oRSP_POINT_R(vflat) vrcph invDyi[2], _0x0000
lbv amin[6], oRSP_POINT_A(v0) vrcp invDyf[3], vH[1]
lpv amid[0], oRSP_POINT_R(vflat) vrcph invDyi[3], ri[1]
lbv amid[6], oRSP_POINT_A(v1) vrcpl invrf[1], rf[1]
lpv amax[0], oRSP_POINT_R(vflat) vrcph invri[1], _0x0000
lbv amax[6], oRSP_POINT_A(v2) /*Resv*/
#else
lpv amin[0], oRSP_POINT_R(vflat) vrcph invDyi[2], _0x0000
lpv amid[0], oRSP_POINT_R(vflat) vrcp invDyf[3], vH[1]
lpv amax[0], oRSP_POINT_R(vflat) vrcph invDyi[3], ri[1]
/*S*/ vrcpl invrf[1], rf[1]
/*S*/ vrcph invri[1], _0x0000
/*S*/ /*Resv*/
#endif
#---------------------------------------------------------------------
# カラー値の小数点位置修正
#---------------------------------------------------------------------
# 1/r の値を Newton 法で求める(1)
# vrcph/l で求めるのは 1/2X の値. (R=1/X)
# 1/X = R*(2-R*X) = R/2*(4+R/2*X*(-4))
#---------------------------------------------------------------------
# 1/w の値の最小値を取得する
# この値は 1/w の正規化に使用される
#---------------------------------------------------------------------
# サブピクセル値を計算する (1)
#---------------------------------------------------------------------
setupEXRej_1:
Assign(iw0, 6)
Assign(iw1, 7)
Assign(iw2, 9)
Assign(txflag, 13)
Assign(cmd1, 15)
Assign(xL, 16)
Assign(DxDyi, v22)
Assign(DxDyf, v23)
Assign(nearWi, v24)
Assign(invWi, v25)
Assign(yf, v26)
/*Resv*/ vmov vL[2], vM[0]
lw iw0, oRSP_POINT_INVWI(v0) vmov vL[3], vH[0]
#define DEBUG_207
#ifdef DEBUG_207
lw iw1, oRSP_POINT_INVWI(v1) vmudl vtmp, invDyf, _0x0020
lw iw2, oRSP_POINT_INVWI(v2) vmadm invDyi, invDyi, _0x0020
#else
lw iw1, oRSP_POINT_INVWI(v1) vmudl vtmp, invDyf, _0x0008
lw iw2, oRSP_POINT_INVWI(v2) vmadm invDyi, invDyi, _0x0008
#endif
lsv aminf[14], oRSP_POINT_ZSF(v0) vmadn invDyf, vzero, _0x0000
#ifdef DEBUG_207
lsv amaxf[14], oRSP_POINT_ZSF(v2) vmudm DxDyi, vL, _0x1000
#else
lsv amaxf[14], oRSP_POINT_ZSF(v2) vmudm DxDyi, vL, _0x4000
#endif
lbu txflag, RSP_LSTAT_TEX_ENABLE(zero) vmadn DxDyf, vzero, _0x0000
#define rfTmp vL
Assign(riTmp, v27)
sub sys0, iw0, iw1 vmudl vtmp, invrf, rf
sra sys1, sys0, 31 vmadm vtmp, invri, rf
and sys0, sys0, sys1 vmadn rfTmp, invrf, ri
sub iw0, iw0, sys0 vmadh riTmp, invri, ri
sub sys0, iw0, iw2 vmudl amin, amin, _0x0100
sra sys1, sys0, 31 vmudl amid, amid, _0x0100
and sys0, sys0, sys1 vmudl amax, amax, _0x0100
lsv amin[14], oRSP_POINT_ZS(v0) vmudh vtmp, vone, _0x0010
lsv amax[14], oRSP_POINT_ZS(v2) vmadn rfTmp, rfTmp, _0xfff0
sub iw0, iw0, sys0 vmadh riTmp, riTmp, _0xfff0
sw iw0, 0(outp) vmudl vtmp, DxDyf, invDyf
llv nearWi[0], 0(outp) vmadm vtmp, DxDyi, invDyf
mfc2 cmd1, ri[1] vmadn DxDyf, DxDyf, invDyi
lh xL, oRSP_POINT_XS(v1) vmadh DxDyi, DxDyi, invDyi
EndAssign(invDyi, v5)
EndAssign(invDyf, v4)
llv invWi[0], oRSP_POINT_INVWI(v1) vmudn yf, vmin, _0x4000
llv invWi[8], oRSP_POINT_INVWI(v0) vmudl vtmp, rfTmp, invrf
llv invWi[12], oRSP_POINT_INVWI(v2) vmadm vtmp, riTmp, invrf
/*Resv*/ vmadn invrf, rfTmp, invri
beq txflag, zero, setupEXRej_noTxtr /*Resv*/
/*Delay*/ vmadh invri, riTmp, invri
EndAssign(iw0, 6)
EndAssign(iw1, 7)
EndAssign(iw2, 9)
#undef rfTmp
EndAssign(riTmp, v27)
#---------------------------------------------------------------
# Texture On 時の処理
# 3 頂点の 1/W を正規化し, S,T に乗じ, amin,amid,amax に
# 格納する.
#---------------------------------------------------------------
Assign(nearWf, v4)
Assign(invWf, v5)
Assign(stw01i, v27)
Assign(stw2_i, v28)
vrcph vtmp[0], nearWi[0] /*S*/
vrcpl nearWf[0], nearWi[1] /*S*/
vadd invWf, vzero, invWi[1q] /*S*/
vrcph nearWi[0], _0x0000 /*S*/
vor stw01i, vzero, _0x7fff /*S*/
vmudm vtmp, invWi, nearWf[0] /*S*/
vmadl vtmp, invWf, nearWf[0] llv stw01i[0], oRSP_POINT_S(v1)
vmadn invWf, invWf, nearWi[0] llv stw01i[8], oRSP_POINT_S(v0)
vmadh invWi, invWi, nearWi[0] /*S*/
EndAssign(nearWf, v4)
EndAssign(nearWi, v24)
Assign(stw01f, v4)
Assign(stw2_f, v24)
vor stw2_i, vzero, _0x7fff /*S*/
vge vtmp, vconst1,vconst1[7] /*[4|5|6]移動*/ llv stw2_i[8], oRSP_POINT_S(v2)
vmudm vtmp, stw01i, invWf[0h] /*S*/
vmadh stw01i, stw01i, invWi[0h] /*S*/
vmadn stw01f, vzero, _0x0000 /*S*/
vmudm vtmp, stw2_i, invWf[6] /*S*/
vmadh stw2_i, stw2_i, invWi[6] /*S*/
vmadn stw2_f, vzero, _0x0000 sdv stw01i[0], 0(outp)
vmrg amin, amin, stw01i /*S で置換可*/ sdv stw01f[0], 8(outp)
vmrg aminf, aminf, stw01f ldv amid[8], 0(outp)
vmrg amax, amax, stw2_i ldv amidf[8], 8(outp)
vmrg amaxf, amaxf, stw2_f /*S*/
EndAssign(invWf, v5)
EndAssign(invWi, v25)
EndAssign(stw01i, v27)
EndAssign(stw01f, v4)
EndAssign(stw2_i, v28)
EndAssign(stw2_f, v24)
#---------------------------------------------------------------------
# ここで合流
#---------------------------------------------------------------------
setupEXRej_noTxtr:
#---------------------------------------------------------------------
# サブピクセル値を計算する (2)
#---------------------------------------------------------------------
Assign(yi, v4)
vsubc yf, vzero, yf lsv amidf[14], oRSP_POINT_ZSF(v1)
vsub yi, vzero, _0x0000 lsv amid[14], oRSP_POINT_ZS(v1)
#---------------------------------------------------------------------
# V 命令と S 命令の調整
#---------------------------------------------------------------------
# 辺 H,M に沿った Attribute の変化量計算
# DaH,DaM
#---------------------------------------------------------------------
Assign(cmd0, 6)
Assign(DaHf, v5)
Assign(DaHi, v24)
Assign(DaMf, v25)
Assign(DaMi, v27)
vmov vmax[2], vmid[1] lbu sys0, RSP_LSTAT_TEX_TILE(zero)
vmov vmax[3], vmin[1] ori cmd0, flag, G_TRI_FILL
vor vtmp, vzero, _0x4000 /*S*/
#ifdef DEBUG_207
Assign(tDxDyf, v28)
vand tDxDyf, DxDyf, _0xfff8 /*S*/
#endif
vsubc DaHf, amaxf, aminf or cmd0, cmd0, txflag
vsub DaHi, amax, amin andi cmd1, cmd1, 0x80
vsubc DaMf, amidf, aminf or cmd1, cmd1, sys0
vsub DaMi, amid, amin sdv vmax[0], 0(outp)
EndAssign(amax, v19)
EndAssign(amid, v18)
#---------------------------------------------------------------------
# XM,XH のサブピクセル計算
#---------------------------------------------------------------------
Assign(soutp, 7)
Assign(xi, v18)
Assign(xf, v19)
vmudn vtmp, vtmp, vmin[0] sb cmd0, 0(outp)
#ifdef DEBUG_207
vmadl vtmp, tDxDyf, yf[1] sb cmd1, 1(outp)
vmadm vtmp, DxDyi, yf[1] sll xL, xL, 14
vmadn xf, tDxDyf, yi[1] sw xL, 8(outp)
EndAssign(tDxDyf, v28)
#else
vmadl vtmp, DxDyf, yf[1] sb cmd1, 1(outp)
vmadm vtmp, DxDyi, yf[1] sll xL, xL, 14
vmadn xf, DxDyf, yi[1] sw xL, 8(outp)
#endif
vmadh xi, DxDyi, yi[1] addiu soutp, outp, 32
EndAssign(xL, 16)
EndAssign(cmd0, 6)
EndAssign(cmd1, 15)
#---------------------------------------------------------------------
# DaDx の計算 (1)
# DaDx = DyM * DaH - DyH * DaM
#---------------------------------------------------------------------
vmudn vtmp, DaHf, vM[1] ssv DxDyi[6], 20(outp) /*H*/
vmadh vtmp, DaHi, vM[1] ssv DxDyf[6], 22(outp) /*H*/
vmadn vtmp, DaMf, vHr[1] ssv DxDyi[4], 28(outp) /*M*/
vmadh vtmp, DaMi, vHr[1] ssv DxDyf[4], 30(outp) /*M*/
EndAssign(vHr, v11)
Assign(DaDxf, v11)
Assign(DaDxi, v28)
vsar DaDxf, DaDxf, DaDxf[1] ssv DxDyi[0], 12(outp) /*L*/
vsar DaDxi, DaDxi, DaDxi[0] ssv DxDyf[0], 14(outp) /*L*/
#---------------------------------------------------------------------
# DaDy の計算 (1)
# DaDy = DxH * DaM - DxM * DaH
#---------------------------------------------------------------------
vmudn vtmp, DaMf, vH[0] ssv xi[6], 16(outp)
vmadh vtmp, DaMi, vH[0] ssv xf[6], 18(outp)
vmadn vtmp, DaHf, vMr[0] ssv xi[4], 24(outp)
vmadh vtmp, DaHi, vMr[0] ssv xf[4], 26(outp)
EndAssign(xf, v19)
EndAssign(xi, v18)
EndAssign(DaHf, v5)
EndAssign(DaHi, v24)
EndAssign(DaMf, v25)
EndAssign(DaMi, v27)
Assign(DaDyf, v5)
Assign(DaDyi, v18)
vsar DaDyf, DaDyf, DaDyf[1] andi sys0, flag, G_RDP_TRI_SHADE_MASK
vsar DaDyi, DaDyi, DaDyi[0] sll sys0, sys0, 4
#---------------------------------------------------------------------
# DaDx の計算 (2)
# DaDx = DaDx / r
#---------------------------------------------------------------------
Assign(toutp, 6)
vmudl vtmp, DaDxf, invrf[1] add toutp, soutp, sys0
vmadm vtmp, DaDxi, invrf[1] sll sys0, txflag, 5
vmadn DaDxf, DaDxf, invri[1] add zoutp, toutp, sys0
vmadh DaDxi, DaDxi, invri[1] andi sys0, flag, G_RDP_TRI_ZBUFF_MASK
EndAssign(txflag, 13)
#---------------------------------------------------------------------
# DaDy の計算 (2)
# DaDy = DaDy / r
#---------------------------------------------------------------------
vmudl vtmp, DaDyf, invrf[1] sll sys0, sys0, 4
vmadm vtmp, DaDyi, invrf[1] add outp, zoutp, sys0
vmadn DaDyf, DaDyf, invri[1] sdv DaDxf[0], 24(soutp)
vmadh DaDyi, DaDyi, invri[1] sdv DaDxi[0], 8(soutp)
EndAssign(invrf, v20)
EndAssign(invri, v21)
Assign(DaDef, v19)
Assign(DaDei, v20)
#---------------------------------------------------------------------
# DaDx,DaDy,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)
vmadn DaDef, DaDxf, DxDyi[3] sdv DaDyf[0], 56(soutp)
vmadh DaDei, DaDxi, DxDyi[3] sdv DaDyi[0], 40(soutp)
EndAssign(DxDyf, v23)
EndAssign(DxDyi, v22)
#---------------------------------------------------------------------
# DaDx,DaDy,DaDe の計算
#---------------------------------------------------------------------
Assign(aminf0, v22)
Assign(aminf1, v21)
# 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 aminf0,DaDef, yi[1] sdv DaDef[8], 48(toutp)
vmadh amin, DaDei, yi[1] sdv DaDei[8], 32(toutp)
vmudn aminf1,DaDef, yf[1] andi isrej, isrej, 0x2020
EndAssign(yf, v26)
EndAssign(yi, v4)
#---------------------------------------------------------------------
# Z 値をスケーリングする
#---------------------------------------------------------------------
vmudn DaDxf, DaDxf, _0x0020 /*S*/
vmadh DaDxi, DaDxi, _0x0020 sdv aminf0[0], 16(soutp)
vmudn DaDyf, DaDyf, _0x0020 sdv amin[0], 0(soutp)
vmadh DaDyi, DaDyi, _0x0020 sdv aminf0[8], 16(toutp)
vmudn DaDef, DaDef, _0x0020 sdv amin[8], 0(toutp)
vmadh DaDei, DaDei, _0x0020 ssv DaDxf[14], 6(zoutp)
vmudl vtmp, aminf1,_0x0020 ssv DaDxi[14], 4(zoutp)
vmadn aminf0,aminf0,_0x0020 ssv DaDyf[14], 14(zoutp)
vmadh amin, amin, _0x0020 ssv DaDyi[14], 12(zoutp)
setupEXRej_ExchgTri:
vmov vMr[0], vMr[4] ssv DaDef[14], 10(zoutp)
vmov vmax[0], vmax[4] ssv DaDei[14], 8(zoutp)
vmov vmin[0], vmin[4] ssv aminf0[14], 2(zoutp)
vmov vmid[0], vmid[4] beq isrej, zero, OutputCloseGfxDone
/*Delay*/ ssv amin[14], 0(zoutp)
vmov vmax[1], vmax[5] mfc2 v0, vmin[12]
vmov vmin[1], vmin[5] mfc2 v1, vmid[12]
vmov vmid[1], vmid[5] _mov (vflat, wflat)
vmov ri[1], ri[5] _mov (isrej, zero)
vmov rf[1], rf[5] mfc2 v2, vmax[12]
vsub vH, vmax, vmin _li (return, setupEXRej_TriStart)
vsub vM, vmid, vmin j OutputClose
vsub vL, vmax, vmid /*Delay*/
EndAssign(v0, 1)
EndAssign(v1, 2)
EndAssign(v2, 3)
EndAssign(vflat, 4)
EndAssign(wflat, 8)
EndAssign(flag, 5)
EndAssign(isrej, 10)
EndAssign(soutp, 7)
EndAssign(toutp, 6)
EndAssign(zoutp, 14)
EndAssign(rf, v2)
EndAssign(ri, v3)
EndAssign(aminf1, v21)
EndAssign(aminf0, v22)
EndAssign(amin, v12)
EndAssign(DaDef, v19)
EndAssign(DaDei, v20)
EndAssign(DaDxf, v11)
EndAssign(DaDxi, v28)
EndAssign(DaDyf, v5)
EndAssign(DaDyi, v18)
EndAssign(vL, v14)
EndAssign(vH, v13)
EndAssign(vM, v7)
EndAssign(vMr, v6)
EndAssign(aminf, v8)
EndAssign(amidf, v9)
EndAssign(amaxf, v10)
EndAssign(vmin, v15)
EndAssign(vmid, v16)
EndAssign(vmax, v17)
#---------------------------------------------------------------------
# caseEXRej_G_LINE3D
# 実装しない
#---------------------------------------------------------------------
.symbol caseEXRej_G_LINE3D, GfxDone
/*======== End of gxsetup_exrej.s ========*/