From e32e1247c3780cc12961e2936be0ffaff7846ddd Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Tue, 3 May 2005 17:28:49 +0000 Subject: [PATCH] added project templates --- templates/devkitARM/gba/template/Makefile | 125 ++++++++++++++ .../devkitARM/gba/template/source/template.c | 41 +++++ .../devkitARM/gba/template/template.pnproj | 1 + .../devkitARM/gp32/template/libmirko/Makefile | 118 ++++++++++++++ .../gp32/template/libmirko/source/template.c | 32 ++++ .../gp32/template/libmirko/template.pnproj | 1 + .../devkitARM/nds/template/arm7/Makefile | 136 ++++++++++++++++ .../nds/template/arm7/source/template.c | 63 ++++++++ .../nds/template/arm7/template.pnproj | 1 + .../devkitARM/nds/template/arm9/Makefile | 152 ++++++++++++++++++ .../nds/template/arm9/source/template.c | 56 +++++++ .../nds/template/arm9/template.pnproj | 1 + .../devkitPPC/gamecube/template/Makefile | 127 +++++++++++++++ .../gamecube/template/source/template.c | 60 +++++++ .../gamecube/template/template.pnproj | 1 + 15 files changed, 915 insertions(+) create mode 100644 templates/devkitARM/gba/template/Makefile create mode 100644 templates/devkitARM/gba/template/source/template.c create mode 100644 templates/devkitARM/gba/template/template.pnproj create mode 100644 templates/devkitARM/gp32/template/libmirko/Makefile create mode 100644 templates/devkitARM/gp32/template/libmirko/source/template.c create mode 100644 templates/devkitARM/gp32/template/libmirko/template.pnproj create mode 100644 templates/devkitARM/nds/template/arm7/Makefile create mode 100644 templates/devkitARM/nds/template/arm7/source/template.c create mode 100644 templates/devkitARM/nds/template/arm7/template.pnproj create mode 100644 templates/devkitARM/nds/template/arm9/Makefile create mode 100644 templates/devkitARM/nds/template/arm9/source/template.c create mode 100644 templates/devkitARM/nds/template/arm9/template.pnproj create mode 100644 templates/devkitPPC/gamecube/template/Makefile create mode 100644 templates/devkitPPC/gamecube/template/source/template.c create mode 100644 templates/devkitPPC/gamecube/template/template.pnproj diff --git a/templates/devkitARM/gba/template/Makefile b/templates/devkitARM/gba/template/Makefile new file mode 100644 index 0000000..339068b --- /dev/null +++ b/templates/devkitARM/gba/template/Makefile @@ -0,0 +1,125 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +-include $(DEVKITARM)/gba_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output, if this ends with _mb generates a multiboot image +# 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 := template_mb +BUILD := build +SOURCES := source +INCLUDES := + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -g -Wall -O3\ + -mcpu=arm7tdmi -mtune=arm7tdmi\ + -fomit-frame-pointer\ + -ffast-math \ + $(ARCH) + +CFLAGS += $(INCLUDE) + +ASFLAGS := $(ARCH) +LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map + +#--------------------------------------------------------------------------------- +# path to tools - this can be deleted if you set the path in windows +#--------------------------------------------------------------------------------- +export PATH := $(DEVKITARM)/bin:$(PATH) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lgba + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBGBA) + +#--------------------------------------------------------------------------------- +# 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)) + +#--------------------------------------------------------------------------------- +# automatically build a list of object files for our project +#--------------------------------------------------------------------------------- +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +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) + +#--------------------------------------------------------------------------------- +# build a list of include paths +#--------------------------------------------------------------------------------- +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +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) *.elf + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).gba : $(OUTPUT).elf + +$(OUTPUT).elf : $(OFILES) $(LIBGBA)/lib/libgba.a + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/templates/devkitARM/gba/template/source/template.c b/templates/devkitARM/gba/template/source/template.c new file mode 100644 index 0000000..a7cbde9 --- /dev/null +++ b/templates/devkitARM/gba/template/source/template.c @@ -0,0 +1,41 @@ +#include "gba_interrupt.h" +#include "gba_input.h" + +/*--------------------------------------------------------------------------------- + + Basic vblank interrupt with key scan & frame counter + +---------------------------------------------------------------------------------*/ +unsigned int frame = 0; +//--------------------------------------------------------------------------------- +void VblankInterrupt() +//--------------------------------------------------------------------------------- +{ + frame += 1; + ScanKeys(); +} + +//--------------------------------------------------------------------------------- +// Program entry point +//--------------------------------------------------------------------------------- +int main(void) +//--------------------------------------------------------------------------------- +{ + // Set up the interrupt handlers + InitInterrupt(); + + SetInterrupt( Int_Vblank, VblankInterrupt); + + // Enable Vblank Interrupt to allow VblankIntrWait + EnableInterrupt(Int_Vblank); + + // Allow Interrupts + REG_IME = 1; + + while (1) + { + VBlankIntrWait(); + } +} + + diff --git a/templates/devkitARM/gba/template/template.pnproj b/templates/devkitARM/gba/template/template.pnproj new file mode 100644 index 0000000..fc064b7 --- /dev/null +++ b/templates/devkitARM/gba/template/template.pnproj @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/devkitARM/gp32/template/libmirko/Makefile b/templates/devkitARM/gp32/template/libmirko/Makefile new file mode 100644 index 0000000..758c0da --- /dev/null +++ b/templates/devkitARM/gp32/template/libmirko/Makefile @@ -0,0 +1,118 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +-include $(DEVKITARM)/gp32_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 +#--------------------------------------------------------------------------------- +TARGET := template +BUILD := build +SOURCES := source +INCLUDES := + +AUTHOR := Dave Murphy +TITLE := GP32 template +#--------------------------------------------------------------------------------- +# path to tools - this can be deleted if you set the path in windows +#--------------------------------------------------------------------------------- +export PATH := $(DEVKITARM)/bin:$(PATH) + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +CFLAGS := -save-temps -g -Wall -O3\ + -mcpu=arm920t -mtune=arm920t\ + -fomit-frame-pointer\ + -ffast-math + +CFLAGS += $(INCLUDE) + +AFLAGS := +LDFLAGS = -g -Wl,-Map,$(notdir $@).map + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lmirkoSDK + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBMIRKO) + +#--------------------------------------------------------------------------------- +# 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)) + +#--------------------------------------------------------------------------------- +# automatically build a list of object files for our project +#--------------------------------------------------------------------------------- +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +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) + +#--------------------------------------------------------------------------------- +# build a list of include paths +#--------------------------------------------------------------------------------- +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +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).gxb + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).fxe : $(OUTPUT).gxb +$(OUTPUT).gxb : $(OUTPUT).elf +$(OUTPUT).elf : $(OFILES) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/templates/devkitARM/gp32/template/libmirko/source/template.c b/templates/devkitARM/gp32/template/libmirko/source/template.c new file mode 100644 index 0000000..647617d --- /dev/null +++ b/templates/devkitARM/gp32/template/libmirko/source/template.c @@ -0,0 +1,32 @@ +// written 2004 Mirko Roller mirko@mirkoroller.de +// Example shows you how to setup 256 color mode + +#include "gp32.h" +#include +#include + +u8 *framebuffer; +u16 palette[256]; + +int main() { + + int x; + + framebuffer = (u8*) FRAMEBUFFER; // 0x0C7B4000 + + gp_setCpuspeed(40); + gp_initFramebuffer(framebuffer,8,85); + + // Palette format: %RRRRRGGGGGBBBBBI (5551) + // I : Intensity Bit 1=on 0=off + + for (x=0;x<32;x++) palette[x] =(x<<1); + for (x=32;x<64;x++) palette[x] =((63-x)<<1); + for (x=64;x<256;x++) palette[x] =0x0; + + gp_drawString(50,110,23,"Hello World",255,(void *)framebuffer); + + while (1); + +} + diff --git a/templates/devkitARM/gp32/template/libmirko/template.pnproj b/templates/devkitARM/gp32/template/libmirko/template.pnproj new file mode 100644 index 0000000..fc064b7 --- /dev/null +++ b/templates/devkitARM/gp32/template/libmirko/template.pnproj @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/devkitARM/nds/template/arm7/Makefile b/templates/devkitARM/nds/template/arm7/Makefile new file mode 100644 index 0000000..5fa73a6 --- /dev/null +++ b/templates/devkitARM/nds/template/arm7/Makefile @@ -0,0 +1,136 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +-include $(DEVKITARM)/ds_rules +#--------------------------------------------------------------------------------- +# TARGET is the name of the output, if this ends with _mb generates a multiboot image +# 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 := template +BUILD := build +SOURCES := gfx source data +INCLUDES := include build + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -g -Wall -O2\ + -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ + -ffast-math \ + $(ARCH) + +CFLAGS += $(INCLUDE) -DARM7 + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map + +#--------------------------------------------------------------------------------- +# path to tools - this can be deleted if you set the path in windows +#--------------------------------------------------------------------------------- +export PATH := $(DEVKITARM)/bin:$(PATH) + +LIBS := -lnds7 + + +#--------------------------------------------------------------------------------- +# 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 := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) + +export CC := $(PREFIX)gcc +export CXX := $(PREFIX)g++ +export AR := $(PREFIX)ar +export OBJCOPY := $(PREFIX)objcopy + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +PCXFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcx))) +BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin))) +PALFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pal))) +RAWFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.raw))) +MAPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.map))) + +export OFILES := $(MAPFILES:.map=.o) $(RAWFILES:.raw=.o) $(PALFILES:.pal=.o) $(BINFILES:.bin=.o) $(PCXFILES:.pcx=.o)\ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) *.elf + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- + +$(OUTPUT).bin : $(OUTPUT).elf + +$(OUTPUT).elf : $(OFILES) + + +#--------------------------------------------------------------------------------- +%.bin: %.elf + @echo built ... $(notdir $@) + @$(OBJCOPY) -O binary $< $@ + +#--------------------------------------------------------------------------------- +%.elf: + @echo linking binary + @$(LD) $(LDFLAGS) -specs=ds_arm7.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $@ + + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/templates/devkitARM/nds/template/arm7/source/template.c b/templates/devkitARM/nds/template/arm7/source/template.c new file mode 100644 index 0000000..9a87353 --- /dev/null +++ b/templates/devkitARM/nds/template/arm7/source/template.c @@ -0,0 +1,63 @@ +//--------------------------------------------------------------------------------- +// Simple ARM7 stub (sends RTC, TSC, and X/Y data to the ARM 9) +//--------------------------------------------------------------------------------- +#include "nds.h" +#include "nds/bios.h" +#include "nds/arm7/touch.h" +#include "nds/arm7/clock.h" + +//--------------------------------------------------------------------------------- +void InterruptHandler(void) { +//--------------------------------------------------------------------------------- + int t1, t2; + static int heartbeat = 0; + + if (IF & IRQ_VBLANK) { + // Update the heartbeat + heartbeat++; + IPC->heartbeat = heartbeat; + + // Read the X/Y buttons and the /PENIRQ line + IPC->buttons = XKEYS; + + // Read the touch screen + IPC->touchX = touchRead(TSC_MEASURE_X); + IPC->touchY = touchRead(TSC_MEASURE_Y); + IPC->touchZ1 = touchRead(TSC_MEASURE_Z1); + IPC->touchZ2 = touchRead(TSC_MEASURE_Z2); + + // Read the time + rtcGetTime((uint8 *)IPC->curtime); + BCDToInteger((uint8 *)&(IPC->curtime[1]), 7); + + // Read the temperature + IPC->temperature = touchReadTemperature(&t1, &t2); + IPC->tdiode1 = t1; + + IPC->tdiode2 = t2; + } + + // Acknowledge interrupts + IF = IF; +} + +//--------------------------------------------------------------------------------- +int main(int argc, char ** argv) { +//--------------------------------------------------------------------------------- + // Reset the clock if needed + rtcReset(); + + // Set up the interrupt handler + IME = 0; + IRQ_HANDLER = &InterruptHandler; + IE = IRQ_VBLANK; + IF = ~0; + DISP_SR = DISP_VBLANK_IRQ; + IME = 1; + + // Keep the ARM7 out of main RAM + while (1) swiWaitForVBlank(); + return 0; +} + +////////////////////////////////////////////////////////////////////// diff --git a/templates/devkitARM/nds/template/arm7/template.pnproj b/templates/devkitARM/nds/template/arm7/template.pnproj new file mode 100644 index 0000000..fc064b7 --- /dev/null +++ b/templates/devkitARM/nds/template/arm7/template.pnproj @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/devkitARM/nds/template/arm9/Makefile b/templates/devkitARM/nds/template/arm9/Makefile new file mode 100644 index 0000000..29d0dec --- /dev/null +++ b/templates/devkitARM/nds/template/arm9/Makefile @@ -0,0 +1,152 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +-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 +#--------------------------------------------------------------------------------- +TARGET := template +BUILD := build +SOURCES := source +INCLUDES := include +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +# note: arm9tdmi isn't the correct CPU arch, but anything newer and LD +# *insists* it has a FPU or VFP, and it won't take no for an answer! +CFLAGS := -g -Wall -O2\ + -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer\ + -ffast-math \ + $(ARCH) + +CFLAGS += $(INCLUDE) -DARM9 + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# path to tools - this can be deleted if you set the path in windows +#--------------------------------------------------------------------------------- +export PATH := $(DEVKITARM)/bin:$(PATH) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +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 := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) + +export CC := $(PREFIX)gcc +export CXX := $(PREFIX)g++ +export AR := $(PREFIX)ar +export OBJCOPY := $(PREFIX)objcopy + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +PCXFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcx))) +BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin))) +PALFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pal))) +RAWFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.raw))) +MAPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.map))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES := $(MAPFILES:.map=.o) $(RAWFILES:.raw=.o) $(PALFILES:.pal=.o) $(BINFILES:.bin=.o) $(PCXFILES:.pcx=.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) *.elf *.nds* *.bin + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds.gba : $(OUTPUT).nds + +$(OUTPUT).nds : $(OUTPUT).bin + +$(OUTPUT).bin : $(OUTPUT).elf + +$(OUTPUT).elf : $(OFILES) + +#--------------------------------------------------------------------------------- +%.ds.gba: %.nds + dsbuild $< + @echo built ... $(notdir $@) + +#--------------------------------------------------------------------------------- +%.nds: %.bin + @ndstool -c $@ -9 $< + @echo built ... $(notdir $@) + + +#--------------------------------------------------------------------------------- +%.bin: %.elf + @$(OBJCOPY) -O binary $< $@ + @echo built ... $(notdir $@) + +#--------------------------------------------------------------------------------- +%.elf: + @echo linking binary + @$(LD) $(LDFLAGS) -specs=ds_arm9.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $@ + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/templates/devkitARM/nds/template/arm9/source/template.c b/templates/devkitARM/nds/template/arm9/source/template.c new file mode 100644 index 0000000..588e3d7 --- /dev/null +++ b/templates/devkitARM/nds/template/arm9/source/template.c @@ -0,0 +1,56 @@ +//--------------------------------------------------------------------------------- +#include "nds.h" + +//--------------------------------------------------------------------------------- +void irqVBlank(void) { +//--------------------------------------------------------------------------------- + IF = IF; +} + +//--------------------------------------------------------------------------------- +int main(void) { +//--------------------------------------------------------------------------------- + static int screen =0; + u16* back = VRAM_A; + u16* front = VRAM_B; + + //turn on the power to the system + powerON(POWER_ALL); + + //set main display to render directly from the frame buffer + videoSetMode(MODE_FB1); + + //set up the sub display + videoSetModeSub(MODE_0_2D | + DISPLAY_SPR_1D_LAYOUT | + DISPLAY_SPR_ACTIVE | + DISPLAY_BG0_ACTIVE | + DISPLAY_BG1_ACTIVE ); + + //vram banks are somewhat complex + vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_SUB_BG, VRAM_D_SUB_SPRITE); + + //irqs are nice..ndslib comes with a very unoptimised default handler + irqInitHandler(irqDefaultHandler); + irqSet(IRQ_VBLANK, irqVBlank); + + while (1) { + + swiWaitForVBlank(); + + //flip screens + if(screen) { + videoSetMode(MODE_FB1); + front = VRAM_B; + back = VRAM_A; + screen = 0; + } else { + videoSetMode(MODE_FB0); + front = VRAM_A; + back = VRAM_B; + screen = 1; + } + } + return 0; +} + diff --git a/templates/devkitARM/nds/template/arm9/template.pnproj b/templates/devkitARM/nds/template/arm9/template.pnproj new file mode 100644 index 0000000..b4acc55 --- /dev/null +++ b/templates/devkitARM/nds/template/arm9/template.pnproj @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/devkitPPC/gamecube/template/Makefile b/templates/devkitPPC/gamecube/template/Makefile new file mode 100644 index 0000000..cb663ae --- /dev/null +++ b/templates/devkitPPC/gamecube/template/Makefile @@ -0,0 +1,127 @@ +#--------------------------------------------------------------------------------- +# Generic makefile for Gamecube projects +# +# Tab stops set to 4 +# | | | | +# 0 1 2 3 +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +-include $(DEVKITPPC)/gamecube_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 +#--------------------------------------------------------------------------------- +TARGET := template +BUILD := build +SOURCES := source +INCLUDES := include + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float +CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) + +LDFLAGS = $(MACHDEP) -mogc -Wl,-Map,$(notdir $@).map -Wl,--cref + +PREFIX := powerpc-gekko- + +export PATH:=$(DEVKITPPC)/bin:$(PATH) + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with +#--------------------------------------------------------------------------------- +LIBS := -logc -lm + +#--------------------------------------------------------------------------------- +# 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)) + +export CC := $(PREFIX)gcc +export CXX := $(PREFIX)g++ +export AR := $(PREFIX)ar +export OBJCOPY := $(PREFIX)objcopy +#--------------------------------------------------------------------------------- +# automatically build a list of object files for our project +#--------------------------------------------------------------------------------- +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.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) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +export OUTPUT := $(CURDIR)/$(TARGET) +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) *.elf + +#--------------------------------------------------------------------------------- +run: + psoload $(TARGET).dol + +#--------------------------------------------------------------------------------- +reload: + psoload -r $(TARGET).dol + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).dol: $(OUTPUT).elf +$(OUTPUT).elf: $(OFILES) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/templates/devkitPPC/gamecube/template/source/template.c b/templates/devkitPPC/gamecube/template/source/template.c new file mode 100644 index 0000000..185953b --- /dev/null +++ b/templates/devkitPPC/gamecube/template/source/template.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include + +static void *xfb = NULL; + +u32 first_frame = 1; +GXRModeObj *rmode; +void (*PSOreload)() = (void(*)())0x80001800; + +//--------------------------------------------------------------------------------- +int main() { +//--------------------------------------------------------------------------------- + VIDEO_Init(); + + switch(VIDEO_GetCurrentTvMode()) + { + case VI_NTSC: + rmode = &TVNtsc480IntDf; + break; + case VI_PAL: + rmode = &TVPal528IntDf; + break; + case VI_MPAL: + rmode = &TVMpal480IntDf; + break; + default: + rmode = &TVNtsc480IntDf; + break; + } + + PAD_Init(); + + xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); + + VIDEO_Configure(rmode); + + VIDEO_SetNextFramebuffer(xfb); + VIDEO_SetBlack(FALSE); + VIDEO_Flush(); + VIDEO_WaitVSync(); + if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); + VIDEO_SetPreRetraceCallback(PAD_ScanPads); + console_init(xfb,20,64,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*2); + VIDEO_SetNextFramebuffer(xfb); + + + while (1) { + + while ( !(PAD_ButtonsDown(0) & PAD_BUTTON_A)) { + if (PAD_ButtonsDown(0) & PAD_BUTTON_START) PSOreload(); + VIDEO_WaitVSync(); + } + } + +} diff --git a/templates/devkitPPC/gamecube/template/template.pnproj b/templates/devkitPPC/gamecube/template/template.pnproj new file mode 100644 index 0000000..fc064b7 --- /dev/null +++ b/templates/devkitPPC/gamecube/template/template.pnproj @@ -0,0 +1 @@ + \ No newline at end of file