Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
melonDS
Commits
f16d2aec
Commit
f16d2aec
authored
Feb 28, 2017
by
StapleButter
Browse files
calculate texture coordinates
parent
fb9dddc3
Changes
5
Hide whitespace changes
Inline
Side-by-side
GPU3D.cpp
View file @
f16d2aec
...
...
@@ -169,10 +169,14 @@ void UpdateClipMatrix();
u32
PolygonMode
;
s16
CurVertex
[
3
];
u8
VertexColor
[
3
];
s16
TexCoords
[
2
];
u32
PolygonAttr
;
u32
CurPolygonAttr
;
u32
TexParam
;
u32
TexPalette
;
Vertex
TempVertexBuffer
[
4
];
u32
VertexNum
;
u32
VertexNumInPoly
;
...
...
@@ -410,6 +414,9 @@ void ClipSegment(Vertex* outbuf, Vertex* vout, Vertex* vin)
INTERPOLATE
(
Color
[
1
]);
INTERPOLATE
(
Color
[
2
]);
INTERPOLATE
(
TexCoords
[
0
]);
INTERPOLATE
(
TexCoords
[
1
]);
mid
.
Clipped
=
true
;
mid
.
ViewportTransformDone
=
false
;
...
...
@@ -798,6 +805,17 @@ void SubmitVertex()
vertextrans
->
Color
[
1
]
=
(
VertexColor
[
1
]
<<
12
)
+
0xFFF
;
vertextrans
->
Color
[
2
]
=
(
VertexColor
[
2
]
<<
12
)
+
0xFFF
;
if
((
TexParam
>>
30
)
==
3
)
{
vertextrans
->
TexCoords
[
0
]
=
(
CurVertex
[
0
]
*
TexMatrix
[
0
]
+
CurVertex
[
1
]
*
TexMatrix
[
4
]
+
CurVertex
[
2
]
*
TexMatrix
[
8
]
+
0x1000
*
TexCoords
[
0
])
>>
12
;
vertextrans
->
TexCoords
[
1
]
=
(
CurVertex
[
0
]
*
TexMatrix
[
1
]
+
CurVertex
[
1
]
*
TexMatrix
[
5
]
+
CurVertex
[
2
]
*
TexMatrix
[
9
]
+
0x1000
*
TexCoords
[
1
])
>>
12
;
}
else
{
vertextrans
->
TexCoords
[
0
]
=
TexCoords
[
0
];
vertextrans
->
TexCoords
[
1
]
=
TexCoords
[
1
];
}
vertextrans
->
Clipped
=
false
;
vertextrans
->
ViewportTransformDone
=
false
;
...
...
@@ -1219,6 +1237,17 @@ void ExecuteCommand()
case
0x21
:
// TODO: more cycles if lights are enabled
// TODO also texcoords if needed
break
;
case
0x22
:
// texcoord
TexCoords
[
0
]
=
ExecParams
[
0
]
&
0xFFFF
;
TexCoords
[
1
]
=
ExecParams
[
1
]
>>
16
;
if
((
TexParam
>>
30
)
==
1
)
{
TexCoords
[
0
]
=
(
TexCoords
[
0
]
*
TexMatrix
[
0
]
+
TexCoords
[
1
]
*
TexMatrix
[
4
]
+
TexMatrix
[
8
]
+
TexMatrix
[
12
])
>>
12
;
TexCoords
[
1
]
=
(
TexCoords
[
0
]
*
TexMatrix
[
1
]
+
TexCoords
[
1
]
*
TexMatrix
[
5
]
+
TexMatrix
[
9
]
+
TexMatrix
[
13
])
>>
12
;
}
break
;
case
0x23
:
// full vertex
...
...
@@ -1264,6 +1293,14 @@ void ExecuteCommand()
PolygonAttr
=
ExecParams
[
0
];
break
;
case
0x2A
:
// texture param
TexParam
=
ExecParams
[
0
];
break
;
case
0x2B
:
// texture palette
TexPalette
=
ExecParams
[
0
]
&
0x1FFF
;
break
;
case
0x40
:
PolygonMode
=
ExecParams
[
0
]
&
0x3
;
VertexNum
=
0
;
...
...
GPU3D.h
View file @
f16d2aec
...
...
@@ -26,6 +26,7 @@ typedef struct
{
s32
Position
[
4
];
s32
Color
[
3
];
s16
TexCoords
[
2
];
bool
Clipped
;
...
...
GPU3D_Soft.cpp
View file @
f16d2aec
...
...
@@ -333,6 +333,8 @@ void RenderPolygon(Polygon* polygon)
perspfactor2
=
0
;
}
//z = 0x1000000 / (perspfactor1 + perspfactor2);
// possible optimization: only do color interpolation if the depth test passes
u32
vr
=
((
perspfactor1
*
rl
)
+
(
perspfactor2
*
rr
))
/
(
perspfactor1
+
perspfactor2
);
u32
vg
=
((
perspfactor1
*
gl
)
+
(
perspfactor2
*
gr
))
/
(
perspfactor1
+
perspfactor2
);
...
...
NDS.cpp
View file @
f16d2aec
...
...
@@ -776,6 +776,9 @@ void debug(u32 param)
{
printf
(
"ARM9 PC=%08X LR=%08X %08X
\n
"
,
ARM9
->
R
[
15
],
ARM9
->
R
[
14
],
ARM9
->
R_IRQ
[
1
]);
printf
(
"ARM7 PC=%08X LR=%08X %08X
\n
"
,
ARM7
->
R
[
15
],
ARM7
->
R
[
14
],
ARM7
->
R_IRQ
[
1
]);
for
(
int
i
=
0
;
i
<
9
;
i
++
)
printf
(
"VRAM %c: %02X
\n
"
,
'A'
+
i
,
GPU
::
VRAMCNT
[
i
]);
}
...
...
melonDS.depend
View file @
f16d2aec
...
...
@@ -10,7 +10,7 @@
1481161027 c:\documents\sources\melonds\types.h
14882
27258
source:c:\documents\sources\melonds\nds.cpp
14882
37361
source:c:\documents\sources\melonds\nds.cpp
<stdio.h>
<string.h>
"NDS.h"
...
...
@@ -119,7 +119,7 @@
1487305393 c:\documents\sources\melonds\dma.h
"types.h"
148822
6688
source:c:\documents\sources\melonds\gpu.cpp
148822
7337
source:c:\documents\sources\melonds\gpu.cpp
<stdio.h>
<string.h>
"NDS.h"
...
...
@@ -146,16 +146,16 @@
"NDS.h"
"NDSCart.h"
148
7610598
c:\documents\sources\melonds\gpu3d.h
148
8238607
c:\documents\sources\melonds\gpu3d.h
148
7681103
source:c:\documents\sources\melonds\gpu3d.cpp
148
8239360
source:c:\documents\sources\melonds\gpu3d.cpp
<stdio.h>
<string.h>
"NDS.h"
"GPU.h"
"FIFO.h"
14882
14777
source:c:\documents\sources\melonds\gpu3d_soft.cpp
14882
37540
source:c:\documents\sources\melonds\gpu3d_soft.cpp
<stdio.h>
<string.h>
"NDS.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment