fx : Première version propre

This commit is contained in:
attilavs2 2024-09-26 19:09:33 +02:00
parent 428be25c0e
commit 950a7b5631
3 changed files with 43 additions and 58 deletions

View file

@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.15)
project(Copy3DEngine LANGUAGES C ASM) project(Copy3DEngine LANGUAGES C ASM)
include(GenerateG1A) include(GenerateG1A)
include(GenerateG3A)
include(Fxconv) include(Fxconv)
find_package(Gint 2.9 REQUIRED) find_package(Gint 2.9 REQUIRED)
find_package(LibProf 2.1 REQUIRED) find_package(LibProf 2.1 REQUIRED)
@ -39,4 +40,7 @@ target_link_options(Copy3DEngine PRIVATE -Wl,--print-memory-usage)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
generate_g1a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g1a" generate_g1a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g1a"
NAME ${NAMEOFGAME} ICON assets-fx/icon.png) NAME ${NAMEOFGAME} ICON assets-fx/icon.png)
else()
generate_g3a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g3a"
NAME ${NAMEOFGAME} ICONS assets-fx/icon.png assets-fx/icon.png)
endif() endif()

View file

@ -72,26 +72,6 @@ void keys_get(){
#endif #endif
} }
bopti_image_t *bopti_make(int width, int height, int8_t fill){
//Make it so fill == 0xFF or 0x00
if(fill)
fill = 0xFF;
bopti_image_t *image = malloc(sizeof(bopti_image_t)+(width*height)/8+1);
image->data = (void*)image+sizeof(bopti_image_t);
image->gray = 0;
image->profile = IMAGE_MONO;
image->width = width;
image->height = height;
memset(image->data, fill, (width*height)/8+1);
return image;
}
void bopti_free(bopti_image_t *image){
free(image);
}
void main_menu(){ void main_menu(){
dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, NAMEOFGAME, -1); dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, NAMEOFGAME, -1);
dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De "AUTHOR, -1); dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De "AUTHOR, -1);
@ -118,26 +98,17 @@ int main(){
prof_init(); prof_init();
dtext(0,0,C_BLACK,"Activer le mode de gris ?"); if(dgray(DGRAY_ON))
dtext(0,10,C_BLACK,"Enable grayscale ?"); goto c3d_abort;
dtext(0,20,C_BLACK,"F1 : Oui/Yes"); dupdate();
dtext(0,30,C_BLACK,"F2 : Non/No");
dimage(0,0,tex_index[0]);
dimage(32,0,tex_index[1]);
dimage(64,0,tex_index[2]);
dimage(96,0,tex_index[3]);
dupdate(); dupdate();
key_event_t keyev = getkey(); getkey();
if(keyev.key == KEY_F1){
if(dgray(DGRAY_ON))
goto c3d_abort;
dupdate();
dimage(0,0,tex_index[0]);
dimage(32,0,tex_index[1]);
dimage(64,0,tex_index[2]);
dimage(96,0,tex_index[3]);
dupdate();
getkey();
}
#if debug #if debug
EngineTimers timers; EngineTimers timers;

View file

@ -172,32 +172,40 @@ void load_map(){
#if asm_opti #if asm_opti
#else #else
inline void __attribute__((always_inline)) draw_stripe(bopti_image_t *tex, int texSampleY, //Fonction fournie par le grand Lephe :D
int linePos, fixed_t texSize, int texX, int x){ inline int __attribute__((always_inline))
uint32_t *light, *dark; get_pixel(bopti_image_t const *img, int u, int v)
dgray_getvram(&light,&dark); {
int layers = 2;
int columns = (img->width + 31) >> 5;
struct rbox pxbox = { uint32_t const *layer_ptr = (void *)img->data;
.x = (texX&31)-(x&31), layer_ptr += (v * columns + (u >> 5)) * layers;
.visual_x = x,
.width = 1, uint32_t mask = 0x80000000u >> (u & 31);
.left = texX,
.columns = 1, int light = (layer_ptr[0] & mask) != 0;
.height = 1 int dark = (layer_ptr[1] & mask) != 0;
}; return (dark << 1) + light;
}
uint32_t *light, *dark;
inline void __attribute__((always_inline))
draw_stripe(bopti_image_t *tex, int texSampleY, int linePos, fixed_t texSize,
int texX, int x){
fixed_t screenPos = fix(linePos); fixed_t screenPos = fix(linePos);
for(int texPos = texSampleY; texPos < TSIZE; ++texPos){ for(int texPos = texSampleY; texPos < TSIZE; ++texPos){
if(screenPos >= 0){ if(screenPos >= 0){
fixed_t oldPos = screenPos; fixed_t oldPos = screenPos;
pxbox.top = texPos; int tpix = get_pixel(tex, texX, texPos);
do{ do{
if(screenPos >= fix(viewport_h)) if(screenPos >= fix(viewport_h))
return; return;
pxbox.y = ffloor(oldPos); dpixel(x, fceil(screenPos), tpix);
bopti_render_scsp(tex,&pxbox,light,dark);
oldPos += 0xFFFF; oldPos += 0xFFFF;
} while(oldPos < screenPos+texSize); } while(oldPos <= screenPos+texSize);
} }
screenPos += texSize; screenPos += texSize;
} }
@ -239,6 +247,8 @@ void draw_walls(
int texSample; int texSample;
int texSampleY; int texSampleY;
dgray_getvram(&light,&dark);
int v_offset = 0; //(int)(sin(f2int(posX + posY)) * 5); //a raffiner un peu int v_offset = 0; //(int)(sin(f2int(posX + posY)) * 5); //a raffiner un peu
fixed_t h_offset = 0; //fix(sin(f2int(posX - posY)) * 0.01); fixed_t h_offset = 0; //fix(sin(f2int(posX - posY)) * 0.01);
@ -355,13 +365,13 @@ void draw_walls(
lineHeight = f2int(fdiv(fix(viewport_h), perpWallDist)); //Taille en px de la ligne lineHeight = f2int(fdiv(fix(viewport_h), perpWallDist)); //Taille en px de la ligne
if (lineHeight < 1) lineHeight = 1; 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) / TSIZE; //taille proportionelle de la ligne a la tex fixed_t texSize = fix(lineHeight) / TSIZE; //taille proportionelle de la ligne a la tex
if (texSize < fix(1.0/(float)TSIZE)) texSize = fix(1.0/(float)TSIZE); //0x400 = 1/64 * 2^16 if (texSize < fix(1.0/(float)TSIZE)) texSize = fix(1.0/(float)TSIZE);
if (texSize > fix((float)viewport_h/(float)TSIZE)) { //0x3D000 = 3.8125 * 2^16, 3.8125 = viewport_h/64 if (texSize > fix((float)viewport_h/(float)TSIZE)) {
texSample = fceil(fdiv(fix(viewport_h), texSize)); texSample = fceil(fdiv(fix(viewport_h), texSize));
texSampleY = TSIZE/2 - texSample/2; texSampleY = TSIZE/2 - texSample/2;
} }
else { else {
texSample = TSIZE; texSample = TSIZE;