mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2024-12-29 13:03:44 +01:00
Compare commits
No commits in common. "12df54420b97e4635fd0ef52e3ed3723c8cdbbdf" and "428be25c0ecc35bb72427cc50a403518cf1016ec" have entirely different histories.
12df54420b
...
428be25c0e
5 changed files with 60 additions and 81 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,5 @@
|
|||
# Build files
|
||||
/build-fx
|
||||
/build-fxg3a
|
||||
/build-cg
|
||||
/build-cg-push
|
||||
/*.g1a
|
||||
|
|
|
@ -5,7 +5,6 @@ cmake_minimum_required(VERSION 3.15)
|
|||
project(Copy3DEngine LANGUAGES C ASM)
|
||||
|
||||
include(GenerateG1A)
|
||||
include(GenerateG3A)
|
||||
include(Fxconv)
|
||||
find_package(Gint 2.9 REQUIRED)
|
||||
find_package(LibProf 2.1 REQUIRED)
|
||||
|
@ -40,7 +39,4 @@ target_link_options(Copy3DEngine PRIVATE -Wl,--print-memory-usage)
|
|||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||
generate_g1a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g1a"
|
||||
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()
|
||||
|
|
51
src/main.c
51
src/main.c
|
@ -72,6 +72,26 @@ void keys_get(){
|
|||
#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(){
|
||||
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);
|
||||
|
@ -98,21 +118,26 @@ int main(){
|
|||
|
||||
prof_init();
|
||||
|
||||
if(dgray(DGRAY_ON))
|
||||
goto c3d_abort;
|
||||
dupdate();
|
||||
|
||||
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]);*/
|
||||
dtext(0,0,C_BLACK,"Activer le mode de gris ?");
|
||||
dtext(0,10,C_BLACK,"Enable grayscale ?");
|
||||
dtext(0,20,C_BLACK,"F1 : Oui/Yes");
|
||||
dtext(0,30,C_BLACK,"F2 : Non/No");
|
||||
|
||||
dupdate();
|
||||
getkey();
|
||||
key_event_t keyev = 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
|
||||
EngineTimers timers;
|
||||
|
|
77
src/moteur.c
77
src/moteur.c
|
@ -172,67 +172,32 @@ void load_map(){
|
|||
|
||||
#if asm_opti
|
||||
#else
|
||||
//Fonction fournie par le grand Lephe :D
|
||||
inline int __attribute__((always_inline))
|
||||
get_pixel(bopti_image_t const *img, int u, int v)
|
||||
{
|
||||
int layers = 2;
|
||||
int columns = (img->width + 31) >> 5;
|
||||
inline void __attribute__((always_inline)) draw_stripe(bopti_image_t *tex, int texSampleY,
|
||||
int linePos, fixed_t texSize, int texX, int x){
|
||||
uint32_t *light, *dark;
|
||||
dgray_getvram(&light,&dark);
|
||||
|
||||
uint32_t const *layer_ptr = (void *)img->data;
|
||||
layer_ptr += (v * columns + (u >> 5)) * layers;
|
||||
|
||||
uint32_t mask = 0x80000000u >> (u & 31);
|
||||
|
||||
int light = (layer_ptr[0] & mask) != 0;
|
||||
int dark = (layer_ptr[1] & mask) != 0;
|
||||
return (dark << 1) + light;
|
||||
}
|
||||
|
||||
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){
|
||||
struct rbox pxbox = {
|
||||
.x = (texX&31)-(x&31),
|
||||
.visual_x = x,
|
||||
.width = 1,
|
||||
.left = texX,
|
||||
.columns = 1,
|
||||
.height = 1
|
||||
};
|
||||
|
||||
fixed_t screenPos = fix(linePos);
|
||||
for(int texPos = texSampleY; texPos < TSIZE; ++texPos){
|
||||
if(screenPos >= 0){
|
||||
fixed_t oldPos = screenPos;
|
||||
int tpix = get_pixel(tex, texX, texPos);
|
||||
pxbox.top = texPos;
|
||||
do{
|
||||
if(screenPos >= fix(viewport_h))
|
||||
return;
|
||||
dpixel(x, ffloor(oldPos), tpix);
|
||||
pxbox.y = ffloor(oldPos);
|
||||
bopti_render_scsp(tex,&pxbox,light,dark);
|
||||
oldPos += 0xFFFF;
|
||||
} while(oldPos <= screenPos+texSize);
|
||||
} while(oldPos < screenPos+texSize);
|
||||
}
|
||||
screenPos += texSize;
|
||||
}
|
||||
|
@ -274,8 +239,6 @@ void draw_walls(
|
|||
int texSample;
|
||||
int texSampleY;
|
||||
|
||||
dgray_getvram(&light,&dark);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -392,13 +355,13 @@ void draw_walls(
|
|||
|
||||
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) / TSIZE; //taille proportionelle de la ligne a la tex
|
||||
if (texSize < fix(1.0/(float)TSIZE)) texSize = fix(1.0/(float)TSIZE);
|
||||
if (texSize > fix((float)viewport_h/(float)TSIZE)) {
|
||||
if (texSize < fix(1.0/(float)TSIZE)) texSize = fix(1.0/(float)TSIZE); //0x400 = 1/64 * 2^16
|
||||
if (texSize > fix((float)viewport_h/(float)TSIZE)) { //0x3D000 = 3.8125 * 2^16, 3.8125 = viewport_h/64
|
||||
texSample = fceil(fdiv(fix(viewport_h), texSize));
|
||||
texSampleY = TSIZE/2 - texSample/2;
|
||||
texSampleY = TSIZE/2 - texSample/2;
|
||||
}
|
||||
else {
|
||||
texSample = TSIZE;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define screen_h 64
|
||||
#define viewport_w 128
|
||||
#define viewport_h 64
|
||||
#define max_dist fix(32)
|
||||
#define max_dist fix(32) //en tuiles << 16, actuellement 32
|
||||
|
||||
#define TSIZE 32
|
||||
|
||||
|
@ -29,11 +29,7 @@ typedef struct {
|
|||
|
||||
} EngineTimers;
|
||||
|
||||
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 draw_stripe(bopti_image_t *tex, int texSampleY, int linePos, fixed_t texSize, int texX, int x);
|
||||
|
||||
void load_map();
|
||||
void end_screen();
|
||||
|
|
Loading…
Reference in a new issue