* Changes to allow BGDC to compile on PCs again (not thoroughyl tested)

parent 39199703
......@@ -7,4 +7,5 @@ The main differences of this projects with the regular BennuGD version are:
* Some of the blitting work is now done by the GPU (even on mobile platforms).
* Support for graphics with a bit depth below 16bpp does not work and will be removed, at some point
Most of these changes were performed in order to improve the engine for use with the (unsuccessful) Kickstarter for [Explosive Dinosaurs](https://www.kickstarter.com/projects/rawrlab/explosive-dinosaurs-minigames-dinosaurs-and-explos)
\ No newline at end of file
Most of these changes were performed in order to improve the engine for use with the (unsuccessful) Kickstarter for [Explosive Dinosaurs](https://www.kickstarter.com/projects/rawrlab/explosive-dinosaurs-minigames-dinosaurs-and-explos)
all:
cd bgdc; $(MAKE) -f Makefile
cd bgdrtm; $(MAKE) -f Makefile
cd bgdi; $(MAKE) -f Makefile
linux:
cd bgdc; $(MAKE) -f Makefile.linux
cd bgdrtm; $(MAKE) -f Makefile.linux
cd bgdi; $(MAKE) -f Makefile.linux
psp:
cd ../3rdparty/dietlibc-glob/; $(MAKE) -f Makefile.psp
cd bgdi; $(MAKE) -f Makefile.psp
clean:
./clean
......@@ -45,13 +45,6 @@
#define BGDC_VERSION "BGDC " VERSION " (" __DATE__ " " __TIME__ ")"
/*
* INSTEAD OF JUST EXITING, GIVE THE USER SOME GRACE TIME TO READ THE ERRORS
*/
#ifdef TARGET_WII
#define exit( retval ) printf("\nQUITTING in 5 seconds.\n"); sleep(5); exit(retval);
#endif
#ifdef __APPLE__
#define _printf(...) printf(__VA_ARGS__)
#endif
......
......@@ -50,8 +50,7 @@ typedef struct _sentence
int line ;
int col ;
int offset ;
}
SENTENCE ;
} SENTENCE ;
typedef struct _procdef
{
......@@ -83,8 +82,7 @@ typedef struct _procdef
SENTENCE * sentences ;
int sentence_count ;
}
PROCDEF ;
} PROCDEF ;
extern int procdef_count ;
extern int procdef_maxid ;
......
......@@ -83,11 +83,7 @@ static char _tmp[128];
/* --------------------------------------------------------------------------- */
#if defined(TARGET_PSP)
int SDL_main( int argc, char *argv[] )
#else
int main( int argc, char *argv[] )
#endif
{
time_t curtime;
struct tm *loctime;
......@@ -103,45 +99,6 @@ int main( int argc, char *argv[] )
int i, j;
char *ptr;
/* The following code has been stolen from devkitpro project's wii-examples */
#ifdef TARGET_WII
/* Now initialize the console, needed by printf */
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
// Initialise the video system
VIDEO_Init();
// This function initialises the attached controllers
WPAD_Init();
// Obtain the preferred video mode from the system
// This will correspond to the settings in the Wii menu
rmode = VIDEO_GetPreferredMode(NULL);
// Allocate memory for the display in the uncached region
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
// Set up the video registers with the chosen mode
VIDEO_Configure(rmode);
// Tell the video hardware where our display memory is
VIDEO_SetNextFramebuffer(xfb);
// Make the display visible
VIDEO_SetBlack(FALSE);
// Flush the video register changes to the hardware
VIDEO_Flush();
// Wait for Video setup to complete
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
#endif
/* get my executable name */
ptr = argv[0] + strlen( argv[0] );
while ( ptr > argv[0] && ptr[-1] != '\\' && ptr[-1] != '/' ) ptr-- ;
......@@ -184,14 +141,6 @@ int main( int argc, char *argv[] )
#endif
langinfo[2] = 0;
#ifdef TARGET_WII
// Initialize the Wii FAT filesystem, check stuff
if (!fatInitDefault()) {
printf("Sorry, I cannot access the FAT filesystem on your card :(\n");
exit(1);
}
#endif
srand( time( NULL ) );
/* build error messages list */
......@@ -242,13 +191,6 @@ int main( int argc, char *argv[] )
sysproc_init();
/* Get command line parameters */
#ifdef TARGET_PSP
if (argc<2){
char* newargv[2]={argv[0],"EBOOT.prg"};
argc = 2;
argv=newargv;
}
#endif
for ( i = 1 ; i < argc ; i++ )
{
......
/* ---------------------------------------------------------------------- */
// PSP specific stuff
// mostly based on ScummVM PSP port
/* ---------------------------------------------------------------------- */
#ifdef TARGET_PSP
#define USERSPACE_ONLY //don't use kernel mode features
#include <psptypes.h>
#include <pspkernel.h>
#include <stdarg.h>
#include <pspdebug.h>
/**
* Define the module info section
*
* 2nd arg must 0x1000 so __init is executed in
* kernelmode for our loaderInit function
*/
#ifndef USERSPACE_ONLY
PSP_MODULE_INFO("BennuGD PSP", PSP_MODULE_USER, 1, 0);
#else
PSP_MODULE_INFO("BennuGD PSP", 0, 1, 1);
#endif
/**
* THREAD_ATTR_USER causes the thread that the startup
* code (crt0.c) starts this program in to be in usermode
* even though the module was started in kernelmode
*/
#ifndef USERSPACE_ONLY
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#endif
#ifndef USERSPACE_ONLY
void MyExceptionHandler(PspDebugRegBlock *regs)
{
/* Do normal initial dump, setup screen etc */
pspDebugScreenInit();
pspDebugScreenSetBackColor(0x00FF0000);
pspDebugScreenSetTextColor(0xFFFFFFFF);
pspDebugScreenClear();
pspDebugScreenPrintf("Exception Details:\n");
pspDebugDumpException(regs);
while (1) ;
}
/**
* Function that is called from _init in kernelmode before the
* main thread is started in usermode.
*/
__attribute__ ((constructor)) void loaderInit()
{
pspKernelSetKernelPC();
pspDebugInstallErrorHandler(MyExceptionHandler);
}
#endif
/* Exit callback */
SceKernelCallbackFunction exit_callback(int arg1, int arg2, void* common)
{
sceKernelExitGame();
exit(0);
return 0;
}
/* Callback thread */
int CallbackThread(SceSize size, void *arg)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", (SceKernelCallbackFunction)exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if (thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
#endif // END OF PSP specific stuff
/* ---------------------------------------------------------------------- */
#!/bin/sh
cd $(dirname 0)/..
for i in $(find . -name "*.o" -print); do rm $i; done
for i in $(find . -name "*.d" -print); do rm $i; done
for i in $(find . -name "bgdrtm.a" -print); do rm $i; done
for i in $(find . -name "*.elf" -print); do rm $i; done
for i in $(find . -name "*.dol" -print); do rm $i; done
for i in $(find . -name "*.FBP" -print); do rm $i; done
for i in $(find . -name "*.SFO" -print); do rm $i; done
cd -
......@@ -65,10 +65,6 @@
#include <commons_defs.h>
/* --------------------------------------------------------------------------- */
#ifdef __MONOLITHIC__
#include <typedef_st.h>
#endif
/* --------------------------------------------------------------------------- */
typedef struct
......
......@@ -32,7 +32,7 @@
#include "instance_st.h"
/* Process definitions, more simple that in the compiler */
/* Process definitions, more simple than in the compiler */
typedef struct _procdef
{
......
......@@ -100,8 +100,7 @@ typedef struct _instance
int breakpoint;
}
INSTANCE ;
} INSTANCE ;
/* Macros para acceder a datos locales o privados de una instancia */
......
......@@ -32,7 +32,9 @@
/* --------------------------------------------------------------------------- */
#ifndef __BGDC__
#include <instance.h>
#endif
/* ---------------------------------------------------------------------- */
......
......@@ -58,12 +58,6 @@ DLCONSTANT __bgdexport( librender, constants_def )[] =
{ "BACKGROUND", TYPE_DWORD, 0 },
{ "SCREEN", TYPE_DWORD, -1 },
{ "SCALE_SCALE2X", TYPE_DWORD, SCALE_SCALE2X },
{ "SCALE_HQ2X", TYPE_DWORD, SCALE_HQ2X },
{ "SCALE_SCANLINE2X", TYPE_DWORD, SCALE_SCANLINE2X },
{ "SCALE_NORMAL2X", TYPE_DWORD, SCALE_NOFILTER },
{ "SCALE_NOFILTER", TYPE_DWORD, SCALE_NOFILTER },
{ NULL , 0 , 0 }
} ;
......
......@@ -29,10 +29,9 @@
#ifndef __SDLHANDLER_H
#define __SDLHANDLER_H
#include <bgddl.h>
#ifdef __BGDC__
#else
#include <bgddl.h>
extern void __bgdexport( libsdlhandler, module_initialize )();
extern void __bgdexport( libsdlhandler, module_finalize )();
extern HOOK __bgdexport( libsdlhandler, handler_hooks )[];
......
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
@echo $(notdir $@)
@rm -f $@
@$(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.o: %.cpp
@echo $(notdir $<)
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.c
@echo $(notdir $<)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.m
@echo $(notdir $<)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(OBJCFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.s
@echo $(notdir $<)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.S
@echo $(notdir $<)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%:
@echo linking ... $(notdir $@)
$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
bin2s -a 32 $< | $(AS) -o $(@)
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := bgdc
BUILD := build
SOURCES := ../../core/bgdc/src
INCLUDES := ../../core/bgdc/include \
../../core/include \
../../3rdparty/SDL/include/ \
../../modules/libbgload/ \
../../modules/mod_say/ \
../../modules/mod_string/ \
../../modules/mod_math/ \
../../modules/mod_mem/ \
../../modules/mod_time/ \
../../modules/mod_file/ \
../../modules/mod_sound/ \
../../modules/libsdlhandler/ \
../../modules/mod_joy/ \
../../modules/libjoy/ \
../../modules/libkey/ \
../../modules/mod_key/ \
../../modules/mod_proc/ \
../../modules/mod_sort/ \
../../modules/mod_timers/ \
../../modules/libgrbase/ \
../../modules/libblit/ \
../../modules/libvideo/ \
../../modules/librender/ \
../../modules/mod_video/ \
../../modules/libmouse/ \
../../modules/mod_mouse/ \
../../modules/mod_map/ \
../../modules/libfont/ \
../../modules/mod_dir/ \
../../modules/libtext/ \
../../modules/mod_text/ \
../../modules/mod_rand/ \
../../modules/mod_grproc/ \
../../modules/libscroll/ \
../../modules/mod_scroll/ \
../../modules/libdraw/ \
../../modules/mod_draw/ \
../../modules/mod_screen/ \
../../modules/mod_path/ \
../../modules/mod_effects/ \
../../modules/mod_blendop/ \
../../modules/libwm/ \
../../modules/mod_wm/ \
../../modules/mod_sys/ \
../../modules/mod_regex/ \
../../modules/mod_fsock/
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -m32 -g -O2 -Wall -D__BGDC__ -D__MONOLITHIC__ -DTARGET_LINUX -DNO_MODIMAGE -DNO_MODMATHI \
-DNO_MODIMAGE -DNO_MODICONV -DNO_MODFMODEX -DNO_MODCHIPMUNK -DNO_MODMULTI -DNO_MODCURL \
-DNO_MODSENSOR -DNO_MODIAP -DNO_MODTHEORA -DVERSION='"1.0.0"' $(MACHDEP) $(INCLUDE)
CXXFLAGS = -save-temps -Xassembler -aln=$@.lst $(CFLAGS)
LDFLAGS = -m32 -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
EXTRA_LIBS = -lmingw32 -mwindows
else
EXTRA_LIBS = -lc
endif
LIBS := -lz -lc -lm $(EXTRA_LIBS)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CURDIR)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) \
../../../core/common/debug.c \
../../../core/common/files.c \
../../../core/common/xctype.c
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(CURDIR)/../../3rdparty/SDL-1.3/linux/include/ \
-I$(CURDIR)/../../3rdparty/SDL-1.3/linux/include/SDL/ \
-I/usr/include
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L/usr/lib
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@rm -fr $(OUTPUT)
make -C $(BUILD) -f $(CURDIR)/Makefile.bgdc
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT)
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT): $(OFILES)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
......@@ -146,7 +146,7 @@ $(BUILD):
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT
@rm -fr $(BUILD) $(OUTPUT)
#---------------------------------------------------------------------------------
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment