@@ -32,7 +32,7 @@ int Chunk::getPosition(int x, int y, int z)
3232 if (pos_indices[x][y][z] == -1 )
3333 {
3434 pos_indices[x][y][z] = positions.size ();
35- positions.emplace_back (Position {abs_x + x*BLOCK_SIZE, abs_y + y*BLOCK_SIZE, abs_z + z*BLOCK_SIZE});
35+ positions.emplace_back (VECTOR3 {abs_x + x*BLOCK_SIZE, abs_y + y*BLOCK_SIZE, abs_z + z*BLOCK_SIZE});
3636 }
3737
3838 return pos_indices[x][y][z];
@@ -165,9 +165,9 @@ void Chunk::buildGeometry()
165165
166166#define MAKE_VERTEX (pos, iver ) { (pos).x , (pos).y , (pos).z , iver.u , iver.v , iver.c }
167167
168- VERTEX Chunk::perspective (const IndexedVertex &v, Position &transformed)
168+ VERTEX Chunk::perspective (const IndexedVertex &v, VECTOR3 &transformed)
169169{
170- std::pair<Position , bool > &p = positions_perspective[v.pos ];
170+ std::pair<VECTOR3 , bool > &p = positions_perspective[v.pos ];
171171 if (!p.second )
172172 {
173173 VERTEX ver = MAKE_VERTEX (transformed, v);
@@ -183,7 +183,7 @@ VERTEX Chunk::perspective(const IndexedVertex &v, Position &transformed)
183183
184184bool Chunk::drawTriangle (const IndexedVertex &low, const IndexedVertex &middle, const IndexedVertex &high, bool backface_culling)
185185{
186- Position pos_low = positions_transformed[low.pos ], pos_middle = positions_transformed[middle.pos ], pos_high = positions_transformed[high.pos ];
186+ VECTOR3 pos_low = positions_transformed[low.pos ], pos_middle = positions_transformed[middle.pos ], pos_high = positions_transformed[high.pos ];
187187
188188#ifndef Z_CLIPPING
189189 if (pos_low.z < GLFix (CLIP_PLANE) || pos_middle.z < GLFix (CLIP_PLANE) || pos_high.z < GLFix (CLIP_PLANE))
@@ -201,7 +201,7 @@ bool Chunk::drawTriangle(const IndexedVertex &low, const IndexedVertex &middle,
201201
202202 VERTEX invisible[3 ];
203203 IndexedVertex visible[3 ];
204- Position *pos_visible[3 ];
204+ VECTOR3 *pos_visible[3 ];
205205 int count_invisible = -1 , count_visible = -1 ;
206206
207207 if (pos_low.z < GLFix (CLIP_PLANE))
@@ -374,15 +374,10 @@ void Chunk::render()
374374 && v13.y >= SCREEN_HEIGHT && v14.y >= SCREEN_HEIGHT && v15.y >= SCREEN_HEIGHT && v16.y >= SCREEN_HEIGHT)
375375 return ;
376376
377- std::fill (positions_perspective.begin (), positions_perspective.end (), std::make_pair<Position , bool >({0 , 0 , 0 }, false ));
377+ std::fill (positions_perspective.begin (), positions_perspective.end (), std::make_pair<VECTOR3 , bool >({0 , 0 , 0 }, false ));
378378
379379 for (unsigned int i = 0 ; i < positions.size (); i++)
380- {
381- Position &position = positions[i];
382- VERTEX t1{position.x , position.y , position.z , 0 , 0 , 0 }, t2;
383- nglMultMatVectRes (transformation, &t1, &t2);
384- positions_transformed[i] = {t2.x , t2.y , t2.z };
385- }
380+ nglMultMatVectRes (transformation, &positions[i], &positions_transformed[i]);
386381
387382 nglForceColor (true );
388383 const IndexedVertex *v = vertices_color.data ();
@@ -416,9 +411,9 @@ void Chunk::render()
416411 const VERTEX *ve = vertices_unaligned.data ();
417412 for (unsigned int i = 0 ; i < vertices_unaligned.size (); i += 4 , ve += 4 )
418413 {
419- nglMultMatVectRes (transformation, ve + 0 , &v1);
420- nglMultMatVectRes (transformation, ve + 1 , &v2);
421- nglMultMatVectRes (transformation, ve + 2 , &v3);
414+ nglMultMatVectRes (transformation, &ve[ 0 ] , &v1);
415+ nglMultMatVectRes (transformation, &ve[ 1 ] , &v2);
416+ nglMultMatVectRes (transformation, &ve[ 2 ] , &v3);
422417
423418 // nglMultMatVectRes doesn't copy u,v and c
424419 v1.u = ve[0 ].u ;
@@ -433,7 +428,7 @@ void Chunk::render()
433428
434429 if (nglDrawTriangle (&v1, &v2, &v3, (v1.c & TEXTURE_DRAW_BACKFACE) == 0 ))
435430 {
436- nglMultMatVectRes (transformation, ve + 3 , &v4);
431+ nglMultMatVectRes (transformation, &ve[ 3 ] , &v4);
437432 v4.u = ve[3 ].u ;
438433 v4.v = ve[3 ].v ;
439434 v4.c = ve[3 ].c ;
@@ -557,7 +552,7 @@ bool Chunk::intersects(AABB &other)
557552 return false ;
558553}
559554
560- bool Chunk::intersectsRay (GLFix rx, GLFix ry, GLFix rz, GLFix dx, GLFix dy, GLFix dz, GLFix &dist, Position &pos, AABB::SIDE &side, bool ignore_water)
555+ bool Chunk::intersectsRay (GLFix rx, GLFix ry, GLFix rz, GLFix dx, GLFix dy, GLFix dz, GLFix &dist, VECTOR3 &pos, AABB::SIDE &side, bool ignore_water)
561556{
562557 GLFix shortest_dist;
563558 if (aabb.intersectsRay (rx, ry, rz, dx, dy, dz, shortest_dist) == AABB::NONE)
@@ -787,9 +782,13 @@ void drawLoadingtext(const int i)
787782
788783 shown = true ;
789784
790- TEXTURE screen;
791- screen.width = SCREEN_WIDTH;
792- screen.height = SCREEN_HEIGHT;
793- screen.bitmap = reinterpret_cast <COLOR*>(SCREEN_BASE_ADDRESS);
794- drawTexture (loadingtext, screen, 0 , 0 , loadingtext.width , loadingtext.height , (SCREEN_WIDTH - loadingtext.width ) / 2 , 0 , loadingtext.width , loadingtext.height );
785+ if (lcd_type () != SCR_320x240_565 && lcd_type () != SCR_320x240_4)
786+ return ;
787+ #ifdef _TINSPIRE
788+ TEXTURE screen;
789+ screen.width = SCREEN_WIDTH;
790+ screen.height = SCREEN_HEIGHT;
791+ screen.bitmap = reinterpret_cast <COLOR*>(REAL_SCREEN_BASE_ADDRESS);
792+ drawTexture (loadingtext, screen, 0 , 0 , loadingtext.width , loadingtext.height , (SCREEN_WIDTH - loadingtext.width ) / 2 , 0 , loadingtext.width , loadingtext.height );
793+ #endif
795794}
0 commit comments