Permalink
Browse files

Upgrade to latest T3F.

  • Loading branch information...
NewCreature committed Jul 13, 2017
1 parent 68f071b commit e5b3f18e7ba5125f1e57e43bfcca82bd32bc95db
View
@@ -0,0 +1,104 @@
#include <allegro5/allegro5.h>
static char base_path[4096] = {0};
static char rpath[4096] = {0};
const char * sub_path(const char * path)
{
return &path[strlen(base_path)];
}
const char * dest_path(const char * path, const char * dest)
{
sprintf(rpath, "%s/%s", dest, sub_path(path));
return rpath;
}
bool copy_file(const char * path, const char * dest_path)
{
ALLEGRO_FILE * src;
ALLEGRO_FILE * dest;
bool ret = false;
int i;
src = al_fopen(path, "rb");
if(src)
{
dest = al_fopen(dest_path, "wb");
if(dest)
{
for(i = 0; i < al_fsize(src); i++)
{
al_fputc(dest, al_fgetc(src));
}
al_fclose(dest);
ret = true;
}
al_fclose(src);
}
return ret;
}
bool copy_dir(const char * path, const char * dest)
{
ALLEGRO_FS_ENTRY * fs_entry;
ALLEGRO_FS_ENTRY * directory_entry;
char buf[1024] = {0};
fs_entry = al_create_fs_entry(path);
if(!fs_entry)
{
return false;
}
if(!al_open_directory(fs_entry))
{
al_destroy_fs_entry(fs_entry);
return false;
}
/* get the base path if we don't have it yet */
if(strlen(base_path) <= 0)
{
sprintf(base_path, "%s/", al_get_fs_entry_name(fs_entry));
}
/* create directory in target path */
strcpy(buf, al_get_fs_entry_name(fs_entry));
al_make_directory(dest_path(buf, dest));
printf("\nCopying directory %s:\n\n", sub_path(buf));
while(1)
{
directory_entry = al_read_directory(fs_entry);
if(directory_entry)
{
strcpy(buf, al_get_fs_entry_name(directory_entry));
if(al_get_fs_entry_mode(directory_entry) & ALLEGRO_FILEMODE_ISDIR)
{
copy_dir(al_get_fs_entry_name(directory_entry), dest);
}
else
{
printf("\t%s\n", sub_path(buf));
copy_file(al_get_fs_entry_name(directory_entry), dest_path(buf, dest));
}
}
else
{
break;
}
}
al_destroy_fs_entry(fs_entry);
return true;
}
int main(int argc, char * argv[])
{
if(argc < 3)
{
printf("Usage: copydir <source path> <destination_path>\n");
}
copy_dir(argv[1], argv[2]);
printf("\n");
return 0;
}
View
No changes.
View
@@ -2,21 +2,25 @@
# assumes user is building from source for their own use (won't select static
# or cross-compile makefiles)
UNAME=$(shell uname)
ifneq (,$(findstring Linux,$(UNAME)))
SYSTEM=linux
ifeq ($(OS),Windows_NT)
SYSTEM=mingw
else
ifneq (,$(findstring Darwin,$(UNAME)))
SYSTEM=macosx
else
ifneq (,$(findstring MINGW,$(UNAME)))
SYSTEM=mingw
else
$(warning Not sure which system you are on, assuming Linux)
$(warning (uname says: '$(UNAME)'))
SYSTEM=linux
endif
endif
UNAME=$(shell uname)
ifneq (,$(findstring Linux,$(UNAME)))
SYSTEM=linux
else
ifneq (,$(findstring Darwin,$(UNAME)))
SYSTEM=macosx
else
ifneq (,$(findstring MINGW,$(UNAME)))
SYSTEM=mingw_cross
else
$(warning Not sure which system you are on, assuming Linux)
$(warning (uname says: '$(UNAME)'))
SYSTEM=linux
endif
endif
endif
endif
top:
View
@@ -27,14 +27,14 @@ $(APP_EXE_NAME) : $(PROJECT_OBJECTS) update_changelog
@echo Executable built!
#Unix way of updating the changelog, will be overwritten by MinGW build script under Windows
update_changelog:
cp -a ../changelog ../docs
update_changelog: ../changelog
$(COPY_COMMAND) $(subst /,$(PATH_SEPARATOR),../changelog ../docs)
$(SED_COMMAND) "s|BUILD_DATE|`date -u +"%a, %d %b %Y %T"`|" ../docs/changelog
$(SED_COMMAND) "s|BUILD_VERSION|$(APP_VERSION)|" ../docs/changelog
clean: app_clean
@$(PLATFORM_CLEAN)
@$(DEL_COMMAND) $(PROJECT_OBJECTS)
@$(DEL_COMMAND) $(subst /,$(PATH_SEPARATOR),$(PROJECT_OBJECTS))
@echo Cleanup complete!
very_clean: clean
View
@@ -19,6 +19,7 @@ APP_URL = http://www.t3-i.com
APP_OBJECTS = main.o DUMBA5/dumba5.o ui_init.o ui_menu_proc.o codecs/dumba5.o codecs/allegro_acodec.o player.o player_registry.o queue.o
APP_LIBS = -ldumb
#APP_CFLAGS =
APP_PACKAGE_DIR = ../packages
#APP_EXTRA_TARGET =
app_clean:
# @
View
@@ -6,5 +6,7 @@ DEPEND_LIBS = -lm $(LINUX_DEPEND_LIBS)
DEL_COMMAND = rm -f
DEL_FOLDER_COMMAND = rm -rf
SED_COMMAND = sed -i
COPY_COMMAND = cp
PATH_SEPARATOR = /
include makefile.common
@@ -7,6 +7,8 @@ LIB_SUFFIX = -static
DEL_COMMAND = rm -f
DEL_FOLDER_COMMAND = rm -rf
SED_COMMAND = sed -i
COPY_COMMAND = cp
PATH_SEPARATOR = /
include makefile.common
View
@@ -12,6 +12,8 @@ DEL_COMMAND = rm -f
DEL_FOLDER_COMMAND = rm -rf
SED_COMMAND = sed -i ''
PLATFORM_CLEAN = rm -rf ../$(APP_TITLE).app
COPY_COMMAND = cp
PATH_SEPARATOR = /
include makefile.common
View
@@ -1,12 +1,19 @@
CC = gcc
CFLAGS = $(GLOBAL_CFLAGS) $(APP_CFLAGS) $(MINGW_CFLAGS) -mwindows
LIB_SUFFIX = .dll
LIB_SUFFIX = -static
PLATFORM_OBJECTS = t3f/menu.o icon.o $(MINGW_PLATFORM_OBJECTS)
PLATFORM_LIBS = -lallegro_dialog$(LIB_SUFFIX) $(MINGW_PLATFORM_LIBS)
DEPEND_LIBS = $(MINGW_CROSS_DEPEND_LIBS) -luuid -lkernel32 -lwinmm -lpsapi\
-lopengl32 -lglu32 -luser32 -lcomdlg32 -lgdi32 -lshell32 -lole32\
-ladvapi32 -lws2_32 -lshlwapi -lvorbisfile -lvorbis -logg -ldumb\
-lfreetype -lpng -lz -ld3d9 -ldsound -lstdc++
DEL_COMMAND = del /q
DEL_FOLDER_COMMAND = rmdir /q
COPY_COMMAND = copy /A
SED_COMMAND = echo
PATH_SEPARATOR = \\
include makefile.common
icon.o : ../icons/windows_icon.ico ../win32/icon.rc
windres -o icon.o ../win32/icon.rc
windres --include-dir=../icons -o icon.o ../win32/icon.rc
View
@@ -12,6 +12,8 @@ DEL_COMMAND = rm -f
DEL_FOLDER_COMMAND = rm -rf
SED_COMMAND = sed -i
EXE_SUFFIX = .exe
COPY_COMMAND = cp
PATH_SEPARATOR = /
include makefile.common
View
@@ -178,7 +178,11 @@ ALLEGRO_BITMAP * t3f_put_bitmap_on_atlas(T3F_ATLAS * ap, ALLEGRO_BITMAP ** bp, i
return NULL;
}
}
t3f_actually_put_bitmap_on_atlas_pixel_copy(ap, *bp, type);
#ifdef ALLEGRO_ANDROID
t3f_actually_put_bitmap_on_atlas_pixel_copy(ap, *bp, type);
#else
t3f_actually_put_bitmap_on_atlas_fbo(ap, *bp, type);
#endif
retbp = al_create_sub_bitmap(ap->page, ap->x + 1, ap->y + 1, al_get_bitmap_width(*bp), al_get_bitmap_height(*bp));
ap->x += al_get_bitmap_width(*bp) + 2;
if(al_get_bitmap_height(*bp) + 2 > ap->line_height)
View
@@ -101,6 +101,7 @@ void t3f_write_controller_config(ALLEGRO_CONFIG * acp, const char * section, T3F
char temp_string2[1024] = {0};
int j;
al_set_config_value(acp, section, "Device Name", cp->device_name ? cp->device_name : "");
for(j = 0; j < cp->bindings; j++)
{
sprintf(temp_string, "Binding %d Type", j);
@@ -139,12 +140,41 @@ void t3f_write_controller_config(ALLEGRO_CONFIG * acp, const char * section, T3F
}
}
static int matched[T3F_MAX_JOYSTICKS] = {0};
static void remap_controller_to_device(T3F_CONTROLLER * cp)
{
int i;
int matching_device = -1;
if(cp->device_name)
{
for(i = 0; i < al_get_num_joysticks(); i++)
{
if(!strcmp(cp->device_name, al_get_joystick_name(t3f_joystick[i])) && !matched[i])
{
matching_device = i;
matched[i] = 1;
break;
}
}
if(matching_device >= 0)
{
for(i = 0; i < cp->bindings; i++)
{
cp->binding[i].joystick = matching_device;
}
}
}
}
bool t3f_read_controller_config(ALLEGRO_CONFIG * acp, const char * section, T3F_CONTROLLER * cp)
{
char temp_string[1024] = {0};
const char * item;
int j;
cp->device_name = al_get_config_value(acp, section, "Device Name");
for(j = 0; j < cp->bindings; j++)
{
sprintf(temp_string, "Binding %d Type", j);
@@ -251,9 +281,44 @@ bool t3f_read_controller_config(ALLEGRO_CONFIG * acp, const char * section, T3F_
}
}
}
if(cp->device_name)
{
remap_controller_to_device(cp);
}
return true;
}
static bool binding_is_joystick(T3F_CONTROLLER * cp, int i)
{
if(cp->binding[i].type == T3F_CONTROLLER_BINDING_JOYSTICK_AXIS || cp->binding[i].type == T3F_CONTROLLER_BINDING_JOYSTICK_BUTTON)
{
return true;
}
return false;
}
static void t3f_find_controller_device_name(T3F_CONTROLLER * cp)
{
int i;
int type;
int source;
/* only get device name for joysticks */
type = cp->binding[0].type;
if(binding_is_joystick(cp, 0))
{
source = cp->binding[0].joystick;
for(i = 1; i < cp->bindings; i++)
{
if(!binding_is_joystick(cp, i) || cp->binding[i].joystick != source)
{
return;
}
}
cp->device_name = al_get_joystick_name(t3f_joystick[source]);
}
}
bool t3f_bind_controller(T3F_CONTROLLER * cp, int binding)
{
ALLEGRO_EVENT_QUEUE * queue;
@@ -303,6 +368,7 @@ bool t3f_bind_controller(T3F_CONTROLLER * cp, int binding)
{
cp->binding[binding].type = T3F_CONTROLLER_BINDING_KEY;
cp->binding[binding].button = event.keyboard.keycode;
t3f_find_controller_device_name(cp);
al_destroy_event_queue(queue);
return true;
}
@@ -318,6 +384,7 @@ bool t3f_bind_controller(T3F_CONTROLLER * cp, int binding)
cp->binding[binding].joystick = t3f_get_joystick_number(event.joystick.id);
cp->binding[binding].stick = event.joystick.stick;
cp->binding[binding].button = event.joystick.button;
t3f_find_controller_device_name(cp);
al_destroy_event_queue(queue);
return true;
}
@@ -333,6 +400,7 @@ bool t3f_bind_controller(T3F_CONTROLLER * cp, int binding)
cp->binding[binding].stick = event.joystick.stick;
cp->binding[binding].axis = event.joystick.axis;
cp->binding[binding].flags = T3F_CONTROLLER_FLAG_AXIS_NEGATIVE;
t3f_find_controller_device_name(cp);
al_destroy_event_queue(queue);
return true;
}
@@ -343,6 +411,7 @@ bool t3f_bind_controller(T3F_CONTROLLER * cp, int binding)
cp->binding[binding].stick = event.joystick.stick;
cp->binding[binding].axis = event.joystick.axis;
cp->binding[binding].flags = T3F_CONTROLLER_FLAG_AXIS_POSITIVE;
t3f_find_controller_device_name(cp);
al_destroy_event_queue(queue);
return true;
}
@@ -361,6 +430,7 @@ bool t3f_bind_controller(T3F_CONTROLLER * cp, int binding)
{
cp->binding[binding].type = T3F_CONTROLLER_BINDING_MOUSE_BUTTON;
cp->binding[binding].button = event.mouse.button;
t3f_find_controller_device_name(cp);
al_destroy_event_queue(queue);
return true;
}
Oops, something went wrong.

0 comments on commit e5b3f18

Please sign in to comment.