prepare CMake switch (WIP) + fix keyboard with the new API

This commit is contained in:
Yann MAGNIN 2022-12-04 18:33:46 +01:00
parent be50e9fc66
commit efefd25173
6 changed files with 58 additions and 117 deletions

44
CMakeLists.txt Normal file
View File

@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.15)
if(
NOT DEFINED ENV{VXSDK_PKG_NAME}
OR NOT DEFINED ENV{VXSDK_PKG_VERSION}
OR NOT DEFINED ENV{VXSDK_BUILD_CFLAGS}
OR NOT DEFINED ENV{VXSDK_BUILD_LDFLAGS}
OR NOT DEFINED ENV{VXSDK_BUILD_LIBS}
OR NOT DEFINED ENV{VXSDK_PREFIX_BUILD}
OR NOT DEFINED ENV{VXSDK_PREFIX_INSTALL})
message(FATAL_ERROR "You should use the vxSDK to build this project")
endif()
set(VXSDK_PKG_NAME $ENV{VXSDK_PKG_NAME})
set(VXSDK_PKG_VERSION $ENV{VXSDK_PKG_VERSION})
set(VXSDK_PREFIX_BUILD $ENV{VXSDK_PREFIX_BUILD})
set(VXSDK_PREFIX_INSTALL $ENV{VXSDK_PREFIX_INSTALL})
set(VXSDK_BUILD_CFLAGS $ENV{VXSDK_BUILD_CFLAGS})
set(VXSDK_BUILD_LDFLAGS $ENV{VXSDK_BUILD_LDFLAGS})
set(VXSDK_BUILD_LIBS $ENV{VXSDK_BUILD_LIBS})
#---
# handle project-specific information
#---
project(${VXSDK_PKG_NAME} VERSION ${VXSDK_PKG_VERSION} LANGUAGES C ASM)
#---
# Handle source listing
#---
file(GLOB_RECURSE SOURCES src *.c *.S *.s)
#---
# Compile-specific declaration
#---
link_directories(${VXSDK_PREFIX_INSTALL}/lib)
include_directories(include ${VXSDK_PREFIX_INSTALL}/include)
add_compile_options(-Wall -Wextra ${VXSDK_BUILD_CFLAGS})
add_executable(${VXSDK_PKG_NAME} ${SOURCES})
target_link_libraries(${VXSDK_PKG_NAME} ${VXSDK_BUILD_LIBS})

Binary file not shown.

View File

@ -1,93 +0,0 @@
#! /usr/bin/make -f
#
# variable definition
#
# color definition, for swagg :D
red := \033[1;31m
green := \033[1;32m
blue := \033[1;34m
white := \033[1;37m
nocolor := \033[1;0m
src := $(foreach path,\
$(shell find src -not -path "*/\.*" -type d), \
$(wildcard $(path)/*.c) \
$(wildcard $(path)/*.S) \
$(wildcard $(path)/*.s))
obj := $(patsubst src_%,$(VXSDK_PREFIX_BUILD)/%.o,$(subst /,_,$(src)))
obj += $(patsubst \
$(VXSDK_ASSETS_SRC)/%,\
$(VXSDK_ASSETS_BUILD)/%.o,\
$(wildcard $(VXSDK_ASSETS_SRC)/*.c) \
)
cflags := -ffreestanding -nostdlib -m4-nofpu -fPIE -O1
cflags += -mb -fstrict-volatile-bitfields -Wa,--dsp
cflags += $(VXSDK_CFLAGS_INCLUDE) -Iinclude
# debug vars
VERBOSE ?= true
#
# build rules
#
GravityDuck: $(obj)
@ printf "$(blue)Create $(red)$@$(nocolor)\n"
sh-elf-vhex-gcc \
-T $(VXSDK_PREFIX_LIB)/fxcg50.ld \
-Wl,-q -Wl,-Map=$(VXSDK_PREFIX_BUILD)/map \
$(VXSDK_CFLAGS_LINK) \
-o $@ $^ \
-Wl,--whole-archive -lvhex-fxcg50 \
-Wl,--no-whole-archive -lc -lgcc
#vxsdk conv addin -b $@ -n vxaddin -o /tmp/vxaddin
version:
@echo "$(VXSDK_PKG_VERSION)"
help:
@ echo 'Rules listing:'
@ echo '... all the default, if no target is provided'
@ echo '... clean remove build object'
@ echo '... fclean remove all generated object'
@ echo '... re same as `make fclean all`'
@ echo '... version display version'
@ echo '... install install the library'
@ echo '... uninstall uninstall the library'
.PHONY: help version
#
# Object rules
#
$(VXSDK_PREFIX_BUILD)%.o:
ifneq ($(VERBOSE),false)
@ mkdir -p $(dir $@)
sh-elf-vhex-gcc \
$(cflags) -D FXCG50 \
-o $@ \
-c $(addprefix src/,$(subst _,/,$(notdir $(basename $@))))
else
@ mkdir -p $(dir $@)
@ printf "$(green)>$(nocolor) $(white)$@$(nocolor)\n"
@ sh-elf-vhex-gcc \
$(cflags) -D FXCG50 \
-o $@ \
-c $(addprefix src/,$(subst _,/,$(notdir $(basename $@))))
endif
$(VXSDK_ASSETS_BUILD)%.o: $(VXSDK_ASSETS_SRC)/%
ifneq ($(VERBOSE),false)
@ mkdir -p $(dir $@)
sh-elf-vhex-gcc $(cflags) -D FXCG50 -o $@ -c $<
else
@ mkdir -p $(dir $@)
@ printf "$(green)>$(nocolor) $(white)$@$(nocolor)\n"
@ sh-elf-vhex-gcc $(cflags) -D FXCG50 -o $@ -c $<
endif

View File

@ -23,7 +23,7 @@ int main(void)
);
dprint(0, 0, C_BLACK, "selected level = %d", level);
dupdate();
while (1) { __asm__("sleep"); }
while (1);
#if 0
unlock = 0;
id_level = 0;

View File

@ -197,7 +197,7 @@ static void menu_select_hud(fps_t *fps)
void menu_title(void)
{
volatile int trigger;
key_event_t e;
vkey_event_t e;
fps_t fps;
int exit;
int timer;
@ -232,13 +232,12 @@ void menu_title(void)
//timer_fps_sync(&fps, 30);
key_us = timer_prof_exec({
while (1) {
e = keyvent_poll();
if (e.type == KEYEV_NONE)
while (keyvent_poll(&e)) {
if (e.type == VKEYEV_NONE)
break;
if (e.type != KEYEV_UP)
if (e.type != VKEYEV_UP)
continue;
if (e.key == KEY_SHIFT)
if (e.key == VKEY_SHIFT)
exit = 0;
}
});
@ -250,7 +249,7 @@ void menu_title(void)
/* menu_select() : level selection */
int menu_select(int max_level)
{
key_event_t e;
vkey_event_t e;
fps_t fps;
int cursor;
int exit;
@ -268,21 +267,18 @@ int menu_select(int max_level)
timer_fps_sync(&fps, 3);
while (1) {
e = keyvent_poll();
if (e.type == KEYEV_NONE)
break;
if (e.type != KEYEV_UP)
while (keyvent_poll(&e)) {
if (e.type != VKEYEV_UP)
continue;
if (e.key == KEY_LEFT) cursor -= 1;
if (e.key == KEY_RIGHT) cursor += 1;
if (e.key == KEY_DOWN) cursor += NB_BUTTON_ROW;
if (e.key == KEY_UP) cursor -= NB_BUTTON_ROW;
if (e.key == VKEY_LEFT) cursor -= 1;
if (e.key == VKEY_RIGHT) cursor += 1;
if (e.key == VKEY_DOWN) cursor += NB_BUTTON_ROW;
if (e.key == VKEY_UP) cursor -= NB_BUTTON_ROW;
if (cursor < 0) cursor = 0;
if (cursor >= max_level) cursor = max_level - 1;
if (e.key == KEY_SHIFT) exit = cursor;
if (e.key == VKEY_SHIFT) exit = cursor;
}
}
timer_fps_quit(&fps);

View File

@ -3,9 +3,3 @@ name = 'GravityDuck'
[dependencies]
vxKernel = 'dev'
[build]
build = 'make'
[extra.vxKernel]
configure = '--static --verbose'