Use DRAWENV for prism effect, add dead zone for DS sticks
This commit is contained in:
parent
a85e394506
commit
7817c495f8
@ -33,6 +33,9 @@
|
||||
#define SCALE 4
|
||||
|
||||
// Pad codes defines
|
||||
|
||||
// Dual shock sticks dead zone
|
||||
#define DS_DZ 60
|
||||
// Applied on PADL
|
||||
#define PadSelect ( 1 )
|
||||
#define PadStart ( 1 << 3 )
|
||||
|
@ -10,13 +10,13 @@ void drawPoly(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpr
|
||||
// Tri drawing
|
||||
long drawTri(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw, int t, int i);
|
||||
void set3VertexLerPos(MESH * mesh, long t);
|
||||
void set3Prism(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, int i);
|
||||
void set3Prism(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, char * db, int i);
|
||||
void set3Tex(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, long t, int i);
|
||||
long interpolateTri(POLY_GT3 * poly, MESH * mesh, long t, long * Flag);
|
||||
//Quad drawing
|
||||
long drawQuad(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw, int t, int i);
|
||||
void set4VertexLerPos(MESH * mesh, long t);
|
||||
void set4Prism(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, int i);
|
||||
void set4Prism(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, char * db, int i);
|
||||
void set4Tex(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, long t, int i);
|
||||
long interpolateQuad(POLY_GT4 * poly4, MESH * mesh, long t, long * Flag);
|
||||
//2D drawing
|
||||
|
@ -23,10 +23,8 @@ void transformMesh(CAMERA * camera, MESH * mesh){
|
||||
SetTransMatrix(&mat);
|
||||
//~ }
|
||||
};
|
||||
//TODO : Break this monster in tiny bits ?
|
||||
void drawPoly(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw) {
|
||||
long nclip, t = 0;
|
||||
// FIXME : t is not incremented, thus always 0. It works if the mesh only has tris or quads, but won't work with mixed meshes.
|
||||
// mesh is POLY_GT3 ( triangle )
|
||||
for (int i = 0; i < (mesh->totalVerts);) {
|
||||
if (mesh->index[t].code == 4) {
|
||||
@ -42,7 +40,7 @@ void drawPoly(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpr
|
||||
};
|
||||
void set3VertexLerPos(MESH * mesh, long t){
|
||||
// Find and set 3 interpolated vertex value
|
||||
// TODO : Finish lerp anim implementation
|
||||
// TODO : Fix artifacts at meshes seams.
|
||||
// Fixed point math precision
|
||||
short precision = 12;
|
||||
// Vertex 1
|
||||
@ -145,12 +143,19 @@ long interpolateQuad(POLY_GT4 * poly4, MESH * mesh, long t, long * Flag){
|
||||
);
|
||||
return nclip;
|
||||
};
|
||||
void set3Prism(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, int i){
|
||||
void set3Prism(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, char * db, int i){
|
||||
// Transparency effect :
|
||||
// Use current DRAWENV clip as TPAGE instead of regular textures
|
||||
//
|
||||
// FIXME : Fixed BGs : find a way to know we're using em.
|
||||
// With pre-rendered background, just set the tpage to bpp, x, y of the image in vram : 8bpp, 320, 0 by default for now
|
||||
// But how do we now fixed BGs are used ?
|
||||
//~ if (fixed_BGS){
|
||||
//~ ( (POLY_GT3 *) poly )->tpage = getTPage( 0, 0, 320, 0 );
|
||||
//~ }
|
||||
( (POLY_GT3 *) poly )->tpage = getTPage( 2, 0,
|
||||
0,
|
||||
256
|
||||
draw[*db].clip.x,
|
||||
draw[*db].clip.y
|
||||
);
|
||||
// Use projected coordinates (results from RotAverage...) as UV coords and clamp them to 0-255,0-224 -> 240 - 16
|
||||
setUV3( poly,
|
||||
@ -166,10 +171,10 @@ void set3Prism(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, int i){
|
||||
setRGB1(poly, mesh->tmesh->c[i+2].r, mesh->tmesh->c[i+2].g, mesh->tmesh->c[i+2].b);
|
||||
setRGB2(poly, mesh->tmesh->c[i+1].r, mesh->tmesh->c[i+1].g, mesh->tmesh->c[i+1].b);
|
||||
};
|
||||
void set4Prism(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, int i){
|
||||
void set4Prism(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, char * db, int i){
|
||||
( (POLY_GT4 *) poly4)->tpage = getTPage( 2, 0,
|
||||
0,
|
||||
256
|
||||
draw[*db].clip.x,
|
||||
draw[*db].clip.y
|
||||
);
|
||||
// Use projected coordinates
|
||||
setUV4( poly4,
|
||||
@ -357,7 +362,7 @@ long drawQuad(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpr
|
||||
}
|
||||
// Transparency effect
|
||||
if (mesh->isPrism){
|
||||
set4Prism(poly4, mesh, draw, i);
|
||||
set4Prism(poly4, mesh, draw, db, i);
|
||||
} else {
|
||||
set4Tex(poly4, mesh, draw, t, i);
|
||||
}
|
||||
@ -432,9 +437,8 @@ long drawTri(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri
|
||||
SetShadeTex( poly, 1 );
|
||||
}
|
||||
// If isPrism flag is set, use it
|
||||
// FIXME : Doesn't work with pre-rendered BGs
|
||||
if ( mesh->isPrism ) {
|
||||
set3Prism(poly, mesh, draw, i);
|
||||
set3Prism(poly, mesh, draw, db, i);
|
||||
} else {
|
||||
set3Tex(poly, mesh, draw, t, i);
|
||||
}
|
||||
|
16
src/main.c
16
src/main.c
@ -25,7 +25,7 @@
|
||||
#include "../include/graphics.h"
|
||||
#include "../include/space.h"
|
||||
|
||||
//~ #define USECD
|
||||
#define USECD
|
||||
|
||||
// START OVERLAY
|
||||
extern u_long load_all_overlays_here;
|
||||
@ -174,7 +174,7 @@ int main() {
|
||||
}
|
||||
}
|
||||
// Main loop
|
||||
while ( VSync(1) ) {
|
||||
while ( VSync(VSYNC) ) {
|
||||
timeS = VSync(-1) / 60;
|
||||
// Check if level has changed
|
||||
// TODO : Proper level system / loader
|
||||
@ -225,10 +225,6 @@ int main() {
|
||||
curLvl.actorPtr->pos.vy,
|
||||
curLvl.actorPtr->pos.vz - (ncos(curLvl.actorPtr->rot.vy/2))
|
||||
);
|
||||
// TODO : Test with real HW/DS
|
||||
//~ fVecActor = curLvl.actorPtr->pos;
|
||||
//~ fVecActor.vx = curLvl.actorPtr->pos.vx + (nsin(curLvl.actorPtr->rot.vy/2));
|
||||
//~ fVecActor.vz = curLvl.actorPtr->pos.vz - (ncos(curLvl.actorPtr->rot.vy/2));
|
||||
// Camera modes
|
||||
if(camMode != 2) {
|
||||
camera.rot.vy = camAngleToAct.vy;
|
||||
@ -660,19 +656,19 @@ void callback() {
|
||||
}
|
||||
if( theControllers[0].type == 0x73 && camMode == 0){
|
||||
// Cam control - horizontal
|
||||
if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < 108) {
|
||||
if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < (128 - DS_DZ/2) ) {
|
||||
angleCam.vy -= ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 7 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
if ( theControllers[0].analog0 > 148 && theControllers[0].analog0 <= 255) {
|
||||
if ( theControllers[0].analog0 > (128 + DS_DZ/2) && theControllers[0].analog0 <= 255 ) {
|
||||
angleCam.vy += ( 16 * ( theControllers[0].analog0 - 128 ) ) >> 7 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < 108) {
|
||||
if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < (128 - DS_DZ/2) ) {
|
||||
angleCam.vy -= ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 7 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
if ( theControllers[0].analog0 > 148 && theControllers[0].analog0 <= 255) {
|
||||
if ( theControllers[0].analog0 > (128 + DS_DZ/2) && theControllers[0].analog0 <= 255) {
|
||||
angleCam.vy += ( 16 * ( theControllers[0].analog0 - 128 ) ) >> 7 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user