-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a3e4d45
Showing
13 changed files
with
609 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.elf | ||
*.nds | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
#--------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#--------------------------------------------------------------------------------- | ||
|
||
ifeq ($(strip $(DEVKITARM)),) | ||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") | ||
endif | ||
|
||
include $(DEVKITARM)/ds_rules | ||
|
||
#--------------------------------------------------------------------------------- | ||
# 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 | ||
# DATA is a list of directories containing binary files embedded using bin2o | ||
# GRAPHICS is a list of directories containing image files to be converted with grit | ||
# ICON is the image used to create the game icon, leave blank to use default rule | ||
#--------------------------------------------------------------------------------- | ||
TARGET := $(shell basename $(CURDIR)) | ||
BUILD := build | ||
SOURCES := source | ||
INCLUDES := include | ||
DATA := data | ||
GRAPHICS := gfx | ||
ICON := | ||
|
||
# specify a directory which contains the nitro filesystem | ||
# this is relative to the Makefile | ||
NITRO_FILES := | ||
|
||
# These set the information text in the nds file | ||
GAME_TITLE := Basic ARM9 template | ||
GAME_SUBTITLE1 := www.devkitpro.org | ||
GAME_SUBTITLE2 := www.drunkencoders.com | ||
|
||
#--------------------------------------------------------------------------------- | ||
# options for code generation | ||
#--------------------------------------------------------------------------------- | ||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s | ||
|
||
CFLAGS := -g -Wall -O2\ | ||
-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 := -lnds9 | ||
|
||
#--------------------------------------------------------------------------------- | ||
# 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) | ||
|
||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON))) \ | ||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(GRAPHICS),$(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))) | ||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png))) | ||
BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) | ||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(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)) \ | ||
$(PNGFILES:.png=.o) \ | ||
$(BMPFILES:.bmp=.o) \ | ||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) | ||
|
||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | ||
-I$(CURDIR)/$(BUILD) | ||
|
||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||
|
||
ifeq ($(strip $(ICON)),) | ||
icons := $(wildcard *.bmp) | ||
ifneq (,$(findstring $(TARGET).bmp,$(icons))) | ||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp | ||
else | ||
ifneq (,$(findstring icon.bmp,$(icons))) | ||
export GAME_ICON := $(CURDIR)/icon.bmp | ||
endif | ||
endif | ||
else | ||
ifeq ($(suffix $(ICON)), .grf) | ||
export GAME_ICON := $(CURDIR)/$(ICON) | ||
else | ||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf | ||
endif | ||
endif | ||
|
||
.PHONY: $(BUILD) clean | ||
|
||
#--------------------------------------------------------------------------------- | ||
$(BUILD) : | ||
@[ -d $@ ] || mkdir -p $@ | ||
@echo "OFILES = $(OFILES)" | ||
@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 $(GAME_ICON) | ||
$(OUTPUT).elf : $(OFILES) | ||
|
||
#--------------------------------------------------------------------------------- | ||
%.bin.o : %.bin | ||
#--------------------------------------------------------------------------------- | ||
@echo $(notdir $<) | ||
$(bin2o) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# This rule creates assembly source files using grit | ||
# grit takes an image file and a .grit describing how the file is to be processed | ||
# add additional rules like this for each image extension | ||
# you use in the graphics folders | ||
#--------------------------------------------------------------------------------- | ||
%.s %.h : %.png %.grit | ||
#--------------------------------------------------------------------------------- | ||
grit $< -fts -o$* | ||
|
||
#--------------------------------------------------------------------------------- | ||
%.s %.h : %.bmp %.grit | ||
#--------------------------------------------------------------------------------- | ||
grit $< -fts -o$* | ||
|
||
#--------------------------------------------------------------------------------- | ||
# Convert non-GRF game icon to GRF if needed | ||
#--------------------------------------------------------------------------------- | ||
$(GAME_ICON): $(notdir $(ICON)) | ||
#--------------------------------------------------------------------------------- | ||
@echo convert $(notdir $<) | ||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr | ||
|
||
-include $(DEPSDIR)/*.d | ||
|
||
#--------------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------------- | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-gt -gB8 -gu8 | ||
-m! | ||
-p | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-gt -gB8 -gu8 | ||
-m -mR8 -mu16 | ||
-p | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
|
||
#include <nds.h> | ||
|
||
#include "Structs.h" | ||
|
||
#ifndef CLASSES_H | ||
#define CLASSES_H | ||
|
||
class PlayerClass; | ||
|
||
class MapClass{ | ||
private: | ||
u16 Buffer1[32*32], Buffer2[32*32]; | ||
public: | ||
int id; | ||
MapClass(int Layer, int MapBase, int TileBase, const u16 *Pal, const u8 *Tiles, const u16 *Map, int TileSize); | ||
|
||
void Init(const u16*, const u16*, const u16*, int); | ||
void Update(PlayerClass *, const u16[]); | ||
void BufferToMem(); | ||
}; | ||
|
||
class EntityClass{ | ||
private: | ||
protected: | ||
u16 *pSpriteBase; | ||
XY c_BGPixels, c_BGTiles; | ||
public: | ||
void oamSetEntity(int Index, int X, int Y, bool Hide); | ||
|
||
EntityClass(const u8 *SpriteData); | ||
}; | ||
|
||
class PlayerClass: public EntityClass { | ||
private: | ||
XY Input; //counters for tracking, Input is for accepting user input | ||
int InputDirection;//Right, Down, Left, Up; make this 1,2,3, or 4 depending on which direction player is moving | ||
public: | ||
int AnimLoop; | ||
|
||
void AcceptUserInput(int BGid); | ||
void AUIReset(); | ||
bool CheckPlayerCollision(); | ||
|
||
friend class MapClass; | ||
friend class NPCClass; | ||
PlayerClass(const u8 *); | ||
}; | ||
|
||
class NPCClass: public EntityClass { | ||
private: | ||
public: | ||
static int NPCCount; | ||
static NPCClass *NPCs[]; | ||
int OamIndex; | ||
|
||
void Hold(PlayerClass *Player); | ||
|
||
NPCClass(const u8 *); | ||
~NPCClass(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
#ifndef STRUCTS_H | ||
#define STRUCTS_H | ||
|
||
struct XY { int X; int Y;}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#include <nds.h> | ||
|
||
#include "Classes.h" | ||
|
||
EntityClass::EntityClass(const u8 *SpriteData) { | ||
c_BGPixels.X=0; c_BGPixels.Y=0; | ||
c_BGTiles.X=0; c_BGTiles.Y=0; | ||
|
||
pSpriteBase = oamAllocateGfx(&oamMain, SpriteSize_16x32, SpriteColorFormat_256Color); | ||
memcpy(pSpriteBase, SpriteData, 256*2); | ||
} | ||
|
||
void EntityClass::oamSetEntity(int index, int X, int Y, bool Hide) | ||
{ | ||
oamSet(&oamMain, | ||
index, | ||
X, Y, | ||
1, //priority | ||
0, //palette index for multiple palettes | ||
SpriteSize_16x32, | ||
SpriteColorFormat_256Color, | ||
pSpriteBase, //pointer to loaded graphics | ||
0, //rot/scale matrix index | ||
false, //double size when rot/scale? | ||
Hide, //hide sprite? | ||
false, false, //vflip, hflip? | ||
false //mosiac? | ||
); | ||
} |
Oops, something went wrong.