better makefile with platforms

This commit is contained in:
Vincent-FK 2021-06-04 16:45:48 +02:00
parent 150cf58be2
commit 9f5cd6c745
9 changed files with 72 additions and 361 deletions

View File

@ -1,15 +1,19 @@
CC = $(CROSS_COMPILE)gcc -g
# By default, this will compile the standard executable
# (close to the original source code, with the original levels...)
#
# You can specify these specific platforms though:
# -"funkey": Specific levels, key mappings, and cross compilation params for the FunKey S
# -"funkey_simulated": Same as "funkey" but without the cross compilation so that you can try it on the host computer
TARGET_FUNKEY ?= 0
ifeq ($(TARGET_FUNKEY),1)
ifeq ($(platform), funkey)
SDL_INCLUDES = $(shell /opt/FunKey-sdk-2.0.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/sdl-config --cflags)
SDL_INCLUDES += $(shell /opt/FunKey-sdk-2.0.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/libmikmod-config --cflags)
SDL_LIBS = $(shell /opt/FunKey-sdk-2.0.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/sdl-config --libs)
SDL_LIBS += $(shell /opt/FunKey-sdk-2.0.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/libmikmod-config --libs)
SDL_LIBS += -Wl,--as-needed -Wl,--gc-sections -Wl,-O1,--sort-common -flto -s
CFLAGS_EXTRA = -DFUNKEY -DHW_SCREEN_RESIZE -DSOUND_SDL_ACTIVATED
else
SDL_INCLUDES = `sdl-config --cflags`
SDL_INCLUDES += `libmikmod-config --cflags`
@ -17,8 +21,12 @@ else
SDL_LIBS += `libmikmod-config --libs`
endif
ifeq ($(platform), funkey_simulated)
CFLAGS_EXTRA = -DFUNKEY -DHW_SCREEN_RESIZE -DSOUND_SDL_ACTIVATED
endif
DEPFLAGS = $(SDL_INCLUDES)
CFLAGS = -Wall -O -std=c99 $(SDL_INCLUDES)
CFLAGS = -Wall -O -std=c99 $(SDL_INCLUDES) $(CFLAGS_EXTRA)
LDFLAGS = $(SDL_LIBS) -lSDL_image -lSDL_mixer
SRC = $(wildcard src/*.c)

View File

@ -1,141 +0,0 @@
12:15
666686676696666
400000000000000
012121212121210
020202020202020
012121212121210
020202020202020
012121232121210
020202020202020
012121212121210
020202020202020
012121212121210
000000000000000
-
10:11
k4000000000
60020202020
70212121212
60020202020
80212121212
60020202020
90212121212
60020202020
60212121212
k0020202023
-
13:15
666667686966666
640022222222556
612121212121216
622000000000226
610121212121016
620220222022226
610121252121016
622220222022026
610121212121016
622000002000226
612121212121216
655222222222236
666666666666666
-
14:13
6668667669666
6500000002206
6000000100006
6000401102206
6211102002006
6120022211006
6220222200116
6001222112006
6221221102206
6001120022216
6101201100226
6102001022126
6002001100136
6666666666666
-
9:20
60000100010001000103
60022222222222222200
70020202020202020200
60022121212121212200
84020202020202020200
60022121212121212200
90020202020202020200
60022222222222222200
60010001000100010003
-
13:15
102020261101224
201021061200220
212212062201222
221221050001110
120122172200022
010022261120211
666566686665666
321200262122121
222101092101020
221221052121212
222122160102010
221210262211112
202020260202020
-
13:15
666676686696666
600222222222036
601212121112106
622002221110226
621110121110126
621112000222226
621112121211126
620222000211126
621011121211126
622011122200226
601211101012106
640222202222006
666666666666666
-
13:17
66666766866966666
01121121121121100
04101202201202200
01121121121121100
01121121121121122
02202202102202123
01121121121121122
01121121121121100
02201202201202200
01121121121121100
01121121121121122
02102202102202132
01121121121121122
-
9:20
62202120202100022005
62122212212212212200
70212221221221221220
63111020202120202122
81111111111111111102
64010222010220010022
62012010212012210221
90210212010212212211
62022010222012222011
-
15:19
0000066668666600000
0007662204022669000
0066222222222226600
0662222222222222660
6622222222222222266
6222266666666622226
6222600000000062226
6226006600066006226
6226006600066006226
6226006600066006226
6226006600066006226
6622600000000062266
0662266666666622660
0066222223222226600
0006666666666666000
-

View File

@ -1,87 +0,0 @@
9:20
k000010001000100013l
60020202020202022206
70020202020202020207
60020202020202022206
80020202020202020208
60020202020202022206
90020202020202020209
64020202020202022206
60j10001000100010006
-
13:13
j022222222204
0121212121210
0000000000000
2121212121212
2222222222222
2121212121212
0000000000000
2121212121212
2222222222222
0000000000000
2222222222222
2121212121212
0000003000000
-
14:13
k678941jl6789
5210002000125
0110002000110
0000211200000
2000020000002
1111102111111
2222220222222
2000000500000
2022222222220
2020000000020
2020222222020
2020200002020
2020202202020
2000203200020
-
13:17
k666676686696666k
22222021111111111
20220002200000200
21111011111120200
01511011115102002
21520200025120120
21222222222111202
212041j0211110010
01201110210020120
21222222210111202
01111111112020020
00200000000001111
3l66676686696666l
-
13:13
6420000020006
6020200020206
6020202020206
k02020002020l
6020202020206
7020200020207
6020202020206
8020200020208
6020202020206
9020200020209
6020202020206
6020200020206
60002000002j6
-
13:13
k66676869666k
4000000000000
0111111111100
0022222222200
0022000002200
0022122212200
0022123212200
0022122212200
0022000002200
0022222222200
0011111111110
000000000000j
l66676869666l
-

View File

@ -1,86 +0,0 @@
10:11
22232002222
20000000022
00000000002
00000000022
22000400022
20000000002
20000000002
20000000022
22000220002
20202022222
-
9:20
60000100010001000103
60022222222222222200
70020202020202020200
60022121212121212200
84020202020202020200
60022121212121212200
90020202020202020200
60022222222222222200
60010001000100010003
-
13:13
0111111111110
0122220222210
0123020203210
0122220222210
0111200021110
0001200021000
0001200021000
0001200021000
0001200021000
0001200021000
0001222221000
0000220220000
0000j22240000
-
14:13
k678941jl6789
5210002000125
0110002000110
0000211200000
2000020000002
1111102111111
2222220222222
2000000500000
2022222222220
2020000000020
2020222222020
2020200002020
2020202202020
2000203200020
-
15:19
0000066668666600000
0007662204022669000
0066222222222226600
0662222222222222660
6622222222222222266
6222266666666622226
6222600000000062226
6226006600066006226
6226006600066006226
6226006600066006226
6226006600066006226
6622600000000062266
0662266666666622660
0066222223222226600
0006666666666666000
-
13:17
k666676686696666k
22222021111111111
20220002200000200
21111011111120200
01511011115102002
21520200025120120
21222222222111202
212041j0211110010
01201110210020120
21222222210111202
01111111112020020
00200000000001111
3l66676686696666l
-

View File

@ -4,10 +4,10 @@
// Use Sound ?
//#define SOUND_FMOD_ACTIVATED
#define SOUND_SDL_ACTIVATED
//#define SOUND_SDL_ACTIVATED
// Resize ?
#define HW_SCREEN_RESIZE
//#define HW_SCREEN_RESIZE
#define HW_SCREEN_WIDTH 240
#define HW_SCREEN_HEIGHT 240
@ -163,7 +163,9 @@
#define PROBA_BONUS_MONSTER 30
// Name of the file that contains the map
#define SRC_MAP "data/level1.lvl"
#define SRC_LEVELS_1_PLAYER "data/levels_1p.lvl"
#define SRC_LEVELS_2_PLAYERS "data/levels_2p.lvl"
#define SRC_LEVELS_EDITOR "data/levels_editor.lvl"

View File

@ -30,12 +30,12 @@ t_game game_new(int nb_joueur, int niveau, int mode, int kill_bomb) {
FILE *level;
if (mode==1){
if (nb_joueur==1)
level=fopen("data/level1.lvl","r");
level=fopen(SRC_LEVELS_1_PLAYER,"r");
else
level=fopen("data/level13.lvl","r");
level=fopen(SRC_LEVELS_2_PLAYERS,"r");
}
else{
level=fopen("data/niveaux.lvl","r");
level=fopen(SRC_LEVELS_EDITOR,"r");
}
the_game.map = map_load_dynamic(level,niveau,nb_joueur);
the_game.player1 = player_init(2,1,1,1);

View File

@ -47,11 +47,15 @@ int input_update(t_game game, int nb_joueur) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_ESCAPE:
#ifdef FUNKEY
case SDLK_q:
#endif //FUNKEY
return 2;
case SDLK_UP:
#ifdef FUNKEY
case SDLK_u:
#endif //FUNKEY
player_set_current_way(player1, UP);
player_move(player1, map);
if (player_win(player1)==1){
@ -60,7 +64,9 @@ int input_update(t_game game, int nb_joueur) {
break;
case SDLK_DOWN:
#ifdef FUNKEY
case SDLK_d:
#endif //FUNKEY
player_set_current_way(player1, DOWN);
player_move(player1, map);
if (player_win(player1)==1){
@ -69,7 +75,9 @@ int input_update(t_game game, int nb_joueur) {
break;
case SDLK_RIGHT:
#ifdef FUNKEY
case SDLK_r:
#endif //FUNKEY
player_set_current_way(player1, RIGHT);
player_move(player1, map);
if (player_win(player1)==1){
@ -78,7 +86,9 @@ int input_update(t_game game, int nb_joueur) {
break;
case SDLK_LEFT:
#ifdef FUNKEY
case SDLK_l:
#endif //FUNKEY
player_set_current_way(player1, LEFT);
player_move(player1, map);
if (player_win(player1)==1){
@ -89,8 +99,10 @@ int input_update(t_game game, int nb_joueur) {
//sert à poser une bombe pour le joueur 1
case SDLK_END: //cette touche sert pour les ordinateurs portables qui n'ont pas forcément la touce 0 à côté des flèches directionnelles)
case SDLK_KP0:
#ifdef FUNKEY
case SDLK_a:
case SDLK_b:
#endif //FUNKEY
x= player_get_x(player1);
y= player_get_y(player1);
@ -102,7 +114,7 @@ int input_update(t_game game, int nb_joueur) {
}
break;
/*
#ifndef FUNKEY
// touches du joueur 2:
case SDLK_e:
if (nb_joueur == 2){
@ -154,7 +166,7 @@ int input_update(t_game game, int nb_joueur) {
}
}
break;
*/
#endif // not defined (FUNKEY)
default: break;
}

View File

@ -27,44 +27,46 @@ SDL_Surface *load_image(const char *filename) {
return img;
}
/// Nearest neighboor optimized with possible out of screen coordinates (for cropping)
void flip_NNOptimized_AllowOutOfScreen(SDL_Surface *virtual_screen, SDL_Surface *hardware_screen, int new_w, int new_h){
int w1=virtual_screen->w;
//int h1=virtual_screen->h;
int w2=new_w;
int h2=new_h;
int x_ratio = (int)((virtual_screen->w<<16)/w2);
int y_ratio = (int)((virtual_screen->h<<16)/h2);
int x2, y2 ;
#if defined(HW_SCREEN_RESIZE) && defined(HW_SCREEN_HEIGHT) && defined(HW_SCREEN_WIDTH)
/// Nearest neighboor optimized with possible out of screen coordinates (for cropping)
void flip_NNOptimized_AllowOutOfScreen(SDL_Surface *virtual_screen, SDL_Surface *hardware_screen, int new_w, int new_h){
int w1=virtual_screen->w;
//int h1=virtual_screen->h;
int w2=new_w;
int h2=new_h;
int x_ratio = (int)((virtual_screen->w<<16)/w2);
int y_ratio = (int)((virtual_screen->h<<16)/h2);
int x2, y2 ;
/// --- Compute padding for centering when out of bounds ---
int y_padding = (HW_SCREEN_HEIGHT-new_h)/2;
int x_padding = 0;
if(w2>HW_SCREEN_WIDTH){
x_padding = (w2-HW_SCREEN_WIDTH)/2 + 1;
}
int x_padding_ratio = x_padding*w1/w2;
//printf("virtual_screen->h=%d, h2=%d\n", virtual_screen->h, h2);
for (int i=0;i<h2;i++)
{
if(i>=HW_SCREEN_HEIGHT){
continue;
/// --- Compute padding for centering when out of bounds ---
int y_padding = (HW_SCREEN_HEIGHT-new_h)/2;
int x_padding = 0;
if(w2>HW_SCREEN_WIDTH){
x_padding = (w2-HW_SCREEN_WIDTH)/2 + 1;
}
int x_padding_ratio = x_padding*w1/w2;
//printf("virtual_screen->h=%d, h2=%d\n", virtual_screen->h, h2);
uint16_t* t = (uint16_t*)(hardware_screen->pixels+((i+y_padding)* ((w2>HW_SCREEN_WIDTH)?HW_SCREEN_WIDTH:w2) )*sizeof(uint16_t));
y2 = ((i*y_ratio)>>16);
uint16_t* p = (uint16_t*)(virtual_screen->pixels + (y2*w1 + x_padding_ratio) *sizeof(uint16_t));
int rat = 0;
for (int j=0;j<w2;j++)
for (int i=0;i<h2;i++)
{
if(j>=HW_SCREEN_WIDTH){
if(i>=HW_SCREEN_HEIGHT){
continue;
}
x2 = (rat>>16);
*t++ = p[x2];
rat += x_ratio;
//printf("y=%d, x=%d, y2=%d, x2=%d, (y2*virtual_screen->w)+x2=%d\n", i, j, y2, x2, (y2*virtual_screen->w)+x2);
uint16_t* t = (uint16_t*)(hardware_screen->pixels+((i+y_padding)* ((w2>HW_SCREEN_WIDTH)?HW_SCREEN_WIDTH:w2) )*sizeof(uint16_t));
y2 = ((i*y_ratio)>>16);
uint16_t* p = (uint16_t*)(virtual_screen->pixels + (y2*w1 + x_padding_ratio) *sizeof(uint16_t));
int rat = 0;
for (int j=0;j<w2;j++)
{
if(j>=HW_SCREEN_WIDTH){
continue;
}
x2 = (rat>>16);
*t++ = p[x2];
rat += x_ratio;
//printf("y=%d, x=%d, y2=%d, x2=%d, (y2*virtual_screen->w)+x2=%d\n", i, j, y2, x2, (y2*virtual_screen->w)+x2);
}
}
}
}
#endif

View File

@ -374,8 +374,9 @@ int editeur_choix_niveau(SDL_Surface *screen){
int are_you_sure(SDL_Surface *screen){
#warning Voluntary Bypass FunKey
#ifdef FUNKEY
return 1;
#endif //FUNKEY
#ifdef HW_SCREEN_RESIZE