Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F3DEX3 implementation [WIP, Help needed] #280

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ WINDOWS_AUTO_BUILDER ?= 0
# Setup extra cflags
EXTRA_CFLAGS ?=
EXTRA_CPP_FLAGS ?=
EXTRA_CFLAGS += -Wno-format-security -Wno-trigraphs
EXTRA_CFLAGS += -Wno-missing-braces -Wno-format-security -Wno-trigraphs

dev:; @$(MAKE) DEVELOPMENT=1

Expand Down Expand Up @@ -188,7 +188,7 @@ VERSION ?= us
$(eval $(call validate-option,VERSION,us))

# Graphics microcode used
GRUCODE ?= f3dex2e
GRUCODE ?= f3dex3

ifeq ($(VERSION),jp)
DEFINES += VERSION_JP=1
Expand All @@ -208,6 +208,9 @@ else ifeq ($(VERSION),sh)
VERSION_JP_US ?= false
endif

# FIXLIGHTS - converts light objects to light color commands for assets, needed for vanilla-style lighting
FIXLIGHTS ?= 0

# Determine our optimization level.
# Optimization Levels 0 through 5 optimize for speed,
# While optimization levels 6, and 7 optimize for size.
Expand Down Expand Up @@ -323,7 +326,8 @@ TARGET := sm64.$(VERSION)
# f3dex2 -
# f3dex2e - default for PC Port
# f3dzex - newer, experimental microcode used in Animal Crossing
$(eval $(call validate-option,GRUCODE,f3d_old f3dex f3dex2 f3dex2e f3d_new f3dzex))
# f3dex3 - even newer, f3dex2 modification by Sauraen, public domain
$(eval $(call validate-option,GRUCODE,f3d_old f3dex f3dex2 f3dex2e f3d_new f3dzex f3dex3))

ifeq ($(GRUCODE),f3d_old)
DEFINES += F3D_OLD=1
Expand All @@ -335,9 +339,12 @@ else ifeq ($(GRUCODE), f3dex2) # Fast3DEX2
DEFINES += F3DEX_GBI_2=1 F3DEX_GBI_SHARED=1
else ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default)
DEFINES += F3DEX_GBI_2E=1 F3DEX_GBI_SHARED=1
else ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
else ifeq ($(GRUCODE), f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
$(warning Fast3DZEX is experimental. Try at your own risk.)
DEFINES += F3DZEX_GBI_2=1 F3DEX_GBI_2=1 F3DEX_GBI_SHARED=1
else ifeq ($(GRUCODE), f3dex3) # Fast3DEX3
$(warning Fast3DEX3 is experimental. Try at your own risk.)
DEFINES += F3DEX_GBI_3=1 F3DEX_GBI_SHARED=1
endif

# Check for certain target types.
Expand Down Expand Up @@ -1087,6 +1094,7 @@ AIFF_EXTRACT_CODEBOOK := $(TOOLS_DIR)/aiff_extract_codebook
VADPCM_ENC := $(TOOLS_DIR)/vadpcm_enc
EXTRACT_DATA_FOR_MIO := $(TOOLS_DIR)/extract_data_for_mio
SKYCONV := $(TOOLS_DIR)/skyconv
FIXLIGHTS_PY := $(TOOLS_DIR)/fixlights.py

# Use the system installed armips if available. Otherwise use the one provided with this repository.
ifneq (,$(call find-command,armips))
Expand Down Expand Up @@ -1399,6 +1407,14 @@ $(BUILD_DIR)/%.o: %.cpp
$(V)$(CXX) $(PROF_FLAGS) -c $(EXTRA_CPP_FLAGS) $(EXTRA_CPP_INCLUDES) $(CFLAGS) -o $@ $<

# Compile C code
ifeq ($(FIXLIGHTS),1)
# This must not be run multiple times at once, so we run it ahead of time rather than in a rule
#DUMMY != $(FIXLIGHTS_PY) actors
# Modify the leveldata build rule to fix lights for any files in that level's folder
$(BUILD_DIR)/levels/%/leveldata.o: levels/%/leveldata.c
$(V)$(FIXLIGHTS_PY) $(dir $<)
$(V)$(CC) -c $(CFLAGS) -MMD -MF $(BUILD_DIR)/$*.d -o $@ $<
endif
$(BUILD_DIR)/%.o: %.c
$(call print,Compiling:,$<,$@)
$(V)$(CC_CHECK) $(PROF_FLAGS) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
Expand Down
2 changes: 1 addition & 1 deletion actors/amp/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const Gfx amp_seg8_dl_08002E58[] = {
// 0x08002EC8
static const Lights1 amp_seg8_lights_08002EC8 = gdSPDefLights1(
0x33, 0x3f, 0x00,
0xcf, 0xff, 0x00, 0x28, 0x28, 0x28
0xcf, 0xff, 0x00, 0x49, 0x49, 0x49
);

// //! Another malformed entry: Vertex interpreted as light
Expand Down
6 changes: 3 additions & 3 deletions actors/bird/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
// 0x05000000
static const Lights1 birds_seg5_lights_05000000 = gdSPDefLights1(
0x07, 0x24, 0x2c,
0x1d, 0x91, 0xb0, 0x28, 0x28, 0x28
0x1d, 0x91, 0xb0, 0x49, 0x49, 0x49
);

// 0x05000018
static const Lights1 birds_seg5_lights_05000018 = gdSPDefLights1(
0x33, 0x27, 0x0d,
0xce, 0x9d, 0x34, 0x28, 0x28, 0x28
0xce, 0x9d, 0x34, 0x49, 0x49, 0x49
);

// 0x05000030
static const Lights1 birds_seg5_lights_05000030 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05000048
Expand Down
10 changes: 5 additions & 5 deletions actors/blargg/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
// Unreferenced light group
UNUSED static const Lights1 blargg_lights_unused = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05004740
static const Lights1 blargg_seg5_lights_05004740 = gdSPDefLights1(
0x3f, 0x0d, 0x05,
0xff, 0x36, 0x16, 0x28, 0x28, 0x28
0xff, 0x36, 0x16, 0x49, 0x49, 0x49
);

// 0x05004758
static const Lights1 blargg_seg5_lights_05004758 = gdSPDefLights1(
0x2c, 0x2c, 0x2c,
0xb2, 0xb2, 0xb2, 0x28, 0x28, 0x28
0xb2, 0xb2, 0xb2, 0x49, 0x49, 0x49
);

// 0x05004770
static const Lights1 blargg_seg5_lights_05004770 = gdSPDefLights1(
0x3f, 0x0a, 0x06,
0xff, 0x2a, 0x1a, 0x28, 0x28, 0x28
0xff, 0x2a, 0x1a, 0x49, 0x49, 0x49
);

// 0x05004788
static const Lights1 blargg_seg5_lights_05004788 = gdSPDefLights1(
0x3f, 0x0b, 0x07,
0xff, 0x2e, 0x1f, 0x28, 0x28, 0x28
0xff, 0x2e, 0x1f, 0x49, 0x49, 0x49
);

// 0x050047A0
Expand Down
2 changes: 1 addition & 1 deletion actors/blue_coin_switch/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 0x08000000
static const Lights1 blue_coin_switch_seg8_lights_08000000 = gdSPDefLights1(
0x7f, 0x7f, 0x7f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x08000018
Expand Down
2 changes: 1 addition & 1 deletion actors/blue_fish/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 0x0301B5C8
static const Lights1 blue_fish_seg3_lights_0301B5C8 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x0301B5E0
Expand Down
6 changes: 3 additions & 3 deletions actors/bobomb/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@ const Gfx bobomb_seg8_dl_08022D78[] = {
// 0x08022DE8
static const Lights1 bobomb_seg8_lights_08022DE8 = gdSPDefLights1(
0x3f, 0x26, 0x04,
0xff, 0x99, 0x12, 0x28, 0x28, 0x28
0xff, 0x99, 0x12, 0x49, 0x49, 0x49
);

// 0x08022E00
static const Lights1 bobomb_seg8_lights_08022E00 = gdSPDefLights1(
0x2c, 0x2c, 0x2c,
0xb2, 0xb2, 0xb2, 0x28, 0x28, 0x28
0xb2, 0xb2, 0xb2, 0x49, 0x49, 0x49
);

// Unreferenced light group
static const Lights1 bobomb_lights_unused = gdSPDefLights1(
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x28, 0x28, 0x28
0x00, 0x00, 0x00, 0x49, 0x49, 0x49
);

// 0x08022E30
Expand Down
2 changes: 1 addition & 1 deletion actors/bomb/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 0x06057AA8
static const Lights1 bomb_seg6_lights_06057AA8 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x06057AC0
Expand Down
2 changes: 1 addition & 1 deletion actors/boo/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 0x05009B28
static const Lights1 boo_seg5_lights_05009B28 = gdSPDefLights1(
0x97, 0x9a, 0xff,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05009B40
Expand Down
2 changes: 1 addition & 1 deletion actors/boo_castle/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 0x06015658
static const Lights1 boo_castle_seg6_lights_06015658 = gdSPDefLights1(
0x97, 0x9a, 0xff,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x06015670
Expand Down
2 changes: 1 addition & 1 deletion actors/book/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// 0x05002558
static const Lights1 book_seg5_lights_05002558 = gdSPDefLights1(
0x7f, 0x7f, 0x7f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05002570
Expand Down
20 changes: 10 additions & 10 deletions actors/bookend/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
// Unreferenced light group
UNUSED static const Lights1 bookend_lights_unused1 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// Unreferenced light group
UNUSED static const Lights1 bookend_lights_unused2 = gdSPDefLights1(
0x03, 0x19, 0x09,
0x0c, 0x66, 0x26, 0x28, 0x28, 0x28
0x0c, 0x66, 0x26, 0x49, 0x49, 0x49
);

// Unreferenced light group
UNUSED static const Lights1 bookend_lights_unused3 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// Unreferenced light group
UNUSED static const Lights1 bookend_lights_unused4 = gdSPDefLights1(
0x3f, 0x00, 0x00,
0xff, 0x00, 0x00, 0x28, 0x28, 0x28
0xff, 0x00, 0x00, 0x49, 0x49, 0x49
);

// 0x05000060
Expand All @@ -43,7 +43,7 @@ ROM_ASSET_LOAD_TEXTURE(bookend_seg5_texture_05001060, "actors/bookend/bookend_co
// 0x05001860
static const Lights1 bookend_seg5_lights_05001860 = gdSPDefLights1(
0x66, 0x66, 0x66,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05001878
Expand Down Expand Up @@ -99,7 +99,7 @@ const Gfx bookend_seg5_dl_05001978[] = {
// 0x05001A08
static const Lights1 bookend_seg5_lights_05001A08 = gdSPDefLights1(
0x66, 0x66, 0x66,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05001A20
Expand Down Expand Up @@ -155,7 +155,7 @@ const Gfx bookend_seg5_dl_05001B20[] = {
// 0x05001BB0
static const Lights1 bookend_seg5_lights_05001BB0 = gdSPDefLights1(
0x66, 0x66, 0x66,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05001BC8
Expand Down Expand Up @@ -210,7 +210,7 @@ const Gfx bookend_seg5_dl_05001D68[] = {
// 0x05001DE0
static const Lights1 bookend_seg5_lights_05001DE0 = gdSPDefLights1(
0x66, 0x66, 0x66,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05001DF8
Expand Down Expand Up @@ -265,7 +265,7 @@ const Gfx bookend_seg5_dl_05001F98[] = {
// 0x05002010
static const Lights1 bookend_seg5_lights_05002010 = gdSPDefLights1(
0x66, 0x66, 0x66,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x05002028
Expand Down Expand Up @@ -305,7 +305,7 @@ const Gfx bookend_seg5_dl_05002140[] = {
// 0x050021B0
static const Lights1 bookend_seg5_lights_050021B0 = gdSPDefLights1(
0x66, 0x66, 0x66,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x050021C8
Expand Down
6 changes: 3 additions & 3 deletions actors/bowser/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ ROM_ASSET_LOAD_TEXTURE(bowser_seg6_texture_06037C38, "actors/bowser/bowser_eye_f
// 0x06038C38
static const Lights1 bowser_seg6_lights_06038C38 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// Unreferenced light group
UNUSED static const Lights1 bowser_lights_unused1 = gdSPDefLights1(
0x33, 0x31, 0x00,
0xce, 0xc7, 0x00, 0x28, 0x28, 0x28
0xce, 0xc7, 0x00, 0x49, 0x49, 0x49
);

// Unreferenced light group
UNUSED static const Lights1 bowser_lights_unused2 = gdSPDefLights1(
0x34, 0x34, 0x00,
0xd2, 0xd2, 0x00, 0x28, 0x28, 0x28
0xd2, 0xd2, 0x00, 0x49, 0x49, 0x49
);

// 0x06038C80
Expand Down
2 changes: 1 addition & 1 deletion actors/bowser_key/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 0x030156E0, ambient color brown - light color orange
static const Lights1 bowser_key_lights = gdSPDefLights1(
0x3f, 0x2c, 0x00,
0xff, 0xb2, 0x00, 0x28, 0x28, 0x28
0xff, 0xb2, 0x00, 0x49, 0x49, 0x49
);

ALIGNED8 const Texture bowser_key_left_texture[] = {
Expand Down
2 changes: 1 addition & 1 deletion actors/breakable_box/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 0x08011A78
static const Lights1 breakable_box_seg8_lights_08011A80 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x08011A90
Expand Down
4 changes: 2 additions & 2 deletions actors/bub/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
// 0x0600E278
static const Lights1 bub_seg6_lights_0600E280 = gdSPDefLights1(
0x3f, 0x3f, 0x3f,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
0xff, 0xff, 0xff, 0x49, 0x49, 0x49
);

// 0x0600E290
static const Lights1 bub_seg6_lights_0600E290 = gdSPDefLights1(
0x3f, 0x1d, 0x25,
0xff, 0x75, 0x94, 0x28, 0x28, 0x28
0xff, 0x75, 0x94, 0x49, 0x49, 0x49
);

// 0x0600E2A8
Expand Down
Loading