diff --git a/.gitignore b/.gitignore index 0038c39..9fc7ca9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -dsgmLib/build/ +build/ template/build/ template/*.elf examples/*/build/ diff --git a/Makefile b/Makefile index dbf9448..b0ff751 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,131 @@ -.PHONY: all +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- -all: - make -C dsgmLib - make -C template - make -C examples \ No newline at end of file +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +include $(DEVKITARM)/ds_rules + +# Uncomment for debug mode +#DSGMDEBUG := -DDEBUG + +#--------------------------------------------------------------------------------- +# 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 := libdsgm +BUILD := build +SOURCES := gfx source data +INCLUDES := include build + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -g -Wall -O2 -fms-extensions\ + -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ + -ffast-math \ + $(ARCH) + +CFLAGS += $(INCLUDE) -DARM9 -DBUILDINGLIB $(DSGMDEBUG) +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +#LIBS := -lnds9 +LIBS := -lnds + + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) + +#--------------------------------------------------------------------------------- +# 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)/lib/$(TARGET).a + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES := $(BINFILES:.bin=.o) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).ds.gba + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +#$(OUTPUT).nds : $(OUTPUT).elf +#$(OUTPUT).elf : $(OFILES) +$(OUTPUT) : $(OFILES) + +#--------------------------------------------------------------------------------- +%.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + $(bin2o) + + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/dsgmLib/Makefile b/dsgmLib/Makefile deleted file mode 100644 index e9bb456..0000000 --- a/dsgmLib/Makefile +++ /dev/null @@ -1,131 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -# Uncomment for debug mode -#DSGMDEBUG := -DDEBUG - -#--------------------------------------------------------------------------------- -# 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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := gfx source data -INCLUDES := include build - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork - -CFLAGS := -g -Wall -O2 -fms-extensions\ - -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ - -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -DBUILDINGLIB $(DSGMDEBUG) -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -#LIBS := -lnds9 -LIBS := -lnds - - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) - -#--------------------------------------------------------------------------------- -# 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)/$(TARGET).a - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(BINFILES:.bin=.o) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).ds.gba - - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -#$(OUTPUT).nds : $(OUTPUT).elf -#$(OUTPUT).elf : $(OFILES) -$(OUTPUT) : $(OFILES) - -#--------------------------------------------------------------------------------- -%.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - $(bin2o) - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/examples/3D/Makefile b/examples/3D/Makefile index 87a119e..fe86fd7 100644 --- a/examples/3D/Makefile +++ b/examples/3D/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/Collision/Makefile b/examples/Collision/Makefile index 87a119e..fe86fd7 100644 --- a/examples/Collision/Makefile +++ b/examples/Collision/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/CustomFont/Makefile b/examples/CustomFont/Makefile index 87a119e..fe86fd7 100644 --- a/examples/CustomFont/Makefile +++ b/examples/CustomFont/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/CustomVariables/Makefile b/examples/CustomVariables/Makefile index 87a119e..fe86fd7 100644 --- a/examples/CustomVariables/Makefile +++ b/examples/CustomVariables/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/DrawableBackground/Makefile b/examples/DrawableBackground/Makefile index 87a119e..fe86fd7 100644 --- a/examples/DrawableBackground/Makefile +++ b/examples/DrawableBackground/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/NiFi/Makefile b/examples/NiFi/Makefile index 87a119e..fe86fd7 100644 --- a/examples/NiFi/Makefile +++ b/examples/NiFi/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/NiFi/NiFi.nds b/examples/NiFi/NiFi.nds index 6271322..91cc984 100644 Binary files a/examples/NiFi/NiFi.nds and b/examples/NiFi/NiFi.nds differ diff --git a/examples/Priority/Makefile b/examples/Priority/Makefile index 87a119e..fe86fd7 100644 --- a/examples/Priority/Makefile +++ b/examples/Priority/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/RoomPersistency/Makefile b/examples/RoomPersistency/Makefile index 87a119e..fe86fd7 100644 --- a/examples/RoomPersistency/Makefile +++ b/examples/RoomPersistency/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/RotsetEffects/Makefile b/examples/RotsetEffects/Makefile index 87a119e..fe86fd7 100644 --- a/examples/RotsetEffects/Makefile +++ b/examples/RotsetEffects/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/TopDownShooter/Makefile b/examples/TopDownShooter/Makefile index 87a119e..fe86fd7 100644 --- a/examples/TopDownShooter/Makefile +++ b/examples/TopDownShooter/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/examples/Unpossible/Makefile b/examples/Unpossible/Makefile index 87a119e..fe86fd7 100644 --- a/examples/Unpossible/Makefile +++ b/examples/Unpossible/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/dsgmLib/include/DSGM.h b/include/DSGM.h similarity index 100% rename from dsgmLib/include/DSGM.h rename to include/DSGM.h diff --git a/dsgmLib/include/DSGM_3D.h b/include/DSGM_3D.h similarity index 100% rename from dsgmLib/include/DSGM_3D.h rename to include/DSGM_3D.h diff --git a/dsgmLib/include/DSGM_alarm.h b/include/DSGM_alarm.h similarity index 100% rename from dsgmLib/include/DSGM_alarm.h rename to include/DSGM_alarm.h diff --git a/dsgmLib/include/DSGM_background.h b/include/DSGM_background.h similarity index 100% rename from dsgmLib/include/DSGM_background.h rename to include/DSGM_background.h diff --git a/dsgmLib/include/DSGM_drawable.h b/include/DSGM_drawable.h similarity index 100% rename from dsgmLib/include/DSGM_drawable.h rename to include/DSGM_drawable.h diff --git a/dsgmLib/include/DSGM_file.h b/include/DSGM_file.h similarity index 100% rename from dsgmLib/include/DSGM_file.h rename to include/DSGM_file.h diff --git a/dsgmLib/include/DSGM_input.h b/include/DSGM_input.h similarity index 100% rename from dsgmLib/include/DSGM_input.h rename to include/DSGM_input.h diff --git a/dsgmLib/include/DSGM_malloc.h b/include/DSGM_malloc.h similarity index 100% rename from dsgmLib/include/DSGM_malloc.h rename to include/DSGM_malloc.h diff --git a/dsgmLib/include/DSGM_misc.h b/include/DSGM_misc.h similarity index 100% rename from dsgmLib/include/DSGM_misc.h rename to include/DSGM_misc.h diff --git a/dsgmLib/include/DSGM_object.h b/include/DSGM_object.h similarity index 93% rename from dsgmLib/include/DSGM_object.h rename to include/DSGM_object.h index 3295d54..a4efa89 100644 --- a/dsgmLib/include/DSGM_object.h +++ b/include/DSGM_object.h @@ -77,8 +77,13 @@ DSGM_ObjectGroup *DSGM_GetObjectGroupFull(DSGM_Room *room, u8 screen, DSGM_Objec #define DSGM_CreateObjectInstance(screen, x, y, object) DSGM_CreateObjectInstanceFull(&DSGM_Rooms[DSGM_currentRoom], (DSGM_ObjectInstance **)&me, screen, x, y, object) DSGM_ObjectInstance *DSGM_CreateObjectInstanceFull(DSGM_Room *room, DSGM_ObjectInstance **meP, u8 screen, int x, int y, DSGM_Object *object); -#define DSGM_DeleteObjectInstance(objectInstance) DSGM_DeleteObjectInstanceFull(&DSGM_Rooms[DSGM_currentRoom], (DSGM_ObjectInstance *)objectInstance) -void DSGM_DeleteObjectInstanceFull(DSGM_Room *room, DSGM_ObjectInstance *objectInstance); +#define DSGM_DeleteObjectInstance(objectInstance) do {\ + bool kill = false;\ + if((DSGM_ObjectInstance *)objectInstance == (DSGM_ObjectInstance *)me) kill = true;\ + DSGM_DeleteObjectInstanceFull(&DSGM_Rooms[DSGM_currentRoom], (DSGM_ObjectInstance **)&me, (DSGM_ObjectInstance *)objectInstance);\ + if(kill) return;\ +} while(0) +void DSGM_DeleteObjectInstanceFull(DSGM_Room *room, DSGM_ObjectInstance **meP, DSGM_ObjectInstance *objectInstance); #define DSGM_GetObjectInstanceRelation(me) DSGM_GetObjectInstanceRelationFull(&DSGM_Rooms[DSGM_currentRoom], (DSGM_ObjectInstance *)me) DSGM_ObjectInstanceRelation DSGM_GetObjectInstanceRelationFull(DSGM_Room *room, DSGM_ObjectInstance *me); diff --git a/dsgmLib/include/DSGM_palette.h b/include/DSGM_palette.h similarity index 100% rename from dsgmLib/include/DSGM_palette.h rename to include/DSGM_palette.h diff --git a/dsgmLib/include/DSGM_projectHelper.h b/include/DSGM_projectHelper.h similarity index 100% rename from dsgmLib/include/DSGM_projectHelper.h rename to include/DSGM_projectHelper.h diff --git a/dsgmLib/include/DSGM_room.h b/include/DSGM_room.h similarity index 100% rename from dsgmLib/include/DSGM_room.h rename to include/DSGM_room.h diff --git a/dsgmLib/include/DSGM_sound.h b/include/DSGM_sound.h similarity index 100% rename from dsgmLib/include/DSGM_sound.h rename to include/DSGM_sound.h diff --git a/dsgmLib/include/DSGM_sprite.h b/include/DSGM_sprite.h similarity index 100% rename from dsgmLib/include/DSGM_sprite.h rename to include/DSGM_sprite.h diff --git a/dsgmLib/include/DSGM_text.h b/include/DSGM_text.h similarity index 100% rename from dsgmLib/include/DSGM_text.h rename to include/DSGM_text.h diff --git a/dsgmLib/include/DSGM_view.h b/include/DSGM_view.h similarity index 100% rename from dsgmLib/include/DSGM_view.h rename to include/DSGM_view.h diff --git a/dsgmLib/include/DSGM_wireless.h b/include/DSGM_wireless.h similarity index 100% rename from dsgmLib/include/DSGM_wireless.h rename to include/DSGM_wireless.h diff --git a/dsgmLib/dsgmLib.a b/lib/libdsgm.a similarity index 55% rename from dsgmLib/dsgmLib.a rename to lib/libdsgm.a index af240a4..2dea4c3 100644 Binary files a/dsgmLib/dsgmLib.a and b/lib/libdsgm.a differ diff --git a/dsgmLib/source/DGM_wireless.c b/source/DGM_wireless.c similarity index 100% rename from dsgmLib/source/DGM_wireless.c rename to source/DGM_wireless.c diff --git a/dsgmLib/source/DSGM.c b/source/DSGM.c similarity index 100% rename from dsgmLib/source/DSGM.c rename to source/DSGM.c diff --git a/dsgmLib/source/DSGM_3D.c b/source/DSGM_3D.c similarity index 100% rename from dsgmLib/source/DSGM_3D.c rename to source/DSGM_3D.c diff --git a/dsgmLib/source/DSGM_background.c b/source/DSGM_background.c similarity index 100% rename from dsgmLib/source/DSGM_background.c rename to source/DSGM_background.c diff --git a/dsgmLib/source/DSGM_drawable.c b/source/DSGM_drawable.c similarity index 100% rename from dsgmLib/source/DSGM_drawable.c rename to source/DSGM_drawable.c diff --git a/dsgmLib/source/DSGM_file.c b/source/DSGM_file.c similarity index 100% rename from dsgmLib/source/DSGM_file.c rename to source/DSGM_file.c diff --git a/dsgmLib/source/DSGM_input.c b/source/DSGM_input.c similarity index 100% rename from dsgmLib/source/DSGM_input.c rename to source/DSGM_input.c diff --git a/dsgmLib/source/DSGM_malloc.c b/source/DSGM_malloc.c similarity index 100% rename from dsgmLib/source/DSGM_malloc.c rename to source/DSGM_malloc.c diff --git a/dsgmLib/source/DSGM_misc.c b/source/DSGM_misc.c similarity index 100% rename from dsgmLib/source/DSGM_misc.c rename to source/DSGM_misc.c diff --git a/dsgmLib/source/DSGM_object.c b/source/DSGM_object.c similarity index 95% rename from dsgmLib/source/DSGM_object.c rename to source/DSGM_object.c index 90ed4be..30d860a 100644 --- a/dsgmLib/source/DSGM_object.c +++ b/source/DSGM_object.c @@ -210,7 +210,18 @@ DSGM_ObjectInstance *DSGM_CreateObjectInstanceFull(DSGM_Room *room, DSGM_ObjectI } } -void DSGM_DeleteObjectInstanceFull(DSGM_Room *room, DSGM_ObjectInstance *objectInstance) { +void DSGM_DeleteObjectInstanceFull(DSGM_Room *room, DSGM_ObjectInstance **meP, DSGM_ObjectInstance *objectInstance) { + printf("full\n"); + swiWaitForVBlank(); + + if(objectInstance->object->destroy) { + printf("destr i[ here\n"); + swiWaitForVBlank(); + } + + DSGM_ObjectInstanceRelation relation = { 0, 0 }; + if(meP && *meP) relation = DSGM_GetObjectInstanceRelationFull(room, *meP); + DSGM_ObjectGroup *group = DSGM_GetObjectGroupFull(room, objectInstance->screen, objectInstance->object); if(!group) { @@ -228,16 +239,37 @@ void DSGM_DeleteObjectInstanceFull(DSGM_Room *room, DSGM_ObjectInstance *objectI int ID = DSGM_GetObjectInstanceIDFull(room, objectInstance); DSGM_Debug("Deleting object instance with ID %d\n", ID); - if(objectInstance->object->destroy) objectInstance->object->destroy(objectInstance); + printf("got ID\n"); + swiWaitForVBlank(); + + if(objectInstance->object->destroy) { + printf("destr part 1\n"); + swiWaitForVBlank(); + + objectInstance->object->destroy(objectInstance); + } + + printf("destr\n"); + swiWaitForVBlank(); + DSGM_DeinitObjectInstanceRotScale(objectInstance); + printf("rotscaled\n"); + swiWaitForVBlank(); + if(ID < group->objectInstanceCount - 1) { DSGM_Debug("Shifting %d object instances for deletion\n", (group->objectInstanceCount - ID - 1)); memcpy(&group->objectInstances[ID], &group->objectInstances[ID + 1], (group->objectInstanceCount - ID - 1) * sizeof(DSGM_ObjectInstance)); } + printf("shifted\n"); + swiWaitForVBlank(); + group->objectInstances = realloc(group->objectInstances, --group->objectInstanceCount * sizeof(DSGM_ObjectInstance)); + printf("re\n"); + swiWaitForVBlank(); + if(spriteNumbersChange) { int i; for(i = 0; i < 128; i++) { @@ -245,6 +277,8 @@ void DSGM_DeleteObjectInstanceFull(DSGM_Room *room, DSGM_ObjectInstance *objectI } DSGM_RedistributeSpriteNumbers(room, screen); } + + if(meP && *meP) *meP = DSGM_GetMeFromObjectInstanceRelationFull(room, &relation); } DSGM_ObjectInstanceRelation DSGM_GetObjectInstanceRelationFull(DSGM_Room *room, DSGM_ObjectInstance *me) { diff --git a/dsgmLib/source/DSGM_palette.c b/source/DSGM_palette.c similarity index 100% rename from dsgmLib/source/DSGM_palette.c rename to source/DSGM_palette.c diff --git a/dsgmLib/source/DSGM_room.c b/source/DSGM_room.c similarity index 100% rename from dsgmLib/source/DSGM_room.c rename to source/DSGM_room.c diff --git a/dsgmLib/source/DSGM_saving.c b/source/DSGM_saving.c similarity index 100% rename from dsgmLib/source/DSGM_saving.c rename to source/DSGM_saving.c diff --git a/dsgmLib/source/DSGM_sound.c b/source/DSGM_sound.c similarity index 100% rename from dsgmLib/source/DSGM_sound.c rename to source/DSGM_sound.c diff --git a/dsgmLib/source/DSGM_sprite.c b/source/DSGM_sprite.c similarity index 100% rename from dsgmLib/source/DSGM_sprite.c rename to source/DSGM_sprite.c diff --git a/dsgmLib/source/DSGM_text.c b/source/DSGM_text.c similarity index 100% rename from dsgmLib/source/DSGM_text.c rename to source/DSGM_text.c diff --git a/template/Makefile b/template/Makefile index 87a119e..fe86fd7 100644 --- a/template/Makefile +++ b/template/Makefile @@ -8,9 +8,7 @@ endif include $(DEVKITARM)/ds_rules -ifeq ($(strip $(DSGMLIB)),) -$(error "Please set in your environment. export DSGMLIB=") -endif +DSGMLIB := $(DEVKITPRO)/dsgmLib #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -46,7 +44,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project (order is important) #--------------------------------------------------------------------------------- -LIBS := $(DSGMLIB)/dsgmLib.a -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 +LIBS := -ldsgm -ldsgmdswifi9 -lfilesystem -lfat -lnds9 -lmm9 #--------------------------------------------------------------------------------- diff --git a/template/template.nds b/template/template.nds index 0074eae..73897c4 100644 Binary files a/template/template.nds and b/template/template.nds differ