mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2024-12-28 20:43:44 +01:00
Merge branch 'dev'
This commit is contained in:
commit
f4cec3a625
4 changed files with 100 additions and 42 deletions
|
@ -2,7 +2,7 @@
|
||||||
# toolchain file and module path of the fxSDK
|
# toolchain file and module path of the fxSDK
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
project(Copy3DEngine)
|
project(Copy3DEngine LANGUAGES C ASM)
|
||||||
|
|
||||||
include(GenerateG3A)
|
include(GenerateG3A)
|
||||||
include(Fxconv)
|
include(Fxconv)
|
||||||
|
@ -18,6 +18,7 @@ set(SOURCES
|
||||||
src/main.c
|
src/main.c
|
||||||
src/moteur.c
|
src/moteur.c
|
||||||
src/map.c
|
src/map.c
|
||||||
|
# src/opti.S
|
||||||
)
|
)
|
||||||
|
|
||||||
set(ASSETS
|
set(ASSETS
|
||||||
|
|
26
src/main.c
26
src/main.c
|
@ -27,10 +27,6 @@
|
||||||
#error Ce code est pour FXCG50/G90+E uniquement, enlevez ce message a vos riques et périls
|
#error Ce code est pour FXCG50/G90+E uniquement, enlevez ce message a vos riques et périls
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define debug //pour afficher les infos de debug
|
|
||||||
|
|
||||||
//extern uint16_t *gint_vram;
|
|
||||||
|
|
||||||
image_t *tex_index[TINDEX_S];
|
image_t *tex_index[TINDEX_S];
|
||||||
|
|
||||||
extern char map_test[map_w][map_h];
|
extern char map_test[map_w][map_h];
|
||||||
|
@ -73,7 +69,7 @@ void keys_get(){
|
||||||
if (keydown(KEY_EXIT)) exit_game = 1;
|
if (keydown(KEY_EXIT)) exit_game = 1;
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
if (keydown(KEY_TAN)) end_screen();
|
//if (keydown(KEY_TAN)) end_screen();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +89,6 @@ int main(){
|
||||||
|
|
||||||
load_map();
|
load_map();
|
||||||
|
|
||||||
image_t *frame_buffer = image_create_vram();
|
|
||||||
|
|
||||||
extern image_t *tex_index[TINDEX_S];
|
extern image_t *tex_index[TINDEX_S];
|
||||||
|
|
||||||
tex_index[1] = &buisson0;
|
tex_index[1] = &buisson0;
|
||||||
|
@ -110,6 +104,10 @@ int main(){
|
||||||
|
|
||||||
prof_init();
|
prof_init();
|
||||||
|
|
||||||
|
#if debug
|
||||||
|
EngineTimers timers;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (!exit_game) {
|
while (!exit_game) {
|
||||||
prof_t frame = prof_make();
|
prof_t frame = prof_make();
|
||||||
prof_enter(frame);
|
prof_enter(frame);
|
||||||
|
@ -119,23 +117,31 @@ int main(){
|
||||||
dma_memset((void*)((uint32_t)gint_vram + viewport_w*viewport_h),
|
dma_memset((void*)((uint32_t)gint_vram + viewport_w*viewport_h),
|
||||||
0xc4c9c4c9, viewport_w*viewport_h);
|
0xc4c9c4c9, viewport_w*viewport_h);
|
||||||
|
|
||||||
draw_walls();
|
|
||||||
|
|
||||||
if(first_frame){
|
if(first_frame){
|
||||||
main_menu();
|
main_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
keys_get();
|
keys_get();
|
||||||
|
|
||||||
|
draw_walls(
|
||||||
|
#if debug
|
||||||
|
&timers
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
if (disp_frame_time == 1) dprint( 1, 10, C_BLACK, "Frame time : %d ms", frame_time);
|
if (disp_frame_time == 1) dprint( 1, 10, C_BLACK, "Frame time : %d ms", frame_time);
|
||||||
|
|
||||||
#ifdef debug
|
#if debug
|
||||||
dprint( 1, 20, C_BLACK, "planeX : %d", planeX);
|
dprint( 1, 20, C_BLACK, "planeX : %d", planeX);
|
||||||
dprint( 1, 30, C_BLACK, "planeY : %d", planeY);
|
dprint( 1, 30, C_BLACK, "planeY : %d", planeY);
|
||||||
dprint( 1, 40, C_BLACK, "dirX : %d", dirX);
|
dprint( 1, 40, C_BLACK, "dirX : %d", dirX);
|
||||||
dprint( 1, 50, C_BLACK, "dirY : %d", dirY);
|
dprint( 1, 50, C_BLACK, "dirY : %d", dirY);
|
||||||
dprint( 1, 60, C_BLACK, "posX : %d", posX);
|
dprint( 1, 60, C_BLACK, "posX : %d", posX);
|
||||||
dprint( 1, 70, C_BLACK, "posY : %d", posY);
|
dprint( 1, 70, C_BLACK, "posY : %d", posY);
|
||||||
|
dprint( 1, 80, C_BLACK, "Raycast time : %d", prof_time(timers.raycast_time));
|
||||||
|
dprint( 1, 90, C_BLACK, "Draw time : %d", prof_time(timers.draw_time));
|
||||||
|
timers.raycast_time = prof_make();
|
||||||
|
timers.draw_time = prof_make();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dupdate();
|
dupdate();
|
||||||
|
|
51
src/moteur.c
51
src/moteur.c
|
@ -167,21 +167,41 @@ void load_map(){
|
||||||
spawn_gen();
|
spawn_gen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_stripe(image_t *tex, int texSampleY, int texSample, int linePos, fixed_t texSize, int texX, int x){
|
#if asm_opti
|
||||||
|
#else
|
||||||
|
inline void __attribute__((always_inline)) draw_stripe(image_t *tex, int texSampleY,
|
||||||
|
int linePos, fixed_t texSize, int texX, int x){
|
||||||
fixed_t screenPos = fix(linePos);
|
fixed_t screenPos = fix(linePos);
|
||||||
uint32_t texDat = (uint32_t)tex->data + 2*texX;
|
uint32_t texDat = (uint32_t)tex->data + 2*texX;
|
||||||
for(int texPos = texSampleY; texPos < 64; texPos++){
|
register int vramSize asm("r2") = 396;
|
||||||
if(screenPos < -texSize) goto noDraw;
|
register int oneConst asm("r12");
|
||||||
for(fixed_t oldPos = screenPos; oldPos < screenPos+texSize; oldPos+=0xFFFF){
|
asm("mov #-1, r12\n"
|
||||||
gint_vram[ffloor(oldPos)*396+x] = *(uint16_t*)texDat;
|
"extu.w r12, r12"
|
||||||
|
: "=r" (oneConst)
|
||||||
|
: "r" (oneConst)
|
||||||
|
);
|
||||||
|
for(int texPos = texSampleY; texPos < 64; ++texPos){
|
||||||
|
if(screenPos >= -texSize){
|
||||||
|
int vrampos = ffloor(screenPos)*vramSize+x;
|
||||||
|
fixed_t oldPos = screenPos;
|
||||||
|
int16_t pix = *(int16_t*)texDat;
|
||||||
|
do{
|
||||||
|
gint_vram[vrampos] = pix;
|
||||||
|
vrampos += vramSize;
|
||||||
|
oldPos += oneConst;
|
||||||
|
}while(oldPos < screenPos+texSize);
|
||||||
}
|
}
|
||||||
noDraw:
|
|
||||||
screenPos += texSize;
|
screenPos += texSize;
|
||||||
texDat += tex->stride;
|
texDat += tex->stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void draw_walls(){
|
void draw_walls(
|
||||||
|
#if debug
|
||||||
|
EngineTimers *timers
|
||||||
|
#endif
|
||||||
|
){
|
||||||
extern fixed_t posX;
|
extern fixed_t posX;
|
||||||
extern fixed_t posY;
|
extern fixed_t posY;
|
||||||
extern fixed_t dirX;
|
extern fixed_t dirX;
|
||||||
|
@ -218,6 +238,9 @@ void draw_walls(){
|
||||||
struct image_linear_map temp;
|
struct image_linear_map temp;
|
||||||
|
|
||||||
for(x = 0; x < viewport_w; x++) {
|
for(x = 0; x < viewport_w; x++) {
|
||||||
|
#if debug
|
||||||
|
prof_enter(timers->raycast_time);
|
||||||
|
#endif
|
||||||
|
|
||||||
//calculate ray position and direction
|
//calculate ray position and direction
|
||||||
cameraX = fdiv(fix(x*2), fix(viewport_w)) - 0xFFFF + h_offset; //x-coordinate in camera space
|
cameraX = fdiv(fix(x*2), fix(viewport_w)) - 0xFFFF + h_offset; //x-coordinate in camera space
|
||||||
|
@ -241,6 +264,7 @@ void draw_walls(){
|
||||||
// stepping further below works. So the values can be computed as below.
|
// stepping further below works. So the values can be computed as below.
|
||||||
// Division through zero is prevented, even though technically that's not
|
// Division through zero is prevented, even though technically that's not
|
||||||
// needed in C++ with IEEE 754 floating point values.
|
// needed in C++ with IEEE 754 floating point values.
|
||||||
|
//Fcalva : It is with fp32s !
|
||||||
|
|
||||||
rayDirX = rayDirX == 0 ? 1 : rayDirX;
|
rayDirX = rayDirX == 0 ? 1 : rayDirX;
|
||||||
rayDirY = rayDirY == 0 ? 1 : rayDirY;
|
rayDirY = rayDirY == 0 ? 1 : rayDirY;
|
||||||
|
@ -277,7 +301,7 @@ void draw_walls(){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Otherwise check if ray has hit a wall
|
//Otherwise check if ray has hit a wall
|
||||||
else if (map_test[mapX][mapY] > 0) {
|
if (map_test[mapX][mapY] > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//jump to next map square, either in x-direction, or in y-direction
|
//jump to next map square, either in x-direction, or in y-direction
|
||||||
|
@ -302,6 +326,11 @@ void draw_walls(){
|
||||||
if (side == 0) perpWallDist = (sideDistX - deltaDistX);
|
if (side == 0) perpWallDist = (sideDistX - deltaDistX);
|
||||||
else perpWallDist = (sideDistY - deltaDistY);
|
else perpWallDist = (sideDistY - deltaDistY);
|
||||||
|
|
||||||
|
#if debug
|
||||||
|
prof_leave(timers->raycast_time);
|
||||||
|
prof_enter(timers->draw_time);
|
||||||
|
#endif
|
||||||
|
|
||||||
//texturing calculations
|
//texturing calculations
|
||||||
|
|
||||||
//calculate value of wallX
|
//calculate value of wallX
|
||||||
|
@ -336,6 +365,10 @@ void draw_walls(){
|
||||||
|
|
||||||
image_t *tex = tex_index[map_test[mapX][mapY]];
|
image_t *tex = tex_index[map_test[mapX][mapY]];
|
||||||
|
|
||||||
draw_stripe(tex, texSampleY, texSample, linePos, texSize, texX, x);
|
draw_stripe(tex, texSampleY, linePos, texSize, texX, x);
|
||||||
|
|
||||||
|
#if debug
|
||||||
|
prof_leave(timers->draw_time);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
src/moteur.h
20
src/moteur.h
|
@ -3,6 +3,7 @@
|
||||||
#ifndef moteur_h
|
#ifndef moteur_h
|
||||||
#define moteur_h
|
#define moteur_h
|
||||||
|
|
||||||
|
#include "libprof.h"
|
||||||
#include <gint/image.h>
|
#include <gint/image.h>
|
||||||
|
|
||||||
//param. graphiques
|
//param. graphiques
|
||||||
|
@ -14,9 +15,26 @@
|
||||||
|
|
||||||
#define TINDEX_S 256
|
#define TINDEX_S 256
|
||||||
|
|
||||||
|
#define debug 0 //pour afficher les infos de debug
|
||||||
|
|
||||||
|
#define asm_opti 0
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
prof_t raycast_time;
|
||||||
|
prof_t draw_time;
|
||||||
|
|
||||||
|
} EngineTimers;
|
||||||
|
|
||||||
|
void draw_stripe(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();
|
||||||
void draw_walls();
|
void draw_walls(
|
||||||
|
#if debug
|
||||||
|
EngineTimers *timers
|
||||||
|
#endif
|
||||||
|
);
|
||||||
void move();
|
void move();
|
||||||
|
|
||||||
#endif /* moteur */
|
#endif /* moteur */
|
||||||
|
|
Loading…
Reference in a new issue