diff --git a/.gitignore b/.gitignore index b1dcd19..ca88d08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Build files /build-fx +/build-fxg3a /build-cg /build-cg-push /*.g1a diff --git a/src/main.c b/src/main.c index f35280f..021a627 100644 --- a/src/main.c +++ b/src/main.c @@ -102,10 +102,14 @@ int main(){ goto c3d_abort; dupdate(); - dimage(0,0,tex_index[0]); + dclear(C_WHITE); + + dscale_bopti(&briques0, fix(2), fix(2), 0, 0); + + /*dimage(0,0,tex_index[0]); dimage(32,0,tex_index[1]); dimage(64,0,tex_index[2]); - dimage(96,0,tex_index[3]); + dimage(96,0,tex_index[3]);*/ dupdate(); getkey(); diff --git a/src/moteur.c b/src/moteur.c index cd87bdc..785e5bf 100644 --- a/src/moteur.c +++ b/src/moteur.c @@ -191,6 +191,33 @@ inline int __attribute__((always_inline)) uint32_t *light, *dark; +void dscale_bopti(bopti_image_t *tex, fixed_t scale_x, fixed_t scale_y, int x, int y){ + fixed_t screen_x = x; + fixed_t screen_y = y; + for(fixed_t tex_y = 0; tex_y < fix(tex->height); tex_y+=scale_y){ + yloop: + ;//For clangd which doesn't like the label (?) + fixed_t oldy = screen_y; + screen_y += scale_y; + if(screen_y >= 64) + break; + for(; oldy < screen_x; oldy += 0xFFFF){ + for(fixed_t tex_x = 0; tex_x < fix(tex->width); tex_x+=scale_x){ + fixed_t oldx = screen_x; + screen_x += scale_x; + if(screen_x >= 128) + goto yloop; + int tpix = get_pixel(tex, tex_x, tex_y); + for(; oldx < screen_x; oldx += 0xFFFF){ + dpixel(screen_x, screen_y, tpix); + } + screen_x = oldx; + } + } + screen_y = oldy; + } +} + inline void __attribute__((always_inline)) draw_stripe(bopti_image_t *tex, int texSampleY, int linePos, fixed_t texSize, int texX, int x){ @@ -203,7 +230,7 @@ inline void __attribute__((always_inline)) do{ if(screenPos >= fix(viewport_h)) return; - dpixel(x, fceil(screenPos), tpix); + dpixel(x, ffloor(oldPos), tpix); oldPos += 0xFFFF; } while(oldPos <= screenPos+texSize); } diff --git a/src/moteur.h b/src/moteur.h index 28dd922..e02d1c2 100644 --- a/src/moteur.h +++ b/src/moteur.h @@ -12,7 +12,7 @@ #define screen_h 64 #define viewport_w 128 #define viewport_h 64 -#define max_dist fix(32) //en tuiles << 16, actuellement 32 +#define max_dist fix(32) #define TSIZE 32 @@ -29,7 +29,11 @@ typedef struct { } EngineTimers; -void draw_stripe(bopti_image_t *tex, int texSampleY, int linePos, fixed_t texSize, int texX, int x); +void dscale_bopti(bopti_image_t *tex, fixed_t scale_x, fixed_t scale_y, + int x, int y); + +void draw_stripe(bopti_image_t *tex, int texSampleY, int linePos, + fixed_t texSize, int texX, int x); void load_map(); void end_screen();