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,8 +192,8 @@ 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
if (mesh->tim){
( (POLY_GT3 *) poly )->tpage = getTPage(mesh->tim->mode&0x3, 0, ( (POLY_GT3 *) poly )->tpage = getTPage(mesh->tim->mode&0x3, 0,
mesh->tim->prect->x, mesh->tim->prect->x,
mesh->tim->prect->y mesh->tim->prect->y
@ -202,6 +202,11 @@ void set3Tex(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, long t, int i){
mesh->tmesh->u[i+2].vx, mesh->tmesh->u[i+2].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); 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,16 +216,18 @@ 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
if (mesh->tim){
( (POLY_GT4 *) poly4)->tpage = getTPage( ( (POLY_GT4 *) poly4)->tpage = getTPage(
mesh->tim->mode&0x3, 0, mesh->tim->mode&0x3, 0,
mesh->tim->prect->x, mesh->tim->prect->x,
mesh->tim->prect->y mesh->tim->prect->y
); );
// Use model UV coordinates // Use model UV coordinates
setUV4( poly4, setUV4( poly4,
mesh->tmesh->u[i+3].vx, mesh->tmesh->u[i+3].vy + mesh->tim->prect->y, mesh->tmesh->u[i+3].vx, mesh->tmesh->u[i+3].vy + mesh->tim->prect->y,
@ -228,6 +235,10 @@ void set4Tex(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, long t, int i){
mesh->tmesh->u[i+0].vx, mesh->tmesh->u[i+0].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 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,8 +140,11 @@ 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++){
// Check data exists
if (curLvl.meshes[k]->tim_data){
LoadTexture(curLvl.meshes[k]->tim_data, curLvl.meshes[k]->tim); 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){
LoadTexture(curLvl.camPtr->tim_data, curLvl.camPtr->BGtim); LoadTexture(curLvl.camPtr->tim_data, curLvl.camPtr->BGtim);
@ -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,8 +109,11 @@ 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++){
// Check data exists
if (curLevel->meshes[k]->tim_data){
LoadTexture(curLevel->meshes[k]->tim_data, curLevel->meshes[k]->tim); LoadTexture(curLevel->meshes[k]->tim_data, curLevel->meshes[k]->tim);
} }
}
// BG texture // BG texture
if (curLevel->camPtr->tim_data){ if (curLevel->camPtr->tim_data){
LoadTexture(curLevel->camPtr->tim_data, curLevel->camPtr->BGtim); LoadTexture(curLevel->camPtr->tim_data, curLevel->camPtr->BGtim);