mirror of
https://github.com/CTurt/dsgmLib.git
synced 2025-06-18 22:55:33 -04:00
Template
This commit is contained in:
parent
82e6dbcb11
commit
fa3818c074
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
dsgmLib/build/
|
||||
template/build/
|
||||
template/*.elf
|
||||
examples/*/build/
|
||||
examples/*/*.elf
|
||||
.DS_Store
|
144
template/Makefile
Normal file
144
template/Makefile
Normal file
@ -0,0 +1,144 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/ds_rules
|
||||
|
||||
ifeq ($(strip $(DSGMLIB)),)
|
||||
$(error "Please set in your environment. export DSGMLIB=<path to dsgmLib>")
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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
|
||||
# MAXMOD_SOUNDBANK contains a directory of music and sound effect files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(shell basename $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include $(DSGMLIB)/include
|
||||
NITRODATA := nitrofiles
|
||||
MAXMOD_SOUNDBANK := music
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -mthumb -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
||||
|
||||
CFLAGS := -g -Wall -O2 -fms-extensions\
|
||||
-fomit-frame-pointer\
|
||||
-ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM9
|
||||
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 (order is important)
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := $(DSGMLIB)/dsgmLib.a -lfilesystem -lfat -lnds9 -lmm9
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(LIBNDS) $(DSGMLIB)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
ifneq ($(strip $(NITRODATA)),)
|
||||
export NITRO_FILES := $(CURDIR)/$(NITRODATA)
|
||||
endif
|
||||
|
||||
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,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MAXMOD_SOUNDBANK)/*.*)),$(CURDIR)/$(MAXMOD_SOUNDBANK)/$(dir))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(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
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).nds : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES) soundbank.h
|
||||
|
||||
soundbank.h: ../$(NITRODATA)/soundbank.bin
|
||||
|
||||
../$(NITRODATA)/soundbank.bin: $(AUDIOFILES)
|
||||
#---------------------------------------------------------------------------------
|
||||
mmutil $^ -d -o../$(NITRODATA)/soundbank.bin -hsoundbank.h
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPSDIR)/*.d
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
55
template/include/project.h
Normal file
55
template/include/project.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#define DSGM_SOUND_STREAM_COUNT 0
|
||||
#define DSGM_SOUND_EFFECT_COUNT 0
|
||||
#define DSGM_SOUND_COUNT (DSGM_SOUND_STREAM_COUNT + DSGM_SOUND_EFFECT_COUNT)
|
||||
#define DSGM_BACKGROUND_COUNT 0
|
||||
#define DSGM_PALETTE_COUNT 0
|
||||
#define DSGM_SPRITE_COUNT 0
|
||||
#define DSGM_OBJECT_COUNT 1
|
||||
#define DSGM_ROOM_COUNT 1
|
||||
|
||||
// Include backgrounds, palettes and sprites to be loaded from RAM
|
||||
|
||||
// No sounds, no enum
|
||||
//typedef enum {
|
||||
//} DSGM_SoundNames;
|
||||
|
||||
// No backgrounds, no enum
|
||||
//typedef enum {
|
||||
//} DSGM_BackgroundNames;
|
||||
|
||||
// No palettes, no enum
|
||||
//typedef enum {
|
||||
//} DSGM_PaletteNames;
|
||||
|
||||
// No sprites, no enum
|
||||
//typedef enum {
|
||||
//} DSGM_SpriteNames;
|
||||
|
||||
typedef enum {
|
||||
hello,
|
||||
} DSGM_ObjectNames;
|
||||
|
||||
typedef struct {
|
||||
DSGM_ObjectInstanceBase;
|
||||
struct {
|
||||
} *variables;
|
||||
} helloObjectInstance;
|
||||
|
||||
typedef enum {
|
||||
Room_1,
|
||||
} DSGM_RoomNames;
|
||||
|
||||
extern DSGM_Sound DSGM_Sounds[DSGM_SOUND_COUNT];
|
||||
extern DSGM_Background DSGM_Backgrounds[DSGM_BACKGROUND_COUNT];
|
||||
extern DSGM_Palette DSGM_Palettes[DSGM_PALETTE_COUNT];
|
||||
extern DSGM_Sprite DSGM_Sprites[DSGM_SPRITE_COUNT];
|
||||
extern DSGM_Object DSGM_Objects[DSGM_OBJECT_COUNT];
|
||||
extern DSGM_Room DSGM_Rooms[DSGM_ROOM_COUNT];
|
||||
|
||||
extern int DSGM_currentRoom;
|
||||
|
||||
void DSGM_SetupRooms(int room);
|
||||
|
||||
void hello_create(helloObjectInstance *me);
|
0
template/nitrofiles/.gitkeep
Normal file
0
template/nitrofiles/.gitkeep
Normal file
17
template/source/main.c
Normal file
17
template/source/main.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include "DSGM.h"
|
||||
|
||||
void DSGM_Init(void);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
DSGM_Init();
|
||||
|
||||
DSGM_LoadRoom(&DSGM_Rooms[DSGM_currentRoom]);
|
||||
|
||||
while(1) {
|
||||
DSGM_LoopRoom(&DSGM_Rooms[DSGM_currentRoom]);
|
||||
|
||||
DSGM_Update();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
200
template/source/project.c
Normal file
200
template/source/project.c
Normal file
@ -0,0 +1,200 @@
|
||||
#include "DSGM.h"
|
||||
|
||||
#include "DSGM_projectHelper.h"
|
||||
|
||||
// User variables / declarations
|
||||
|
||||
// Resources
|
||||
DSGM_Sound DSGM_Sounds[DSGM_SOUND_COUNT] = {
|
||||
};
|
||||
|
||||
DSGM_Background DSGM_Backgrounds[DSGM_BACKGROUND_COUNT] = {
|
||||
};
|
||||
|
||||
DSGM_Palette DSGM_Palettes[DSGM_PALETTE_COUNT] = {
|
||||
};
|
||||
|
||||
DSGM_Sprite DSGM_Sprites[DSGM_SPRITE_COUNT] = {
|
||||
};
|
||||
|
||||
DSGM_Object DSGM_Objects[DSGM_OBJECT_COUNT] = {
|
||||
// hello
|
||||
{
|
||||
DSGM_NO_SPRITE,
|
||||
(DSGM_Event)hello_create,
|
||||
DSGM_NO_EVENT,
|
||||
DSGM_NO_EVENT,
|
||||
DSGM_NO_EVENT,
|
||||
NULL, 0,
|
||||
|
||||
sizeof(*((helloObjectInstance *)0)->variables)
|
||||
},
|
||||
};
|
||||
|
||||
DSGM_Room DSGM_Rooms[DSGM_ROOM_COUNT] = {
|
||||
// Room_1
|
||||
{
|
||||
// Backgrounds
|
||||
{
|
||||
// Bottom screen
|
||||
{
|
||||
// Layer 0
|
||||
{
|
||||
DSGM_TEXT_BACKGROUND, // Background
|
||||
DSGM_BOTTOM, // Screen
|
||||
0, // Layer
|
||||
false, // Attached to view system
|
||||
7, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
|
||||
// Layer 1
|
||||
{
|
||||
DSGM_NO_BACKGROUND, // Background
|
||||
DSGM_BOTTOM, // Screen
|
||||
1, // Layer
|
||||
true, // Attached to view system
|
||||
0, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
|
||||
// Layer 2
|
||||
{
|
||||
DSGM_NO_BACKGROUND, // Background
|
||||
DSGM_BOTTOM, // Screen
|
||||
2, // Layer
|
||||
true, // Attached to view system
|
||||
0, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
|
||||
// Layer 3
|
||||
{
|
||||
DSGM_NO_BACKGROUND, // Background
|
||||
DSGM_BOTTOM, // Screen
|
||||
3, // Layer
|
||||
true, // Attached to view system
|
||||
0, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
},
|
||||
|
||||
// Top screen
|
||||
{
|
||||
// Layer 0
|
||||
{
|
||||
DSGM_TEXT_BACKGROUND, // Background
|
||||
DSGM_TOP, // Screen
|
||||
0, // Layer
|
||||
false, // Attached to view system
|
||||
7, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
|
||||
// Layer 1
|
||||
{
|
||||
DSGM_NO_BACKGROUND, // Background
|
||||
DSGM_TOP, // Screen
|
||||
1, // Layer
|
||||
true, // Attached to view system
|
||||
0, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
|
||||
// Layer 2
|
||||
{
|
||||
DSGM_NO_BACKGROUND, // Background
|
||||
DSGM_TOP, // Screen
|
||||
2, // Layer
|
||||
true, // Attached to view system
|
||||
0, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
|
||||
// Layer 3
|
||||
{
|
||||
DSGM_NO_BACKGROUND, // Background
|
||||
DSGM_TOP, // Screen
|
||||
3, // Layer
|
||||
true, // Attached to view system
|
||||
0, // Map base
|
||||
0, // Tile base
|
||||
0, 0, 0
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
// Initial views
|
||||
{
|
||||
// Bottom screen
|
||||
{
|
||||
0, 0
|
||||
},
|
||||
|
||||
// Top screen
|
||||
{
|
||||
0, 0
|
||||
}
|
||||
},
|
||||
|
||||
// Views
|
||||
{
|
||||
// Bottom screen
|
||||
{
|
||||
0, 0
|
||||
},
|
||||
|
||||
// Top screen
|
||||
{
|
||||
0, 0
|
||||
}
|
||||
},
|
||||
|
||||
// Object groups are dynamic, so must be set up at run time, see DSGM_SetupRooms.
|
||||
{
|
||||
NULL,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
0,
|
||||
0
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
int DSGM_currentRoom = Room_1;
|
||||
|
||||
void DSGM_SetupRooms(int room) {
|
||||
if(room != DSGM_ALL_ROOMS) {
|
||||
switch(room) {
|
||||
case Room_1: goto Room_1; break;
|
||||
}
|
||||
}
|
||||
|
||||
Room_1:
|
||||
DSGM_Debug("Room_1 reset\n");
|
||||
DSGM_LeaveRoom(&DSGM_Rooms[Room_1]);
|
||||
|
||||
DSGM_SetupViews(&DSGM_Rooms[Room_1]);
|
||||
|
||||
DSGM_SetupObjectGroups(&DSGM_Rooms[Room_1], DSGM_TOP, 0);
|
||||
|
||||
DSGM_SetupObjectGroups(&DSGM_Rooms[Room_1], DSGM_BOTTOM, 1);
|
||||
|
||||
DSGM_SetupObjectInstances(&DSGM_Rooms[Room_1].objectGroups[DSGM_BOTTOM][0], &DSGM_Objects[hello], DSGM_BOTTOM, 1,
|
||||
0, 0
|
||||
);
|
||||
|
||||
if(room != DSGM_ALL_ROOMS) return;
|
||||
}
|
||||
|
||||
void hello_create(helloObjectInstance *me) {
|
||||
DSGM_DrawText(DSGM_BOTTOM, 1, 1, "Hello!");
|
||||
}
|
BIN
template/template.nds
Normal file
BIN
template/template.nds
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user