Skip to content

Commit

Permalink
Merged linker & start.s files thanks to @Wolfvak
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Feb 24, 2017
1 parent d475baf commit 52b89b6
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 237 deletions.
42 changes: 17 additions & 25 deletions Makefile
Expand Up @@ -18,7 +18,7 @@ include $(DEVKITARM)/ds_rules
#---------------------------------------------------------------------------------
export TARGET := Decrypt9WIP
BUILD := build
SOURCES := source source/fatfs source/decryptor source/gamecart source/abstraction
SOURCES := source source/fatfs source/decryptor source/gamecart
DATA := data
INCLUDES := source source/font source/fatfs

Expand All @@ -32,7 +32,7 @@ THEME :=
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork -flto

CFLAGS := -g -Wall -Wextra -Wpedantic -pedantic -O2\
CFLAGS := -g -Wall -Wextra -Wpedantic -Wno-main -O2\
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
-ffast-math -std=c99\
$(ARCH)
Expand Down Expand Up @@ -60,13 +60,7 @@ endif
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions

ASFLAGS := -g $(ARCH) -DEXEC_$(EXEC_METHOD)
LDFLAGS = -nostartfiles -g $(ARCH) -Wl,-Map,$(TARGET).map

ifeq ($(EXEC_METHOD),GATEWAY)
LDFLAGS += --specs=../gateway.specs
else ifeq ($(EXEC_METHOD),A9LH)
LDFLAGS += --specs=../a9lh.specs
endif
LDFLAGS = -T../link.ld -nostartfiles -g $(ARCH) -Wl,-Map,$(TARGET).map

LIBS :=

Expand Down Expand Up @@ -120,50 +114,48 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \

export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

.PHONY: common clean all gateway a9lh cakehax cakerop brahma release
.PHONY: common clean all gateway binary cakehax cakerop brahma release

#---------------------------------------------------------------------------------
all: a9lh
all: binary

common:
@[ -d $(OUTPUT_D) ] || mkdir -p $(OUTPUT_D)
@[ -d $(BUILD) ] || mkdir -p $(BUILD)

submodules:
@-git submodule update --init --recursive

gateway: common
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile EXEC_METHOD=GATEWAY
binary: common
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

gateway: binary
@cp resources/LauncherTemplate.dat $(OUTPUT_D)/Launcher.dat
@dd if=$(OUTPUT).bin of=$(OUTPUT_D)/Launcher.dat bs=1497296 seek=1 conv=notrunc

a9lh: common
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile EXEC_METHOD=A9LH

cakehax: submodules common
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile EXEC_METHOD=GATEWAY
cakehax: submodules binary
@make dir_out=$(OUTPUT_D) name=$(TARGET).dat -C CakeHax bigpayload
@dd if=$(OUTPUT).bin of=$(OUTPUT).dat bs=512 seek=160

cakerop: cakehax
@make DATNAME=$(TARGET).dat DISPNAME=$(TARGET) GRAPHICS=../resources/CakesROP -C CakesROP
@mv CakesROP/CakesROP.nds $(OUTPUT_D)/$(TARGET).nds

brahma: submodules a9lh
brahma: submodules binary
@[ -d BrahmaLoader/data ] || mkdir -p BrahmaLoader/data
@cp $(OUTPUT).bin BrahmaLoader/data/payload.bin
@cp resources/BrahmaAppInfo BrahmaLoader/resources/AppInfo
@cp resources/BrahmaIcon.png BrahmaLoader/resources/icon.png
@make --no-print-directory -C BrahmaLoader APP_TITLE=$(TARGET)
@mv BrahmaLoader/output/*.3dsx $(OUTPUT_D)
@mv BrahmaLoader/output/*.smdh $(OUTPUT_D)

release:
@rm -fr $(BUILD) $(OUTPUT_D) $(RELEASE)
@make --no-print-directory binary
@-make --no-print-directory gateway
@-make --no-print-directory cakerop
@rm -fr $(BUILD) $(OUTPUT).bin $(OUTPUT).elf
@make --no-print-directory brahma
@-make --no-print-directory brahma
@[ -d $(RELEASE) ] || mkdir -p $(RELEASE)
@[ -d $(RELEASE)/$(TARGET) ] || mkdir -p $(RELEASE)/$(TARGET)
@[ -d $(RELEASE)/scripts ] || mkdir -p $(RELEASE)/scripts
Expand All @@ -178,7 +170,7 @@ release:
@cp $(CURDIR)/README.md $(RELEASE)
@-[ ! -n "$(strip $(THEME))" ] || (mkdir $(RELEASE)/$(THEME) && cp $(CURDIR)/resources/$(THEME)/*.bin $(RELEASE)/$(THEME))
@-7z a $(RELEASE)/$(TARGET)-`date +'%Y%m%d-%H%M%S'`.zip $(RELEASE)/*

#---------------------------------------------------------------------------------
clean:
@echo clean ...
Expand Down
12 changes: 0 additions & 12 deletions a9lh.ld

This file was deleted.

5 changes: 0 additions & 5 deletions a9lh.specs

This file was deleted.

12 changes: 0 additions & 12 deletions gateway.ld

This file was deleted.

5 changes: 0 additions & 5 deletions gateway.specs

This file was deleted.

18 changes: 18 additions & 0 deletions link.ld
@@ -0,0 +1,18 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)

SECTIONS
{
. = 0x23F00000;

.text.start : ALIGN(4) { *(.text.start) }
.text : ALIGN(4) { *(.text*) }
.rodata : ALIGN(4) { *(.rodata*) }
.data : ALIGN(4) { *(.data*) }
.bss : ALIGN(4) { __bss_start = .; *(.bss* COMMON); __bss_end = .;}

. = ALIGN(4);

__end__ = ABSOLUTE(.);
}
68 changes: 0 additions & 68 deletions source/abstraction/a9-start.s

This file was deleted.

101 changes: 0 additions & 101 deletions source/abstraction/gw-start.s

This file was deleted.

3 changes: 3 additions & 0 deletions source/common.h
Expand Up @@ -37,6 +37,9 @@
#define align(v,a) \
(((v) % (a)) ? ((v) + (a) - ((v) % (a))) : (v))

#define ENTRY_BRAHMA (1)
#define ENTRY_GATEWAY (2)

// standard work area, size must be a multiple of 0x200 (512)
#define BUFFER_ADDRESS ((u8*) 0x21000000)
#define BUFFER_MAX_SIZE ((u32) (1 * 1024 * 1024))
Expand Down
11 changes: 2 additions & 9 deletions source/draw.h
Expand Up @@ -59,15 +59,8 @@
#define DBG_N_CHARS_Y ((DBG_END_Y - DBG_START_Y) / DBG_STEP_Y)
#define DBG_N_CHARS_X (((DBG_END_X - DBG_START_X) / FONT_WIDTH) + 1)

#ifdef EXEC_GATEWAY
#define TOP_SCREEN (u8*)(*(u32*)((uint32_t)0x080FFFC0 + 4 * (*(u32*)0x080FFFD8 & 1)))
#define BOT_SCREEN (u8*)(*(u32*)((uint32_t)0x080FFFD0 + 4 * (*(u32*)0x080FFFDC & 1)))
#elif defined EXEC_A9LH
#define TOP_SCREEN (u8*)(*(u32*)0x23FFFE00)
#define BOT_SCREEN (u8*)(*(u32*)0x23FFFE08)
#else
#error "Unknown execution method"
#endif
#define TOP_SCREEN (u8*)(*(u32*)0x23FFFE00)
#define BOT_SCREEN (u8*)(*(u32*)0x23FFFE08)

#define ScreenWidth(x) (((x) == (TOP_SCREEN) ? 400 : 320))
#define IsCharPartOfWord(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= '0' && (x) <= '9') || ((x) >= 'A' && (x) <= 'Z'))
Expand Down

0 comments on commit 52b89b6

Please sign in to comment.