mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2024-12-28 04:23:44 +01:00
fx : Première version propre
This commit is contained in:
parent
428be25c0e
commit
950a7b5631
3 changed files with 43 additions and 58 deletions
|
@ -5,6 +5,7 @@ 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)
|
||||
|
@ -39,4 +40,7 @@ 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()
|
||||
|
|
47
src/main.c
47
src/main.c
|
@ -72,26 +72,6 @@ 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);
|
||||
|
@ -118,26 +98,17 @@ int main(){
|
|||
|
||||
prof_init();
|
||||
|
||||
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");
|
||||
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();
|
||||
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();
|
||||
}
|
||||
getkey();
|
||||
|
||||
#if debug
|
||||
EngineTimers timers;
|
||||
|
|
50
src/moteur.c
50
src/moteur.c
|
@ -172,32 +172,40 @@ void load_map(){
|
|||
|
||||
#if asm_opti
|
||||
#else
|
||||
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);
|
||||
//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;
|
||||
|
||||
struct rbox pxbox = {
|
||||
.x = (texX&31)-(x&31),
|
||||
.visual_x = x,
|
||||
.width = 1,
|
||||
.left = texX,
|
||||
.columns = 1,
|
||||
.height = 1
|
||||
};
|
||||
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;
|
||||
|
||||
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);
|
||||
for(int texPos = texSampleY; texPos < TSIZE; ++texPos){
|
||||
if(screenPos >= 0){
|
||||
fixed_t oldPos = screenPos;
|
||||
pxbox.top = texPos;
|
||||
int tpix = get_pixel(tex, texX, texPos);
|
||||
do{
|
||||
if(screenPos >= fix(viewport_h))
|
||||
return;
|
||||
pxbox.y = ffloor(oldPos);
|
||||
bopti_render_scsp(tex,&pxbox,light,dark);
|
||||
dpixel(x, fceil(screenPos), tpix);
|
||||
oldPos += 0xFFFF;
|
||||
} while(oldPos < screenPos+texSize);
|
||||
} while(oldPos <= screenPos+texSize);
|
||||
}
|
||||
screenPos += texSize;
|
||||
}
|
||||
|
@ -239,6 +247,8 @@ 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);
|
||||
|
||||
|
@ -355,13 +365,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); //0x400 = 1/64 * 2^16
|
||||
if (texSize > fix((float)viewport_h/(float)TSIZE)) { //0x3D000 = 3.8125 * 2^16, 3.8125 = viewport_h/64
|
||||
if (texSize < fix(1.0/(float)TSIZE)) texSize = fix(1.0/(float)TSIZE);
|
||||
if (texSize > fix((float)viewport_h/(float)TSIZE)) {
|
||||
texSample = fceil(fdiv(fix(viewport_h), texSize));
|
||||
texSampleY = TSIZE/2 - texSample/2;
|
||||
texSampleY = TSIZE/2 - texSample/2;
|
||||
}
|
||||
else {
|
||||
texSample = TSIZE;
|
||||
|
|
Loading…
Reference in a new issue