1// --------------------------------------------------------------------------- 2// Project: NintendoWare 3// File: lyt_PaneShader.vsh 4// 5// Copyright (C)2009-2010 Nintendo Co., Ltd. All rights reserved. 6// 7// These coded instructions, statements, and computer programs contain 8// proprietary information of Nintendo of America Inc. and/or Nintendo 9// Company Ltd., and are protected by Federal copyright law. They may 10// not be disclosed to third parties or copied or duplicated in any form, 11// in whole or in part, without the prior written consent of Nintendo. 12// 13// $Revision: 17413 $ 14// --------------------------------------------------------------------------- 15 16// Input registers map 17 18#pragma bind_symbol(aVertexIndex, v0, v0) 19 20// Constant values 21 22#pragma bind_symbol(uProjection, c0, c3) 23#pragma bind_symbol(uModelView, c4, c6) 24#pragma bind_symbol(uTransform, c7, c7) 25#pragma bind_symbol(uTexMtx0, c8, c9) 26#pragma bind_symbol(uTexMtx1, c10, c11) 27#pragma bind_symbol(uTexMtx2, c12, c13) 28#pragma bind_symbol(uColor, c14, c14) 29#pragma bind_symbol(uFrameSpec, c15, c15) 30#pragma bind_symbol(uVertexColor, c16, c19) 31#pragma bind_symbol(uVertexTexCoord0, c20, c23) 32#pragma bind_symbol(uVertexTexCoord1, c24, c27) 33#pragma bind_symbol(uVertexTexCoord2, c28, c31) 34#pragma bind_symbol(uRcpTexSize0, c32, c32) 35 36// Output registers map 37 38#pragma output_map(position, o0) 39#pragma output_map(color, o1) 40#pragma output_map(texture0, o2.xy) 41#pragma output_map(texture1, o3.xy) 42#pragma output_map(texture2, o4.xy) 43 44#define aVertexIndex v0 45 46#define uProjection c0 47#define uModelView c4 48#define uTransform c7 49#define uTexMtx0 c8 50#define uTexMtx1 c10 51#define uTexMtx2 c12 52#define uColor c14 53#define uFrameSpec c15 54#define uVertexColor c16 55#define uVertexTexCoord0 c20 56#define uVertexTexCoord1 c24 57#define uVertexTexCoord2 c28 58#define uRcpTexSize0 c32 59 60#define vPosition o0 61#define vColor o1 62#define vTexCoord0 o2 63#define vTexCoord1 o3 64#define vTexCoord2 o4 65 66#define CONST c95 67def CONST, 0.0, 0.5, 1.0, 255 68#define CONST_0 CONST.x 69#define CONST_1_2 CONST.y 70#define CONST_1 CONST.z 71#define CONST_255 CONST.w 72#define CONST_0_0_0_1 CONST.xxxz 73 74#define CONST2 c94 75def CONST2, 1, -1, 0, 2 76 77#define CMP_EQ 0 78#define CMP_NE 1 79#define CMP_LT 2 80#define CMP_LE 3 81#define CMP_GT 4 82#define CMP_GE 5 83 84#define ifc_0_or_1(c0, c1) ifc c0, c1, 0 85#define ifc_0_and_1(c0, c1) ifc c0, c1, 1 86#define ifc_0(c0) ifc c0, 0, 2 87#define ifc_1(c1) ifc 0, c1, 3 88 89#define aPosition r0 90#define aColor r1 91#define aTexCoord0 r2 92#define aTexCoord1 r3 93#define aTexCoord2 r4 94#define aFrameSpec r5 95#define aTexScale r6 96 97#define tmp0 r15 98#define tmp1 r14 99 100main: 101 // aPosition = [ aVertexIndex.x, - aVertexIndex.y, 0, 1 ] 102 mul aPosition, aVertexIndex, CONST2.xyzz 103 mov aPosition.zw, CONST2.zzzx 104 105 // if (IsConstVertex(uFrameSpec)) { 106 // aTexCoord[0,1,2] = [ aVertex.x, aVertex.y, 0, 1 ] 107 // aColor = 255 108 // } else { 109 // i = 1 * aVertex.x + 2 * aVertex.y 110 // aTexCoord[0,1,2] = uVertexTexCoord[0,1,2][i] 111 // aColor = uVertexColor[i] 112 // } 113 mov aFrameSpec, uFrameSpec 114 mul aFrameSpec.xy, aFrameSpec.x, CONST_1_2 115 flr aFrameSpec.x, aFrameSpec 116 cmp CMP_GT, CMP_GT, aFrameSpec.y, aFrameSpec.x 117 ifc_0(1) 118 mov aTexCoord0, aVertexIndex 119 mov aTexCoord0.zw, CONST2.zzzx 120 mov aTexCoord1, aTexCoord0 121 mov aTexCoord2, aTexCoord0 122 mov aColor, CONST_255 123 else 124 dp3 tmp0, aVertexIndex, CONST2.xwz 125 mova a0.xy, tmp0 126 mov aTexCoord0, uVertexTexCoord0[a0.x] 127 mov aTexCoord1, uVertexTexCoord1[a0.x] 128 mov aTexCoord2, uVertexTexCoord2[a0.x] 129 mov aColor, uVertexColor[a0.x] 130 endif 131 132 // POSITION TRANSFORM 133 mov tmp0, uTransform 134 mad aPosition.xy, aPosition.xy, tmp0.xy, tmp0.zw 135 dp4 tmp0.x, aPosition, uModelView[0] 136 dp4 tmp0.y, aPosition, uModelView[1] 137 dp4 tmp0.z, aPosition, uModelView[2] 138 mov tmp0.w, aPosition.w 139 m4x4 vPosition, tmp0, uProjection 140 141 // GLOBAL COLOR 142 mul vColor, aColor, uColor 143 144 // TEXCOORD0 FRAME TRANSFORM 145 // if (IsFrame(uFrameSpec)) { 146 mul aFrameSpec.xy, aFrameSpec.x, CONST_1_2 147 flr aFrameSpec.x, aFrameSpec 148 cmp CMP_GT, CMP_GT, aFrameSpec.y, aFrameSpec.x 149 ifc_0(1) 150 151 // texSize = uFrameSpec.zw 152 // if (IsSwap(uFrameSpec)) { 153 // aTexScale = polySize * uRcpTexSize0.yx 154 // } else { 155 // aTexScale = polySize * uRcpTexSize0.xy 156 // } 157 mul aFrameSpec.xy, aFrameSpec.x, CONST_1_2 158 flr aFrameSpec.x, aFrameSpec 159 mov tmp1, aFrameSpec 160 cmp CMP_GT, CMP_GT, aFrameSpec.y, aFrameSpec.x 161 mov aTexScale, uTransform 162 ifc_0(1) 163 mul aTexScale, aTexScale, uRcpTexSize0.yx 164 else 165 mul aTexScale, aTexScale, uRcpTexSize0.xy 166 endif 167 168 // aTexCoord[0,1,2] *= texScale 169 mul aTexCoord0.xy, aTexCoord0, aTexScale 170 mul aTexCoord1.xy, aTexCoord1, aTexScale 171 mul aTexCoord2.xy, aTexCoord2, aTexScale 172 173 // if (IsRight(uFrameSpec)) { 174 // aTexCoord[0,1,2].x += 1 - texScale.x 175 // } 176 mul aFrameSpec.xy, aFrameSpec.x, CONST_1_2 177 flr aFrameSpec.x, aFrameSpec 178 cmp CMP_GT, CMP_GT, aFrameSpec.y, aFrameSpec.x 179 add aTexScale, CONST_1, -aTexScale 180 ifc_0(1) 181 add aTexCoord0.x, aTexCoord0, aTexScale 182 add aTexCoord1.x, aTexCoord1, aTexScale 183 add aTexCoord2.x, aTexCoord2, aTexScale 184 endif 185 186 // if (IsBottom(uFrameSpec)) { 187 // aTexCoord[0,1,2].y += 1 - texScale.y 188 // } 189 mul aFrameSpec.xy, aFrameSpec.x, CONST_1_2 190 flr aFrameSpec.x, aFrameSpec 191 cmp CMP_GT, CMP_GT, aFrameSpec.y, aFrameSpec.x 192 ifc_0(1) 193 add aTexCoord0.y, aTexCoord0, aTexScale 194 add aTexCoord1.y, aTexCoord1, aTexScale 195 add aTexCoord2.y, aTexCoord2, aTexScale 196 endif 197 198 // if (IsHorizontalFlip(uFrameSpec)) { 199 // aTexCoord[0,1,2].x = 1 - aTexCoord[0,1,2].x 200 // } 201 mul aFrameSpec.xy, aFrameSpec.x, CONST_1_2 202 flr aFrameSpec.x, aFrameSpec 203 cmp CMP_GT, CMP_GT, aFrameSpec.y, aFrameSpec.x 204 ifc_0(1) 205 add aTexCoord0.x, CONST_1, -aTexCoord0 206 add aTexCoord1.x, CONST_1, -aTexCoord1 207 add aTexCoord2.x, CONST_1, -aTexCoord2 208 endif 209 210 // if (IsVerticalFlip(uFrameSpec)) { 211 // aTexCoord[0,1,2].y = 1 - aTexCoord[0,1,2].y 212 // } 213 mul aFrameSpec.xy, aFrameSpec.x, CONST_1_2 214 flr aFrameSpec.x, aFrameSpec 215 cmp CMP_GT, CMP_GT, aFrameSpec.y, aFrameSpec.x 216 ifc_0(1) 217 add aTexCoord0.y, CONST_1, -aTexCoord0 218 add aTexCoord1.y, CONST_1, -aTexCoord1 219 add aTexCoord2.y, CONST_1, -aTexCoord2 220 endif 221 222 // if (IsSwap(uFrameSpec)) { 223 // aTexCoord[0,1,2].xy = aTexCoord[0,1,2].yx 224 // } 225 cmp CMP_GT, CMP_GT, tmp1.y, tmp1.x 226 ifc_0(1) 227 mov aTexCoord0, aTexCoord0.yxzw 228 mov aTexCoord1, aTexCoord1.yxzw 229 mov aTexCoord2, aTexCoord2.yxzw 230 endif 231 232 nop 233 endif 234 235 // TEXCOORD TRANSFORM 236 dp4 vTexCoord0.xz, aTexCoord0, uTexMtx0[0] 237 dp4 vTexCoord0.yw, aTexCoord0, uTexMtx0[1] 238 dp4 vTexCoord1.xz, aTexCoord1, uTexMtx1[0] 239 dp4 vTexCoord1.yw, aTexCoord1, uTexMtx1[1] 240 dp4 vTexCoord2.xz, aTexCoord2, uTexMtx2[0] 241 dp4 vTexCoord2.yw, aTexCoord2, uTexMtx2[1] 242 end 243endmain: 244