Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ GFX_PRECMP_DIR = 'precompressed/gfx_compressible'
OBJS = $(BUILD_DIR)/$(GAME).o $(BUILD_DIR)/audio.o


# All .bin/.png gfx files and paths. Include _jp variants when building JP.
# All .bin/.png gfx files and paths. Include _<region> variants when building JP/EU.
GFX_UNCMP_PATHS = $(GFX_UNCMP_DIR)/common $(GFX_UNCMP_DIR)/$(GAME)
GFX_CMP_PATHS = $(GFX_CMP_DIR)/common $(GFX_CMP_DIR)/$(GAME)
GFX_PRECMP_PATHS = $(GFX_PRECMP_DIR)/common $(GFX_PRECMP_DIR)/$(GAME)

ifeq ($(REGION), jp)
GFX_UNCMP_PATHS += $(GFX_UNCMP_DIR)/common_jp $(GFX_UNCMP_DIR)/$(GAME)_jp
GFX_CMP_PATHS += $(GFX_CMP_DIR)/common_jp $(GFX_CMP_DIR)/$(GAME)_jp
GFX_PRECMP_PATHS += $(GFX_PRECMP_DIR)/common_jp $(GFX_PRECMP_DIR)/$(GAME)_jp
ifneq ($(filter jp eu,$(REGION)),)
REGION_SUFFIX = _$(REGION)
GFX_UNCMP_PATHS += $(GFX_UNCMP_DIR)/common$(REGION_SUFFIX) $(GFX_UNCMP_DIR)/$(GAME)$(REGION_SUFFIX)
GFX_CMP_PATHS += $(GFX_CMP_DIR)/common$(REGION_SUFFIX) $(GFX_CMP_DIR)/$(GAME)$(REGION_SUFFIX)
GFX_PRECMP_PATHS += $(GFX_PRECMP_DIR)/common$(REGION_SUFFIX) $(GFX_PRECMP_DIR)/$(GAME)$(REGION_SUFFIX)
endif

# All .bin gfx files
Expand Down Expand Up @@ -195,9 +196,9 @@ endif
ROOMLAYOUTFILES = $(wildcard rooms/$(GAME)/small/*.bin)
ROOMLAYOUTFILES += $(wildcard rooms/$(GAME)/large/*.bin)

ifeq ($(REGION), jp)
ROOMLAYOUTFILES += $(wildcard rooms/$(GAME)_jp/small/*.bin)
ROOMLAYOUTFILES += $(wildcard rooms/$(GAME)_jp/large/*.bin)
ifneq ($(filter jp eu,$(REGION)),)
ROOMLAYOUTFILES += $(wildcard rooms/$(GAME)$(REGION_SUFFIX)/small/*.bin)
ROOMLAYOUTFILES += $(wildcard rooms/$(GAME)$(REGION_SUFFIX)/large/*.bin)
endif

ROOMLAYOUTFILES := $(ROOMLAYOUTFILES:.bin=.cmp)
Expand All @@ -206,8 +207,8 @@ ROOMLAYOUTFILES := $(foreach file, $(ROOMLAYOUTFILES), \

COLLISIONFILES = $(wildcard tileset_layouts/$(GAME)/tilesetCollisions*.bin)

ifeq ($(REGION), jp)
COLLISIONFILES += $(wildcard tileset_layouts/$(GAME)_jp/tilesetCollisions*.bin)
ifneq ($(filter jp eu,$(REGION)),)
COLLISIONFILES += $(wildcard tileset_layouts/$(GAME)$(REGION_SUFFIX)/tilesetCollisions*.bin)
endif

COLLISIONFILES := $(COLLISIONFILES:.bin=.cmp)
Expand All @@ -216,8 +217,8 @@ COLLISIONFILES := $(foreach file, $(COLLISIONFILES), \

MAPPINGINDICESFILES = $(wildcard tileset_layouts/$(GAME)/tilesetMappings*.bin)

ifeq ($(REGION), jp)
MAPPINGINDICESFILES += $(wildcard tileset_layouts/$(GAME)_jp/tilesetMappings*.bin)
ifneq ($(filter jp eu,$(REGION)),)
MAPPINGINDICESFILES += $(wildcard tileset_layouts/$(GAME)$(REGION_SUFFIX)/tilesetMappings*.bin)
endif
MAPPINGINDICESFILES := $(foreach file, $(MAPPINGINDICESFILES), \
$(BUILD_DIR)/tileset_layouts/$(notdir $(file)))
Expand Down Expand Up @@ -277,8 +278,8 @@ $(BUILD_DIR)/$(GAME).o: $(GAME).s $(TEXT_DATA_FILE) $(BUILD_DIR)/textDefines.s M
$(BUILD_DIR)/%.o: code/%.s | $(BUILD_DIR)
$(CC) -o $@ $(CFLAGS) $<

ifeq ($(REGION), jp)
$(BUILD_DIR)/rooms/%.cmp: rooms/$(GAME)_jp/small/%.bin | $(BUILD_DIR)/rooms
ifneq ($(filter jp eu,$(REGION)),)
$(BUILD_DIR)/rooms/%.cmp: rooms/$(GAME)$(REGION_SUFFIX)/small/%.bin | $(BUILD_DIR)/rooms
@echo "Compressing $< to $@..."
@$(PYTHON) tools/build/compressRoomLayout.py $< $@ $(OPTIMIZE)
endif
Expand Down Expand Up @@ -352,18 +353,18 @@ endif
ifeq ($(BUILD_VANILLA),true)

# Precompressed copy rules for vanilla builds.
# For JP, game_jp source rules are listed first to take priority over the
# For JP/EU, game_<region> source rules are listed first to take priority over the
# generic game rules (which serve as fallback for shared files).
define define_precmp_copy_rule
$(BUILD_DIR)/$(1)/%.$(2): precompressed/$(1)/$(3)/%.$(2) | $(BUILD_DIR)/$(1)
@echo "Copying $$< to $$@..."
@cp $$< $$@
endef

ifeq ($(REGION), jp)
$(eval $(call define_precmp_copy_rule,tileset_layouts,bin,$(GAME)_jp))
$(eval $(call define_precmp_copy_rule,tileset_layouts,cmp,$(GAME)_jp))
$(eval $(call define_precmp_copy_rule,rooms,cmp,$(GAME)_jp))
ifneq ($(filter jp eu,$(REGION)),)
$(eval $(call define_precmp_copy_rule,tileset_layouts,bin,$(GAME)$(REGION_SUFFIX)))
$(eval $(call define_precmp_copy_rule,tileset_layouts,cmp,$(GAME)$(REGION_SUFFIX)))
$(eval $(call define_precmp_copy_rule,rooms,cmp,$(GAME)$(REGION_SUFFIX)))
endif

$(eval $(call define_precmp_copy_rule,tileset_layouts,bin,$(GAME)))
Expand Down Expand Up @@ -406,10 +407,10 @@ $(BUILD_DIR)/tileset_layouts/tilesetCollisions%.cmp: tileset_layouts/$(GAME)/til
@$(PYTHON) tools/build/compressTilesetLayoutData.py $< $@ 0 $(BUILD_DIR)/tileset_layouts/collisionsDictionary.bin

# Generate large room compression rules for each group prefix (04, 05, 06).
# For JP, the _jp source directory rules are listed first to take priority.
# For JP/EU, the _<region> source directory rules are listed first to take priority.
define define_large_room_rules
ifeq ($(REGION), jp)
$(BUILD_DIR)/rooms/room$(1)%.cmp: rooms/$(GAME)_jp/large/room$(1)%.bin | $(BUILD_DIR)/rooms
ifneq ($(filter jp eu,$(REGION)),)
$(BUILD_DIR)/rooms/room$(1)%.cmp: rooms/$(GAME)$(REGION_SUFFIX)/large/room$(1)%.bin | $(BUILD_DIR)/rooms
@echo "Compressing $$< to $$@..."
@$$(PYTHON) tools/build/compressRoomLayout.py $$< $$@ -d rooms/$(GAME)/dictionary$(2).bin
endif
Expand Down
94 changes: 89 additions & 5 deletions code/bank0.s
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,13 @@ bitTable:

.ifdef REGION_JP
.ASC "AZ7J"
.else
.endif
.ifdef REGION_US
.asc "AZ7E"
.endif
.ifdef REGION_EU
.asc "AZ7P"
.endif
.else ; ROM_AGES
.asc "ZELDA NAYRU"

Expand Down Expand Up @@ -1256,21 +1260,54 @@ loadGfxHeader:
ldh a,(<hRomBank)
ld b,a
push bc
.ifndef REGION_EU
ld a,:bank1Moveable.gfxHeaderTable
.else
ld a,:gfxHeaderTable
.endif
setrombank
ld a,e
.ifndef REGION_EU
ld hl,bank1Moveable.gfxHeaderTable
.else
ld hl,gfxHeaderTable
.endif
rst_addDoubleIndex
ldi a,(hl)
ld h,(hl)
ld l,a
--
ldi a,(hl)

.ifdef REGION_EU
or a
jr nz,++
ld a,(wActiveLanguage)
ld c,a
add a,a
add a,c
ld c,a
rst_addAToHl
ld a,$0c
sub c
ld b,a
ldi a,(hl)
ld c,a
ldi a,(hl)
ld d,a
ldi a,(hl)
ld e,a
ld a,b
rst_addAToHl
jr +
.endif
++
ld c,a
ldi a,(hl)
ld d,a
ldi a,(hl)
ld e,a
+
push de
ldi a,(hl)
ld d,a
Expand All @@ -1285,7 +1322,11 @@ loadGfxHeader:
ldh (<hFF91),a
pop hl
call decompressGraphics
.ifndef REGION_EU
ld a,:bank1Moveable.gfxHeaderTable
.else
ld a,:gfxHeaderTable
.endif
setrombank
ldh a,(<hFF90)
ld l,a
Expand Down Expand Up @@ -1550,18 +1591,30 @@ loadTileset:
ld b,a
push bc

.ifndef REGION_EU
ld a,:bank1Moveable.tilesetLayoutTable
.else
ld a,:tilesetLayoutTable
.endif
setrombank
ld a,e
.ifndef REGION_EU
ld hl,bank1Moveable.tilesetLayoutTable
.else
ld hl,tilesetLayoutTable
.endif
rst_addDoubleIndex
ldi a,(hl)
ld h,(hl)
ld l,a
--
ldi a,(hl)
push hl
.ifndef REGION_EU
ld hl,bank1Moveable.tilesetLayoutDictionaryTable
.else
ld hl,tilesetLayoutDictionaryTable
.endif
rst_addDoubleIndex
ldi a,(hl)
ld h,(hl)
Expand Down Expand Up @@ -1608,7 +1661,11 @@ loadTileset:
pop hl
call loadTilesetHlpr

.ifndef REGION_EU
ld a,:bank1Moveable.tilesetLayoutTable
.else
ld a, :tilesetLayoutTable
.endif
setrombank

; Retrieve header position
Expand Down Expand Up @@ -2032,26 +2089,26 @@ flagLocationGroupTable:
; @param hActiveFileSlot File index
initializeFile:
ld c,$00
jr ++
jr runFileOp

;;
; @param hActiveFileSlot File index
saveFile:
ld c,$01
jr ++
jr runFileOp

;;
; @param hActiveFileSlot File index
loadFile:
ld c,$02
jr ++
jr runFileOp

;;
; @param hActiveFileSlot File index
eraseFile:
ld c,$03

++
runFileOp:
ldh a,(<hRomBank)
push af
callfrombank0 fileManagement.fileManagementFunction
Expand All @@ -2061,6 +2118,15 @@ eraseFile:
ld a,c
ret

.ifdef REGION_EU
ld b,a
ld c,$04
jr runFileOp

ld c,$05
jr runFileOp
.endif

;;
vblankInterrupt:
ldh a,(<hNextLcdInterruptBehaviour)
Expand Down Expand Up @@ -5378,19 +5444,37 @@ readByteFromW7TextTableBank:
ldh a,(<hRomBank)
push af

.ifdef REGION_EU
ld a,b
jr $06
ldh a,($97)
push af
.endif

.ifdef REGION_JP
ld a,:textTableJP
.else
ld a,(w7TextTableBank)
.endif

.ifdef REGION_EU
ld b,a
.endif

bit 7,h
jr z,+

res 7,h
set 6,h

.ifndef REGION_EU
inc a
+
.else
inc b
+
ld a,b
.endif
setrombank
ldi a,(hl)
ldh (<hFF8B),a
Expand Down
8 changes: 8 additions & 0 deletions code/bank1.s
Original file line number Diff line number Diff line change
Expand Up @@ -3963,6 +3963,12 @@ func_5cfe:
inc l
xor a
ld (hl),a

; TODO : EU alignment
.ifdef REGION_EU
.db 0 0 0 0 0 0
.endif

jr @end
.endif

Expand Down Expand Up @@ -5346,8 +5352,10 @@ m_section_superfree Bank_1_Data_2 NAMESPACE bank1Moveable

.include {"{GAME_DATA_DIR}/paletteHeaders.s"}
.include {"{GAME_DATA_DIR}/uncmpGfxHeaders.s"}
.ifndef REGION_EU
.include {"{GAME_DATA_DIR}/gfxHeaders.s"}
.include {"{GAME_DATA_DIR}/tilesetHeaders.s"}
.endif

.ends

Expand Down
Loading