#171163 - scizzorz - Wed Nov 04, 2009 5:31 am
Hello!
I've been doing a bit of DS learning recently and I'm slightly confused on where to place my files and how to organize my makefile
Right now I have a directory named NDS, inside that is /build/, /source/, and /gfx/
Inside of /gfx/ I have a 16x32 256-color sprite bitmap which I can convert with:
(I also have sprite.grit inside /gfx/)
My makefile looks like this (I copy-pasted out of a tutorial on sprites and changed a few things):
And then I have main.cpp (mainly copy-pasted as well with a tiny modification to see if the sprite.h is loading correctly):
And when running the GCC make...
Am I placing my graphics in the wrong folder or is my makefile wrong?
I would really, really appreciate any help that you could give me - I'm brand new to programming in C++ and pretty much everything up there^^^ :)
I've been doing a bit of DS learning recently and I'm slightly confused on where to place my files and how to organize my makefile
Right now I have a directory named NDS, inside that is /build/, /source/, and /gfx/
Inside of /gfx/ I have a 16x32 256-color sprite bitmap which I can convert with:
Code: |
C:/grit/grit obj/sprite.bmp -gB4 -gt -ftc -W3 -pe16 -gu8 |
(I also have sprite.grit inside /gfx/)
Code: |
-gB4 -gt -ftc -W3 -pe16 -gu8 |
My makefile looks like this (I copy-pasted out of a tutorial on sprites and changed a few things):
Code: |
.SUFFIXES:
ifeq ($(strip $(DEVKITARM)),) $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") endif include $(DEVKITARM)/ds_rules TARGET := $(shell basename $(CURDIR)) BUILD := build SOURCES := source DATA := data INCLUDES := include GRAPHICS := gfx ARCH := -mthumb -mthumb-interwork CFLAGS := -g -Wall -O2\ -march=armv5te -mtune=arm946e-s -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) -mno-fpu -Wl,-Map,$(notdir $*.map) LIBS := -lnds9 LIBDIRS := $(LIBNDS) ifneq ($(BUILD),$(notdir $(CURDIR))) export OUTPUT := $(CURDIR)/$(TARGET) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(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,$(DATA),$(notdir $(wildcard $(dir)/*.*))) PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png))) ifeq ($(strip $(CPPFILES)),) export LD := $(CC) else export LD := $(CXX) endif export OFILES := $(addsuffix .o,$(BINFILES)) \ $(PNGFILES:.png=.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).arm9 $(TARGET).ds.gba else DEPENDS := $(OFILES:.o=.d) $(OUTPUT).nds : $(OUTPUT).arm9 $(OUTPUT).arm9 : $(OUTPUT).elf $(OUTPUT).elf : $(OFILES) %.bin.o : %.bin @echo $(notdir $<) @$(bin2o) %.c %.h : %.bmp %.grit grit $< -ftc -o$* -include $(DEPENDS) endif |
And then I have main.cpp (mainly copy-pasted as well with a tiny modification to see if the sprite.h is loading correctly):
Code: |
#include <nds.h>
#include <stdio.h> #include "sprite.h" volatile int frame = 0; //--------------------------------------------------------------------------------- void Vblank() { frame++; } //--------------------------------------------------------------------------------- int main(void) { touchPosition touchXY; irqSet(IRQ_VBLANK, Vblank); consoleDemoInit(); iprintf(" Hello DS dev'rs\n"); iprintf(" \x1b[32mwww.devkitpro.org\n"); iprintf(" \x1b[32;1mwww.drunkencoders.com\x1b[39m"); while(1) { swiWaitForVBlank(); touchRead(&touchXY); // print at using ansi escape sequence \x1b[line;columnH iprintf("\x1b[10;0HFrame = %d",frame); iprintf("\x1b[16;0HTouch (x,y) = (%03d, %03d)",touchXY.px,touchXY.py); iprintf("\x1b[17;0HPal 1 [%4d]",spritePal[1]); } return 0; } |
And when running the GCC make...
Code: |
main.cpp
arm-eabi-g++ -MMD -MP -MF /c/Users/John/NDS/build/main.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -I/c/Users/John/NDS/include -I/c/devkit Pro/libnds/include -I/c/devkitPro/libnds/include -I/c/Users/John/NDS/build -DARM9 -fno-rtti -fno-exceptions -c /c/Users/John/NDS/source/main.cpp -o main.o c:/Users/John/NDS/source/main.cpp:4:22: error: rhahkzor.h: No such file or directory c:/Users/John/NDS/source/main.cpp: In function 'int main()': c:/Users/John/NDS/source/main.cpp:32: error: 'rhahkzorPal' was not declared in this scope make[1]: *** [main.o] Error 1 make: *** [build] Error 2 |
Am I placing my graphics in the wrong folder or is my makefile wrong?
I would really, really appreciate any help that you could give me - I'm brand new to programming in C++ and pretty much everything up there^^^ :)