Fixes #6: now works on real HW

This commit is contained in:
ABelliqueux 2021-07-01 17:35:08 +02:00
parent 06c799aca2
commit a85e394506
3 changed files with 48 additions and 31 deletions

View File

@ -192,16 +192,21 @@ void set3Tex(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, long t, int i){
CVECTOR outCol = { 0,0,0,0 }; CVECTOR outCol = { 0,0,0,0 };
CVECTOR outCol1 = { 0,0,0,0 }; CVECTOR outCol1 = { 0,0,0,0 };
CVECTOR outCol2 = { 0,0,0,0 }; CVECTOR outCol2 = { 0,0,0,0 };
// No transparency effect
// Use regular TPAGE // Use regular TPAGE
( (POLY_GT3 *) poly )->tpage = getTPage(mesh->tim->mode&0x3, 0, if (mesh->tim){
mesh->tim->prect->x, ( (POLY_GT3 *) poly )->tpage = getTPage(mesh->tim->mode&0x3, 0,
mesh->tim->prect->y mesh->tim->prect->x,
); mesh->tim->prect->y
setUV3(poly, mesh->tmesh->u[i].vx , mesh->tmesh->u[i].vy + mesh->tim->prect->y, );
mesh->tmesh->u[i+2].vx, mesh->tmesh->u[i+2].vy + mesh->tim->prect->y, setUV3(poly, mesh->tmesh->u[i].vx , mesh->tmesh->u[i].vy + mesh->tim->prect->y,
mesh->tmesh->u[i+1].vx, mesh->tmesh->u[i+1].vy + mesh->tim->prect->y); mesh->tmesh->u[i+2].vx, mesh->tmesh->u[i+2].vy + mesh->tim->prect->y,
mesh->tmesh->u[i+1].vx, mesh->tmesh->u[i+1].vy + mesh->tim->prect->y);
} else {
( (POLY_GT3 *) poly)->tpage = getTPage( 2,0,0,0 );
setUV3(poly, 0,0,0,0,0,0);
}
NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vx ], &mesh->tmesh->c[ i+0 ], mesh->p, &outCol); NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vx ], &mesh->tmesh->c[ i+0 ], mesh->p, &outCol);
NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vz ], &mesh->tmesh->c[ i+2 ], mesh->p, &outCol1); NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vz ], &mesh->tmesh->c[ i+2 ], mesh->p, &outCol1);
NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vy ], &mesh->tmesh->c[ i+1 ], mesh->p, &outCol2); NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vy ], &mesh->tmesh->c[ i+1 ], mesh->p, &outCol2);
@ -211,23 +216,29 @@ void set3Tex(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, long t, int i){
}; };
void set4Tex(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, long t, int i){ void set4Tex(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, long t, int i){
CVECTOR outCol = {0,0,0,0}; CVECTOR outCol = {255,255,255,0};
CVECTOR outCol1 = {0,0,0,0}; CVECTOR outCol1 = {255,255,255,0};
CVECTOR outCol2 = {0,0,0,0}; CVECTOR outCol2 = {255,255,255,0};
CVECTOR outCol3 = {0,0,0,0}; CVECTOR outCol3 = {255,255,255,0};
// Use regular TPAGE // Use regular TPAGE
( (POLY_GT4 *) poly4)->tpage = getTPage( if (mesh->tim){
mesh->tim->mode&0x3, 0, ( (POLY_GT4 *) poly4)->tpage = getTPage(
mesh->tim->prect->x, mesh->tim->mode&0x3, 0,
mesh->tim->prect->y mesh->tim->prect->x,
); mesh->tim->prect->y
// Use model UV coordinates );
setUV4( poly4,
mesh->tmesh->u[i+3].vx, mesh->tmesh->u[i+3].vy + mesh->tim->prect->y, // Use model UV coordinates
mesh->tmesh->u[i+2].vx, mesh->tmesh->u[i+2].vy + mesh->tim->prect->y, setUV4( poly4,
mesh->tmesh->u[i+0].vx, mesh->tmesh->u[i+0].vy + mesh->tim->prect->y, mesh->tmesh->u[i+3].vx, mesh->tmesh->u[i+3].vy + mesh->tim->prect->y,
mesh->tmesh->u[i+1].vx, mesh->tmesh->u[i+1].vy + mesh->tim->prect->y mesh->tmesh->u[i+2].vx, mesh->tmesh->u[i+2].vy + mesh->tim->prect->y,
); mesh->tmesh->u[i+0].vx, mesh->tmesh->u[i+0].vy + mesh->tim->prect->y,
mesh->tmesh->u[i+1].vx, mesh->tmesh->u[i+1].vy + mesh->tim->prect->y
);
} else {
( (POLY_GT4 *) poly4)->tpage = getTPage( 2,0,0,0 );
setUV4(poly4, 0,0,0,0,0,0,0,0);
}
NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.pad ] , &mesh->tmesh->c[ i+3 ], mesh->p, &outCol); NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.pad ] , &mesh->tmesh->c[ i+3 ], mesh->p, &outCol);
NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vz ] , &mesh->tmesh->c[ i+2 ], mesh->p, &outCol1); NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vz ] , &mesh->tmesh->c[ i+2 ], mesh->p, &outCol1);
NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vx ] , &mesh->tmesh->c[ i+0 ], mesh->p, &outCol2); NormalColorDpq(&mesh->tmesh->n[ mesh->index[t].order.vx ] , &mesh->tmesh->c[ i+0 ], mesh->p, &outCol2);

View File

@ -25,7 +25,7 @@
#include "../include/graphics.h" #include "../include/graphics.h"
#include "../include/space.h" #include "../include/space.h"
#define USECD //~ #define USECD
// START OVERLAY // START OVERLAY
extern u_long load_all_overlays_here; extern u_long load_all_overlays_here;
@ -37,7 +37,7 @@ u_long overlaySize = 0;
#include "../levels/level1.h" #include "../levels/level1.h"
// Levels // Levels
volatile u_char level = 1; volatile u_char level = 0;
u_short levelWas = 0; u_short levelWas = 0;
u_short levelHasChanged = 0; u_short levelHasChanged = 0;
// Overlay // Overlay
@ -140,7 +140,10 @@ int main() {
VSyncCallback(callback); VSyncCallback(callback);
// Load textures // Load textures
for (int k = 0; k < *curLvl.meshes_length ; k++){ for (int k = 0; k < *curLvl.meshes_length ; k++){
LoadTexture(curLvl.meshes[k]->tim_data, curLvl.meshes[k]->tim); // Check data exists
if (curLvl.meshes[k]->tim_data){
LoadTexture(curLvl.meshes[k]->tim_data, curLvl.meshes[k]->tim);
}
} }
// Load current BG if exists // Load current BG if exists
if (curLvl.camPtr->tim_data){ if (curLvl.camPtr->tim_data){
@ -323,7 +326,7 @@ int main() {
if (curLvl.camPath->pos > (1 << precision) ){ if (curLvl.camPath->pos > (1 << precision) ){
curLvl.camPath->pos = 0; curLvl.camPath->pos = 0;
curLvl.camPath->cursor ++; curLvl.camPath->cursor ++;
} }
// Last key pos is reached, reset cursor to first key pos, lerping sequence is over // Last key pos is reached, reset cursor to first key pos, lerping sequence is over
if ( curLvl.camPath->cursor == curLvl.camPath->len - 1 ){ if ( curLvl.camPath->cursor == curLvl.camPath->len - 1 ){
lerping = 0; lerping = 0;
@ -454,7 +457,6 @@ int main() {
} }
} }
else { else {
//FIXME : Light is not applied to planes
// Draw current node's plane // Draw current node's plane
drawPoly( curLvl.curNode->plane, &Flag, atime, &camMode, &nextpri, ot[db], &db, &draw[db]); drawPoly( curLvl.curNode->plane, &Flag, atime, &camMode, &nextpri, ot[db], &db, &draw[db]);
// Draw surrounding planes // Draw surrounding planes

View File

@ -61,6 +61,7 @@ void ScrRst(void){
VSync( 0 ); // Wait for current drawing to finish VSync( 0 ); // Wait for current drawing to finish
SetDispMask( 0 ); // Set mask to not displayed SetDispMask( 0 ); // Set mask to not displayed
ResetGraph( 1 ); // Cancel current drawing ResetGraph( 1 ); // Cancel current drawing
// Clear FB
setRECT(&scr, 0, 0, SCREENXRES, SCREENYRES); setRECT(&scr, 0, 0, SCREENXRES, SCREENYRES);
ClearImage(&scr, CLEAR_COLOR_R, CLEAR_COLOR_G, CLEAR_COLOR_B ); ClearImage(&scr, CLEAR_COLOR_R, CLEAR_COLOR_G, CLEAR_COLOR_B );
DrawSync( 0 ); DrawSync( 0 );
@ -108,7 +109,10 @@ void SwitchLevel( LEVEL * curLevel, LEVEL * loadLevel ){
LvlPtrSet( curLevel, loadLevel); LvlPtrSet( curLevel, loadLevel);
// Reload textures // Reload textures
for (int k = 0; k < *curLevel->meshes_length ; k++){ for (int k = 0; k < *curLevel->meshes_length ; k++){
LoadTexture(curLevel->meshes[k]->tim_data, curLevel->meshes[k]->tim); // Check data exists
if (curLevel->meshes[k]->tim_data){
LoadTexture(curLevel->meshes[k]->tim_data, curLevel->meshes[k]->tim);
}
} }
// BG texture // BG texture
if (curLevel->camPtr->tim_data){ if (curLevel->camPtr->tim_data){