Merge branch 'master' of https://github.com/pret/pokeemerald into dexnav
This commit is contained in:
commit
53e6ba1c48
44
.github/workflows/build.yml
vendored
44
.github/workflows/build.yml
vendored
@ -7,11 +7,29 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GAME_VERSION: EMERALD
|
||||
GAME_REVISION: 0
|
||||
GAME_LANGUAGE: ENGLISH
|
||||
MODERN: 0
|
||||
COMPARE: 1
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Checkout syms
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
path: symbols
|
||||
ref: symbols
|
||||
|
||||
- name: Checkout agbcc
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
path: agbcc
|
||||
repository: pret/agbcc
|
||||
|
||||
- name: Install binutils
|
||||
run: sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi
|
||||
# build-essential, git, and libpng-dev are already installed
|
||||
@ -20,16 +38,18 @@ jobs:
|
||||
|
||||
- name: Install agbcc
|
||||
run: |
|
||||
git clone https://github.com/pret/agbcc.git
|
||||
cd agbcc
|
||||
./build.sh
|
||||
./install.sh ../
|
||||
working-directory: agbcc
|
||||
|
||||
- name: Compare
|
||||
run: make -j${nproc} compare
|
||||
run: make -j${nproc} all syms
|
||||
|
||||
- name: Modern
|
||||
run: make -j${nproc} modern
|
||||
env:
|
||||
MODERN: 1
|
||||
COMPARE: 0
|
||||
run: make -j${nproc} all
|
||||
|
||||
- name: Webhook
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
@ -38,3 +58,17 @@ jobs:
|
||||
CALCROM_DISCORD_WEBHOOK_AVATAR_URL: https://i.imgur.com/38BQHdd.png
|
||||
CALCROM_DISCORD_WEBHOOK_URL: ${{ secrets.CALCROM_DISCORD_WEBHOOK_URL }}
|
||||
run: sh .github/calcrom/webhook.sh pokeemerald
|
||||
|
||||
- name: Move symfiles
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
run: |
|
||||
cp -v *.sym symbols/
|
||||
|
||||
- name: Update symfiles
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
uses: EndBug/add-and-commit@v7
|
||||
with:
|
||||
branch: symbols
|
||||
cwd: "./symbols"
|
||||
add: "*.sym"
|
||||
message: ${{ github.event.commits[0].message }}
|
||||
|
||||
157
Makefile
157
Makefile
@ -1,6 +1,10 @@
|
||||
TOOLCHAIN := $(DEVKITARM)
|
||||
COMPARE ?= 0
|
||||
|
||||
ifeq (compare,$(MAKECMDGOALS))
|
||||
COMPARE := 1
|
||||
endif
|
||||
|
||||
# don't use dkP's base_tools anymore
|
||||
# because the redefinition of $(CC) conflicts
|
||||
# with when we want to use $(CC) to preprocess files
|
||||
@ -16,6 +20,7 @@ endif
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
OBJCOPY := $(PREFIX)objcopy
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
AS := $(PREFIX)as
|
||||
|
||||
LD := $(PREFIX)ld
|
||||
@ -36,6 +41,10 @@ MAKER_CODE := 01
|
||||
REVISION := 0
|
||||
MODERN ?= 0
|
||||
|
||||
ifeq (modern,$(MAKECMDGOALS))
|
||||
MODERN := 1
|
||||
endif
|
||||
|
||||
# use arm-none-eabi-cpp for macOS
|
||||
# as macOS's default compiler is clang
|
||||
# and clang's preprocessor will warn on \u
|
||||
@ -67,6 +76,7 @@ SHELL := /bin/bash -o pipefail
|
||||
|
||||
ELF = $(ROM:.gba=.elf)
|
||||
MAP = $(ROM:.gba=.map)
|
||||
SYM = $(ROM:.gba=.sym)
|
||||
|
||||
C_SUBDIR = src
|
||||
GFLIB_SUBDIR = gflib
|
||||
@ -121,6 +131,8 @@ FIX := tools/gbafix/gbafix$(EXE)
|
||||
MAPJSON := tools/mapjson/mapjson$(EXE)
|
||||
JSONPROC := tools/jsonproc/jsonproc$(EXE)
|
||||
|
||||
PERL := perl
|
||||
|
||||
TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
|
||||
TOOLBASE = $(TOOLDIRS:tools/%=%)
|
||||
TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE))
|
||||
@ -143,12 +155,28 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst
|
||||
|
||||
# Build tools when building the rom
|
||||
# Disable dependency scanning for clean/tidy/tools
|
||||
ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS)))
|
||||
$(call infoshell, $(MAKE) tools)
|
||||
# Use a separate minimal makefile for speed
|
||||
# Since we don't need to reload most of this makefile
|
||||
ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall syms,$(MAKECMDGOALS)))
|
||||
$(call infoshell, $(MAKE) -f make_tools.mk)
|
||||
else
|
||||
NODEP := 1
|
||||
NODEP ?= 1
|
||||
endif
|
||||
|
||||
# check if we need to scan dependencies based on the rule
|
||||
ifeq (,$(MAKECMDGOALS))
|
||||
SCAN_DEPS ?= 1
|
||||
else
|
||||
# clean, tidy, tools, mostlyclean, clean-tools, $(TOOLDIRS), tidymodern, tidynonmodern don't even build the ROM
|
||||
# berry_fix and libagbsyscall do their own thing
|
||||
ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) tidymodern tidynonmodern berry_fix libagbsyscall,$(MAKECMDGOALS)))
|
||||
SCAN_DEPS ?= 0
|
||||
else
|
||||
SCAN_DEPS ?= 1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(SCAN_DEPS),1)
|
||||
C_SRCS_IN := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c)
|
||||
C_SRCS := $(foreach src,$(C_SRCS_IN),$(if $(findstring .inc.c,$(src)),,$(src)))
|
||||
C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS))
|
||||
@ -178,15 +206,17 @@ OBJS := $(C_OBJS) $(GFLIB_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $
|
||||
OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS))
|
||||
|
||||
SUBDIRS := $(sort $(dir $(OBJS)))
|
||||
$(shell mkdir -p $(SUBDIRS))
|
||||
endif
|
||||
|
||||
AUTO_GEN_TARGETS :=
|
||||
|
||||
$(shell mkdir -p $(SUBDIRS))
|
||||
|
||||
all: rom
|
||||
|
||||
tools: $(TOOLDIRS)
|
||||
|
||||
syms: $(SYM)
|
||||
|
||||
$(TOOLDIRS):
|
||||
@$(MAKE) -C $@
|
||||
|
||||
@ -196,7 +226,7 @@ ifeq ($(COMPARE),1)
|
||||
endif
|
||||
|
||||
# For contributors to make sure a change didn't affect the contents of the ROM.
|
||||
compare: ; @$(MAKE) COMPARE=1
|
||||
compare: all
|
||||
|
||||
clean: mostlyclean clean-tools
|
||||
|
||||
@ -270,47 +300,79 @@ else
|
||||
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(C_BUILDDIR)/%.o: c_dep :=
|
||||
else
|
||||
$(C_BUILDDIR)/%.o: c_dep = $(shell [[ -f $(C_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(C_SUBDIR)/$*.c)
|
||||
endif
|
||||
|
||||
ifeq ($(DINFO),1)
|
||||
override CFLAGS += -g
|
||||
endif
|
||||
|
||||
$(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep)
|
||||
@$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i
|
||||
@$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $(C_BUILDDIR)/$*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(GFLIB_BUILDDIR)/%.o: c_dep :=
|
||||
else
|
||||
$(GFLIB_BUILDDIR)/%.o: c_dep = $(shell [[ -f $(GFLIB_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(GFLIB_SUBDIR)/$*.c)
|
||||
endif
|
||||
|
||||
$(GFLIB_BUILDDIR)/%.o : $(GFLIB_SUBDIR)/%.c $$(c_dep)
|
||||
@$(CPP) $(CPPFLAGS) $< -o $(GFLIB_BUILDDIR)/$*.i
|
||||
@$(PREPROC) $(GFLIB_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(GFLIB_BUILDDIR)/$*.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $(GFLIB_BUILDDIR)/$*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $(GFLIB_BUILDDIR)/$*.s
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(C_BUILDDIR)/%.o: c_asm_dep :=
|
||||
else
|
||||
$(C_BUILDDIR)/%.o: c_asm_dep = $(shell [[ -f $(C_SUBDIR)/$*.s ]] && $(SCANINC) -I "" $(C_SUBDIR)/$*.s)
|
||||
endif
|
||||
|
||||
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $$(c_asm_dep)
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
# The dep rules have to be explicit or else missing files won't be reported.
|
||||
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
|
||||
# It doesn't look like $(shell) can be deferred so there might not be a better way.
|
||||
|
||||
ifeq ($(SCAN_DEPS),1)
|
||||
ifeq ($(NODEP),1)
|
||||
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c
|
||||
ifeq (,$(KEEP_TEMPS))
|
||||
@echo "$(CC1) <flags> -o $@ $<"
|
||||
@$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
|
||||
else
|
||||
@$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i
|
||||
@$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $(C_BUILDDIR)/$*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s
|
||||
endif
|
||||
else
|
||||
define C_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2)
|
||||
ifeq (,$$(KEEP_TEMPS))
|
||||
@echo "$$(CC1) <flags> -o $$@ $$<"
|
||||
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
|
||||
else
|
||||
@$$(CPP) $$(CPPFLAGS) $$< -o $$(C_BUILDDIR)/$3.i
|
||||
@$$(PREPROC) $$(C_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(C_BUILDDIR)/$3.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $$(C_BUILDDIR)/$3.s
|
||||
$$(AS) $$(ASFLAGS) -o $$@ $$(C_BUILDDIR)/$3.s
|
||||
endif
|
||||
endef
|
||||
$(foreach src, $(C_SRCS), $(eval $(call C_DEP,$(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(src)),$(src),$(patsubst $(C_SUBDIR)/%.c,%,$(src)))))
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(GFLIB_BUILDDIR)/%.o: $(GFLIB_SUBDIR)/%.c $$(c_dep)
|
||||
ifeq (,$(KEEP_TEMPS))
|
||||
@echo "$(CC1) <flags> -o $@ $<"
|
||||
@$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
|
||||
else
|
||||
@$(CPP) $(CPPFLAGS) $< -o $(GFLIB_BUILDDIR)/$*.i
|
||||
@$(PREPROC) $(GFLIB_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(GFLIB_BUILDDIR)/$*.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $(GFLIB_BUILDDIR)/$*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $(GFLIB_BUILDDIR)/$*.s
|
||||
endif
|
||||
else
|
||||
define GFLIB_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2)
|
||||
ifeq (,$$(KEEP_TEMPS))
|
||||
@echo "$$(CC1) <flags> -o $$@ $$<"
|
||||
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
|
||||
else
|
||||
@$$(CPP) $$(CPPFLAGS) $$< -o $$(GFLIB_BUILDDIR)/$3.i
|
||||
@$$(PREPROC) $$(GFLIB_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(GFLIB_BUILDDIR)/$3.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $$(GFLIB_BUILDDIR)/$3.s
|
||||
$$(AS) $$(ASFLAGS) -o $$@ $$(GFLIB_BUILDDIR)/$3.s
|
||||
endif
|
||||
endef
|
||||
$(foreach src, $(GFLIB_SRCS), $(eval $(call GFLIB_DEP,$(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o, $(src)),$(src),$(patsubst $(GFLIB_SUBDIR)/%.c,%, $(src)))))
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
|
||||
else
|
||||
define SRC_ASM_DATA_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I "" $2)
|
||||
$$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@
|
||||
endef
|
||||
$(foreach src, $(C_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src))))
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s
|
||||
@ -327,12 +389,8 @@ ifeq ($(NODEP),1)
|
||||
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
|
||||
else
|
||||
define DATA_ASM_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I "" $2)
|
||||
$$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@
|
||||
endef
|
||||
$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src))))
|
||||
$(foreach src, $(C_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src))))
|
||||
$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src))))
|
||||
endif
|
||||
endif
|
||||
|
||||
$(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s
|
||||
@ -367,7 +425,7 @@ $(ROM): $(ELF)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(FIX) $@ -p --silent
|
||||
|
||||
modern: ; @$(MAKE) MODERN=1
|
||||
modern: all
|
||||
|
||||
berry_fix/berry_fix.gba: berry_fix
|
||||
|
||||
@ -376,3 +434,10 @@ berry_fix:
|
||||
|
||||
libagbsyscall:
|
||||
@$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)
|
||||
|
||||
###################
|
||||
### Symbol file ###
|
||||
###################
|
||||
|
||||
$(SYM): $(ELF)
|
||||
$(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" | $(PERL) -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\S+)$$/\1 \2 \3 \4/g' > $@
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
"movement_range_y": 1,
|
||||
"trainer_type": "TRAINER_TYPE_NONE",
|
||||
"trainer_sight_or_berry_tree_id": "0",
|
||||
"script": "MagmaHideout_2F_2R_EventScript_MaxElixir",
|
||||
"script": "MagmaHideout_2F_2R_EventScript_ItemMaxElixir",
|
||||
"flag": "FLAG_ITEM_MAGMA_HIDEOUT_2F_2R_MAX_ELIXIR"
|
||||
},
|
||||
{
|
||||
|
||||
@ -115,7 +115,7 @@
|
||||
"movement_range_y": 1,
|
||||
"trainer_type": "TRAINER_TYPE_NONE",
|
||||
"trainer_sight_or_berry_tree_id": "0",
|
||||
"script": "MagmaHideout_4F_EventScript_MaxRevive",
|
||||
"script": "MagmaHideout_4F_EventScript_ItemMaxRevive",
|
||||
"flag": "FLAG_ITEM_MAGMA_HIDEOUT_4F_MAX_REVIVE"
|
||||
}
|
||||
],
|
||||
|
||||
@ -634,7 +634,7 @@ MagmaHideout_1F_EventScript_ItemRareCandy:: @ 82914DE
|
||||
finditem ITEM_RARE_CANDY
|
||||
end
|
||||
|
||||
MagmaHideout_2F_2R_EventScript_MaxElixir:: @ 82914EB
|
||||
MagmaHideout_2F_2R_EventScript_ItemMaxElixir:: @ 82914EB
|
||||
finditem ITEM_MAX_ELIXIR
|
||||
end
|
||||
|
||||
@ -650,7 +650,7 @@ MagmaHideout_3F_2R_EventScript_ItemPPMax:: @ 8291512
|
||||
finditem ITEM_PP_MAX
|
||||
end
|
||||
|
||||
MagmaHideout_4F_EventScript_MaxRevive:: @ 829151F
|
||||
MagmaHideout_4F_EventScript_ItemMaxRevive:: @ 829151F
|
||||
finditem ITEM_MAX_REVIVE
|
||||
end
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#define APPLAUSE_METER_SIZE 5
|
||||
#define CONTEST_NUM_APPEALS 5
|
||||
#define CONTEST_LAST_APPEAL (CONTEST_NUM_APPEALS - 1)
|
||||
#define MAX_CONTEST_MOVE_HEARTS 8
|
||||
|
||||
#define LINK_CONTEST_FLAG_IS_LINK (1 << 0)
|
||||
#define LINK_CONTEST_FLAG_IS_WIRELESS (1 << 1)
|
||||
|
||||
@ -142,19 +142,15 @@ struct MapHeader
|
||||
/* 0x16 */ u8 weather;
|
||||
/* 0x17 */ u8 mapType;
|
||||
/* 0x18 */ u8 filler_18[2];
|
||||
/* 0x1A */ u8 flags;
|
||||
// fields correspond to the arguments in the map_header_flags macro
|
||||
/* 0x1A */ bool8 allowCycling:1;
|
||||
bool8 allowEscaping:1; // Escape Rope and Dig
|
||||
bool8 allowRunning:1;
|
||||
bool8 showMapName:5; // the last 4 bits are unused
|
||||
// but the 5 bit sized bitfield is required to match
|
||||
/* 0x1B */ u8 battleType;
|
||||
};
|
||||
|
||||
// Flags for gMapHeader.flags, as defined in the map_header_flags macro
|
||||
#define MAP_ALLOW_CYCLING (1 << 0)
|
||||
#define MAP_ALLOW_ESCAPING (1 << 1) // Escape Rope and Dig
|
||||
#define MAP_ALLOW_RUNNING (1 << 2)
|
||||
#define MAP_SHOW_MAP_NAME (1 << 3)
|
||||
#define UNUSED_MAP_FLAGS (1 << 4 | 1 << 5 | 1 << 6 | 1 << 7)
|
||||
|
||||
#define SHOW_MAP_NAME_ENABLED ((gMapHeader.flags & (MAP_SHOW_MAP_NAME | UNUSED_MAP_FLAGS)) == MAP_SHOW_MAP_NAME)
|
||||
|
||||
|
||||
struct ObjectEvent
|
||||
{
|
||||
|
||||
11
make_tools.mk
Normal file
11
make_tools.mk
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
|
||||
|
||||
.PHONY: all $(TOOLDIRS)
|
||||
|
||||
all: $(TOOLDIRS)
|
||||
|
||||
$(TOOLDIRS):
|
||||
@$(MAKE) -C $@
|
||||
@ -1420,7 +1420,7 @@ static void MakeCaptureStars(struct Sprite *sprite)
|
||||
LoadBallParticleGfx(BALL_MASTER);
|
||||
for (i = 0; i < ARRAY_COUNT(sCaptureStars); i++)
|
||||
{
|
||||
u8 spriteId = CreateSprite(&sBallParticleSpriteTemplates[4], sprite->pos1.x, sprite->pos1.y, subpriority);
|
||||
u8 spriteId = CreateSprite(&sBallParticleSpriteTemplates[BALL_MASTER], sprite->pos1.x, sprite->pos1.y, subpriority);
|
||||
if (spriteId != MAX_SPRITES)
|
||||
{
|
||||
gSprites[spriteId].sDuration = 24;
|
||||
|
||||
@ -1962,10 +1962,10 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
|
||||
|
||||
if (gTrainers[trainerNum].doubleBattle == TRUE)
|
||||
personalityValue = 0x80;
|
||||
else if (gTrainers[trainerNum].encounterMusic_gender & 0x80)
|
||||
personalityValue = 0x78;
|
||||
else if (gTrainers[trainerNum].encounterMusic_gender & F_TRAINER_FEMALE)
|
||||
personalityValue = 0x78; // Use personality more likely to result in a female Pokémon
|
||||
else
|
||||
personalityValue = 0x88;
|
||||
personalityValue = 0x88; // Use personality more likely to result in a male Pokémon
|
||||
|
||||
for (j = 0; gTrainers[trainerNum].trainerName[j] != EOS; j++)
|
||||
nameHash += gTrainers[trainerNum].trainerName[j];
|
||||
|
||||
@ -1328,7 +1328,7 @@ static const u8 sText_SpaceIs[] = _(" is");
|
||||
static const u8 sText_ApostropheS[] = _("'s");
|
||||
|
||||
// For displaying names of invalid moves
|
||||
static const u8 sATypeMove_Table[][NUMBER_OF_MON_TYPES - 1] =
|
||||
static const u8 sATypeMove_Table[NUMBER_OF_MON_TYPES][17] =
|
||||
{
|
||||
[TYPE_NORMAL] = _("a NORMAL move"),
|
||||
[TYPE_FIGHTING] = _("a FIGHTING move"),
|
||||
|
||||
@ -1053,7 +1053,7 @@ void Bike_HandleBumpySlopeJump(void)
|
||||
|
||||
bool32 IsRunningDisallowed(u8 metatile)
|
||||
{
|
||||
if (!(gMapHeader.flags & MAP_ALLOW_RUNNING) || IsRunningDisallowedByMetatile(metatile) == TRUE)
|
||||
if (!gMapHeader.allowRunning || IsRunningDisallowedByMetatile(metatile) == TRUE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
@ -258,6 +258,11 @@ enum {
|
||||
#define TAG_BLINK_EFFECT_CONTESTANT2 0x80EA
|
||||
#define TAG_BLINK_EFFECT_CONTESTANT3 0x80EB
|
||||
|
||||
#define TILE_FILLED_APPEAL_HEART 0x5012
|
||||
#define TILE_FILLED_JAM_HEART 0x5014
|
||||
#define TILE_EMPTY_APPEAL_HEART 0x5035
|
||||
#define TILE_EMPTY_JAM_HEART 0x5036
|
||||
|
||||
enum {
|
||||
SLIDER_HEART_ANIM_NORMAL,
|
||||
SLIDER_HEART_ANIM_DISAPPEAR,
|
||||
@ -3203,27 +3208,25 @@ static void PrintContestMoveDescription(u16 a)
|
||||
ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01);
|
||||
ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01);
|
||||
|
||||
// Appeal hearts
|
||||
if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF)
|
||||
numHearts = 0;
|
||||
else
|
||||
numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10;
|
||||
if (numHearts > 8)
|
||||
numHearts = 8;
|
||||
// Filled-in hearts
|
||||
ContestBG_FillBoxWithTile(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11);
|
||||
// Empty hearts
|
||||
ContestBG_FillBoxWithTile(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11);
|
||||
if (numHearts > MAX_CONTEST_MOVE_HEARTS)
|
||||
numHearts = MAX_CONTEST_MOVE_HEARTS;
|
||||
ContestBG_FillBoxWithTile(0, TILE_EMPTY_APPEAL_HEART, 0x15, 0x1f, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
|
||||
ContestBG_FillBoxWithTile(0, TILE_FILLED_APPEAL_HEART, 0x15, 0x1f, numHearts, 0x01, 0x11);
|
||||
|
||||
// Jam hearts
|
||||
if (gContestEffects[gContestMoves[a].effect].jam == 0xFF)
|
||||
numHearts = 0;
|
||||
else
|
||||
numHearts = gContestEffects[gContestMoves[a].effect].jam / 10;
|
||||
if (numHearts > 8)
|
||||
numHearts = 8;
|
||||
// Filled-in hearts
|
||||
ContestBG_FillBoxWithTile(0, 0x5036, 0x15, 0x20, 0x08, 0x01, 0x11);
|
||||
// Empty hearts
|
||||
ContestBG_FillBoxWithTile(0, 0x5014, 0x15, 0x20, numHearts, 0x01, 0x11);
|
||||
if (numHearts > MAX_CONTEST_MOVE_HEARTS)
|
||||
numHearts = MAX_CONTEST_MOVE_HEARTS;
|
||||
ContestBG_FillBoxWithTile(0, TILE_EMPTY_JAM_HEART, 0x15, 0x20, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
|
||||
ContestBG_FillBoxWithTile(0, TILE_FILLED_JAM_HEART, 0x15, 0x20, numHearts, 0x01, 0x11);
|
||||
|
||||
FillWindowPixelBuffer(WIN_MOVE_DESCRIPTION, PIXEL_FILL(0));
|
||||
Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, gContestEffectDescriptionPointers[gContestMoves[a].effect]);
|
||||
|
||||
@ -910,7 +910,7 @@ static void ItemUseOnFieldCB_EscapeRope(u8 taskId)
|
||||
|
||||
bool8 CanUseDigOrEscapeRopeOnCurMap(void)
|
||||
{
|
||||
if (gMapHeader.flags & MAP_ALLOW_ESCAPING)
|
||||
if (gMapHeader.allowEscaping)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
@ -965,7 +965,7 @@ static u16 GetCenterScreenMetatileBehavior(void)
|
||||
|
||||
bool32 Overworld_IsBikingAllowed(void)
|
||||
{
|
||||
if (!(gMapHeader.flags & MAP_ALLOW_CYCLING))
|
||||
if (!gMapHeader.allowCycling)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
@ -1690,7 +1690,7 @@ void CB2_ReturnToFieldFadeFromBlack(void)
|
||||
|
||||
static void FieldCB_FadeTryShowMapPopup(void)
|
||||
{
|
||||
if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE)
|
||||
if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE)
|
||||
ShowMapNamePopup();
|
||||
FieldCB_WarpExitFadeFromBlack();
|
||||
}
|
||||
@ -1936,7 +1936,7 @@ static bool32 LoadMapInStepsLocal(u8 *state, bool32 a2)
|
||||
(*state)++;
|
||||
break;
|
||||
case 11:
|
||||
if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE)
|
||||
if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE)
|
||||
ShowMapNamePopup();
|
||||
(*state)++;
|
||||
break;
|
||||
|
||||
@ -119,6 +119,11 @@ enum
|
||||
SPRITE_ARR_ID_COUNT = SPRITE_ARR_ID_MOVE_SELECTOR2 + MOVE_SELECTOR_SPRITES_COUNT
|
||||
};
|
||||
|
||||
#define TILE_EMPTY_APPEAL_HEART 0x1039
|
||||
#define TILE_FILLED_APPEAL_HEART 0x103A
|
||||
#define TILE_FILLED_JAM_HEART 0x103C
|
||||
#define TILE_EMPTY_JAM_HEART 0x103D
|
||||
|
||||
static EWRAM_DATA struct PokemonSummaryScreenData
|
||||
{
|
||||
/*0x00*/ union {
|
||||
@ -2645,29 +2650,30 @@ static void DrawContestMoveHearts(u16 move)
|
||||
|
||||
if (move != MOVE_NONE)
|
||||
{
|
||||
// Draw appeal hearts
|
||||
u8 effectValue = gContestEffects[gContestMoves[move].effect].appeal;
|
||||
if (effectValue != 0xFF)
|
||||
effectValue /= 10;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
for (i = 0; i < MAX_CONTEST_MOVE_HEARTS; i++)
|
||||
{
|
||||
if (effectValue != 0xFF && i < effectValue)
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = 0x103A;
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = TILE_FILLED_APPEAL_HEART;
|
||||
else
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = 0x1039;
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = TILE_EMPTY_APPEAL_HEART;
|
||||
}
|
||||
|
||||
// Draw jam hearts
|
||||
effectValue = gContestEffects[gContestMoves[move].effect].jam;
|
||||
|
||||
if (effectValue != 0xFF)
|
||||
effectValue /= 10;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
for (i = 0; i < MAX_CONTEST_MOVE_HEARTS; i++)
|
||||
{
|
||||
if (effectValue != 0xFF && i < effectValue)
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x226] = 0x103C;
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x226] = TILE_FILLED_JAM_HEART;
|
||||
else
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x226] = 0x103D;
|
||||
tilemap[(i / 4 * 32) + (i & 3) + 0x226] = TILE_EMPTY_JAM_HEART;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1007,7 +1007,7 @@ static void InitMapBasedOnPlayerLocation(void)
|
||||
break;
|
||||
case MAP_TYPE_UNDERGROUND:
|
||||
case MAP_TYPE_UNKNOWN:
|
||||
if (gMapHeader.flags & MAP_ALLOW_ESCAPING)
|
||||
if (gMapHeader.allowEscaping)
|
||||
{
|
||||
mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum);
|
||||
gRegionMap->mapSecId = mapHeader->regionMapSectionId;
|
||||
|
||||
@ -23,32 +23,59 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
#include "preproc.h"
|
||||
#include "c_file.h"
|
||||
#include "char_util.h"
|
||||
#include "utf8.h"
|
||||
#include "string_parser.h"
|
||||
|
||||
CFile::CFile(std::string filename) : m_filename(filename)
|
||||
CFile::CFile(const char * filenameCStr, bool isStdin)
|
||||
{
|
||||
FILE *fp = std::fopen(filename.c_str(), "rb");
|
||||
FILE *fp;
|
||||
|
||||
if (isStdin) {
|
||||
fp = stdin;
|
||||
m_filename = std::string{"<stdin>/"}.append(filenameCStr);
|
||||
} else {
|
||||
fp = std::fopen(filenameCStr, "rb");
|
||||
m_filename = std::string(filenameCStr);
|
||||
}
|
||||
|
||||
std::string& filename = m_filename;
|
||||
|
||||
if (fp == NULL)
|
||||
FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
|
||||
|
||||
std::fseek(fp, 0, SEEK_END);
|
||||
m_size = 0;
|
||||
m_buffer = (char *)malloc(CHUNK_SIZE + 1);
|
||||
if (m_buffer == NULL) {
|
||||
FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename.c_str());
|
||||
}
|
||||
|
||||
m_size = std::ftell(fp);
|
||||
std::size_t numAllocatedBytes = CHUNK_SIZE + 1;
|
||||
std::size_t bufferOffset = 0;
|
||||
std::size_t count;
|
||||
|
||||
if (m_size < 0)
|
||||
FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
|
||||
while ((count = std::fread(m_buffer + bufferOffset, 1, CHUNK_SIZE, fp)) != 0) {
|
||||
if (!std::ferror(fp)) {
|
||||
m_size += count;
|
||||
|
||||
m_buffer = new char[m_size + 1];
|
||||
if (std::feof(fp)) {
|
||||
break;
|
||||
}
|
||||
|
||||
std::rewind(fp);
|
||||
|
||||
if (std::fread(m_buffer, m_size, 1, fp) != 1)
|
||||
FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
|
||||
numAllocatedBytes += CHUNK_SIZE;
|
||||
bufferOffset += CHUNK_SIZE;
|
||||
m_buffer = (char *)realloc(m_buffer, numAllocatedBytes);
|
||||
if (m_buffer == NULL) {
|
||||
FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename.c_str());
|
||||
}
|
||||
} else {
|
||||
FATAL_ERROR("Failed to read \"%s\". (error: %s)", filename.c_str(), std::strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
m_buffer[m_size] = 0;
|
||||
|
||||
@ -56,6 +83,7 @@ CFile::CFile(std::string filename) : m_filename(filename)
|
||||
|
||||
m_pos = 0;
|
||||
m_lineNum = 1;
|
||||
m_isStdin = isStdin;
|
||||
}
|
||||
|
||||
CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
|
||||
@ -64,13 +92,14 @@ CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
|
||||
m_pos = other.m_pos;
|
||||
m_size = other.m_size;
|
||||
m_lineNum = other.m_lineNum;
|
||||
m_isStdin = other.m_isStdin;
|
||||
|
||||
other.m_buffer = nullptr;
|
||||
other.m_buffer = NULL;
|
||||
}
|
||||
|
||||
CFile::~CFile()
|
||||
{
|
||||
delete[] m_buffer;
|
||||
free(m_buffer);
|
||||
}
|
||||
|
||||
void CFile::Preproc()
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
class CFile
|
||||
{
|
||||
public:
|
||||
CFile(std::string filename);
|
||||
CFile(const char * filenameCStr, bool isStdin);
|
||||
CFile(CFile&& other);
|
||||
CFile(const CFile&) = delete;
|
||||
~CFile();
|
||||
@ -42,6 +42,7 @@ private:
|
||||
long m_size;
|
||||
long m_lineNum;
|
||||
std::string m_filename;
|
||||
bool m_isStdin;
|
||||
|
||||
bool ConsumeHorizontalWhitespace();
|
||||
bool ConsumeNewline();
|
||||
@ -55,4 +56,6 @@ private:
|
||||
void RaiseWarning(const char* format, ...);
|
||||
};
|
||||
|
||||
#define CHUNK_SIZE 4096
|
||||
|
||||
#endif // C_FILE_H
|
||||
|
||||
@ -103,9 +103,9 @@ void PreprocAsmFile(std::string filename)
|
||||
}
|
||||
}
|
||||
|
||||
void PreprocCFile(std::string filename)
|
||||
void PreprocCFile(const char * filename, bool isStdin)
|
||||
{
|
||||
CFile cFile(filename);
|
||||
CFile cFile(filename, isStdin);
|
||||
cFile.Preproc();
|
||||
}
|
||||
|
||||
@ -132,9 +132,9 @@ char* GetFileExtension(char* filename)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 3)
|
||||
if (argc < 3 || argc > 4)
|
||||
{
|
||||
std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
|
||||
std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -147,9 +147,17 @@ int main(int argc, char **argv)
|
||||
|
||||
if ((extension[0] == 's') && extension[1] == 0)
|
||||
PreprocAsmFile(argv[1]);
|
||||
else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
|
||||
PreprocCFile(argv[1]);
|
||||
else
|
||||
else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0) {
|
||||
if (argc == 4) {
|
||||
if (argv[3][0] == '-' && argv[3][1] == 'i' && argv[3][2] == '\0') {
|
||||
PreprocCFile(argv[1], true);
|
||||
} else {
|
||||
FATAL_ERROR("unknown argument flag \"%s\".\n", argv[3]);
|
||||
}
|
||||
} else {
|
||||
PreprocCFile(argv[1], false);
|
||||
}
|
||||
} else
|
||||
FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
|
||||
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user