mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2024-12-28 04:23:44 +01:00
Compare commits
2 commits
428be25c0e
...
12df54420b
Author | SHA1 | Date | |
---|---|---|---|
|
12df54420b | ||
|
950a7b5631 |
5 changed files with 81 additions and 60 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
# Build files
|
# Build files
|
||||||
/build-fx
|
/build-fx
|
||||||
|
/build-fxg3a
|
||||||
/build-cg
|
/build-cg
|
||||||
/build-cg-push
|
/build-cg-push
|
||||||
/*.g1a
|
/*.g1a
|
||||||
|
|
|
@ -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()
|
||||||
|
|
51
src/main.c
51
src/main.c
|
@ -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,21 @@ 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");
|
|
||||||
|
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]);*/
|
||||||
|
|
||||||
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;
|
||||||
|
|
77
src/moteur.c
77
src/moteur.c
|
@ -172,32 +172,67 @@ 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;
|
||||||
|
|
||||||
|
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){
|
||||||
|
|
||||||
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, ffloor(oldPos), 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 +274,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 +392,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;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#define screen_h 64
|
#define screen_h 64
|
||||||
#define viewport_w 128
|
#define viewport_w 128
|
||||||
#define viewport_h 64
|
#define viewport_h 64
|
||||||
#define max_dist fix(32) //en tuiles << 16, actuellement 32
|
#define max_dist fix(32)
|
||||||
|
|
||||||
#define TSIZE 32
|
#define TSIZE 32
|
||||||
|
|
||||||
|
@ -29,7 +29,11 @@ typedef struct {
|
||||||
|
|
||||||
} EngineTimers;
|
} 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 load_map();
|
||||||
void end_screen();
|
void end_screen();
|
||||||
|
|
Loading…
Reference in a new issue