Add application version extracted from tags or commits

This commit is contained in:
Lucas S. Vieira 2024-11-02 21:00:28 -03:00
parent 6d3150b650
commit b7ad804e99
3 changed files with 29 additions and 10 deletions

View file

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21)
project(PSXEngine
LANGUAGES C CXX ASM
VERSION 1.0.0
VERSION 0.1.0
DESCRIPTION "Platformer Engine for PSX"
HOMEPAGE_URL "https://luksamuk.codes")
@ -14,6 +14,7 @@ list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake/")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
git_get_exact_tag(GIT_TAG)
string(SUBSTRING "${GIT_SHA1}" 0 7 GIT_SHORTHASH)
string(SUBSTRING "${GIT_REFSPEC}" 11 -1 GIT_BRANCH)
@ -22,6 +23,12 @@ add_definitions("-DGIT_SHA1=\"${GIT_SHA1}\"")
add_definitions("-DGIT_REFSPEC=\"${GIT_REFSPEC}\"")
add_definitions("-DGIT_COMMIT=\"${GIT_BRANCH}/${GIT_SHORTHASH}\"")
if(GIT_TAG)
add_definitions("-DGIT_VERSION=\"${GIT_TAG}\"")
else()
add_definitions("-DGIT_VERSION=\"GIT ${GIT_SHORTHASH}\"")
endif()
set(CMAKE_C_FLAGS "-Wall")
psn00bsdk_add_executable(engine

View file

@ -17,6 +17,9 @@
#define GIT_COMMIT "UNKNOWN"
#endif
#ifndef GIT_VERSION
#define GIT_VERSION "UNKNOWN"
#endif
#define BCD_TO_DEC(x) (((x & 0xF0) >> 4) * 10 + (x & 0x0F))
#define SIGNUM(x) (x < 0 ? -1 : 1)

View file

@ -10,6 +10,7 @@
#include "screen.h"
#include "sound.h"
#include "timer.h"
#include "basic_font.h"
#include "screens/fmv.h"
#include "screens/level.h"
@ -228,7 +229,7 @@ screen_title_drawtitle(screen_title_data *data)
255, 0,
0, 174,
255, 174);
sort_prim(poly, 1);
sort_prim(poly, 3);
}
static void
@ -262,7 +263,7 @@ screen_title_drawtxt(screen_title_data *data, uint8_t idx, int16_t cx, int16_t c
u0 + w , v0,
u0, v0 + h,
u0 + w , v0 + h);
sort_prim(poly, 0);
sort_prim(poly, 1);
}
static void
@ -300,7 +301,7 @@ screen_title_drawprl(screen_title_data *data)
w - 1, v0,
0, v0 + h,
w - 1, v0 + h);
sort_prim(poly, 1);
sort_prim(poly, OT_LENGTH - 2);
if(s) break;
}
@ -396,11 +397,19 @@ screen_title_draw(void *d)
if(data->menu_option < 3)
screen_title_drawtxt(data, 5, CENTERX + 60, 208);
}
int16_t x;
snprintf(buffer, 255, "v0.1 Beta");
x = SCREEN_XRES - (strlen(buffer) * 8) - 8;
draw_text(x, SCREEN_YRES - 14, 0, buffer);
}
int16_t x;
font_set_color(
LERPC(data->rgb_count, 200),
LERPC(data->rgb_count, 200),
LERPC(data->rgb_count, 200));
x = SCREEN_XRES - (strlen(GIT_VERSION) * 8) - 8;
font_draw_sm(GIT_VERSION, x, SCREEN_YRES - 21);
snprintf(buffer, 255, "2024 luksamuk");
x = SCREEN_XRES - (strlen(buffer) * 8) - 8;
font_draw_sm(buffer, x, SCREEN_YRES - 14);
}