From d980f28fb7c360164a95ac41817e23f8fe1380f6 Mon Sep 17 00:00:00 2001 From: attilavs2 Date: Sun, 20 Aug 2023 15:45:57 +0200 Subject: [PATCH] Tests sampling --- CMakeLists.txt | 2 +- src/main.c | 2 +- src/moteur.c | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 769b34e..a666cb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ 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 -Os) +target_compile_options(myaddin PRIVATE -Wall -Wextra -Ofast) target_link_libraries(myaddin Gint::Gint ) target_link_libraries(myaddin LibProf::LibProf) target_link_options(myaddin PRIVATE -Wl,--print-memory-usage) diff --git a/src/main.c b/src/main.c index f33e29c..66f2e02 100644 --- a/src/main.c +++ b/src/main.c @@ -43,7 +43,7 @@ void USB_capture() { } #endif -//#define debug //pour afficher les infos de debug +#define debug //pour afficher les infos de debug extern char map_test[map_w][map_h]; diff --git a/src/moteur.c b/src/moteur.c index 6e7e689..0d99fc7 100644 --- a/src/moteur.c +++ b/src/moteur.c @@ -261,7 +261,11 @@ void draw_walls(image_t *tex_1, image_t *tex_2, image_t *tex_3, image_t *tex_4, deltaDistY = abs(fdiv(0xFFFF, rayDirY)); //calculate step and initial sideDist - if (rayDirX <= 0) { + if (rayDirX == 0) { + stepX = 0; + sideDistX = 0; + } + else if (rayDirX < 0) { stepX = -1; //true sideDistX = fmul(posX - fix(mapX), deltaDistX); } @@ -270,7 +274,11 @@ void draw_walls(image_t *tex_1, image_t *tex_2, image_t *tex_3, image_t *tex_4, sideDistX = fmul( fix(mapX + 1) - posX, deltaDistX); } - if (rayDirY <= 0) { + if (rayDirY == 0) { + stepY = 0; + sideDistY = 0; + } + else if (rayDirY < 0) { stepY = -1; //true sideDistY = fmul(posY - fix(mapY), deltaDistY); } @@ -338,7 +346,7 @@ void draw_walls(image_t *tex_1, image_t *tex_2, image_t *tex_3, image_t *tex_4, if (texSize < 0x400) texSize = 0x400; //0x400 = 1/64 * 2^16 if (texSize > 0x3D000) { //0x3D000 = 3.8125 * 2^16, 3.8125 = viewport_h/64 texSample = ffloor(fdiv(fix(viewport_h), texSize)); - texSampleY = 32 - (int)texSample * 0.5; + texSampleY = 32 - (int)texSample * 0.5 + 1; } else { texSample = 64;