Skip to content

Commit

Permalink
Merge pull request #661 from laqieer/master
Browse files Browse the repository at this point in the history
Handwritten asm files and small bugfixes in building
  • Loading branch information
RevoSucks authored Aug 17, 2024
2 parents 4501247 + 19c30b3 commit b7b95d8
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -951,3 +951,9 @@ sound/songs/midi/*.s
# Generated source files
src/msg_data.c
include/msg_data.h

# Source files written in ASM
!src/rom_header.s
!src/crt0.s
!src/m4a_1.s
!src/libagbsyscall.s
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ ifeq (,$(findstring $(CFILES_GENERATED),$(CFILES)))
CFILES += $(CFILES_GENERATED)
endif
ASM_S_FILES := $(wildcard $(ASM_SUBDIR)/*.s)
SRC_S_FILES := src/rom_header.s src/crt0.s src/m4a_1.s src/libagbsyscall.s
DATA_S_FILES := $(wildcard $(DATA_SUBDIR)/*.s)
SOUND_S_FILES := $(wildcard sound/*.s sound/songs/*.s sound/songs/mml/*.s sound/voicegroups/*.s)
SFILES := $(ASM_S_FILES) $(DATA_S_FILES) $(SOUND_S_FILES)
SFILES := $(ASM_S_FILES) $(SRC_S_FILES) $(DATA_S_FILES) $(SOUND_S_FILES)
SFILES_COMPILED := $(CFILES:.c=.s)
C_OBJECTS := $(CFILES:.c=.o)
ASM_OBJECTS := $(SFILES:.s=.o)
BANIM_OBJECT := data/banim/data_banim.o
Expand All @@ -99,8 +101,7 @@ compare: $(ROM)
.PHONY: compare

clean:
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.fk' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
$(RM) $(ROM) $(ELF) $(MAP) $(ALL_OBJECTS) $(OBJECTS_LST) src/*.s graphics/*.h $(CFILES_GENERATED)
$(RM) $(ROM) $(ELF) $(MAP) $(ALL_OBJECTS) $(OBJECTS_LST) $(SFILES_COMPILED) graphics/*.h $(CFILES_GENERATED)
$(RM) -rf $(DEPS_DIR)
# Remove battle animation binaries
$(RM) -f data/banim/*.bin data/banim/*.o data/banim/*.lz data/banim/*.bak
Expand All @@ -109,6 +110,7 @@ clean:
# Remove converted songs
$(RM) -f $(MID_SUBDIR)/*.s
$(RM) -f $(AUTO_GEN_TARGETS)
find . \( -iname '*.o' -o -iname '*.obj' -o -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.fk' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +

.PHONY: clean

Expand All @@ -119,6 +121,13 @@ tag:

.PHONY: tag

#### Recipes ####

# Comprssed Texts Recipes

src/msg_data.c: msg_list.txt
$(TEXTENCODE) $< $@

# Graphics Recipes

include graphics_file_rules.mk
Expand Down Expand Up @@ -157,12 +166,15 @@ $(BANIM_OBJECT): $(shell ./scripts/arm_compressing_linker.py -t linker_script_ba
%_oam_r.bin: %_motion.o
$(OBJCOPY) -O binary -j .data.oam_r $< $@

#### Recipes ####

# Automatic dependency generation

MAKEDEP = mkdir -p $(DEPS_DIR)/$(dir $*) && $(CPP) $(CPPFLAGS) $< -MM -MG -MT $*.o > $(DEPS_DIR)/$*.d

MAKECMDGOALS_NODEP := clean tag

ifeq (,$(filter $(MAKECMDGOALS),$(MAKECMDGOALS_NODEP)))
-include $(addprefix $(DEPS_DIR)/,$(CFILES:.c=.d))
endif

$(DEPS_DIR)/%.d: %.c
@$(MAKEDEP)
Expand All @@ -177,10 +189,6 @@ $(ELF): $(ALL_OBJECTS) $(OBJECTS_LST) $(LDSCRIPT) $(SYM_FILES)
%.gba: %.elf
$(OBJCOPY) --strip-debug -O binary --pad-to 0x9000000 --gap-fill=0xff $< $@

# Generate msg_data.c
src/msg_data.c: msg_list.txt
$(TEXTENCODE) $< $@

$(C_OBJECTS): %.o: %.c $(DEPS_DIR)/%.d
@$(MAKEDEP)
$(CPP) $(CPPFLAGS) $< | iconv -f UTF-8 -t CP932 | $(CC1) $(CC1FLAGS) -o $*.s
Expand Down
7 changes: 4 additions & 3 deletions ldscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ SECTIONS
ALIGN(4)
{
/* .text */
asm/crt0.o(.text);
src/rom_header.o(.text);
src/crt0.o(.text);
asm/arm.o(.text);
src/main.o(.text);
src/fe3_dummy.o(.text);
Expand Down Expand Up @@ -608,9 +609,9 @@ SECTIONS
src/classchg-menuselect.o(.text);
src/classchg-postconfirm.o(.text);
src/bmguide.o(.text);
asm/m4a_1.o(.text);
src/m4a_1.o(.text);
src/m4a.o(.text);
asm/libagbsyscall.o(.text);
src/libagbsyscall.o(.text);
src/agb_sram.o(.text);
*libgcc.a:_ashldi3.o(.text);
*libgcc.a:_call_via_rX.o(.text);
Expand Down
5 changes: 0 additions & 5 deletions asm/crt0.s → src/crt0.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

.include "gba.inc"

.global Init
Init:
b crt0
.include "asm/rom_header.inc"

.global crt0
crt0:
@ Switch to IRQ Mode
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions asm/rom_header.inc → src/rom_header.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.syntax unified
.arm

.global Init
Init:
b crt0

.global RomHeaderNintendoLogo
RomHeaderNintendoLogo:
.byte 0x24,0xff,0xae,0x51,0x69,0x9a,0xa2,0x21
Expand Down

0 comments on commit b7b95d8

Please sign in to comment.