Skip to content

Commit

Permalink
v5 Animations!
Browse files Browse the repository at this point in the history
  • Loading branch information
Mori-TM committed Oct 30, 2022
1 parent 82f0432 commit 7415e29
Show file tree
Hide file tree
Showing 99 changed files with 60,050 additions and 0 deletions.
224 changes: 224 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif

include $(DEVKITARM)/ds_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files embedded using bin2o
# GRAPHICS is a list of directories containing image files to be converted with grit
# AUDIO is a list of directories containing audio to be converted by maxmod
# ICON is the image used to create the game icon, leave blank to use default rule
# NITRO is a directory that will be accessible via NitroFS
#---------------------------------------------------------------------------------
TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source
INCLUDES := include
DATA := data
GRAPHICS := gfx
AUDIO := audio
ICON :=

# specify a directory which contains the nitro filesystem
# this is relative to the Makefile
NITRO :=

#---------------------------------------------------------------------------------
# options for code generation
# -Wregister -Wattributes
#---------------------------------------------------------------------------------
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
#-S -fverbose-asm -Wall -O3
CFLAGS := -g -Wall -O3 -w\
-fomit-frame-pointer\
-ffast-math\
$(ARCH) $(INCLUDE) -DARM9
CXXFLAGS := $(CFLAGS)-fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project (order is important)
#---------------------------------------------------------------------------------
LIBS := -lnds9

# automatigically add libraries for NitroFS
ifneq ($(strip $(NITRO)),)
LIBS := -lfilesystem -lfat $(LIBS)
endif
# automagically add maxmod library
ifneq ($(strip $(AUDIO)),)
LIBS := -lmm9 $(LIBS)
endif

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS) $(PORTLIBS)

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT := $(CURDIR)/$(TARGET)

export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))

export DEPSDIR := $(CURDIR)/$(BUILD)

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

# prepare NitroFS directory
ifneq ($(strip $(NITRO)),)
export NITRO_FILES := $(CURDIR)/$(NITRO)
endif

# get audio list for maxmod
ifneq ($(strip $(AUDIO)),)
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))

# place the soundbank file in NitroFS if using it
ifneq ($(strip $(NITRO)),)
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin

# otherwise, needs to be loaded from memory
else
export SOUNDBANK := soundbank.bin
BINFILES += $(SOUNDBANK)
endif
endif

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES_BIN := $(addsuffix .o,$(BINFILES))

export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))

export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

ifeq ($(strip $(ICON)),)
icons := $(wildcard *.bmp)

ifneq (,$(findstring $(TARGET).bmp,$(icons)))
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
else
ifneq (,$(findstring icon.bmp,$(icons)))
export GAME_ICON := $(CURDIR)/icon.bmp
endif
endif
else
ifeq ($(suffix $(ICON)), .grf)
export GAME_ICON := $(CURDIR)/$(ICON)
else
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
endif
endif

.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
@mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)

#---------------------------------------------------------------------------------
else

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
$(OUTPUT).elf: $(OFILES)

# source files depend on generated headers
$(OFILES_SOURCES) : $(HFILES)

# need to build soundbank first
$(OFILES): $(SOUNDBANK)

#---------------------------------------------------------------------------------
# rule to build solution from music files
#---------------------------------------------------------------------------------
$(SOUNDBANK) : $(MODFILES)
#---------------------------------------------------------------------------------
mmutil $^ -d -o$@ -hsoundbank.h

#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)

#---------------------------------------------------------------------------------
%.pcx.o %_pcx.h : %.pcx
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)

#---------------------------------------------------------------------------------
# This rule creates assembly source files using grit
# grit takes an image file and a .grit describing how the file is to be processed
# add additional rules like this for each image extension
# you use in the graphics folders
#---------------------------------------------------------------------------------
%.s %.h: %.png all.grit
#---------------------------------------------------------------------------------
grit $< -fts -o$*

#---------------------------------------------------------------------------------
# Convert non-GRF game icon to GRF if needed
#---------------------------------------------------------------------------------
$(GAME_ICON): $(notdir $(ICON))
#---------------------------------------------------------------------------------
@echo convert $(notdir $<)
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr

-include $(DEPSDIR)/*.d

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
Binary file added OOT_v5.nds
Binary file not shown.
Binary file added audio/Zelda.mod
Binary file not shown.
Binary file added data/Earth.pcx
Binary file not shown.
Binary file added data/Link.bin
Binary file not shown.
Binary file added data/LinkTex.pcx
Binary file not shown.
Binary file added data/Tex196C0925_c.pcx
Binary file not shown.
Binary file added data/Tex1E3F706A_c.pcx
Binary file not shown.
Binary file added data/Tex212D3C4E_c.pcx
Binary file not shown.
Binary file added data/Tex26D56437_c.pcx
Binary file not shown.
Binary file added data/Tex2C312C37_c.pcx
Binary file not shown.
Binary file added data/Tex2CCE0C4A_c.pcx
Binary file not shown.
Binary file added data/Tex3024F421_c.pcx
Binary file not shown.
Binary file added data/Tex3718093C_c.pcx
Binary file not shown.
Binary file added data/Tex377F628B_c.pcx
Binary file not shown.
Binary file added data/Tex37DD4E64_c.pcx
Binary file not shown.
Binary file added data/Tex382B7295_c.pcx
Binary file not shown.
Binary file added data/Tex39B4C203_c.pcx
Binary file not shown.
Binary file added data/Tex3C72B2A_c.pcx
Binary file not shown.
Binary file added data/Tex3FADD34B_c.pcx
Binary file not shown.
Binary file added data/Tex434C33B4_c.pcx
Binary file not shown.
Binary file added data/Tex4598980_c.pcx
Binary file not shown.
Binary file added data/Tex481A1D93_c.pcx
Binary file not shown.
Binary file added data/Tex494BEA05_c.pcx
Binary file not shown.
Binary file added data/Tex4B2B76B_c.pcx
Binary file not shown.
Binary file added data/Tex4C32C130_c.pcx
Binary file not shown.
Binary file added data/Tex4E87E087_c.pcx
Binary file not shown.
Binary file added data/Tex4FD46FF6_c.pcx
Binary file not shown.
Binary file added data/Tex5F40F14E_c.pcx
Binary file not shown.
Binary file added data/Tex636C5E89_c.pcx
Binary file not shown.
Binary file added data/Tex64674252_c.pcx
Binary file not shown.
Binary file added data/Tex64FFE518_c.pcx
Binary file not shown.
Binary file added data/Tex69F2958_c.pcx
Binary file not shown.
Binary file added data/Tex6E0371FC_c.pcx
Binary file not shown.
Binary file added data/Tex7003A16E_c.pcx
Binary file not shown.
Binary file added data/Tex73181CBF_c.pcx
Binary file not shown.
Binary file added data/Tex779FAD4E_c.pcx
Binary file not shown.
Binary file added data/Tex7C539D9A_c.pcx
Binary file not shown.
Binary file added data/Tex7DBBF446_c.pcx
Binary file not shown.
Binary file added data/Tex8AA76A5_c.pcx
Binary file not shown.
Binary file added data/Texawning.pcx
Binary file not shown.
Binary file added data/Texbark.pcx
Binary file not shown.
Binary file added data/Texblack.pcx
Binary file not shown.
Binary file added data/Texbridge.pcx
Binary file not shown.
Binary file added data/Texbush.pcx
Binary file not shown.
Binary file added data/Texbushside.pcx
Binary file not shown.
Binary file added data/Texcurtain.pcx
Binary file not shown.
Binary file added data/Texcut.pcx
Binary file not shown.
Binary file added data/Texdead.pcx
Binary file not shown.
Binary file added data/Texdoodd.pcx
Binary file not shown.
Binary file added data/Texdoodh.pcx
Binary file not shown.
Binary file added data/Texdoods.pcx
Binary file not shown.
Binary file added data/Texedge.pcx
Binary file not shown.
Binary file added data/Texenter.pcx
Binary file not shown.
Binary file added data/Texexit.pcx
Binary file not shown.
Binary file added data/Texfade.pcx
Binary file not shown.
Binary file added data/Texfence.pcx
Binary file not shown.
Binary file added data/Texfencew.pcx
Binary file not shown.
Binary file added data/Texgrass.pcx
Binary file not shown.
Binary file added data/Texgrassmix.pcx
Binary file not shown.
Binary file added data/Texhouse.pcx
Binary file not shown.
Binary file added data/Texkokiri_forest_minimap.pcx
Binary file not shown.
Binary file added data/Texladder.pcx
Binary file not shown.
Binary file added data/Texleaf.pcx
Binary file not shown.
Binary file added data/Texledge.pcx
Binary file not shown.
Binary file added data/Texmido.pcx
Binary file not shown.
Binary file added data/Texpatch.pcx
Binary file not shown.
Binary file added data/Texporch.pcx
Binary file not shown.
Binary file added data/Texrail.pcx
Binary file not shown.
Binary file added data/Texsaria.pcx
Binary file not shown.
Binary file added data/Texshop.pcx
Binary file not shown.
Binary file added data/Texshroom.pcx
Binary file not shown.
Binary file added data/Texstep.pcx
Binary file not shown.
Binary file added data/Texsteptop.pcx
Binary file not shown.
Binary file added data/Textower.pcx
Binary file not shown.
Binary file added data/Textrees.pcx
Binary file not shown.
Binary file added data/Textreetop.pcx
Binary file not shown.
Binary file added data/Textrunks.pcx
Binary file not shown.
Binary file added data/Texvine.pcx
Binary file not shown.
Binary file added data/Texvineh.pcx
Binary file not shown.
Binary file added data/Texvinew.pcx
Binary file not shown.
Binary file added data/Texwall.pcx
Binary file not shown.
Binary file added data/Texwalls.pcx
Binary file not shown.
Binary file added data/Texwater.pcx
Binary file not shown.
17 changes: 17 additions & 0 deletions source/Audio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "soundbank.h"
#include "soundbank_bin.h"

FORCE_INLINE void AudioInit()
{
mmInitDefaultMem((mm_addr)soundbank_bin);
}

FORCE_INLINE void AudioLoad(mm_word module_ID)
{
mmLoad(module_ID);
}

FORCE_INLINE void AudioPlay(mm_word module_ID)
{
mmStart(module_ID, MM_PLAY_LOOP);
}
134 changes: 134 additions & 0 deletions source/Camera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
const vec3 CameraPosOff = { 0.0, 3.0, 5.0 };
vec3 CameraPos = { 0.0, 2.5, 8.0 };
vec3 CameraDir = { 0.0, 0.0,-1.0 };
vec3 CameraUp = { 0.0, 1.0, 0.0 };
vec3 PlayerPos = { 5.0, -2.0, 0.0 };
vec3 PlayerDir = { 0.0, 0.0,-1.0 };
//f32 PlayerRotY = 0.0;
vec2 PlayerRot = { 0.0, 0.0 };
f32 PlayerCameraDist = 0.0;

bool ChangedPlayerDir = false;

void UpdatePlayer()
{
f32 Speed = DeltaTime * 1.5;
CameraDir = Mul3(CameraDir, Vec3f(Speed));

f32 PrevPlayerY = PlayerPos.y;
f32 PrevCameraY = CameraPos.y;


if (KeysHeld & KEY_RIGHT)
{
PlayerDir.x = CameraDir.x;
PlayerDir.y = 0.0;
PlayerDir.z = CameraDir.z;
Normalize3P(&PlayerDir);
PlayerDir = Mul3(PlayerDir, Vec3f(Speed));
PlayerDir = Cross3P(&CameraUp, &PlayerDir);
PlayerPos = Add3P(&PlayerPos, &PlayerDir);

ChangedPlayerDir = true;
}
if (KeysHeld & KEY_LEFT)
{
PlayerDir.x = -CameraDir.x;
PlayerDir.y = 0.0;
PlayerDir.z = -CameraDir.z;
Normalize3P(&PlayerDir);
PlayerDir = Mul3(PlayerDir, Vec3f(Speed));
PlayerDir = Cross3P(&CameraUp, &PlayerDir);
// PlayerDir.x = -PlayerDir.x;
// PlayerDir.y = -PlayerDir.y;
// PlayerDir.z = -PlayerDir.z;

PlayerPos = Add3P(&PlayerPos, &PlayerDir);

ChangedPlayerDir = true;
}
if (KeysHeld & KEY_DOWN)
{
PlayerDir.x = CameraDir.x;
PlayerDir.y = 0.0;
PlayerDir.z = CameraDir.z;
Normalize3P(&PlayerDir);
PlayerDir = Mul3(PlayerDir, Vec3f(Speed));
// PlayerDir = CameraDir;
PlayerPos = Add3P(&PlayerPos, &PlayerDir);

if (PlayerCameraDist < 5.8)
CameraPos = Add3P(&CameraPos, &PlayerDir);

ChangedPlayerDir = true;
}
if (KeysHeld & KEY_UP)
{
// PlayerDir.x = -CameraDir.x;
// PlayerDir.y = -CameraDir.y;
// PlayerDir.z = -CameraDir.z;
PlayerDir.x = -CameraDir.x;
PlayerDir.y = 0.0;
PlayerDir.z = -CameraDir.z;
Normalize3P(&PlayerDir);
PlayerDir = Mul3(PlayerDir, Vec3f(Speed));
PlayerPos = Add3P(&PlayerPos, &PlayerDir);

if (PlayerCameraDist > 7.8)
CameraPos = Add3P(&CameraPos, &PlayerDir);

ChangedPlayerDir = true;
}

// if (Key[SDL_SCANCODE_Q] && ChangedPlayerDir)
// {
// vec3 Dir = Div3(PlayerDir, Vec3f(Speed));
//
// f32 AbsX = fabsf(Dir.x);
// f32 AbsZ = fabsf(Dir.z);
//
// mat4 M = RotateYMat4(LoadMat4Identity(), ToRadians(PlayerRotY));
// M = TranslateMat4(M, PlayerPos);
// vec4 Pos = { CameraPos.x, CameraPos.y, CameraPos.z, 1.0 };
//
// Pos = MultiplyVec4Mat4P(&Pos, &M);
// CameraPos.x = Pos.x;
// CameraPos.y = Pos.y;
// CameraPos.z = Pos.z;
//
// ChangedPlayerDir = false;
// // CameraPos = Mul3P(&CameraPos, &Dir);
// }

// vec3 Dir = Div3(PlayerDir, Vec3f(Speed));
// PrintVec3(&CameraPos);

PlayerPos.y = PrevPlayerY;
CameraPos.y = PrevCameraY;
}

//stylus = mouse
//D-Pad = wasd
//L-Shoulder = Q
void UpdateCamera()
{
PlayerCameraDist = GetDistanceVec3P(&CameraPos, &PlayerPos);
// Uint8* Key = SDL_GetKeyboardState(NULL);




CameraDir = Sub3(CameraPos, PlayerPos);
Normalize3P(&CameraDir);
// LightPos = { CameraDir.x, 0.0, CameraDir.z };
// Normalize3P(&LightPos);
// LightPos = CameraDir;
PlayerRot = { -CameraDir.x * 2.0, -CameraDir.z * 2.0 };
Normalize2P(&PlayerRot);
UpdatePlayer();

PlayerPos.y += 1.0;
gluLookAtV(&CameraPos, &PlayerPos, &CameraUp);
PlayerPos.y -= 1.0;
// CameraPos = Add3P(&CameraPosOff, &PlayerPos);
}
Loading

0 comments on commit 7415e29

Please sign in to comment.