Optimisations compilateur et petites améliorations

This commit is contained in:
attilavs2 2023-12-03 12:13:09 +01:00
parent 25c6bee67a
commit f2669d8a57
4 changed files with 16 additions and 22 deletions

View file

@ -23,10 +23,10 @@ set(ASSETS
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(myaddin PRIVATE -Wall -Wextra -O3 -fira-region=all )
target_compile_options(myaddin PRIVATE -Wall -Wextra -Ofast -fira-region=all -flto -fno-math-errno -funsafe-math-optimizations -fassociative-math -freciprocal-math)
target_link_libraries(myaddin Gint::Gint )
target_link_libraries(myaddin LibProf::LibProf)
target_link_options(myaddin PRIVATE -Wl,--print-memory-usage)
target_link_options(myaddin PRIVATE -Wl,--print-memory-usage,-flto)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(TARGET myaddin OUTPUT "Maze3D.g3a"

View file

@ -6,7 +6,7 @@
#include <gint/image.h>
#include <libprof.h>
#define USB
//#define USB
#ifdef USB
#include <gint/usb-ff-bulk.h>
@ -18,7 +18,7 @@
#include "moteur.h"
#include "map_test.h"
//====== Maze3D V0.2 =====
//====== Maze3D V0.3 =====
// Git du moteur : https://github.com/attilavs2/Raycaster_G90
// Git du jeu : https://gitea.planet-casio.com/Fcalva/Maze3D
//
@ -141,8 +141,6 @@ int main(){
drect(0, 0, 395, 112, 0x9dbd);
drect(0,112, 395, 243, 0xc4c9);
image_clear(frame_buffer);
draw_walls(&buisson0, &briques0, &sky_tex, &WXOR_tex, &D_tex, frame_buffer);
if(first_frame == 1) main_menu();

View file

@ -8,7 +8,7 @@ char map_test[map_w][map_h] = {
{1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,1,2,1,1,1,1,1,1,0,0,0,1,0,1,1,1,0,0,1,0,1,0,1,1,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* 0.5 + rand() * 0.5;
seed_x = seed & 0b00000000000000000000000001111111;
seed_y = (seed >> 8) & 0b00000000000000000000000000111111;
seed_x = seed & 0b1111111;
seed_y = (seed >> 8) & 0b111111;
if (seed_x < map_w && seed_y < map_h && (seed_x < 111 && seed_y > 15)){
if(map_test[seed_x][seed_y] == 0){
break;
@ -144,7 +145,7 @@ void spawn_gen(){
}
fixed_t start_dirX, start_dirY;
int dirSeed = (seed >> 9) & 0b00000000000000000000000000000011 ;
int dirSeed = (seed >> 9) & 0b11 ;
switch(dirSeed){
case 0: {
start_dirX = 0x0;
@ -204,7 +205,6 @@ void draw_walls(image_t *tex_1, image_t *tex_2, image_t *tex_3, image_t *tex_4,
extern fixed_t planeY;
extern char map_test[map_w][map_h];
unsigned short color;
fixed_t cameraX;
fixed_t rayDirX;
fixed_t rayDirY;
@ -219,7 +219,6 @@ void draw_walls(image_t *tex_1, image_t *tex_2, image_t *tex_3, image_t *tex_4,
int mapY;
int stepX; //what direction to step in x or y-direction (either +1 or -1)
int stepY;
int hit = 0; //was there a wall hit?
int side; //was a NS or a EW wall hit?
int lineHeight;
int texX;
@ -286,12 +285,10 @@ void draw_walls(image_t *tex_1, image_t *tex_2, image_t *tex_3, image_t *tex_4,
while(true) {
//Check if the ray is out of range/bounds
if (sideDistX >= max_dist || sideDistY >= max_dist || mapX < 0 || mapY < 0 || mapX >= map_w || mapY >= map_h) {
hit = 0;
break;
}
//Otherwise check if ray has hit a wall
else if (map_test[mapX][mapY] != 0) {
hit = 1;
else if (map_test[mapX][mapY] > 0) {
break;
}
//jump to next map square, either in x-direction, or in y-direction
@ -336,20 +333,19 @@ void draw_walls(image_t *tex_1, image_t *tex_2, image_t *tex_3, image_t *tex_4,
lineHeight = f2int(fdiv(fix(viewport_h), perpWallDist)); //Taille en px de la ligne
if (lineHeight < 1) lineHeight = 1;
if (lineHeight > viewport_h) lineHeight = viewport_h - 1;
//if (lineHeight > viewport_h) lineHeight = viewport_h - 1;
fixed_t texSize = fix(lineHeight) / 64; //taille proportionelle de la ligne a la tex
if (texSize < 0x400) texSize = 0x400; //0x400 = 1/64 * 2^16
if (texSize > 0x3D000) { //0x3D000 = 3.8125 * 2^16, 3.8125 = viewport_h/64
texSample = fceil(fdiv(fix(viewport_h), texSize));
texSampleY = 32 - (int)texSample * 0.5 + 1;
texSampleY = 32 - (int)texSample * 0.5;
}
else {
texSample = 64;
texSampleY = 0;
}
image_t texStripe;
image_clear(&texStripe);