From 183228e28e129aace5e65c4f88ed77e3ddb7a1af Mon Sep 17 00:00:00 2001 From: KonPet <45455208+SkilLP@users.noreply.github.com> Date: Thu, 21 Oct 2021 00:03:39 +0200 Subject: [PATCH 1/2] Change stuff to make it build Removed the arm7 section Changed the makefile to only use the arm9 stuff Epicpkmn: Fix source/Graphics/GraphicsManager.cpp Co-Authored-By: Pk11 Co-Authored-By: Kaisaan <34224128+Kaisaan@users.noreply.github.com> --- .gitignore | 8 + CMakeLists.txt | 34 + Makefile | 154 +- arm7/Makefile | 132 -- arm7/source/main.cpp | 72 - arm9/Makefile | 153 -- arm9/source/Graphics/GraphicsManager.cpp | 234 --- {arm9/data => data}/sounds/normal_hitclap.bin | Bin .../data => data}/sounds/normal_hitfinish.bin | Bin .../data => data}/sounds/normal_hitnormal.bin | Bin .../sounds/normal_hitwhistle.bin | Bin .../sounds/normal_sliderslide.bin | Bin .../sounds/normal_slidertick.bin | Bin .../sounds/normal_sliderwhistle.bin | Bin {arm9/data => data}/sounds/soft_hitclap.bin | Bin {arm9/data => data}/sounds/soft_hitfinish.bin | Bin {arm9/data => data}/sounds/soft_hitnormal.bin | Bin .../data => data}/sounds/soft_hitwhistle.bin | Bin .../data => data}/sounds/soft_sliderslide.bin | Bin .../data => data}/sounds/soft_slidertick.bin | Bin .../sounds/soft_sliderwhistle.bin | Bin {arm9/data => data}/sounds/spinnerbonus.bin | Bin {arm9/data => data}/sounds/spinnerspin.bin | Bin {arm9/data => data}/textures/circle.bin | Bin .../data => data}/textures/circleapproach.bin | Bin .../data => data}/textures/circleoverlay.bin | Bin {arm9/data => data}/textures/disc.bin | Bin {arm9/data => data}/textures/hit0.bin | Bin {arm9/data => data}/textures/hit100.bin | Bin {arm9/data => data}/textures/hit100k.bin | Bin {arm9/data => data}/textures/hit300.bin | Bin {arm9/data => data}/textures/hit300g.bin | Bin {arm9/data => data}/textures/hit300k.bin | Bin {arm9/data => data}/textures/hit50.bin | Bin {arm9/data => data}/textures/scorebar.bin | Bin .../textures/scorebar_colour.bin | Bin {arm9/data => data}/textures/scorebar_ki.bin | Bin .../textures/scorebar_kidanger.bin | Bin .../textures/scorebar_kidanger2.bin | Bin {arm9/data => data}/textures/slider10.bin | Bin {arm9/data => data}/textures/slider30.bin | Bin {arm9/data => data}/textures/sliderb0.bin | Bin {arm9/data => data}/textures/sliderb1.bin | Bin {arm9/data => data}/textures/sliderb2.bin | Bin {arm9/data => data}/textures/sliderb3.bin | Bin {arm9/data => data}/textures/sliderb4.bin | Bin {arm9/data => data}/textures/sliderb5.bin | Bin {arm9/data => data}/textures/sliderb6.bin | Bin {arm9/data => data}/textures/sliderb7.bin | Bin {arm9/data => data}/textures/sliderb8.bin | Bin {arm9/data => data}/textures/sliderb9.bin | Bin {arm9/data => data}/textures/sliderfollow.bin | Bin .../data => data}/textures/sliderreverse.bin | Bin {arm9/data => data}/textures/slidertick.bin | Bin {arm9/data => data}/textures/spinner.bin | Bin {arm9/data => data}/textures/spinnerbars.bin | Bin {arm9/data => data}/textures/spinnerbg.bin | 0 {arm9/data => data}/textures/verdana9.bin | Bin {arm9/data => data}/textures/white.bin | 0 {arm9/fonts => fonts}/370.bmf | Bin {arm9/fonts => fonts}/4x6_a.bmf | Bin {arm9/fonts => fonts}/gomics.bmf | Bin {arm9/fonts => fonts}/hoo06.bmf | Bin {arm9/fonts => fonts}/ver08.bmf | Bin osuds.pnproj | 1 - osuds.pnps | 1 - osuds.ppg | 1 - {arm9/source => source}/Beatmaps/Beatmap.cpp | 483 +++--- {arm9/source => source}/Beatmaps/Beatmap.h | 158 +- .../Beatmaps/BeatmapElements.cpp | 164 +- .../Beatmaps/BeatmapElements.h | 106 +- .../Beatmaps/BeatmapManager.cpp | 164 +- .../Beatmaps/BeatmapManager.h | 78 +- .../Beatmaps/DifficultyManager.cpp | 42 +- .../Beatmaps/DifficultyManager.h | 78 +- .../GameplayElements/HitObjectManager.cpp | 206 +-- .../GameplayElements/HitObjectManager.h | 62 +- .../GameplayElements/Lifebar.cpp | 228 +-- .../GameplayElements/Lifebar.h | 102 +- .../GameplayElements/ScoreManager.cpp | 72 +- .../GameplayElements/ScoreManager.h | 72 +- {arm9/source => source}/Graphics/GfxInfo.cpp | 686 ++++---- {arm9/source => source}/Graphics/GfxInfo.h | 230 +-- source/Graphics/GraphicsManager.cpp | 277 +++ .../Graphics/GraphicsManager.h | 124 +- .../Graphics/SpriteContainer.cpp | 46 +- .../Graphics/SpriteContainer.h | 64 +- .../Graphics/SpriteManager.cpp | 156 +- .../Graphics/SpriteManager.h | 66 +- .../Graphics/Transformation.cpp | 106 +- .../Graphics/Transformation.h | 84 +- .../source => source}/Graphics/pAnimation.cpp | 58 +- {arm9/source => source}/Graphics/pAnimation.h | 44 +- {arm9/source => source}/Graphics/pSprite.cpp | 386 ++--- {arm9/source => source}/Graphics/pSprite.h | 206 +-- .../Helpers/AudioManager.cpp | 392 ++--- .../source => source}/Helpers/AudioManager.h | 212 +-- .../source => source}/Helpers/FileReader.cpp | 333 ++-- {arm9/source => source}/Helpers/FileReader.h | 96 +- .../source => source}/Helpers/InputHelper.cpp | 58 +- {arm9/source => source}/Helpers/InputHelper.h | 38 +- .../source => source}/Helpers/MathHelper.cpp | 22 +- {arm9/source => source}/Helpers/MathHelper.h | 50 +- .../HitObjects/HitCircle.cpp | 230 +-- .../source => source}/HitObjects/HitCircle.h | 42 +- .../HitObjects/HitObject.cpp | 206 +-- .../source => source}/HitObjects/HitObject.h | 164 +- .../HitObjects/HitSlider.cpp | 1088 ++++++------ .../source => source}/HitObjects/HitSlider.h | 102 +- .../HitObjects/HitSpinner.cpp | 396 ++--- .../source => source}/HitObjects/HitSpinner.h | 78 +- .../source => source}/Libraries/ByteMapFont.c | 404 ++--- .../source => source}/Libraries/ByteMapFont.h | 186 +-- .../source => source}/Libraries/gfxconsole.c | 1480 ++++++++--------- .../source => source}/Libraries/gfxconsole.h | 462 ++--- {arm9/source => source}/Libraries/nitrofs.c | 6 +- {arm9/source => source}/Libraries/nitrofs.h | 2 +- {arm9/source => source}/Modes/Mode.cpp | 28 +- {arm9/source => source}/Modes/Mode.h | 76 +- {arm9/source => source}/Modes/ModeLoader.cpp | 106 +- {arm9/source => source}/Modes/Player.cpp | 148 +- {arm9/source => source}/Modes/Player.h | 82 +- {arm9/source => source}/Modes/SongSelect.cpp | 358 ++-- {arm9/source => source}/Modes/SongSelect.h | 84 +- {arm9/source => source}/Rulesets/Ruleset.cpp | 120 +- {arm9/source => source}/Rulesets/Ruleset.h | 74 +- .../source => source}/Rulesets/RulesetOsu.cpp | 250 +-- {arm9/source => source}/Rulesets/RulesetOsu.h | 58 +- {arm9/source => source}/System/GameBase.cpp | 28 +- {arm9/source => source}/System/GameBase.h | 28 +- {arm9/source => source}/System/GameClock.cpp | 148 +- {arm9/source => source}/System/GameClock.h | 64 +- {arm9/source => source}/System/ICallback.h | 40 +- .../source => source}/System/TextManager.cpp | 320 ++-- {arm9/source => source}/System/TextManager.h | 120 +- {arm9/source => source}/defines.h | 2 +- {arm9/source => source}/exception.c | 522 +++--- {arm9/source => source}/main.cpp | 0 138 files changed, 6941 insertions(+), 7100 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt delete mode 100644 arm7/Makefile delete mode 100644 arm7/source/main.cpp delete mode 100644 arm9/Makefile delete mode 100644 arm9/source/Graphics/GraphicsManager.cpp rename {arm9/data => data}/sounds/normal_hitclap.bin (100%) rename {arm9/data => data}/sounds/normal_hitfinish.bin (100%) rename {arm9/data => data}/sounds/normal_hitnormal.bin (100%) rename {arm9/data => data}/sounds/normal_hitwhistle.bin (100%) rename {arm9/data => data}/sounds/normal_sliderslide.bin (100%) rename {arm9/data => data}/sounds/normal_slidertick.bin (100%) rename {arm9/data => data}/sounds/normal_sliderwhistle.bin (100%) rename {arm9/data => data}/sounds/soft_hitclap.bin (100%) rename {arm9/data => data}/sounds/soft_hitfinish.bin (100%) rename {arm9/data => data}/sounds/soft_hitnormal.bin (100%) rename {arm9/data => data}/sounds/soft_hitwhistle.bin (100%) rename {arm9/data => data}/sounds/soft_sliderslide.bin (100%) rename {arm9/data => data}/sounds/soft_slidertick.bin (100%) rename {arm9/data => data}/sounds/soft_sliderwhistle.bin (100%) rename {arm9/data => data}/sounds/spinnerbonus.bin (100%) rename {arm9/data => data}/sounds/spinnerspin.bin (100%) rename {arm9/data => data}/textures/circle.bin (100%) rename {arm9/data => data}/textures/circleapproach.bin (100%) rename {arm9/data => data}/textures/circleoverlay.bin (100%) rename {arm9/data => data}/textures/disc.bin (100%) rename {arm9/data => data}/textures/hit0.bin (100%) rename {arm9/data => data}/textures/hit100.bin (100%) rename {arm9/data => data}/textures/hit100k.bin (100%) rename {arm9/data => data}/textures/hit300.bin (100%) rename {arm9/data => data}/textures/hit300g.bin (100%) rename {arm9/data => data}/textures/hit300k.bin (100%) rename {arm9/data => data}/textures/hit50.bin (100%) rename {arm9/data => data}/textures/scorebar.bin (100%) rename {arm9/data => data}/textures/scorebar_colour.bin (100%) rename {arm9/data => data}/textures/scorebar_ki.bin (100%) rename {arm9/data => data}/textures/scorebar_kidanger.bin (100%) rename {arm9/data => data}/textures/scorebar_kidanger2.bin (100%) rename {arm9/data => data}/textures/slider10.bin (100%) rename {arm9/data => data}/textures/slider30.bin (100%) rename {arm9/data => data}/textures/sliderb0.bin (100%) rename {arm9/data => data}/textures/sliderb1.bin (100%) rename {arm9/data => data}/textures/sliderb2.bin (100%) rename {arm9/data => data}/textures/sliderb3.bin (100%) rename {arm9/data => data}/textures/sliderb4.bin (100%) rename {arm9/data => data}/textures/sliderb5.bin (100%) rename {arm9/data => data}/textures/sliderb6.bin (100%) rename {arm9/data => data}/textures/sliderb7.bin (100%) rename {arm9/data => data}/textures/sliderb8.bin (100%) rename {arm9/data => data}/textures/sliderb9.bin (100%) rename {arm9/data => data}/textures/sliderfollow.bin (100%) rename {arm9/data => data}/textures/sliderreverse.bin (100%) rename {arm9/data => data}/textures/slidertick.bin (100%) rename {arm9/data => data}/textures/spinner.bin (100%) rename {arm9/data => data}/textures/spinnerbars.bin (100%) rename {arm9/data => data}/textures/spinnerbg.bin (100%) rename {arm9/data => data}/textures/verdana9.bin (100%) rename {arm9/data => data}/textures/white.bin (100%) rename {arm9/fonts => fonts}/370.bmf (100%) rename {arm9/fonts => fonts}/4x6_a.bmf (100%) rename {arm9/fonts => fonts}/gomics.bmf (100%) rename {arm9/fonts => fonts}/hoo06.bmf (100%) rename {arm9/fonts => fonts}/ver08.bmf (100%) delete mode 100644 osuds.pnproj delete mode 100644 osuds.pnps delete mode 100644 osuds.ppg rename {arm9/source => source}/Beatmaps/Beatmap.cpp (95%) rename {arm9/source => source}/Beatmaps/Beatmap.h (95%) rename {arm9/source => source}/Beatmaps/BeatmapElements.cpp (94%) rename {arm9/source => source}/Beatmaps/BeatmapElements.h (94%) rename {arm9/source => source}/Beatmaps/BeatmapManager.cpp (89%) rename {arm9/source => source}/Beatmaps/BeatmapManager.h (94%) rename {arm9/source => source}/Beatmaps/DifficultyManager.cpp (98%) rename {arm9/source => source}/Beatmaps/DifficultyManager.h (96%) rename {arm9/source => source}/GameplayElements/HitObjectManager.cpp (95%) rename {arm9/source => source}/GameplayElements/HitObjectManager.h (94%) rename {arm9/source => source}/GameplayElements/Lifebar.cpp (96%) rename {arm9/source => source}/GameplayElements/Lifebar.h (95%) rename {arm9/source => source}/GameplayElements/ScoreManager.cpp (94%) rename {arm9/source => source}/GameplayElements/ScoreManager.h (94%) rename {arm9/source => source}/Graphics/GfxInfo.cpp (98%) rename {arm9/source => source}/Graphics/GfxInfo.h (95%) create mode 100644 source/Graphics/GraphicsManager.cpp rename {arm9/source => source}/Graphics/GraphicsManager.h (96%) rename {arm9/source => source}/Graphics/SpriteContainer.cpp (95%) rename {arm9/source => source}/Graphics/SpriteContainer.h (94%) rename {arm9/source => source}/Graphics/SpriteManager.cpp (94%) rename {arm9/source => source}/Graphics/SpriteManager.h (94%) rename {arm9/source => source}/Graphics/Transformation.cpp (94%) rename {arm9/source => source}/Graphics/Transformation.h (94%) rename {arm9/source => source}/Graphics/pAnimation.cpp (95%) rename {arm9/source => source}/Graphics/pAnimation.h (95%) rename {arm9/source => source}/Graphics/pSprite.cpp (95%) rename {arm9/source => source}/Graphics/pSprite.h (96%) rename {arm9/source => source}/Helpers/AudioManager.cpp (96%) rename {arm9/source => source}/Helpers/AudioManager.h (94%) rename {arm9/source => source}/Helpers/FileReader.cpp (88%) rename {arm9/source => source}/Helpers/FileReader.h (93%) rename {arm9/source => source}/Helpers/InputHelper.cpp (92%) rename {arm9/source => source}/Helpers/InputHelper.h (93%) rename {arm9/source => source}/Helpers/MathHelper.cpp (93%) rename {arm9/source => source}/Helpers/MathHelper.h (95%) rename {arm9/source => source}/HitObjects/HitCircle.cpp (95%) rename {arm9/source => source}/HitObjects/HitCircle.h (94%) rename {arm9/source => source}/HitObjects/HitObject.cpp (95%) rename {arm9/source => source}/HitObjects/HitObject.h (95%) rename {arm9/source => source}/HitObjects/HitSlider.cpp (96%) rename {arm9/source => source}/HitObjects/HitSlider.h (95%) rename {arm9/source => source}/HitObjects/HitSpinner.cpp (96%) rename {arm9/source => source}/HitObjects/HitSpinner.h (94%) rename {arm9/source => source}/Libraries/ByteMapFont.c (95%) rename {arm9/source => source}/Libraries/ByteMapFont.h (96%) rename {arm9/source => source}/Libraries/gfxconsole.c (96%) rename {arm9/source => source}/Libraries/gfxconsole.h (97%) rename {arm9/source => source}/Libraries/nitrofs.c (99%) rename {arm9/source => source}/Libraries/nitrofs.h (99%) rename {arm9/source => source}/Modes/Mode.cpp (92%) rename {arm9/source => source}/Modes/Mode.h (94%) rename {arm9/source => source}/Modes/ModeLoader.cpp (94%) rename {arm9/source => source}/Modes/Player.cpp (93%) rename {arm9/source => source}/Modes/Player.h (94%) rename {arm9/source => source}/Modes/SongSelect.cpp (95%) rename {arm9/source => source}/Modes/SongSelect.h (94%) rename {arm9/source => source}/Rulesets/Ruleset.cpp (95%) rename {arm9/source => source}/Rulesets/Ruleset.h (94%) rename {arm9/source => source}/Rulesets/RulesetOsu.cpp (95%) rename {arm9/source => source}/Rulesets/RulesetOsu.h (94%) rename {arm9/source => source}/System/GameBase.cpp (94%) rename {arm9/source => source}/System/GameBase.h (92%) rename {arm9/source => source}/System/GameClock.cpp (93%) rename {arm9/source => source}/System/GameClock.h (93%) rename {arm9/source => source}/System/ICallback.h (94%) rename {arm9/source => source}/System/TextManager.cpp (95%) rename {arm9/source => source}/System/TextManager.h (94%) rename {arm9/source => source}/defines.h (94%) rename {arm9/source => source}/exception.c (93%) rename {arm9/source => source}/main.cpp (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b887bf --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.o +*.map +*.nds +*.elf + +.idea +cmake-build-debug +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..14508f3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,34 @@ +# That file is here only to make IDE's happy so they could index all source files. +# Real building happens through Makefile. + +cmake_minimum_required(VERSION 3.9) +project(osuds) + +set(CMAKE_CXX_STANDARD 20) + +# Set to your devkitPro's installation dir if environment variable does not exist. +set(DEVKITPRO C:/devkitpro) + +include_directories(${DEVKITPRO}/libnds/lib) +include_directories(${DEVKITPRO}/libnds/include) +include_directories(${DEVKITPRO}/libnds/include/nds) +include_directories(${DEVKITPRO}/libnds/include/nds/arm9) +include_directories(${DEVKITPRO}/devkitARM) +include_directories(${DEVKITPRO}/devkitARM/arm-none-eabi/include) +include_directories(arm9/source) +include_directories(arm9/fonts) +include_directories(arm9/data) +include_directories(arm9/build) + +link_directories(${DEVKITPRO}/libnds/lib) +link_directories(${DEVKITPRO}/libnds/include) +link_directories(${DEVKITPRO}/libnds/include/nds) +link_directories(${DEVKITPRO}/libnds/include/nds/arm9) + +add_compile_definitions(ARM9) +add_compile_definitions(ARM7) +add_compile_definitions(iprintf=printf) + +FILE(GLOB_RECURSE src *.cpp *.hpp *.c *.h) + +add_executable(osuds ${src}) \ No newline at end of file diff --git a/Makefile b/Makefile index ab5ad0c..ee85ce6 100644 --- a/Makefile +++ b/Makefile @@ -1,45 +1,149 @@ #--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- + ifeq ($(strip $(DEVKITARM)),) $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") endif include $(DEVKITARM)/ds_rules -export TARGET := $(shell basename $(CURDIR)) -export TOPDIR := $(CURDIR) +#--------------------------------------------------------------------------------- +# 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 +# MAXMOD_SOUNDBANK contains a directory of music and sound effect files +#--------------------------------------------------------------------------------- +TARGET := osuNDS +BUILD := build +SOURCES := source \ + source/Libraries \ + source/System \ + source/Beatmaps \ + source/Graphics \ + source/Helpers \ + source/GameplayElements \ + source/HitObjects \ + source/Rulesets \ + source/Modes +DATA := data/textures \ + data/sounds +INCLUDES := source \ + include +GRAPHICS := gfx +FONTS := fonts +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -.PHONY: $(TARGET).arm7 $(TARGET).arm9 +CFLAGS := -g -Wall -O2\ + -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ + -ffast-math \ + $(ARCH) +CFLAGS += $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s $(INCLUDE) +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 := -lfat -lnds9 + + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) + +#--------------------------------------------------------------------------------- +# 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 := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ + $(foreach dir,$(FONTS),$(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))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) +FONTFILES := $(foreach dir,$(FONTS),$(notdir $(wildcard $(dir)/*.bmf))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES := $(addsuffix .o,$(BINFILES)) \ + $(addsuffix .o,$(FONTFILES)) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds + +#--------------------------------------------------------------------------------- +else + #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- -all: $(TARGET).nds +$(OUTPUT).nds : $(OUTPUT).elf +$(OUTPUT).elf : $(OFILES) #--------------------------------------------------------------------------------- -$(TARGET).nds : $(TARGET).arm7 $(TARGET).arm9 - ndstool -c $(TARGET).nds -7 $(TARGET).arm7 -9 $(TARGET).arm9 +%.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) #--------------------------------------------------------------------------------- -$(TARGET).arm7 : arm7/$(TARGET).elf -$(TARGET).arm9 : arm9/$(TARGET).elf +%.bmf.o : %.bmf +#--------------------------------------------------------------------------------- +# @echo $(notdir $<) + @$(bin2o) -#--------------------------------------------------------------------------------- -arm7/$(TARGET).elf: - $(MAKE) -C arm7 - -#--------------------------------------------------------------------------------- -arm9/$(TARGET).elf: - $(MAKE) -C arm9 - -#--------------------------------------------------------------------------------- -clean: - $(MAKE) -C arm9 clean - $(MAKE) -C arm7 clean - rm -f $(TARGET).nds $(TARGET).arm7 $(TARGET).arm9 - -#--------------------------------------------------------------------------------- -emu: - ndstool -c $(TARGET).nds -7 $(TARGET).arm7 -9 $(TARGET).arm9 -d nitro \ No newline at end of file + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/arm7/Makefile b/arm7/Makefile deleted file mode 100644 index d2e0578..0000000 --- a/arm7/Makefile +++ /dev/null @@ -1,132 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# 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 -# all directories are relative to this makefile -#--------------------------------------------------------------------------------- -BUILD := build -SOURCES := source -INCLUDES := include build -DATA := - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb-interwork - -CFLAGS := -g -Wall -O2\ - -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ - -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM7 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-rtti - - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,-Map,$(notdir $*).map - -LIBS := -ldswifi7 -lnds7 - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) - - -#--------------------------------------------------------------------------------- -# 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 ARM7BIN := $(TOPDIR)/$(TARGET).arm7 -export ARM7ELF := $(CURDIR)/$(TARGET).arm7.elf -export DEPSDIR := $(CURDIR)/$(BUILD) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) *.elf - - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(ARM7BIN) : $(ARM7ELF) - @$(OBJCOPY) -O binary $< $@ - @echo built ... $(notdir $@) - - -$(ARM7ELF) : $(OFILES) - @echo linking $(notdir $@) - @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ - - -#--------------------------------------------------------------------------------- -# you need a rule like this for each extension you use as binary data -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/arm7/source/main.cpp b/arm7/source/main.cpp deleted file mode 100644 index 6a0eb91..0000000 --- a/arm7/source/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*--------------------------------------------------------------------------------- - -default ARM7 core - -Copyright (C) 2005 -Michael Noland (joat) -Jason Rogers (dovoto) -Dave Murphy (WinterMute) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you -must not claim that you wrote the original software. If you use -this software in a product, an acknowledgment in the product -documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source -distribution. - ----------------------------------------------------------------------------------*/ -#include -#include - -//--------------------------------------------------------------------------------- -void VcountHandler() { - //--------------------------------------------------------------------------------- - inputGetAndSend(); -} - -//--------------------------------------------------------------------------------- -void VblankHandler(void) { -//--------------------------------------------------------------------------------- - Wifi_Update(); -} - - -//--------------------------------------------------------------------------------- -int main() { -//--------------------------------------------------------------------------------- - irqInit(); - fifoInit(); - - // read User Settings from firmware - readUserSettings(); - - // Start the RTC tracking IRQ - initClockIRQ(); - - SetYtrigger(80); - - installWifiFIFO(); - installSoundFIFO(); - - installSystemFIFO(); - - irqSet(IRQ_VCOUNT, VcountHandler); - irqSet(IRQ_VBLANK, VblankHandler); - - irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK); - - // Keep the ARM7 mostly idle - while (1) swiWaitForVBlank(); -} - - diff --git a/arm9/Makefile b/arm9/Makefile deleted file mode 100644 index c0f27f0..0000000 --- a/arm9/Makefile +++ /dev/null @@ -1,153 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# 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 -# all directories are relative to this makefile -#--------------------------------------------------------------------------------- -BUILD := build -SOURCES := source \ - source/Libraries \ - source/System \ - source/Beatmaps \ - source/Graphics \ - source/Helpers \ - source/GameplayElements \ - source/HitObjects \ - source/Rulesets \ - source/Modes -INCLUDES := source \ - include -DATA := data/textures \ - data/sounds -FONTS := fonts - - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork - -CFLAGS := -g -Wall -O2\ - -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ - -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s - -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS := -lfat -lnds9 - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) - -#--------------------------------------------------------------------------------- -# 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 ARM9BIN := $(TOPDIR)/$(TARGET).arm9 -export ARM9ELF := $(CURDIR)/$(TARGET).arm9.elf -export DEPSDIR := $(CURDIR)/$(BUILD) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ - $(foreach dir,$(FONTS),$(CURDIR)/$(dir)) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) -FONTFILES := $(foreach dir,$(FONTS),$(notdir $(wildcard $(dir)/*.bmf))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(addsuffix .o,$(FONTFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) *.elf *.nds* *.bin - - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(ARM9BIN) : $(ARM9ELF) - @$(OBJCOPY) -O binary $< $@ - @echo built ... $(notdir $@) - -$(ARM9ELF) : $(OFILES) - @echo linking $(notdir $@) - @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ - -#--------------------------------------------------------------------------------- -# you need a rule like this for each extension you use as binary data -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - -#--------------------------------------------------------------------------------- -%.bmf.o : %.bmf -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/arm9/source/Graphics/GraphicsManager.cpp b/arm9/source/Graphics/GraphicsManager.cpp deleted file mode 100644 index 7d52814..0000000 --- a/arm9/source/Graphics/GraphicsManager.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include "GraphicsManager.h" - -GraphicsManager GraphicsManager::sGraphicsManager; - -GraphicsManager::GraphicsManager() -{ - videoSetMode(MODE_5_3D); - videoSetModeSub(MODE_5_2D); - - vramSetBankA(VRAM_A_TEXTURE); - vramSetBankC(VRAM_C_SUB_BG); - vramSetBankD(VRAM_D_MAIN_BG_0x06000000); - vramSetBankE(VRAM_E_TEX_PALETTE); - - REG_BG0CNT = 1; - - glInit(); - glEnable(GL_BLEND | GL_TEXTURE_2D | GL_ANTIALIAS); - - // setup the rear plane - glClearColor(20,20,31,31); - glClearPolyID(63); - glClearDepth(0x7FFF); - - glViewport(0,0,255,191); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - //gluPerspective(100.3, 4.0/3.0, 0.1, 100); //fovy, aspect(width/height), zNear, zFar - glOrtho(0.f, 6.40f, 0.f, 4.80f, 0.1f, 100.f); - - // camera is flipped around a bit - x increases left to right, y increases top to bottom (0,0) to (640,480) - gluLookAt( 0, 4.8, -50.0, //camera position - 0, 4.8, 0.0, //look at - 0.0, -1.0, 0.0); //up - - glMatrixMode(GL_MODELVIEW); - - mPolygonId = 0; - - //// LOAD TEXTURES //// - - glGenTextures(NUMBER_OF_TEXTURES, textures); - - int pal0 = gluTexLoadPal(palette0, 4, GL_RGB4); - - LoadGLTexture(TX_PLAY_CIRCLE, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal0, uv64x64, circle_bin); - LoadGLTexture(TX_PLAY_CIRCLEOVERLAY, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal0, uv64x64, circleoverlay_bin); - LoadGLTexture(TX_PLAY_CIRCLEAPPROACH, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal0, uv64x64, circleapproach_bin); - - LoadGLTexture(TX_PLAY_DISC, GL_RGB4, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal0, uv32x32, disc_bin); - LoadGLTexture(TX_PLAY_SLIDERTICK, GL_RGB4, TEXTURE_SIZE_16, TEXTURE_SIZE_16, pal0, uv16x16, slidertick_bin); - LoadGLTexture(TX_PLAY_SLIDERREVERSE, GL_RGB4, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal0, uv32x32, sliderreverse_bin); - - LoadGLTexture(TX_WHITE, GL_RGB4, TEXTURE_SIZE_8, TEXTURE_SIZE_8, pal0, uv8x8, white_bin); - - int pal1 = gluTexLoadPal(palette1, 16, GL_RGB16); - - LoadGLTexture(TX_PLAY_SPINNER, GL_RGB16, TEXTURE_SIZE_128, TEXTURE_SIZE_128, pal1, uv128x128, spinner_bin); - LoadGLTexture(TX_PLAY_SPINNERBARS, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_256, pal1, uv256x192, spinnerbars_bin); - LoadGLTexture(TX_PLAY_SCOREBAR_BAR, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_16, pal1, uv256x16, scorebar_colour_bin); - - int pal2 = gluTexLoadPal(palette2, 16, GL_RGB4); - - LoadGLTexture(TX_PLAY_SPINNERBG, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_256, pal2, uv256x192, spinnerbg_bin); - - int pal3 = gluTexLoadPal(palette3, 4, GL_RGB4); - - LoadGLTexture(TX_PLAY_SLIDERB0, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb0_bin); - LoadGLTexture(TX_PLAY_SLIDERB1, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb1_bin); - LoadGLTexture(TX_PLAY_SLIDERB2, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb2_bin); - LoadGLTexture(TX_PLAY_SLIDERB3, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb3_bin); - LoadGLTexture(TX_PLAY_SLIDERB4, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb4_bin); - LoadGLTexture(TX_PLAY_SLIDERB5, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb5_bin); - LoadGLTexture(TX_PLAY_SLIDERB6, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb6_bin); - LoadGLTexture(TX_PLAY_SLIDERB7, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb7_bin); - LoadGLTexture(TX_PLAY_SLIDERB8, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb8_bin); - LoadGLTexture(TX_PLAY_SLIDERB9, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb9_bin); - LoadGLTexture(TX_PLAY_SLIDERFOLLOW, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderfollow_bin); - - int pal4 = gluTexLoadPal(palette4, 16, GL_RGB16); - - LoadGLTexture(TX_PLAY_HIT0, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit0_bin); - LoadGLTexture(TX_PLAY_HIT300, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit300_bin); - LoadGLTexture(TX_PLAY_HIT300K, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit300k_bin); - LoadGLTexture(TX_PLAY_HIT300G, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit300g_bin); - - int pal5 = gluTexLoadPal(palette5, 16, GL_RGB16); - - LoadGLTexture(TX_PLAY_HIT50, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal5, uv64x64, hit50_bin); - LoadGLTexture(TX_PLAY_HIT100, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal5, uv64x64, hit100_bin); - LoadGLTexture(TX_PLAY_HIT100K, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal5, uv64x64, hit100k_bin); - - int pal6 = gluTexLoadPal(palette6, 4, GL_RGB4); - - LoadGLTexture(TX_PLAY_SLIDER30, GL_RGB4, TEXTURE_SIZE_16, TEXTURE_SIZE_16, pal6, uv16x16, slider30_bin); - LoadGLTexture(TX_PLAY_SLIDER10, GL_RGB4, TEXTURE_SIZE_16, TEXTURE_SIZE_16, pal6, uv16x16, slider10_bin); - - int pal7 = gluTexLoadPal(palette7, 16, GL_RGB16); - - LoadGLTexture(TX_PLAY_SCOREBAR_KI, GL_RGB16, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal7, uv32x32, scorebar_ki_bin); - LoadGLTexture(TX_PLAY_SCOREBAR_KIDANGER, GL_RGB16, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal7, uv32x32, scorebar_kidanger_bin); - LoadGLTexture(TX_PLAY_SCOREBAR_KIDANGER2, GL_RGB16, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal7, uv32x32, scorebar_kidanger2_bin); - - int pal8 = gluTexLoadPal(palette8, 16, GL_RGB16); - - LoadGLTexture(TX_PLAY_SCOREBAR, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_16, pal8, uv256x16, scorebar_bin); - - // 16 bit textures - - //LoadGLTexture(TX_SONGSELECT_SONGBG, GL_RGB, TEXTURE_SIZE_64, TEXTURE_SIZE_512, -1, NULL, songbg_osu_bin); -} - -void GraphicsManager::LoadGLTextureEx(TextureType tex, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int palette, const u32* uv, const u8* texture, u32 size) -{ - /* DON'T TOUCH THIS FUNCTION - * there seems to be some sort of memory problem somewhere, but it's completely eluding me where it is - * the game only loads the textures if this function is the way it is >.> - */ - - void* temp = malloc(size); - - glBindTexture(0, textures[tex]); - glTexImage2D(0, 0, type, sizeX, sizeY, 0, GL_TEXTURE_COLOR0_TRANSPARENT, (u8*)texture); - - free(temp); - - textureInfo[tex].palette = palette; - textureInfo[tex].format = type; - textureInfo[tex].uv = uv; -} - -void GraphicsManager::Draw(TextureType tex, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, s32 angle, float z, const u32* uv) -{ - if (uv == NULL) - uv = textureInfo[tex].uv; - - s32 x1 = 270, x2 = 370, y1 = 190, y2 = 290; - //float z = zvalue[tex] + deltaz; - - if (fieldtype == FIELD_PLAY) - { - x += PlayXOffset; - y += PlayYOffset; - } - - switch (origin) - { - case ORIGIN_TOPLEFT: - x1 = ForceBounds(x); - x2 = ForceBounds(x + width); - y1 = ForceBounds(y); - y2 = ForceBounds(y + height); - break; - - case ORIGIN_CENTER: - width >>= 1; - height >>= 1; - - x1 = ForceBounds(x - width); - x2 = ForceBounds(x + width); - y1 = ForceBounds(y - height); - y2 = ForceBounds(y + height); - break; - - case ORIGIN_BOTTOMLEFT: - x1 = ForceBounds(x); - x2 = ForceBounds(x + width); - y1 = ForceBounds(y - height); - y2 = ForceBounds(y); - break; - - case ORIGIN_TOPRIGHT: - x1 = ForceBounds(x - width); - x2 = ForceBounds(x); - y1 = ForceBounds(y); - y2 = ForceBounds(y + height); - } - - //need to keep rotating polygonid - if (++mPolygonId > 63) - mPolygonId = 0; - - //don't draw things out of the screen - if (x1 > 640 || x2 < 0 || y1 > 480 || y2 < 0) - return; - - glPushMatrix(); - - glPolyFmt(POLY_ALPHA(alpha&31) | POLY_ID(mPolygonId) | POLY_CULL_NONE); - glColor(color); - - if (angle != 0) - { - glTranslatef(x/100.0, y/100.0, 0); - glRotateZi(angle); - glTranslatef(-x/100.0, -y/100.0, 0); - } - - glBindTexture(0, textures[tex]); - - if (textureInfo[tex].palette >= 0) - glColorTable(textureInfo[tex].format, textureInfo[tex].palette); - - glBegin(GL_QUADS); - - GFX_TEX_COORD = uv[0]; - glVertex2lu1f(x1, y1, z); - - GFX_TEX_COORD = uv[1]; - glVertex2lu1f(x2, y1, z); - - GFX_TEX_COORD = uv[2]; - glVertex2lu1f(x2, y2, z); - - GFX_TEX_COORD = uv[3]; - glVertex2lu1f(x1, y2, z); - - glEnd(); - - glPopMatrix(1); -} - -s32 GraphicsManager::ForceBounds(s32 value) -{ - if (value < -200) - return -200; - - if (value > 799) - return 799; - - return value; -} - diff --git a/arm9/data/sounds/normal_hitclap.bin b/data/sounds/normal_hitclap.bin similarity index 100% rename from arm9/data/sounds/normal_hitclap.bin rename to data/sounds/normal_hitclap.bin diff --git a/arm9/data/sounds/normal_hitfinish.bin b/data/sounds/normal_hitfinish.bin similarity index 100% rename from arm9/data/sounds/normal_hitfinish.bin rename to data/sounds/normal_hitfinish.bin diff --git a/arm9/data/sounds/normal_hitnormal.bin b/data/sounds/normal_hitnormal.bin similarity index 100% rename from arm9/data/sounds/normal_hitnormal.bin rename to data/sounds/normal_hitnormal.bin diff --git a/arm9/data/sounds/normal_hitwhistle.bin b/data/sounds/normal_hitwhistle.bin similarity index 100% rename from arm9/data/sounds/normal_hitwhistle.bin rename to data/sounds/normal_hitwhistle.bin diff --git a/arm9/data/sounds/normal_sliderslide.bin b/data/sounds/normal_sliderslide.bin similarity index 100% rename from arm9/data/sounds/normal_sliderslide.bin rename to data/sounds/normal_sliderslide.bin diff --git a/arm9/data/sounds/normal_slidertick.bin b/data/sounds/normal_slidertick.bin similarity index 100% rename from arm9/data/sounds/normal_slidertick.bin rename to data/sounds/normal_slidertick.bin diff --git a/arm9/data/sounds/normal_sliderwhistle.bin b/data/sounds/normal_sliderwhistle.bin similarity index 100% rename from arm9/data/sounds/normal_sliderwhistle.bin rename to data/sounds/normal_sliderwhistle.bin diff --git a/arm9/data/sounds/soft_hitclap.bin b/data/sounds/soft_hitclap.bin similarity index 100% rename from arm9/data/sounds/soft_hitclap.bin rename to data/sounds/soft_hitclap.bin diff --git a/arm9/data/sounds/soft_hitfinish.bin b/data/sounds/soft_hitfinish.bin similarity index 100% rename from arm9/data/sounds/soft_hitfinish.bin rename to data/sounds/soft_hitfinish.bin diff --git a/arm9/data/sounds/soft_hitnormal.bin b/data/sounds/soft_hitnormal.bin similarity index 100% rename from arm9/data/sounds/soft_hitnormal.bin rename to data/sounds/soft_hitnormal.bin diff --git a/arm9/data/sounds/soft_hitwhistle.bin b/data/sounds/soft_hitwhistle.bin similarity index 100% rename from arm9/data/sounds/soft_hitwhistle.bin rename to data/sounds/soft_hitwhistle.bin diff --git a/arm9/data/sounds/soft_sliderslide.bin b/data/sounds/soft_sliderslide.bin similarity index 100% rename from arm9/data/sounds/soft_sliderslide.bin rename to data/sounds/soft_sliderslide.bin diff --git a/arm9/data/sounds/soft_slidertick.bin b/data/sounds/soft_slidertick.bin similarity index 100% rename from arm9/data/sounds/soft_slidertick.bin rename to data/sounds/soft_slidertick.bin diff --git a/arm9/data/sounds/soft_sliderwhistle.bin b/data/sounds/soft_sliderwhistle.bin similarity index 100% rename from arm9/data/sounds/soft_sliderwhistle.bin rename to data/sounds/soft_sliderwhistle.bin diff --git a/arm9/data/sounds/spinnerbonus.bin b/data/sounds/spinnerbonus.bin similarity index 100% rename from arm9/data/sounds/spinnerbonus.bin rename to data/sounds/spinnerbonus.bin diff --git a/arm9/data/sounds/spinnerspin.bin b/data/sounds/spinnerspin.bin similarity index 100% rename from arm9/data/sounds/spinnerspin.bin rename to data/sounds/spinnerspin.bin diff --git a/arm9/data/textures/circle.bin b/data/textures/circle.bin similarity index 100% rename from arm9/data/textures/circle.bin rename to data/textures/circle.bin diff --git a/arm9/data/textures/circleapproach.bin b/data/textures/circleapproach.bin similarity index 100% rename from arm9/data/textures/circleapproach.bin rename to data/textures/circleapproach.bin diff --git a/arm9/data/textures/circleoverlay.bin b/data/textures/circleoverlay.bin similarity index 100% rename from arm9/data/textures/circleoverlay.bin rename to data/textures/circleoverlay.bin diff --git a/arm9/data/textures/disc.bin b/data/textures/disc.bin similarity index 100% rename from arm9/data/textures/disc.bin rename to data/textures/disc.bin diff --git a/arm9/data/textures/hit0.bin b/data/textures/hit0.bin similarity index 100% rename from arm9/data/textures/hit0.bin rename to data/textures/hit0.bin diff --git a/arm9/data/textures/hit100.bin b/data/textures/hit100.bin similarity index 100% rename from arm9/data/textures/hit100.bin rename to data/textures/hit100.bin diff --git a/arm9/data/textures/hit100k.bin b/data/textures/hit100k.bin similarity index 100% rename from arm9/data/textures/hit100k.bin rename to data/textures/hit100k.bin diff --git a/arm9/data/textures/hit300.bin b/data/textures/hit300.bin similarity index 100% rename from arm9/data/textures/hit300.bin rename to data/textures/hit300.bin diff --git a/arm9/data/textures/hit300g.bin b/data/textures/hit300g.bin similarity index 100% rename from arm9/data/textures/hit300g.bin rename to data/textures/hit300g.bin diff --git a/arm9/data/textures/hit300k.bin b/data/textures/hit300k.bin similarity index 100% rename from arm9/data/textures/hit300k.bin rename to data/textures/hit300k.bin diff --git a/arm9/data/textures/hit50.bin b/data/textures/hit50.bin similarity index 100% rename from arm9/data/textures/hit50.bin rename to data/textures/hit50.bin diff --git a/arm9/data/textures/scorebar.bin b/data/textures/scorebar.bin similarity index 100% rename from arm9/data/textures/scorebar.bin rename to data/textures/scorebar.bin diff --git a/arm9/data/textures/scorebar_colour.bin b/data/textures/scorebar_colour.bin similarity index 100% rename from arm9/data/textures/scorebar_colour.bin rename to data/textures/scorebar_colour.bin diff --git a/arm9/data/textures/scorebar_ki.bin b/data/textures/scorebar_ki.bin similarity index 100% rename from arm9/data/textures/scorebar_ki.bin rename to data/textures/scorebar_ki.bin diff --git a/arm9/data/textures/scorebar_kidanger.bin b/data/textures/scorebar_kidanger.bin similarity index 100% rename from arm9/data/textures/scorebar_kidanger.bin rename to data/textures/scorebar_kidanger.bin diff --git a/arm9/data/textures/scorebar_kidanger2.bin b/data/textures/scorebar_kidanger2.bin similarity index 100% rename from arm9/data/textures/scorebar_kidanger2.bin rename to data/textures/scorebar_kidanger2.bin diff --git a/arm9/data/textures/slider10.bin b/data/textures/slider10.bin similarity index 100% rename from arm9/data/textures/slider10.bin rename to data/textures/slider10.bin diff --git a/arm9/data/textures/slider30.bin b/data/textures/slider30.bin similarity index 100% rename from arm9/data/textures/slider30.bin rename to data/textures/slider30.bin diff --git a/arm9/data/textures/sliderb0.bin b/data/textures/sliderb0.bin similarity index 100% rename from arm9/data/textures/sliderb0.bin rename to data/textures/sliderb0.bin diff --git a/arm9/data/textures/sliderb1.bin b/data/textures/sliderb1.bin similarity index 100% rename from arm9/data/textures/sliderb1.bin rename to data/textures/sliderb1.bin diff --git a/arm9/data/textures/sliderb2.bin b/data/textures/sliderb2.bin similarity index 100% rename from arm9/data/textures/sliderb2.bin rename to data/textures/sliderb2.bin diff --git a/arm9/data/textures/sliderb3.bin b/data/textures/sliderb3.bin similarity index 100% rename from arm9/data/textures/sliderb3.bin rename to data/textures/sliderb3.bin diff --git a/arm9/data/textures/sliderb4.bin b/data/textures/sliderb4.bin similarity index 100% rename from arm9/data/textures/sliderb4.bin rename to data/textures/sliderb4.bin diff --git a/arm9/data/textures/sliderb5.bin b/data/textures/sliderb5.bin similarity index 100% rename from arm9/data/textures/sliderb5.bin rename to data/textures/sliderb5.bin diff --git a/arm9/data/textures/sliderb6.bin b/data/textures/sliderb6.bin similarity index 100% rename from arm9/data/textures/sliderb6.bin rename to data/textures/sliderb6.bin diff --git a/arm9/data/textures/sliderb7.bin b/data/textures/sliderb7.bin similarity index 100% rename from arm9/data/textures/sliderb7.bin rename to data/textures/sliderb7.bin diff --git a/arm9/data/textures/sliderb8.bin b/data/textures/sliderb8.bin similarity index 100% rename from arm9/data/textures/sliderb8.bin rename to data/textures/sliderb8.bin diff --git a/arm9/data/textures/sliderb9.bin b/data/textures/sliderb9.bin similarity index 100% rename from arm9/data/textures/sliderb9.bin rename to data/textures/sliderb9.bin diff --git a/arm9/data/textures/sliderfollow.bin b/data/textures/sliderfollow.bin similarity index 100% rename from arm9/data/textures/sliderfollow.bin rename to data/textures/sliderfollow.bin diff --git a/arm9/data/textures/sliderreverse.bin b/data/textures/sliderreverse.bin similarity index 100% rename from arm9/data/textures/sliderreverse.bin rename to data/textures/sliderreverse.bin diff --git a/arm9/data/textures/slidertick.bin b/data/textures/slidertick.bin similarity index 100% rename from arm9/data/textures/slidertick.bin rename to data/textures/slidertick.bin diff --git a/arm9/data/textures/spinner.bin b/data/textures/spinner.bin similarity index 100% rename from arm9/data/textures/spinner.bin rename to data/textures/spinner.bin diff --git a/arm9/data/textures/spinnerbars.bin b/data/textures/spinnerbars.bin similarity index 100% rename from arm9/data/textures/spinnerbars.bin rename to data/textures/spinnerbars.bin diff --git a/arm9/data/textures/spinnerbg.bin b/data/textures/spinnerbg.bin similarity index 100% rename from arm9/data/textures/spinnerbg.bin rename to data/textures/spinnerbg.bin diff --git a/arm9/data/textures/verdana9.bin b/data/textures/verdana9.bin similarity index 100% rename from arm9/data/textures/verdana9.bin rename to data/textures/verdana9.bin diff --git a/arm9/data/textures/white.bin b/data/textures/white.bin similarity index 100% rename from arm9/data/textures/white.bin rename to data/textures/white.bin diff --git a/arm9/fonts/370.bmf b/fonts/370.bmf similarity index 100% rename from arm9/fonts/370.bmf rename to fonts/370.bmf diff --git a/arm9/fonts/4x6_a.bmf b/fonts/4x6_a.bmf similarity index 100% rename from arm9/fonts/4x6_a.bmf rename to fonts/4x6_a.bmf diff --git a/arm9/fonts/gomics.bmf b/fonts/gomics.bmf similarity index 100% rename from arm9/fonts/gomics.bmf rename to fonts/gomics.bmf diff --git a/arm9/fonts/hoo06.bmf b/fonts/hoo06.bmf similarity index 100% rename from arm9/fonts/hoo06.bmf rename to fonts/hoo06.bmf diff --git a/arm9/fonts/ver08.bmf b/fonts/ver08.bmf similarity index 100% rename from arm9/fonts/ver08.bmf rename to fonts/ver08.bmf diff --git a/osuds.pnproj b/osuds.pnproj deleted file mode 100644 index c073665..0000000 --- a/osuds.pnproj +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/osuds.pnps b/osuds.pnps deleted file mode 100644 index c1e00ba..0000000 --- a/osuds.pnps +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/osuds.ppg b/osuds.ppg deleted file mode 100644 index 9a1da20..0000000 --- a/osuds.ppg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/arm9/source/Beatmaps/Beatmap.cpp b/source/Beatmaps/Beatmap.cpp similarity index 95% rename from arm9/source/Beatmaps/Beatmap.cpp rename to source/Beatmaps/Beatmap.cpp index a6f4744..f706eed 100644 --- a/arm9/source/Beatmaps/Beatmap.cpp +++ b/source/Beatmaps/Beatmap.cpp @@ -1,238 +1,245 @@ -#include "Beatmap.h" - -Beatmap::Beatmap(const char* filename, const char* basedir) -{ - fLoadable = false; - - mFilename = filename; - mBaseDir = basedir; - mReader = NULL; - - FileReader r(filename); - - if (r.Ready()) - { - //check header before processing - char id[4] = { r.ReadInt8(), r.ReadInt8(), r.ReadInt8(), 0 }; - if (strcmp(id, "ODS") == 0) - { - u8 odsver = r.ReadInt8(); - - mTitle = r.ReadString(); - mArtist = r.ReadString(); - mCreator = r.ReadString(); - mVersion = r.ReadString(); - mAudioFilename = r.ReadString(); - - fLoadable = true; - } - } - - fReady = false; -} - -void Beatmap::Initialize() -{ - if (!fReady) - { - if (!fLoadable) - { - iprintf("\x1b[0;0Hcannot load this file"); - return; - } - - chdir(mBaseDir.c_str()); - mReader = new FileReader(mFilename); - - //skip header - mReader->Skip(3); - - u8 odsver = mReader->ReadInt8(); - - mTitle = mReader->ReadString(); - mArtist = mReader->ReadString(); - mCreator = mReader->ReadString(); - mVersion = mReader->ReadString(); - mAudioFilename = mReader->ReadString(); - - DifficultyManager::DifficultyHpDrain = mReader->ReadInt8(); - DifficultyManager::DifficultyCircleSize = mReader->ReadInt8(); - DifficultyManager::DifficultyOverall = mReader->ReadInt8(); - DifficultyManager::SliderMultiplier = mReader->ReadFloat(); - DifficultyManager::SliderTickRate = mReader->ReadFloat(); - DifficultyManager::DifficultyHpDrainRate = mReader->ReadFloat(); - DifficultyManager::DifficultyPeppyStars = mReader->ReadInt8(); - DifficultyManager::DifficultyEyupStars = mReader->ReadFloat(); - - u32 tpointcount = mReader->ReadVarInt(); - for (u32 j=0; jReadInt32(); - float beattime = mReader->ReadFloat(); - u8 samplesetid = mReader->ReadInt8(); - - BeatmapElements::Element().AddTimingPoint(time, beattime, samplesetid); - } - - u32 breakcount = mReader->ReadVarInt(); - for (u32 j=0; jReadInt32(); - s32 endtime = mReader->ReadInt32(); - - BeatmapElements::Element().AddBreakPoint(starttime, endtime); - } - - iprintf("\x1b[2J"); - mHitObjectCount = mReader->ReadVarInt(); - mHitObjectRead = 0; - mLastObjectEndTime = 0; - mForceNewCombo = true; - - //read ahead - ReadNextObject(); - mFirstObjectTime = mNextObjectTime; - - //the time to skip to is the first object - 8 beats - mSkipTime = MathHelper::Max(0, (s32)mNextObjectTime - (BeatmapElements::Element().GetTimingPoint(mNextObjectTime).BeatTime*8)); - - //strangely calling this in ctor of BeatmapElements causes game to not load :/ - BeatmapElements::Element().ResetColours(true); - - //now we can play this map - fReady = true; - } -} - -void Beatmap::CleanUp() -{ - //set object back to uninitialised state - fReady = false; - - if (mReader != NULL) - delete mReader; - mReader = NULL; -} - -Beatmap::~Beatmap() -{ - if (mReader != NULL) - delete mReader; -} - -void Beatmap::Buffer(list& hitObjectList) -{ - if (!fReady) - { - iprintf("\x1b[0;0Hnot ready to buffer"); - return; - } - - //we buffer objects to 10 seconds ahead - while (mHitObjectRead < mHitObjectCount && mNextObjectTime < GameClock::Clock().Time() + 3000) - { - HitObject* object; - - //all coordinates are s16 in file but s32 in RAM - - HitObjectType type = mNextObjectType; - s32 x = mNextObjectX; - s32 y = mNextObjectY; - HitObjectSound sound = (HitObjectSound)mReader->ReadInt8(); - - if (mForceNewCombo) - { - type = (HitObjectType)(type|HIT_COMBO); - mForceNewCombo = false; - } - - switch (type & ~HIT_COMBO) //ignore HIT_COMBO - { - case HIT_NORMAL: - { - object = new HitCircle(x, y, mNextObjectTime, type, sound); - break; - } - - case HIT_SLIDER: - { - u32 repeats = mReader->ReadInt16(); - u32 lengthtime = mReader->ReadInt32(); - - u32 pointcount = mReader->ReadVarInt(); - vector points; - points.reserve(pointcount); - - for (u32 i=0; ix = (s16)mReader->ReadInt16(); //s32 x - tPoint->y = (s16)mReader->ReadInt16(); //s32 y - tPoint->angle = mReader->ReadInt32(); //s32 angle - - points.push_back(tPoint); - } - - u32 tickcount = mReader->ReadVarInt(); - vector ticks; - ticks.reserve(tickcount); - - for (u32 i=0; ix = (s16)mReader->ReadInt16(); //s32 x - tPoint->y = (s16)mReader->ReadInt16(); //s32 y - - ticks.push_back(tPoint); - } - - object = new HitSlider(x, y, mNextObjectTime, lengthtime, points, ticks, repeats, type, sound); - - //free allocated memory - for (u32 i=0; iReadInt32(); - object = new HitSpinner(mNextObjectTime, endtime, sound); - mForceNewCombo = true; - break; - } - } - - //track when the beatmap has ended - mLastObjectEndTime = object->GetEndTime(); - - //add to list - hitObjectList.push_back(object); - - ++mHitObjectRead; - if (mHitObjectRead < mHitObjectCount) - { - ReadNextObject(); - object->SetPostCreateOptions((mNextObjectType & HIT_COMBO) | mForceNewCombo, mNextObjectX, mNextObjectY); - } - else - { - object->SetPostCreateOptions(true, 0, 0); - } - } -} - -void Beatmap::ReadNextObject() -{ - mNextObjectTime = mReader->ReadInt32(); - mNextObjectType = (HitObjectType)mReader->ReadInt8(); - mNextObjectX = (s16)mReader->ReadInt16(); - mNextObjectY = (s16)mReader->ReadInt16(); -} - - - +#include "Beatmap.h" + +Beatmap::Beatmap(const char* filename, const char* basedir) +{ + fLoadable = false; + + mFilename = filename; + mBaseDir = basedir; + mReader = NULL; + + FileReader r(filename); + + if (r.Ready()) + { + //check header before processing + char id[4] = { r.ReadInt8(), r.ReadInt8(), r.ReadInt8(), 0 }; + if (strcmp(id, "ODS") == 0) + { + u8 odsver = r.ReadInt8(); + + mTitle = r.ReadString(); + mArtist = r.ReadString(); + mCreator = r.ReadString(); + mVersion = r.ReadString(); + mAudioFilename = r.ReadString(); + + fLoadable = true; + } + } + + fReady = false; +} + +void Beatmap::Initialize() +{ + if (!fReady) + { + if (!fLoadable) + { + iprintf("\x1b[0;0Hcannot load this file"); + return; + } + + chdir(mBaseDir.c_str()); + mReader = new FileReader(mFilename); + + //skip header + mReader->Skip(3); + + u8 odsver = mReader->ReadInt8(); + + mTitle = mReader->ReadString(); + mArtist = mReader->ReadString(); + mCreator = mReader->ReadString(); + mVersion = mReader->ReadString(); + mAudioFilename = mReader->ReadString(); + nocashMessage(mAudioFilename.c_str()); + + DifficultyManager::DifficultyHpDrain = mReader->ReadInt8(); + DifficultyManager::DifficultyCircleSize = mReader->ReadInt8(); + DifficultyManager::DifficultyOverall = mReader->ReadInt8(); + DifficultyManager::SliderMultiplier = mReader->ReadFloat(); + DifficultyManager::SliderTickRate = mReader->ReadFloat(); + DifficultyManager::DifficultyHpDrainRate = mReader->ReadFloat(); + DifficultyManager::DifficultyPeppyStars = mReader->ReadInt8(); + DifficultyManager::DifficultyEyupStars = mReader->ReadFloat(); + + u32 tpointcount = mReader->ReadVarInt(); + for (u32 j=0; jReadInt32(); + float beattime = mReader->ReadFloat(); + u8 samplesetid = mReader->ReadInt8(); + + BeatmapElements::Element().AddTimingPoint(time, beattime, samplesetid); + } + + nocashMessage("hio\n"); + + u32 breakcount = mReader->ReadVarInt(); + nocashMessage(std::to_string(breakcount).c_str()); + for (u32 j=0; jReadInt32(); + s32 endtime = mReader->ReadInt32(); + + BeatmapElements::Element().AddBreakPoint(starttime, endtime); + } + + nocashMessage("hio\n"); + + iprintf("\x1b[2J"); + mHitObjectCount = mReader->ReadVarInt(); + mHitObjectRead = 0; + mLastObjectEndTime = 0; + mForceNewCombo = true; + + //read ahead + ReadNextObject(); + mFirstObjectTime = mNextObjectTime; + + //the time to skip to is the first object - 8 beats + mSkipTime = MathHelper::Max(0, (s32)mNextObjectTime - (BeatmapElements::Element().GetTimingPoint(mNextObjectTime).BeatTime*8)); + + //strangely calling this in ctor of BeatmapElements causes game to not load :/ + BeatmapElements::Element().ResetColours(true); + + //now we can play this map + fReady = true; + } +} + +void Beatmap::CleanUp() +{ + //set object back to uninitialised state + fReady = false; + + if (mReader != NULL) + delete mReader; + mReader = NULL; +} + +Beatmap::~Beatmap() +{ + if (mReader != NULL) + delete mReader; +} + +void Beatmap::Buffer(list& hitObjectList) +{ + if (!fReady) + { + iprintf("\x1b[0;0Hnot ready to buffer"); + return; + } + + //we buffer objects to 10 seconds ahead + while (mHitObjectRead < mHitObjectCount && mNextObjectTime < GameClock::Clock().Time() + 3000) + { + HitObject* object; + + //all coordinates are s16 in file but s32 in RAM + + HitObjectType type = mNextObjectType; + s32 x = mNextObjectX; + s32 y = mNextObjectY; + HitObjectSound sound = (HitObjectSound)mReader->ReadInt8(); + + if (mForceNewCombo) + { + type = (HitObjectType)(type|HIT_COMBO); + mForceNewCombo = false; + } + + switch (type & ~HIT_COMBO) //ignore HIT_COMBO + { + case HIT_NORMAL: + { + object = new HitCircle(x, y, mNextObjectTime, type, sound); + break; + } + + case HIT_SLIDER: + { + u32 repeats = mReader->ReadInt16(); + u32 lengthtime = mReader->ReadInt32(); + + u32 pointcount = mReader->ReadVarInt(); + vector points; + points.reserve(pointcount); + + for (u32 i=0; ix = (s16)mReader->ReadInt16(); //s32 x + tPoint->y = (s16)mReader->ReadInt16(); //s32 y + tPoint->angle = mReader->ReadInt32(); //s32 angle + + points.push_back(tPoint); + } + + u32 tickcount = mReader->ReadVarInt(); + vector ticks; + ticks.reserve(tickcount); + + for (u32 i=0; ix = (s16)mReader->ReadInt16(); //s32 x + tPoint->y = (s16)mReader->ReadInt16(); //s32 y + + + ticks.push_back(tPoint); + } + + object = new HitSlider(x, y, mNextObjectTime, lengthtime, points, ticks, repeats, type, sound); + + //free allocated memory + for (u32 i=0; iReadInt32(); + object = new HitSpinner(mNextObjectTime, endtime, sound); + mForceNewCombo = true; + break; + } + } + + //track when the beatmap has ended + mLastObjectEndTime = object->GetEndTime(); + + //add to list + hitObjectList.push_back(object); + + ++mHitObjectRead; + if (mHitObjectRead < mHitObjectCount) + { + ReadNextObject(); + object->SetPostCreateOptions((mNextObjectType & HIT_COMBO) | mForceNewCombo, mNextObjectX, mNextObjectY); + } + else + { + object->SetPostCreateOptions(true, 0, 0); + } + } +} + +void Beatmap::ReadNextObject() +{ + mNextObjectTime = mReader->ReadInt32(); + mNextObjectType = (HitObjectType)mReader->ReadInt8(); + mNextObjectX = (s16)mReader->ReadInt16(); + mNextObjectY = (s16)mReader->ReadInt16(); +} + + + diff --git a/arm9/source/Beatmaps/Beatmap.h b/source/Beatmaps/Beatmap.h similarity index 95% rename from arm9/source/Beatmaps/Beatmap.h rename to source/Beatmaps/Beatmap.h index d7489b8..25e35ab 100644 --- a/arm9/source/Beatmaps/Beatmap.h +++ b/source/Beatmaps/Beatmap.h @@ -1,79 +1,79 @@ -#include -#include -#include -#include -#include -#include - -#include "BeatmapElements.h" - -#include "System/GameClock.h" -#include "Helpers/FileReader.h" -#include "Helpers/MathHelper.h" - -#include "HitObjects/HitObject.h" -#include "HitObjects/HitCircle.h" -#include "HitObjects/HitSlider.h" -#include "HitObjects/HitSpinner.h" - -#include "Graphics/SpriteManager.h" - -#ifndef __BEATMAP_H__ -#define __BEATMAP_H__ - -using namespace std; - -//typedef list::iterator hitObjectIterator; - -class Beatmap -{ - public: - Beatmap(const char* filename, const char* basedir); - virtual ~Beatmap(); - - void Initialize(); - void CleanUp(); - - void Buffer(list& hitObjectList); - bool GameOver() { return mHitObjectRead == mHitObjectCount && GameClock::Clock().Time() >= mLastObjectEndTime + 3000; } - - string& Filename() { return mFilename; } - string& Title() { return mTitle; } - string& Artist() { return mArtist; } - string& Creator() { return mCreator; } - string& Version() { return mVersion; } - string& AudioFilename() { return mAudioFilename; } - - string& BaseDir() { return mBaseDir; } - - s32 SkipTime() { return mSkipTime; } - s32 StartTime() { return mFirstObjectTime; } - - protected: - FileReader* mReader; - - u32 mHitObjectCount, mHitObjectRead; - s32 mFirstObjectTime, mLastObjectEndTime; - - void ReadNextObject(); - s32 mNextObjectTime; - s32 mNextObjectX, mNextObjectY; - HitObjectType mNextObjectType; - - s32 mSkipTime; - bool mForceNewCombo; - - bool fReady, fLoadable; - - string mFilename; - string mTitle; - string mArtist; - string mCreator; - string mVersion; - string mAudioFilename; - - string mBaseDir; -}; - -#endif - +#include +#include +#include +#include +#include +#include + +#include "BeatmapElements.h" + +#include "System/GameClock.h" +#include "Helpers/FileReader.h" +#include "Helpers/MathHelper.h" + +#include "HitObjects/HitObject.h" +#include "HitObjects/HitCircle.h" +#include "HitObjects/HitSlider.h" +#include "HitObjects/HitSpinner.h" + +#include "Graphics/SpriteManager.h" + +#ifndef __BEATMAP_H__ +#define __BEATMAP_H__ + +using namespace std; + +//typedef list::iterator hitObjectIterator; + +class Beatmap +{ + public: + Beatmap(const char* filename, const char* basedir); + virtual ~Beatmap(); + + void Initialize(); + void CleanUp(); + + void Buffer(list& hitObjectList); + bool GameOver() { return mHitObjectRead == mHitObjectCount && GameClock::Clock().Time() >= mLastObjectEndTime + 3000; } + + string& Filename() { return mFilename; } + string& Title() { return mTitle; } + string& Artist() { return mArtist; } + string& Creator() { return mCreator; } + string& Version() { return mVersion; } + string& AudioFilename() { return mAudioFilename; } + + string& BaseDir() { return mBaseDir; } + + s32 SkipTime() { return mSkipTime; } + s32 StartTime() { return mFirstObjectTime; } + + protected: + FileReader* mReader; + + u32 mHitObjectCount, mHitObjectRead; + s32 mFirstObjectTime, mLastObjectEndTime; + + void ReadNextObject(); + s32 mNextObjectTime; + s32 mNextObjectX, mNextObjectY; + HitObjectType mNextObjectType; + + s32 mSkipTime; + bool mForceNewCombo; + + bool fReady, fLoadable; + + string mFilename; + string mTitle; + string mArtist; + string mCreator; + string mVersion; + string mAudioFilename; + + string mBaseDir; +}; + +#endif + diff --git a/arm9/source/Beatmaps/BeatmapElements.cpp b/source/Beatmaps/BeatmapElements.cpp similarity index 94% rename from arm9/source/Beatmaps/BeatmapElements.cpp rename to source/Beatmaps/BeatmapElements.cpp index 2798a20..4e79bdb 100644 --- a/arm9/source/Beatmaps/BeatmapElements.cpp +++ b/source/Beatmaps/BeatmapElements.cpp @@ -1,82 +1,82 @@ -#include "BeatmapElements.h" - -BeatmapElements BeatmapElements::sInstance; - -const TimingPoint& BeatmapElements::GetTimingPoint(s32 time) -{ -/* - u32 i; - for (i=0; i time) - break; - } - return mTimingPoints[MathHelper::Max(i-1, 0)]; -*/ - u32 i; - for ( - i = mTimingPoints.size() - 1; - i > 0 && mTimingPoints[i].Time > time; - --i - ); - return mTimingPoints[i]; -} - -const TimingPoint& BeatmapElements::GetTimingPoint() -{ - return GetTimingPoint(GameClock::Clock().Time()); -} - -const bool BeatmapElements::IsBreak() -{ - for (u32 i=0; i mBreakPoints[i].StartTime && GameClock::Clock().Time() < mBreakPoints[i].EndTime) - return true; - } - return false; -} - -rgb BeatmapElements::GetNextColour() -{ - //backwards compatibility - increase counter BEFORE returning - if (++mCurrentColour >= mColours.size()) - mCurrentColour = 0; - - return mColours[mCurrentColour]; -} - -void BeatmapElements::AddTimingPoint(s32 time, float beattime, u8 samplesetid) -{ - TimingPoint tPoint = { - time, - beattime, - samplesetid - }; - - mTimingPoints.push_back(tPoint); -} - -void BeatmapElements::AddBreakPoint(s32 start, s32 end) -{ - BreakPoint bPoint = { - start, - end - }; - - mBreakPoints.push_back(bPoint); -} - -void BeatmapElements::ResetColours(bool fill) -{ - mColours.clear(); - mCurrentColour = 0; - - if (fill) - { - mColours.push_back(RGB15(31,18,0)); - mColours.push_back(RGB15(1,30,1)); - mColours.push_back(RGB15(1,1,30)); - mColours.push_back(RGB15(30,1,1)); - } -} +#include "BeatmapElements.h" + +BeatmapElements BeatmapElements::sInstance; + +const TimingPoint& BeatmapElements::GetTimingPoint(s32 time) +{ +/* + u32 i; + for (i=0; i time) + break; + } + return mTimingPoints[MathHelper::Max(i-1, 0)]; +*/ + u32 i; + for ( + i = mTimingPoints.size() - 1; + i > 0 && mTimingPoints[i].Time > time; + --i + ); + return mTimingPoints[i]; +} + +const TimingPoint& BeatmapElements::GetTimingPoint() +{ + return GetTimingPoint(GameClock::Clock().Time()); +} + +const bool BeatmapElements::IsBreak() +{ + for (u32 i=0; i mBreakPoints[i].StartTime && GameClock::Clock().Time() < mBreakPoints[i].EndTime) + return true; + } + return false; +} + +rgb BeatmapElements::GetNextColour() +{ + //backwards compatibility - increase counter BEFORE returning + if (++mCurrentColour >= mColours.size()) + mCurrentColour = 0; + + return mColours[mCurrentColour]; +} + +void BeatmapElements::AddTimingPoint(s32 time, float beattime, u8 samplesetid) +{ + TimingPoint tPoint = { + time, + beattime, + samplesetid + }; + + mTimingPoints.push_back(tPoint); +} + +void BeatmapElements::AddBreakPoint(s32 start, s32 end) +{ + BreakPoint bPoint = { + start, + end + }; + + mBreakPoints.push_back(bPoint); +} + +void BeatmapElements::ResetColours(bool fill) +{ + mColours.clear(); + mCurrentColour = 0; + + if (fill) + { + mColours.push_back(RGB15(31,18,0)); + mColours.push_back(RGB15(1,30,1)); + mColours.push_back(RGB15(1,1,30)); + mColours.push_back(RGB15(30,1,1)); + } +} diff --git a/arm9/source/Beatmaps/BeatmapElements.h b/source/Beatmaps/BeatmapElements.h similarity index 94% rename from arm9/source/Beatmaps/BeatmapElements.h rename to source/Beatmaps/BeatmapElements.h index a13a625..003f67e 100644 --- a/arm9/source/Beatmaps/BeatmapElements.h +++ b/source/Beatmaps/BeatmapElements.h @@ -1,53 +1,53 @@ -#include -#include - -#include "Helpers/MathHelper.h" -#include "System/GameClock.h" - -#ifndef __BEATMAPELEMENTS_H__ -#define __BEATMAPELEMENTS_H__ - -using namespace std; - -typedef struct { - s32 Time; - float BeatTime; - u8 SampleSetId; -} TimingPoint; - -typedef struct { - s32 StartTime; - s32 EndTime; -} BreakPoint; - -class BeatmapElements -{ - public: - static BeatmapElements& Element() { return sInstance; } - - const TimingPoint& GetTimingPoint(s32 time); - const TimingPoint& GetTimingPoint(); - - const bool IsBreak(); - - rgb GetNextColour(); - - void AddTimingPoint(s32 time, float beattime, u8 samplesetid); - void AddBreakPoint(s32 start, s32 end); - void ResetColours(bool fill); - - protected: - static BeatmapElements sInstance; - - vector mTimingPoints; - vector mBreakPoints; - vector mColours; - u32 mCurrentColour; - - private: - BeatmapElements() {} - ~BeatmapElements() {} -}; - -#endif - +#include +#include + +#include "Helpers/MathHelper.h" +#include "System/GameClock.h" + +#ifndef __BEATMAPELEMENTS_H__ +#define __BEATMAPELEMENTS_H__ + +using namespace std; + +typedef struct { + s32 Time; + float BeatTime; + u8 SampleSetId; +} TimingPoint; + +typedef struct { + s32 StartTime; + s32 EndTime; +} BreakPoint; + +class BeatmapElements +{ + public: + static BeatmapElements& Element() { return sInstance; } + + const TimingPoint& GetTimingPoint(s32 time); + const TimingPoint& GetTimingPoint(); + + const bool IsBreak(); + + rgb GetNextColour(); + + void AddTimingPoint(s32 time, float beattime, u8 samplesetid); + void AddBreakPoint(s32 start, s32 end); + void ResetColours(bool fill); + + protected: + static BeatmapElements sInstance; + + vector mTimingPoints; + vector mBreakPoints; + vector mColours; + u32 mCurrentColour; + + private: + BeatmapElements() {} + ~BeatmapElements() {} +}; + +#endif + diff --git a/arm9/source/Beatmaps/BeatmapManager.cpp b/source/Beatmaps/BeatmapManager.cpp similarity index 89% rename from arm9/source/Beatmaps/BeatmapManager.cpp rename to source/Beatmaps/BeatmapManager.cpp index 9e51d62..201cd12 100644 --- a/arm9/source/Beatmaps/BeatmapManager.cpp +++ b/source/Beatmaps/BeatmapManager.cpp @@ -1,82 +1,84 @@ -#include "BeatmapManager.h" - -Beatmap* BeatmapManager::mBeatmapCurrent = NULL; -vector BeatmapManager::mBeatmaps; - -void BeatmapManager::Load(u32 index) -{ - if (mBeatmapCurrent != NULL) - mBeatmapCurrent->CleanUp(); - - Mode::ChangeToOsuDir(); - mBeatmapCurrent = mBeatmaps[index]; - mBeatmapCurrent->Initialize(); -} - -void BeatmapManager::BuildCollection() -{ - Mode::ChangeToOsuDir(); - - DIR* dir = opendir("."); - struct dirent* entry; - - while ((entry = readdir(dir)) != NULL) - { - //ignore generic names - //if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) - if (entry->d_name[0] == '.') - continue; - - chdir(entry->d_name); - DIR* subdir = opendir("."); - - //if this is a folder, find all the .ods files inside - if (subdir != NULL) - { - struct dirent* subentry; - - while ((subentry = readdir(subdir)) != NULL) - { - DIR* filetest = opendir(subentry->d_name); - - if (filetest == NULL) - { - char* ext = subentry->d_name; - - int length = strlen(ext); - if (length < 4) - continue; - - //ext is now the extension of the current file - ext += length - 4; - - //if we have on our hands a .ods file, add it to our collection - if (strcmp(ext, ".ods") == 0) - { - mBeatmaps.push_back(new Beatmap(subentry->d_name, entry->d_name)); - } - } - else - { - closedir(filetest); - } - } - } - - closedir(subdir); - chdir(".."); - } - - closedir(dir); -} - -u32 BeatmapManager::MapCount() -{ - return 8;//mBeatmaps.size(); -} - -u32 BeatmapManager::SongCount() -{ - //TODO: algorithm plz - return mBeatmaps.size(); +#include "BeatmapManager.h" + +Beatmap* BeatmapManager::mBeatmapCurrent = NULL; +vector BeatmapManager::mBeatmaps; + +void BeatmapManager::Load(u32 index) +{ + if (mBeatmapCurrent != NULL) + mBeatmapCurrent->CleanUp(); + + Mode::ChangeToOsuDir(); + mBeatmapCurrent = mBeatmaps[index]; + mBeatmapCurrent->Initialize(); +} + +void BeatmapManager::BuildCollection() +{ + Mode::ChangeToOsuDir(); + + DIR* dir = opendir("."); + struct dirent* entry; + + while ((entry = readdir(dir)) != NULL) + { + //ignore generic names + //if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + if (entry->d_name[0] == '.') + continue; + + chdir(entry->d_name); + DIR* subdir = opendir("."); + + //if this is a folder, find all the .ods files inside + if (subdir != NULL) + { + struct dirent* subentry; + + while ((subentry = readdir(subdir)) != NULL) + { + DIR* filetest = opendir(subentry->d_name); + + if (filetest == NULL) + { + char* ext = subentry->d_name; + + int length = strlen(ext); + if (length < 4) + continue; + + nocashMessage(ext); + + //ext is now the extension of the current file + ext += length - 4; + + //if we have on our hands a .ods file, add it to our collection + if (strcmp(ext, ".ods") == 0) + { + mBeatmaps.push_back(new Beatmap(subentry->d_name, entry->d_name)); + } + } + else + { + closedir(filetest); + } + } + } + + closedir(subdir); + chdir(".."); + } + + closedir(dir); +} + +u32 BeatmapManager::MapCount() +{ + return 8;//mBeatmaps.size(); +} + +u32 BeatmapManager::SongCount() +{ + //TODO: algorithm plz + return mBeatmaps.size(); } \ No newline at end of file diff --git a/arm9/source/Beatmaps/BeatmapManager.h b/source/Beatmaps/BeatmapManager.h similarity index 94% rename from arm9/source/Beatmaps/BeatmapManager.h rename to source/Beatmaps/BeatmapManager.h index b076495..d545038 100644 --- a/arm9/source/Beatmaps/BeatmapManager.h +++ b/source/Beatmaps/BeatmapManager.h @@ -1,39 +1,39 @@ -#include -#include -#include -#include -#include -#include - -#include "Beatmap.h" -#include "BeatmapElements.h" -#include "DifficultyManager.h" -#include "Modes/Mode.h" - -#ifndef __BEATMAPMANAGER_H__ -#define __BEATMAPMANAGER_H__ - -using namespace std; - -typedef vector::iterator beatmapIterator; - -class BeatmapManager -{ - public: - static Beatmap& Current() { return *mBeatmapCurrent; } - - static void BuildCollection(); - static void Load(u32 index); - static u32 MapCount(); - static u32 SongCount(); - - static vector& Beatmaps() { return mBeatmaps; } - - protected: - static Beatmap* mBeatmapCurrent; - - static vector mBeatmaps; -}; - -#endif - +#include +#include +#include +#include +#include +#include + +#include "Beatmap.h" +#include "BeatmapElements.h" +#include "DifficultyManager.h" +#include "Modes/Mode.h" + +#ifndef __BEATMAPMANAGER_H__ +#define __BEATMAPMANAGER_H__ + +using namespace std; + +typedef vector::iterator beatmapIterator; + +class BeatmapManager +{ + public: + static Beatmap& Current() { return *mBeatmapCurrent; } + + static void BuildCollection(); + static void Load(u32 index); + static u32 MapCount(); + static u32 SongCount(); + + static vector& Beatmaps() { return mBeatmaps; } + + protected: + static Beatmap* mBeatmapCurrent; + + static vector mBeatmaps; +}; + +#endif + diff --git a/arm9/source/Beatmaps/DifficultyManager.cpp b/source/Beatmaps/DifficultyManager.cpp similarity index 98% rename from arm9/source/Beatmaps/DifficultyManager.cpp rename to source/Beatmaps/DifficultyManager.cpp index c60ba65..1475aba 100644 --- a/arm9/source/Beatmaps/DifficultyManager.cpp +++ b/source/Beatmaps/DifficultyManager.cpp @@ -1,21 +1,21 @@ -#include "DifficultyManager.h" - -u32 DifficultyManager::preemptTime[] = {1800, 1680, 1560, 1440, 1320, 1200, 1050, 900, 750, 600, 450}; -//u32 DifficultyManager::circleSize[] = {100, 92, 84, 76, 68, 60, 52, 44, 36, 28, 20}; -u32 DifficultyManager::circleSize[] = {100, 92, 84, 76, 68, 60, 52, 52, 52, 52, 52}; -//u32 DifficultyManager::circleSize[] = {120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20}; -u32 DifficultyManager::hitWindow300[] = {80, 74, 68, 62, 56, 50, 44, 38, 32, 26, 20}; -u32 DifficultyManager::hitWindow100[] = {140, 132, 124, 116, 108, 100, 92, 84, 76, 68, 60}; -u32 DifficultyManager::hitWindow50[] = {200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100}; -u32 DifficultyManager::spinnerTime[] = {525, 480, 435, 390, 345, 300, 270, 240, 210, 180, 150}; -s32 DifficultyManager::missHpDrain[] = {-10, -18, -26, -34, -42, -50, -56, -62, -68, -74, -80}; - -u8 DifficultyManager::DifficultyHpDrain = 5; -u8 DifficultyManager::DifficultyCircleSize = 5; -u8 DifficultyManager::DifficultyOverall = 5; -float DifficultyManager::SliderMultiplier = 1.0; -float DifficultyManager::SliderTickRate = 1.0; -float DifficultyManager::DifficultyHpDrainRate = 1.0; -u8 DifficultyManager::DifficultyPeppyStars = 3; -float DifficultyManager::DifficultyEyupStars = 3.0; - +#include "DifficultyManager.h" + +u32 DifficultyManager::preemptTime[] = {1800, 1680, 1560, 1440, 1320, 1200, 1050, 900, 750, 600, 450}; +//u32 DifficultyManager::circleSize[] = {100, 92, 84, 76, 68, 60, 52, 44, 36, 28, 20}; +u32 DifficultyManager::circleSize[] = {100, 92, 84, 76, 68, 60, 52, 52, 52, 52, 52}; +//u32 DifficultyManager::circleSize[] = {120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20}; +u32 DifficultyManager::hitWindow300[] = {80, 74, 68, 62, 56, 50, 44, 38, 32, 26, 20}; +u32 DifficultyManager::hitWindow100[] = {140, 132, 124, 116, 108, 100, 92, 84, 76, 68, 60}; +u32 DifficultyManager::hitWindow50[] = {200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100}; +u32 DifficultyManager::spinnerTime[] = {525, 480, 435, 390, 345, 300, 270, 240, 210, 180, 150}; +s32 DifficultyManager::missHpDrain[] = {-10, -18, -26, -34, -42, -50, -56, -62, -68, -74, -80}; + +u8 DifficultyManager::DifficultyHpDrain = 5; +u8 DifficultyManager::DifficultyCircleSize = 5; +u8 DifficultyManager::DifficultyOverall = 5; +float DifficultyManager::SliderMultiplier = 1.0; +float DifficultyManager::SliderTickRate = 1.0; +float DifficultyManager::DifficultyHpDrainRate = 1.0; +u8 DifficultyManager::DifficultyPeppyStars = 3; +float DifficultyManager::DifficultyEyupStars = 3.0; + diff --git a/arm9/source/Beatmaps/DifficultyManager.h b/source/Beatmaps/DifficultyManager.h similarity index 96% rename from arm9/source/Beatmaps/DifficultyManager.h rename to source/Beatmaps/DifficultyManager.h index 6e2b8fd..5ae7dee 100644 --- a/arm9/source/Beatmaps/DifficultyManager.h +++ b/source/Beatmaps/DifficultyManager.h @@ -1,39 +1,39 @@ -#include - -#ifndef __DIFFICULTYMANAGER_H__ -#define __DIFFICULTYMANAGER_H__ - -class DifficultyManager -{ - public: - static u8 DifficultyHpDrain; - static u8 DifficultyCircleSize; - static u8 DifficultyOverall; - static float SliderMultiplier; - static float SliderTickRate; - static float DifficultyHpDrainRate; - static u8 DifficultyPeppyStars; - static float DifficultyEyupStars; - - //inline - static u32 GetCircleSize() { return circleSize[DifficultyCircleSize]; } //possibly *1.2 - static u32 GetPreemptTime() { return preemptTime[DifficultyOverall]; } - static u32 GetHitWindow300() { return hitWindow300[DifficultyOverall]; } - static u32 GetHitWindow100() { return hitWindow100[DifficultyOverall]; } - static u32 GetHitWindow50() { return hitWindow50[DifficultyOverall]; } - static u32 GetHitWindow() { return hitWindow50[DifficultyOverall] << 1; } - static u32 GetSpinnerTime() { return spinnerTime[DifficultyOverall]; } - static s32 GetMissHpDrain() { return missHpDrain[DifficultyHpDrain]; } - - protected: - static u32 preemptTime[]; - static u32 circleSize[]; - static u32 hitWindow300[]; - static u32 hitWindow100[]; - static u32 hitWindow50[]; - static u32 spinnerTime[]; - static s32 missHpDrain[]; -}; - -#endif - +#include + +#ifndef __DIFFICULTYMANAGER_H__ +#define __DIFFICULTYMANAGER_H__ + +class DifficultyManager +{ + public: + static u8 DifficultyHpDrain; + static u8 DifficultyCircleSize; + static u8 DifficultyOverall; + static float SliderMultiplier; + static float SliderTickRate; + static float DifficultyHpDrainRate; + static u8 DifficultyPeppyStars; + static float DifficultyEyupStars; + + //inline + static u32 GetCircleSize() { return circleSize[DifficultyCircleSize]; } //possibly *1.2 + static u32 GetPreemptTime() { return preemptTime[DifficultyOverall]; } + static u32 GetHitWindow300() { return hitWindow300[DifficultyOverall]; } + static u32 GetHitWindow100() { return hitWindow100[DifficultyOverall]; } + static u32 GetHitWindow50() { return hitWindow50[DifficultyOverall]; } + static u32 GetHitWindow() { return hitWindow50[DifficultyOverall] << 1; } + static u32 GetSpinnerTime() { return spinnerTime[DifficultyOverall]; } + static s32 GetMissHpDrain() { return missHpDrain[DifficultyHpDrain]; } + + protected: + static u32 preemptTime[]; + static u32 circleSize[]; + static u32 hitWindow300[]; + static u32 hitWindow100[]; + static u32 hitWindow50[]; + static u32 spinnerTime[]; + static s32 missHpDrain[]; +}; + +#endif + diff --git a/arm9/source/GameplayElements/HitObjectManager.cpp b/source/GameplayElements/HitObjectManager.cpp similarity index 95% rename from arm9/source/GameplayElements/HitObjectManager.cpp rename to source/GameplayElements/HitObjectManager.cpp index ebddd85..546a26e 100644 --- a/arm9/source/GameplayElements/HitObjectManager.cpp +++ b/source/GameplayElements/HitObjectManager.cpp @@ -1,104 +1,104 @@ -#include "HitObjectManager.h" - -HitObjectManager::~HitObjectManager() -{ - //delete hitobjects - for (hitObjectIterator it = mHitObjects.begin(); it != mHitObjects.end(); ++it) - { - if (*it != NULL) - delete *it; - } -} - -void HitObjectManager::Add(HitObject* object) -{ - mHitObjects.push_back(object); -} - -void HitObjectManager::HandleInput() -{ - touchPosition touch = InputHelper::TouchRead(); - - HitObject* hitObject; - - // remove all hitobjects before the current time and all hitobjects that have been hit - bool process = true; - while (process) - { - process = false; - - if (mHitObjects.size() == 0) - return; - - // process hitobjects one at a time - hitObject = mHitObjects.front(); - - if (hitObject->GetEndTime() <= GameClock::Clock().Time() || hitObject->GetHit() == true) - { - // sprites are handled by spritemanager and will not be deleted (see HitObject.h) - - // TODO: this is a bit hacky - find a way to guarantee this won't cause a crash - if (GameClock::Clock().Time() - hitObject->GetEndTime() < 1000 && hitObject->GetHit() == false) - hitObject->Hit(); - - mHitObjects.pop_front(); - delete hitObject; - - process = true; - } - } - - // now we are left with the next hitobject that can react to user interaction - - if (InputHelper::KeyDown(KEY_TOUCH)) - hitObject->OnTouchDown(touch); - - if (InputHelper::KeyHeld(KEY_TOUCH)) - hitObject->OnTouch(touch); - - if (InputHelper::KeyUp(KEY_TOUCH)) - hitObject->OnTouchUp(touch); - - hitObject->Update(); - -/* - //get the first unhit hitobject - if (mHitObjects.size() == 0) - return; - - HitObject* hitObject = mHitObjects.front(); - - //only the topmost object can be hit at any time - if (hitObject->GetEndTime() <= GameClock::Clock().Time() && hitObject->GetHit() == false) - { - hitObject->Hit(); - } - - if (hitObject->GetHit() == true) - { - //sprites are handled by spritemanager and will not be deleted (see HitObject.h) - delete hitObject; - mHitObjects.pop_front(); - - if (mHitObjects.size() == 0) - return; - - hitObject = mHitObjects.front(); - } - - //at this point hitObject is pointing to the topmost unhit object if such an object exists - if (hitObject != NULL) - { - if (InputHelper::KeyDown(KEY_TOUCH)) - hitObject->OnTouchDown(touch); - - if (InputHelper::KeyHeld(KEY_TOUCH)) - hitObject->OnTouch(touch); - - if (InputHelper::KeyUp(KEY_TOUCH)) - hitObject->OnTouchUp(touch); - - hitObject->Update(); - } -*/ +#include "HitObjectManager.h" + +HitObjectManager::~HitObjectManager() +{ + //delete hitobjects + for (hitObjectIterator it = mHitObjects.begin(); it != mHitObjects.end(); ++it) + { + if (*it != NULL) + delete *it; + } +} + +void HitObjectManager::Add(HitObject* object) +{ + mHitObjects.push_back(object); +} + +void HitObjectManager::HandleInput() +{ + touchPosition touch = InputHelper::TouchRead(); + + HitObject* hitObject; + + // remove all hitobjects before the current time and all hitobjects that have been hit + bool process = true; + while (process) + { + process = false; + + if (mHitObjects.size() == 0) + return; + + // process hitobjects one at a time + hitObject = mHitObjects.front(); + + if (hitObject->GetEndTime() <= GameClock::Clock().Time() || hitObject->GetHit() == true) + { + // sprites are handled by spritemanager and will not be deleted (see HitObject.h) + + // TODO: this is a bit hacky - find a way to guarantee this won't cause a crash + if (GameClock::Clock().Time() - hitObject->GetEndTime() < 1000 && hitObject->GetHit() == false) + hitObject->Hit(); + + mHitObjects.pop_front(); + delete hitObject; + + process = true; + } + } + + // now we are left with the next hitobject that can react to user interaction + + if (InputHelper::KeyDown(KEY_TOUCH)) + hitObject->OnTouchDown(touch); + + if (InputHelper::KeyHeld(KEY_TOUCH)) + hitObject->OnTouch(touch); + + if (InputHelper::KeyUp(KEY_TOUCH)) + hitObject->OnTouchUp(touch); + + hitObject->Update(); + +/* + //get the first unhit hitobject + if (mHitObjects.size() == 0) + return; + + HitObject* hitObject = mHitObjects.front(); + + //only the topmost object can be hit at any time + if (hitObject->GetEndTime() <= GameClock::Clock().Time() && hitObject->GetHit() == false) + { + hitObject->Hit(); + } + + if (hitObject->GetHit() == true) + { + //sprites are handled by spritemanager and will not be deleted (see HitObject.h) + delete hitObject; + mHitObjects.pop_front(); + + if (mHitObjects.size() == 0) + return; + + hitObject = mHitObjects.front(); + } + + //at this point hitObject is pointing to the topmost unhit object if such an object exists + if (hitObject != NULL) + { + if (InputHelper::KeyDown(KEY_TOUCH)) + hitObject->OnTouchDown(touch); + + if (InputHelper::KeyHeld(KEY_TOUCH)) + hitObject->OnTouch(touch); + + if (InputHelper::KeyUp(KEY_TOUCH)) + hitObject->OnTouchUp(touch); + + hitObject->Update(); + } +*/ } \ No newline at end of file diff --git a/arm9/source/GameplayElements/HitObjectManager.h b/source/GameplayElements/HitObjectManager.h similarity index 94% rename from arm9/source/GameplayElements/HitObjectManager.h rename to source/GameplayElements/HitObjectManager.h index 420a9af..79c57aa 100644 --- a/arm9/source/GameplayElements/HitObjectManager.h +++ b/source/GameplayElements/HitObjectManager.h @@ -1,31 +1,31 @@ -#include -#include -#include - -#include "HitObjects/HitObject.h" -#include "HitObjects/HitCircle.h" -#include "HitObjects/HitSlider.h" -#include "HitObjects/HitSpinner.h" -#include "Helpers/InputHelper.h" - -#ifndef __HITOBJECTMANAGER_H__ -#define __HITOBJECTMANAGER_H__ - -using namespace std; - -typedef list::iterator hitObjectIterator; - -class HitObjectManager -{ - public: - ~HitObjectManager(); - - void Add(HitObject* object); - void HandleInput(); - - protected: - list mHitObjects; -}; - -#endif - +#include +#include +#include + +#include "HitObjects/HitObject.h" +#include "HitObjects/HitCircle.h" +#include "HitObjects/HitSlider.h" +#include "HitObjects/HitSpinner.h" +#include "Helpers/InputHelper.h" + +#ifndef __HITOBJECTMANAGER_H__ +#define __HITOBJECTMANAGER_H__ + +using namespace std; + +typedef list::iterator hitObjectIterator; + +class HitObjectManager +{ + public: + ~HitObjectManager(); + + void Add(HitObject* object); + void HandleInput(); + + protected: + list mHitObjects; +}; + +#endif + diff --git a/arm9/source/GameplayElements/Lifebar.cpp b/source/GameplayElements/Lifebar.cpp similarity index 96% rename from arm9/source/GameplayElements/Lifebar.cpp rename to source/GameplayElements/Lifebar.cpp index 69317f7..27408bf 100644 --- a/arm9/source/GameplayElements/Lifebar.cpp +++ b/source/GameplayElements/Lifebar.cpp @@ -1,115 +1,115 @@ -#include "Lifebar.h" - -Lifebar::Lifebar() -{ - pSprite* spr; - - spr = new pSprite(TX_PLAY_SCOREBAR, 0, 0, 640, 42, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(31,31,31), 31); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_SCOREBAR_BAR, 0, 0, 400, 40, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(31,31,31), 31, -0.01f); - mSprites.push_back(spr); +#include "Lifebar.h" + +Lifebar::Lifebar() +{ + pSprite* spr; - spr = new pSprite(TX_PLAY_SCOREBAR_KI, 400, 18, 80, 80, ORIGIN_CENTER, FIELD_SCREEN, RGB15(31,31,31), 31, -0.02f); - mSprites.push_back(spr); - - mUV = new u32[4]; //deleted by pSprite - mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(0)); - mUV[1] = TEXTURE_PACK(inttot16(160),inttot16(0)); - mUV[2] = TEXTURE_PACK(inttot16(160),inttot16(16)); - mUV[3] = TEXTURE_PACK(inttot16(0),inttot16(16)); - - mSprites[1]->UV = mUV; -} - -//can only be called after beatmap has been loaded -void Lifebar::Initialize() -{ - mHpLossPerMs = DifficultyManager::DifficultyHpDrainRate * 2; //units are hp/ms based off a 200 point scale - mHpCurrent = 0; - mHpDisplay = 0; - - mTimeLastUpdate = GameClock::Clock().Time(); - mFillTime = MathHelper::Min(10000, BeatmapManager::Current().StartTime()); - mFillRate = MAXHP/((mFillTime-700)/(float)1000*60); - - for (u32 time = BeatmapManager::Current().StartTime() - mFillTime; - time < BeatmapManager::Current().StartTime()-700; time += 150) - { - mSprites[2]->Scale(time, time+90, 1.5, 1); - } -} - -void Lifebar::Update() -{ - s32 now = GameClock::Clock().Time(); - s32 startTime = BeatmapManager::Current().StartTime(); - - if (now > startTime && BeatmapElements::Element().IsBreak() == false) - { - mHpCurrent -= (now - mTimeLastUpdate) * mHpLossPerMs; - if (mHpCurrent < 0) - mHpCurrent = 0; - } - //intro animation - else if (now > startTime - mFillTime && now < startTime) - { - Set(mHpCurrent + mFillRate, false); - } - - int dhp = mHpCurrent - mHpDisplay; - if (MathHelper::Abs(dhp) > MAXCHANGE) - dhp = MathHelper::Sgn(dhp) * MAXCHANGE; - mHpDisplay += dhp; - - //mHpDisplay represents the required width of the sprite - mSprites[2]->Move(mHpDisplay, 18); - if (mHpDisplay >= 200) - mSprites[2]->Texture = TX_PLAY_SCOREBAR_KI; - else if (mHpDisplay >= 70) - mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER; - else - mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER2; - - mSprites[1]->Width = (u32)mHpDisplay; - mUV[1] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(0)); - mUV[2] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(16)); - - mTimeLastUpdate = now; -} - -void Lifebar::Set(float value, bool limit) -{ - if (value < 0) value = 0; - if (value > MAXHP) value = MAXHP; - - mHpCurrent = value; - if (!limit) - mHpDisplay = value; - mTimeLastUpdate = GameClock::Clock().Time(); -} - -void Lifebar::Increase(float value) -{ - Set(mHpCurrent + value); - - //animate ki icon :D - if (value > 0) - Bulge(); -} - -void Lifebar::Bulge() -{ - s32 now = GameClock::Clock().Time(); - - mSprites[2]->Scale(now, now+90, 1.5, 1); -} - -void Lifebar::ClearTransforms() -{ - for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) - { - (*it)->ClearTransforms(); - } -} - + spr = new pSprite(TX_PLAY_SCOREBAR, 0, 0, 640, 42, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(31,31,31), 31); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_SCOREBAR_BAR, 0, 0, 400, 40, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(31,31,31), 31, -0.01f); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_SCOREBAR_KI, 400, 18, 80, 80, ORIGIN_CENTER, FIELD_SCREEN, RGB15(31,31,31), 31, -0.02f); + mSprites.push_back(spr); + + mUV = new u32[4]; //deleted by pSprite + mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(0)); + mUV[1] = TEXTURE_PACK(inttot16(160),inttot16(0)); + mUV[2] = TEXTURE_PACK(inttot16(160),inttot16(16)); + mUV[3] = TEXTURE_PACK(inttot16(0),inttot16(16)); + + mSprites[1]->UV = mUV; +} + +//can only be called after beatmap has been loaded +void Lifebar::Initialize() +{ + mHpLossPerMs = DifficultyManager::DifficultyHpDrainRate * 2; //units are hp/ms based off a 200 point scale + mHpCurrent = 0; + mHpDisplay = 0; + + mTimeLastUpdate = GameClock::Clock().Time(); + mFillTime = MathHelper::Min(10000, BeatmapManager::Current().StartTime()); + mFillRate = MAXHP/((mFillTime-700)/(float)1000*60); + + for (u32 time = BeatmapManager::Current().StartTime() - mFillTime; + time < BeatmapManager::Current().StartTime()-700; time += 150) + { + mSprites[2]->Scale(time, time+90, 1.5, 1); + } +} + +void Lifebar::Update() +{ + s32 now = GameClock::Clock().Time(); + s32 startTime = BeatmapManager::Current().StartTime(); + + if (now > startTime && BeatmapElements::Element().IsBreak() == false) + { + mHpCurrent -= (now - mTimeLastUpdate) * mHpLossPerMs; + if (mHpCurrent < 0) + mHpCurrent = 0; + } + //intro animation + else if (now > startTime - mFillTime && now < startTime) + { + Set(mHpCurrent + mFillRate, false); + } + + int dhp = mHpCurrent - mHpDisplay; + if (MathHelper::Abs(dhp) > MAXCHANGE) + dhp = MathHelper::Sgn(dhp) * MAXCHANGE; + mHpDisplay += dhp; + + //mHpDisplay represents the required width of the sprite + mSprites[2]->Move(mHpDisplay, 18); + if (mHpDisplay >= 200) + mSprites[2]->Texture = TX_PLAY_SCOREBAR_KI; + else if (mHpDisplay >= 70) + mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER; + else + mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER2; + + mSprites[1]->Width = (u32)mHpDisplay; + mUV[1] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(0)); + mUV[2] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(16)); + + mTimeLastUpdate = now; +} + +void Lifebar::Set(float value, bool limit) +{ + if (value < 0) value = 0; + if (value > MAXHP) value = MAXHP; + + mHpCurrent = value; + if (!limit) + mHpDisplay = value; + mTimeLastUpdate = GameClock::Clock().Time(); +} + +void Lifebar::Increase(float value) +{ + Set(mHpCurrent + value); + + //animate ki icon :D + if (value > 0) + Bulge(); +} + +void Lifebar::Bulge() +{ + s32 now = GameClock::Clock().Time(); + + mSprites[2]->Scale(now, now+90, 1.5, 1); +} + +void Lifebar::ClearTransforms() +{ + for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) + { + (*it)->ClearTransforms(); + } +} + diff --git a/arm9/source/GameplayElements/Lifebar.h b/source/GameplayElements/Lifebar.h similarity index 95% rename from arm9/source/GameplayElements/Lifebar.h rename to source/GameplayElements/Lifebar.h index 758011d..d182d42 100644 --- a/arm9/source/GameplayElements/Lifebar.h +++ b/source/GameplayElements/Lifebar.h @@ -1,51 +1,51 @@ -#include -#include - -#include "ScoreManager.h" -#include "System/GameClock.h" -#include "Graphics/SpriteContainer.h" -#include "Beatmaps/BeatmapManager.h" - -#ifndef __LIFEBAR_H__ -#define __LIFEBAR_H__ - -class Lifebar : public SpriteContainer -{ - public: - Lifebar(); - void Initialize(); - - void Update(); - void Set(float value, bool limit = true); - void Increase(float value); - void ClearTransforms(); - - static const u32 MAXHP = 400; //matches with actual width of sprite - static const u32 MAXCHANGE = 10; - - //values for increase - static const u32 HP_300 = 12; - static const u32 HP_100 = 5; - static const u32 HP_50 = 1; - static const u32 HP_GEKI = 28; - static const u32 HP_KATSU = 20; - static const u32 HP_SLIDER_REPEAT = 8; - static const u32 HP_SLIDER_TICK = 6; - static const u32 HP_SPINNER_SPIN = 4; - static const u32 HP_SPINNER_BONUS = 5; - - protected: - float mHpCurrent; - float mHpDisplay; - float mHpLossPerMs; - s32 mFillTime; - float mFillRate; - s32 mTimeLastUpdate; - - u32* mUV; - - void Bulge(); -}; - -#endif - +#include +#include + +#include "ScoreManager.h" +#include "System/GameClock.h" +#include "Graphics/SpriteContainer.h" +#include "Beatmaps/BeatmapManager.h" + +#ifndef __LIFEBAR_H__ +#define __LIFEBAR_H__ + +class Lifebar : public SpriteContainer +{ + public: + Lifebar(); + void Initialize(); + + void Update(); + void Set(float value, bool limit = true); + void Increase(float value); + void ClearTransforms(); + + static const u32 MAXHP = 400; //matches with actual width of sprite + static const u32 MAXCHANGE = 10; + + //values for increase + static const u32 HP_300 = 12; + static const u32 HP_100 = 5; + static const u32 HP_50 = 1; + static const u32 HP_GEKI = 28; + static const u32 HP_KATSU = 20; + static const u32 HP_SLIDER_REPEAT = 8; + static const u32 HP_SLIDER_TICK = 6; + static const u32 HP_SPINNER_SPIN = 4; + static const u32 HP_SPINNER_BONUS = 5; + + protected: + float mHpCurrent; + float mHpDisplay; + float mHpLossPerMs; + s32 mFillTime; + float mFillRate; + s32 mTimeLastUpdate; + + u32* mUV; + + void Bulge(); +}; + +#endif + diff --git a/arm9/source/GameplayElements/ScoreManager.cpp b/source/GameplayElements/ScoreManager.cpp similarity index 94% rename from arm9/source/GameplayElements/ScoreManager.cpp rename to source/GameplayElements/ScoreManager.cpp index 0b9ee09..eb7f9c9 100644 --- a/arm9/source/GameplayElements/ScoreManager.cpp +++ b/source/GameplayElements/ScoreManager.cpp @@ -1,36 +1,36 @@ -#include "ScoreManager.h" - -ScoreManager::ScoreManager() -{ - mScore = 0; - mCombo = 0; -} - -void ScoreManager::Add(ScoreType score, bool forceNoCombo) -{ - if (score == SCORE_MISS) - { - mCombo = 0; - } - else if (score == SCORE_SPIN_100 || score == SCORE_SPIN_1000) - { - if (score == SCORE_SPIN_100) - mScore += 100; - else - mScore += score; - } - else if (score == SCORE_TICK_30 || score == SCORE_TICK_10) - { - mScore += score; - if (!forceNoCombo) - ++mCombo; - } - else - { - mScore += score + MathHelper::Max(0, mCombo-1) * (score/25) * DifficultyManager::DifficultyPeppyStars; - if (!forceNoCombo) - ++mCombo; - } -} - - +#include "ScoreManager.h" + +ScoreManager::ScoreManager() +{ + mScore = 0; + mCombo = 0; +} + +void ScoreManager::Add(ScoreType score, bool forceNoCombo) +{ + if (score == SCORE_MISS) + { + mCombo = 0; + } + else if (score == SCORE_SPIN_100 || score == SCORE_SPIN_1000) + { + if (score == SCORE_SPIN_100) + mScore += 100; + else + mScore += score; + } + else if (score == SCORE_TICK_30 || score == SCORE_TICK_10) + { + mScore += score; + if (!forceNoCombo) + ++mCombo; + } + else + { + mScore += score + MathHelper::Max(0, mCombo-1) * (score/25) * DifficultyManager::DifficultyPeppyStars; + if (!forceNoCombo) + ++mCombo; + } +} + + diff --git a/arm9/source/GameplayElements/ScoreManager.h b/source/GameplayElements/ScoreManager.h similarity index 94% rename from arm9/source/GameplayElements/ScoreManager.h rename to source/GameplayElements/ScoreManager.h index 3ee6d16..1fcfde3 100644 --- a/arm9/source/GameplayElements/ScoreManager.h +++ b/source/GameplayElements/ScoreManager.h @@ -1,36 +1,36 @@ -#include -#include -#include "Helpers/MathHelper.h" -#include "Beatmaps/DifficultyManager.h" - -#ifndef __SCOREMANAGER_H__ -#define __SCOREMANAGER_H__ - -typedef enum { - SCORE_300 = 300, - SCORE_100 = 100, - SCORE_50 = 50, - SCORE_TICK_30 = 30, - SCORE_TICK_10 = 10, - SCORE_SPIN_100 = 101,//should be 100 but conflicts with SCORE_100 - SCORE_SPIN_1000 = 1000, - SCORE_MISS = 0 -} ScoreType; - -class ScoreManager -{ - public: - ScoreManager(); - - void Add(ScoreType score, bool forceNoCombo = false); - - u32 Score() { return mScore; } - u32 Combo() { return mCombo; } - - protected: - u32 mScore; - u32 mCombo; -}; - -#endif - +#include +#include +#include "Helpers/MathHelper.h" +#include "Beatmaps/DifficultyManager.h" + +#ifndef __SCOREMANAGER_H__ +#define __SCOREMANAGER_H__ + +typedef enum { + SCORE_300 = 300, + SCORE_100 = 100, + SCORE_50 = 50, + SCORE_TICK_30 = 30, + SCORE_TICK_10 = 10, + SCORE_SPIN_100 = 101,//should be 100 but conflicts with SCORE_100 + SCORE_SPIN_1000 = 1000, + SCORE_MISS = 0 +} ScoreType; + +class ScoreManager +{ + public: + ScoreManager(); + + void Add(ScoreType score, bool forceNoCombo = false); + + u32 Score() { return mScore; } + u32 Combo() { return mCombo; } + + protected: + u32 mScore; + u32 mCombo; +}; + +#endif + diff --git a/arm9/source/Graphics/GfxInfo.cpp b/source/Graphics/GfxInfo.cpp similarity index 98% rename from arm9/source/Graphics/GfxInfo.cpp rename to source/Graphics/GfxInfo.cpp index 363ff5a..01ea3f5 100644 --- a/arm9/source/Graphics/GfxInfo.cpp +++ b/source/Graphics/GfxInfo.cpp @@ -1,343 +1,343 @@ -#include -#include "GfxInfo.h" - -/* -const float zvalue[] = -{ - 0.000f, 0.000f, -0.01f, //hitcircle - 0.000f, 0.000f, 0.000f, //hitspinner - -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, //slider ball - 0.015f, -0.01f, 0.000f, 0.000f, //hitslider - 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, //score - -0.005f, -0.005f, //slider score - -0.05f, -0.05f, -0.05f, -0.05f, -0.05f, //scorebar - 0.000f, //verdana9 - 0.000f //white -}; -*/ - -const u16 palette0[] = //circle, circleoverlay, circleapproach, disc, slidertick, sliderreverse, verdana9, white -{ - RGB15(31,0,31), RGB15(31,31,31), RGB15(28,28,28), RGB15(0,0,0) -}; - -const u16 palette1[] = //spinner, spinnerbars, scorebar_bar -{ - RGB15(31,31,31), RGB15(31,0,0), RGB15(31,4,0), RGB15(31,9,0), - RGB15(4,3,3), RGB15(29,14,7), RGB15(31,12,0), RGB15(31,17,0), - RGB15(31,23,7), RGB15(31,26,14), RGB15(31,23,0), RGB15(31,30,23), - RGB15(31,27,0), RGB15(31,31,8), RGB15(31,31,0), RGB15(0,14,22) -}; - -const u16 palette2[] = //spinnerbg -{ - RGB15(31,31,31), RGB15(1,2,5), RGB15(5,5,5), RGB15(0,0,0), - RGB15(5,13,31), RGB15(14,15,16), RGB15(2,5,13), RGB15(1,4,10), - RGB15(3,7,17), RGB15(3,8,21), RGB15(4,10,25), RGB15(1,3,8), - RGB15(5,11,28), RGB15(6,7,7), RGB15(4,5,8), RGB15(8,9,11) -}; - -const u16 palette3[] = //sliderball, sliderfollowcircle -{ - RGB15(31,0,31), RGB15(31,24,0), RGB15(31,0,0), RGB15(31,31,0) -}; - -const u16 palette4[] = //hit300, hit300k, hit300g, hit0 -{ - RGB15(31,0,31), RGB15(31,26,4), RGB15(30,18,1), RGB15(31,30,12), - RGB15(31,31,23), RGB15(9,6,4), RGB15(28,5,1), RGB15(3,3,4), - RGB15(1,1,1), RGB15(2,2,2), RGB15(5,4,4), RGB15(28,2,2), - RGB15(15,7,3), RGB15(13,13,10), RGB15(22,22,17), RGB15(21,17,4) -}; - -const u16 palette5[] = //hit50. hit100, hit100k -{ - RGB15(31,0,31), RGB15(3,3,4), RGB15(12,30,8), RGB15(4,10,3), - RGB15(7,25,3), RGB15(12,15,28), RGB15(19,31,16), RGB15(5,6,11), - RGB15(17,20,30), RGB15(6,9,23), RGB15(5,18,3), RGB15(23,24,29), - RGB15(28,30,29), RGB15(24,31,23), RGB15(12,13,13), RGB15(18,19,19) -}; - -const u16 palette6[] = //slider30, slider10 -{ - RGB15(31,0,31), RGB15(31,7,29), RGB15(0,0,0), RGB15(31,20,30) -}; - -const u16 palette7[] = //scorebar_ki, scorebar_kidanger, scorebar_kidanger2 -{ - RGB15(31,31,31), RGB15(1,0,0), RGB15(20,20,20), RGB15(10,0,0), - RGB15(27,0,0), RGB15(20,0,0), RGB15(7,8,4), RGB15(12,12,0), - RGB15(22,23,9), RGB15(16,17,0), RGB15(20,21,0), RGB15(31,31,9), - RGB15(24,24,0), RGB15(30,31,1), RGB15(27,28,1), RGB15(16,16,6) -}; - -const u16 palette8[] = //scorebar -{ - RGB15(31,31,31), RGB15(0,0,0), RGB15(10,17,31), RGB15(19,17,31), - RGB15(21,23,31), RGB15(11,11,12), RGB15(17,17,31), RGB15(14,19,31), - RGB15(5,5,6), RGB15(18,18,31), RGB15(23,22,31), RGB15(20,18,31), - RGB15(16,19,31), RGB15(19,21,31), RGB15(14,14,18), RGB15(15,16,22) -}; - -const u32 uv8x8[] = { - TEXTURE_PACK(inttot16(0),inttot16(0)), - TEXTURE_PACK(inttot16(8), inttot16(0)), - TEXTURE_PACK(inttot16(8),inttot16(8)), - TEXTURE_PACK(inttot16(0), inttot16(8)) -}; - -const u32 uv16x16[] = { - TEXTURE_PACK(inttot16(0),inttot16(0)), - TEXTURE_PACK(inttot16(16), inttot16(0)), - TEXTURE_PACK(inttot16(16),inttot16(16)), - TEXTURE_PACK(inttot16(0), inttot16(16)) -}; - -const u32 uv32x32[] = { - TEXTURE_PACK(inttot16(0),inttot16(0)), - TEXTURE_PACK(inttot16(32), inttot16(0)), - TEXTURE_PACK(inttot16(32),inttot16(32)), - TEXTURE_PACK(inttot16(0), inttot16(32)) -}; - -const u32 uv64x64[] = { - TEXTURE_PACK(inttot16(0),inttot16(0)), - TEXTURE_PACK(inttot16(64), 0), - TEXTURE_PACK(inttot16(64),inttot16(64)), - TEXTURE_PACK(inttot16(0), inttot16(64)) -}; - -const u32 uv128x128[] = { - TEXTURE_PACK(inttot16(0),inttot16(0)), - TEXTURE_PACK(inttot16(128), inttot16(0)), - TEXTURE_PACK(inttot16(128),inttot16(128)), - TEXTURE_PACK(inttot16(0), inttot16(128)) -}; - -const u32 uv256x16[] = { - TEXTURE_PACK(inttot16(0),inttot16(0)), - TEXTURE_PACK(inttot16(256), inttot16(0)), - TEXTURE_PACK(inttot16(256),inttot16(16)), - TEXTURE_PACK(inttot16(0), inttot16(16)) -}; - -const u32 uv256x192[] = { - TEXTURE_PACK(inttot16(0),inttot16(0)), - TEXTURE_PACK(inttot16(256), inttot16(0)), - TEXTURE_PACK(inttot16(256),inttot16(192)), - TEXTURE_PACK(inttot16(0), inttot16(192)) -}; - -const v16 plu[] = { - floattov16(-2.00f), - floattov16(-1.99f), floattov16(-1.98f), floattov16(-1.97f), floattov16(-1.96f), floattov16(-1.95f), - floattov16(-1.94f), floattov16(-1.93f), floattov16(-1.92f), floattov16(-1.91f), floattov16(-1.90f), - floattov16(-1.89f), floattov16(-1.88f), floattov16(-1.87f), floattov16(-1.86f), floattov16(-1.85f), - floattov16(-1.84f), floattov16(-1.83f), floattov16(-1.82f), floattov16(-1.81f), floattov16(-1.80f), - floattov16(-1.79f), floattov16(-1.78f), floattov16(-1.77f), floattov16(-1.76f), floattov16(-1.75f), - floattov16(-1.74f), floattov16(-1.73f), floattov16(-1.72f), floattov16(-1.71f), floattov16(-1.70f), - floattov16(-1.69f), floattov16(-1.68f), floattov16(-1.67f), floattov16(-1.66f), floattov16(-1.65f), - floattov16(-1.64f), floattov16(-1.63f), floattov16(-1.62f), floattov16(-1.61f), floattov16(-1.60f), - floattov16(-1.59f), floattov16(-1.58f), floattov16(-1.57f), floattov16(-1.56f), floattov16(-1.55f), - floattov16(-1.54f), floattov16(-1.53f), floattov16(-1.52f), floattov16(-1.51f), floattov16(-1.50f), - floattov16(-1.49f), floattov16(-1.48f), floattov16(-1.47f), floattov16(-1.46f), floattov16(-1.45f), - floattov16(-1.44f), floattov16(-1.43f), floattov16(-1.42f), floattov16(-1.41f), floattov16(-1.40f), - floattov16(-1.39f), floattov16(-1.38f), floattov16(-1.37f), floattov16(-1.36f), floattov16(-1.35f), - floattov16(-1.34f), floattov16(-1.33f), floattov16(-1.32f), floattov16(-1.31f), floattov16(-1.30f), - floattov16(-1.29f), floattov16(-1.28f), floattov16(-1.27f), floattov16(-1.26f), floattov16(-1.25f), - floattov16(-1.24f), floattov16(-1.23f), floattov16(-1.22f), floattov16(-1.21f), floattov16(-1.20f), - floattov16(-1.19f), floattov16(-1.18f), floattov16(-1.17f), floattov16(-1.16f), floattov16(-1.15f), - floattov16(-1.14f), floattov16(-1.13f), floattov16(-1.12f), floattov16(-1.11f), floattov16(-1.10f), - floattov16(-1.09f), floattov16(-1.08f), floattov16(-1.07f), floattov16(-1.06f), floattov16(-1.05f), - floattov16(-1.04f), floattov16(-1.03f), floattov16(-1.02f), floattov16(-1.01f), floattov16(-1.00f), - - floattov16(-0.99f), floattov16(-0.98f), floattov16(-0.97f), floattov16(-0.96f), floattov16(-0.95f), - floattov16(-0.94f), floattov16(-0.93f), floattov16(-0.92f), floattov16(-0.91f), floattov16(-0.90f), - floattov16(-0.89f), floattov16(-0.88f), floattov16(-0.87f), floattov16(-0.86f), floattov16(-0.85f), - floattov16(-0.84f), floattov16(-0.83f), floattov16(-0.82f), floattov16(-0.81f), floattov16(-0.80f), - floattov16(-0.79f), floattov16(-0.78f), floattov16(-0.77f), floattov16(-0.76f), floattov16(-0.75f), - floattov16(-0.74f), floattov16(-0.73f), floattov16(-0.72f), floattov16(-0.71f), floattov16(-0.70f), - floattov16(-0.69f), floattov16(-0.68f), floattov16(-0.67f), floattov16(-0.66f), floattov16(-0.65f), - floattov16(-0.64f), floattov16(-0.63f), floattov16(-0.62f), floattov16(-0.61f), floattov16(-0.60f), - floattov16(-0.59f), floattov16(-0.58f), floattov16(-0.57f), floattov16(-0.56f), floattov16(-0.55f), - floattov16(-0.54f), floattov16(-0.53f), floattov16(-0.52f), floattov16(-0.51f), floattov16(-0.50f), - floattov16(-0.49f), floattov16(-0.48f), floattov16(-0.47f), floattov16(-0.46f), floattov16(-0.45f), - floattov16(-0.44f), floattov16(-0.43f), floattov16(-0.42f), floattov16(-0.41f), floattov16(-0.40f), - floattov16(-0.39f), floattov16(-0.38f), floattov16(-0.37f), floattov16(-0.36f), floattov16(-0.35f), - floattov16(-0.34f), floattov16(-0.33f), floattov16(-0.32f), floattov16(-0.31f), floattov16(-0.30f), - floattov16(-0.29f), floattov16(-0.28f), floattov16(-0.27f), floattov16(-0.26f), floattov16(-0.25f), - floattov16(-0.24f), floattov16(-0.23f), floattov16(-0.22f), floattov16(-0.21f), floattov16(-0.20f), - floattov16(-0.19f), floattov16(-0.18f), floattov16(-0.17f), floattov16(-0.16f), floattov16(-0.15f), - floattov16(-0.14f), floattov16(-0.13f), floattov16(-0.12f), floattov16(-0.11f), floattov16(-0.10f), - floattov16(-0.09f), floattov16(-0.08f), floattov16(-0.07f), floattov16(-0.06f), floattov16(-0.05f), - floattov16(-0.04f), floattov16(-0.03f), floattov16(-0.02f), floattov16(-0.01f), - - floattov16(0.00f), floattov16(0.01f), floattov16(0.02f), floattov16(0.03f), floattov16(0.04f), - floattov16(0.05f), floattov16(0.06f), floattov16(0.07f), floattov16(0.08f), floattov16(0.09f), - floattov16(0.10f), floattov16(0.11f), floattov16(0.12f), floattov16(0.13f), floattov16(0.14f), - floattov16(0.15f), floattov16(0.16f), floattov16(0.17f), floattov16(0.18f), floattov16(0.19f), - floattov16(0.20f), floattov16(0.21f), floattov16(0.22f), floattov16(0.23f), floattov16(0.24f), - floattov16(0.25f), floattov16(0.26f), floattov16(0.27f), floattov16(0.28f), floattov16(0.29f), - floattov16(0.30f), floattov16(0.31f), floattov16(0.32f), floattov16(0.33f), floattov16(0.34f), - floattov16(0.35f), floattov16(0.36f), floattov16(0.37f), floattov16(0.38f), floattov16(0.39f), - floattov16(0.40f), floattov16(0.41f), floattov16(0.42f), floattov16(0.43f), floattov16(0.44f), - floattov16(0.45f), floattov16(0.46f), floattov16(0.47f), floattov16(0.48f), floattov16(0.49f), - floattov16(0.50f), floattov16(0.51f), floattov16(0.52f), floattov16(0.53f), floattov16(0.54f), - floattov16(0.55f), floattov16(0.56f), floattov16(0.57f), floattov16(0.58f), floattov16(0.59f), - floattov16(0.60f), floattov16(0.61f), floattov16(0.62f), floattov16(0.63f), floattov16(0.64f), - floattov16(0.65f), floattov16(0.66f), floattov16(0.67f), floattov16(0.68f), floattov16(0.69f), - floattov16(0.70f), floattov16(0.71f), floattov16(0.72f), floattov16(0.73f), floattov16(0.74f), - floattov16(0.75f), floattov16(0.76f), floattov16(0.77f), floattov16(0.78f), floattov16(0.79f), - floattov16(0.80f), floattov16(0.81f), floattov16(0.82f), floattov16(0.83f), floattov16(0.84f), - floattov16(0.85f), floattov16(0.86f), floattov16(0.87f), floattov16(0.88f), floattov16(0.89f), - floattov16(0.90f), floattov16(0.91f), floattov16(0.92f), floattov16(0.93f), floattov16(0.94f), - floattov16(0.95f), floattov16(0.96f), floattov16(0.97f), floattov16(0.98f), floattov16(0.99f), - - floattov16(1.00f), floattov16(1.01f), floattov16(1.02f), floattov16(1.03f), floattov16(1.04f), - floattov16(1.05f), floattov16(1.06f), floattov16(1.07f), floattov16(1.08f), floattov16(1.09f), - floattov16(1.10f), floattov16(1.11f), floattov16(1.12f), floattov16(1.13f), floattov16(1.14f), - floattov16(1.15f), floattov16(1.16f), floattov16(1.17f), floattov16(1.18f), floattov16(1.19f), - floattov16(1.20f), floattov16(1.21f), floattov16(1.22f), floattov16(1.23f), floattov16(1.24f), - floattov16(1.25f), floattov16(1.26f), floattov16(1.27f), floattov16(1.28f), floattov16(1.29f), - floattov16(1.30f), floattov16(1.31f), floattov16(1.32f), floattov16(1.33f), floattov16(1.34f), - floattov16(1.35f), floattov16(1.36f), floattov16(1.37f), floattov16(1.38f), floattov16(1.39f), - floattov16(1.40f), floattov16(1.41f), floattov16(1.42f), floattov16(1.43f), floattov16(1.44f), - floattov16(1.45f), floattov16(1.46f), floattov16(1.47f), floattov16(1.48f), floattov16(1.49f), - floattov16(1.50f), floattov16(1.51f), floattov16(1.52f), floattov16(1.53f), floattov16(1.54f), - floattov16(1.55f), floattov16(1.56f), floattov16(1.57f), floattov16(1.58f), floattov16(1.59f), - floattov16(1.60f), floattov16(1.61f), floattov16(1.62f), floattov16(1.63f), floattov16(1.64f), - floattov16(1.65f), floattov16(1.66f), floattov16(1.67f), floattov16(1.68f), floattov16(1.69f), - floattov16(1.70f), floattov16(1.71f), floattov16(1.72f), floattov16(1.73f), floattov16(1.74f), - floattov16(1.75f), floattov16(1.76f), floattov16(1.77f), floattov16(1.78f), floattov16(1.79f), - floattov16(1.80f), floattov16(1.81f), floattov16(1.82f), floattov16(1.83f), floattov16(1.84f), - floattov16(1.85f), floattov16(1.86f), floattov16(1.87f), floattov16(1.88f), floattov16(1.89f), - floattov16(1.90f), floattov16(1.91f), floattov16(1.92f), floattov16(1.93f), floattov16(1.94f), - floattov16(1.95f), floattov16(1.96f), floattov16(1.97f), floattov16(1.98f), floattov16(1.99f), - - floattov16(2.00f), floattov16(2.01f), floattov16(2.02f), floattov16(2.03f), floattov16(2.04f), - floattov16(2.05f), floattov16(2.06f), floattov16(2.07f), floattov16(2.08f), floattov16(2.09f), - floattov16(2.10f), floattov16(2.11f), floattov16(2.12f), floattov16(2.13f), floattov16(2.14f), - floattov16(2.15f), floattov16(2.16f), floattov16(2.17f), floattov16(2.18f), floattov16(2.19f), - floattov16(2.20f), floattov16(2.21f), floattov16(2.22f), floattov16(2.23f), floattov16(2.24f), - floattov16(2.25f), floattov16(2.26f), floattov16(2.27f), floattov16(2.28f), floattov16(2.29f), - floattov16(2.30f), floattov16(2.31f), floattov16(2.32f), floattov16(2.33f), floattov16(2.34f), - floattov16(2.35f), floattov16(2.36f), floattov16(2.37f), floattov16(2.38f), floattov16(2.39f), - floattov16(2.40f), floattov16(2.41f), floattov16(2.42f), floattov16(2.43f), floattov16(2.44f), - floattov16(2.45f), floattov16(2.46f), floattov16(2.47f), floattov16(2.48f), floattov16(2.49f), - floattov16(2.50f), floattov16(2.51f), floattov16(2.52f), floattov16(2.53f), floattov16(2.54f), - floattov16(2.55f), floattov16(2.56f), floattov16(2.57f), floattov16(2.58f), floattov16(2.59f), - floattov16(2.60f), floattov16(2.61f), floattov16(2.62f), floattov16(2.63f), floattov16(2.64f), - floattov16(2.65f), floattov16(2.66f), floattov16(2.67f), floattov16(2.68f), floattov16(2.69f), - floattov16(2.70f), floattov16(2.71f), floattov16(2.72f), floattov16(2.73f), floattov16(2.74f), - floattov16(2.75f), floattov16(2.76f), floattov16(2.77f), floattov16(2.78f), floattov16(2.79f), - floattov16(2.80f), floattov16(2.81f), floattov16(2.82f), floattov16(2.83f), floattov16(2.84f), - floattov16(2.85f), floattov16(2.86f), floattov16(2.87f), floattov16(2.88f), floattov16(2.89f), - floattov16(2.90f), floattov16(2.91f), floattov16(2.92f), floattov16(2.93f), floattov16(2.94f), - floattov16(2.95f), floattov16(2.96f), floattov16(2.97f), floattov16(2.98f), floattov16(2.99f), - - floattov16(3.00f), floattov16(3.01f), floattov16(3.02f), floattov16(3.03f), floattov16(3.04f), - floattov16(3.05f), floattov16(3.06f), floattov16(3.07f), floattov16(3.08f), floattov16(3.09f), - floattov16(3.10f), floattov16(3.11f), floattov16(3.12f), floattov16(3.13f), floattov16(3.14f), - floattov16(3.15f), floattov16(3.16f), floattov16(3.17f), floattov16(3.18f), floattov16(3.19f), - floattov16(3.20f), floattov16(3.21f), floattov16(3.22f), floattov16(3.23f), floattov16(3.24f), - floattov16(3.25f), floattov16(3.26f), floattov16(3.27f), floattov16(3.28f), floattov16(3.29f), - floattov16(3.30f), floattov16(3.31f), floattov16(3.32f), floattov16(3.33f), floattov16(3.34f), - floattov16(3.35f), floattov16(3.36f), floattov16(3.37f), floattov16(3.38f), floattov16(3.39f), - floattov16(3.40f), floattov16(3.41f), floattov16(3.42f), floattov16(3.43f), floattov16(3.44f), - floattov16(3.45f), floattov16(3.46f), floattov16(3.47f), floattov16(3.48f), floattov16(3.49f), - floattov16(3.50f), floattov16(3.51f), floattov16(3.52f), floattov16(3.53f), floattov16(3.54f), - floattov16(3.55f), floattov16(3.56f), floattov16(3.57f), floattov16(3.58f), floattov16(3.59f), - floattov16(3.60f), floattov16(3.61f), floattov16(3.62f), floattov16(3.63f), floattov16(3.64f), - floattov16(3.65f), floattov16(3.66f), floattov16(3.67f), floattov16(3.68f), floattov16(3.69f), - floattov16(3.70f), floattov16(3.71f), floattov16(3.72f), floattov16(3.73f), floattov16(3.74f), - floattov16(3.75f), floattov16(3.76f), floattov16(3.77f), floattov16(3.78f), floattov16(3.79f), - floattov16(3.80f), floattov16(3.81f), floattov16(3.82f), floattov16(3.83f), floattov16(3.84f), - floattov16(3.85f), floattov16(3.86f), floattov16(3.87f), floattov16(3.88f), floattov16(3.89f), - floattov16(3.90f), floattov16(3.91f), floattov16(3.92f), floattov16(3.93f), floattov16(3.94f), - floattov16(3.95f), floattov16(3.96f), floattov16(3.97f), floattov16(3.98f), floattov16(3.99f), - - floattov16(4.00f), floattov16(4.01f), floattov16(4.02f), floattov16(4.03f), floattov16(4.04f), - floattov16(4.05f), floattov16(4.06f), floattov16(4.07f), floattov16(4.08f), floattov16(4.09f), - floattov16(4.10f), floattov16(4.11f), floattov16(4.12f), floattov16(4.13f), floattov16(4.14f), - floattov16(4.15f), floattov16(4.16f), floattov16(4.17f), floattov16(4.18f), floattov16(4.19f), - floattov16(4.20f), floattov16(4.21f), floattov16(4.22f), floattov16(4.23f), floattov16(4.24f), - floattov16(4.25f), floattov16(4.26f), floattov16(4.27f), floattov16(4.28f), floattov16(4.29f), - floattov16(4.30f), floattov16(4.31f), floattov16(4.32f), floattov16(4.33f), floattov16(4.34f), - floattov16(4.35f), floattov16(4.36f), floattov16(4.37f), floattov16(4.38f), floattov16(4.39f), - floattov16(4.40f), floattov16(4.41f), floattov16(4.42f), floattov16(4.43f), floattov16(4.44f), - floattov16(4.45f), floattov16(4.46f), floattov16(4.47f), floattov16(4.48f), floattov16(4.49f), - floattov16(4.50f), floattov16(4.51f), floattov16(4.52f), floattov16(4.53f), floattov16(4.54f), - floattov16(4.55f), floattov16(4.56f), floattov16(4.57f), floattov16(4.58f), floattov16(4.59f), - floattov16(4.60f), floattov16(4.61f), floattov16(4.62f), floattov16(4.63f), floattov16(4.64f), - floattov16(4.65f), floattov16(4.66f), floattov16(4.67f), floattov16(4.68f), floattov16(4.69f), - floattov16(4.70f), floattov16(4.71f), floattov16(4.72f), floattov16(4.73f), floattov16(4.74f), - floattov16(4.75f), floattov16(4.76f), floattov16(4.77f), floattov16(4.78f), floattov16(4.79f), - floattov16(4.80f), floattov16(4.81f), floattov16(4.82f), floattov16(4.83f), floattov16(4.84f), - floattov16(4.85f), floattov16(4.86f), floattov16(4.87f), floattov16(4.88f), floattov16(4.89f), - floattov16(4.90f), floattov16(4.91f), floattov16(4.92f), floattov16(4.93f), floattov16(4.94f), - floattov16(4.95f), floattov16(4.96f), floattov16(4.97f), floattov16(4.98f), floattov16(4.99f), - - floattov16(5.00f), floattov16(5.01f), floattov16(5.02f), floattov16(5.03f), floattov16(5.04f), - floattov16(5.05f), floattov16(5.06f), floattov16(5.07f), floattov16(5.08f), floattov16(5.09f), - floattov16(5.10f), floattov16(5.11f), floattov16(5.12f), floattov16(5.13f), floattov16(5.14f), - floattov16(5.15f), floattov16(5.16f), floattov16(5.17f), floattov16(5.18f), floattov16(5.19f), - floattov16(5.20f), floattov16(5.21f), floattov16(5.22f), floattov16(5.23f), floattov16(5.24f), - floattov16(5.25f), floattov16(5.26f), floattov16(5.27f), floattov16(5.28f), floattov16(5.29f), - floattov16(5.30f), floattov16(5.31f), floattov16(5.32f), floattov16(5.33f), floattov16(5.34f), - floattov16(5.35f), floattov16(5.36f), floattov16(5.37f), floattov16(5.38f), floattov16(5.39f), - floattov16(5.40f), floattov16(5.41f), floattov16(5.42f), floattov16(5.43f), floattov16(5.44f), - floattov16(5.45f), floattov16(5.46f), floattov16(5.47f), floattov16(5.48f), floattov16(5.49f), - floattov16(5.50f), floattov16(5.51f), floattov16(5.52f), floattov16(5.53f), floattov16(5.54f), - floattov16(5.55f), floattov16(5.56f), floattov16(5.57f), floattov16(5.58f), floattov16(5.59f), - floattov16(5.60f), floattov16(5.61f), floattov16(5.62f), floattov16(5.63f), floattov16(5.64f), - floattov16(5.65f), floattov16(5.66f), floattov16(5.67f), floattov16(5.68f), floattov16(5.69f), - floattov16(5.70f), floattov16(5.71f), floattov16(5.72f), floattov16(5.73f), floattov16(5.74f), - floattov16(5.75f), floattov16(5.76f), floattov16(5.77f), floattov16(5.78f), floattov16(5.79f), - floattov16(5.80f), floattov16(5.81f), floattov16(5.82f), floattov16(5.83f), floattov16(5.84f), - floattov16(5.85f), floattov16(5.86f), floattov16(5.87f), floattov16(5.88f), floattov16(5.89f), - floattov16(5.90f), floattov16(5.91f), floattov16(5.92f), floattov16(5.93f), floattov16(5.94f), - floattov16(5.95f), floattov16(5.96f), floattov16(5.97f), floattov16(5.98f), floattov16(5.99f), - - floattov16(6.00f), floattov16(6.01f), floattov16(6.02f), floattov16(6.03f), floattov16(6.04f), - floattov16(6.05f), floattov16(6.06f), floattov16(6.07f), floattov16(6.08f), floattov16(6.09f), - floattov16(6.10f), floattov16(6.11f), floattov16(6.12f), floattov16(6.13f), floattov16(6.14f), - floattov16(6.15f), floattov16(6.16f), floattov16(6.17f), floattov16(6.18f), floattov16(6.19f), - floattov16(6.20f), floattov16(6.21f), floattov16(6.22f), floattov16(6.23f), floattov16(6.24f), - floattov16(6.25f), floattov16(6.26f), floattov16(6.27f), floattov16(6.28f), floattov16(6.29f), - floattov16(6.30f), floattov16(6.31f), floattov16(6.32f), floattov16(6.33f), floattov16(6.34f), - floattov16(6.35f), floattov16(6.36f), floattov16(6.37f), floattov16(6.38f), floattov16(6.39f), - floattov16(6.40f), floattov16(6.41f), floattov16(6.42f), floattov16(6.43f), floattov16(6.44f), - floattov16(6.45f), floattov16(6.46f), floattov16(6.47f), floattov16(6.48f), floattov16(6.49f), - floattov16(6.50f), floattov16(6.51f), floattov16(6.52f), floattov16(6.53f), floattov16(6.54f), - floattov16(6.55f), floattov16(6.56f), floattov16(6.57f), floattov16(6.58f), floattov16(6.59f), - floattov16(6.60f), floattov16(6.61f), floattov16(6.62f), floattov16(6.63f), floattov16(6.64f), - floattov16(6.65f), floattov16(6.66f), floattov16(6.67f), floattov16(6.68f), floattov16(6.69f), - floattov16(6.70f), floattov16(6.71f), floattov16(6.72f), floattov16(6.73f), floattov16(6.74f), - floattov16(6.75f), floattov16(6.76f), floattov16(6.77f), floattov16(6.78f), floattov16(6.79f), - floattov16(6.80f), floattov16(6.81f), floattov16(6.82f), floattov16(6.83f), floattov16(6.84f), - floattov16(6.85f), floattov16(6.86f), floattov16(6.87f), floattov16(6.88f), floattov16(6.89f), - floattov16(6.90f), floattov16(6.91f), floattov16(6.92f), floattov16(6.93f), floattov16(6.94f), - floattov16(6.95f), floattov16(6.96f), floattov16(6.97f), floattov16(6.98f), floattov16(6.99f), - - floattov16(7.00f), floattov16(7.01f), floattov16(7.02f), floattov16(7.03f), floattov16(7.04f), - floattov16(7.05f), floattov16(7.06f), floattov16(7.07f), floattov16(7.08f), floattov16(7.09f), - floattov16(7.10f), floattov16(7.11f), floattov16(7.12f), floattov16(7.13f), floattov16(7.14f), - floattov16(7.15f), floattov16(7.16f), floattov16(7.17f), floattov16(7.18f), floattov16(7.19f), - floattov16(7.20f), floattov16(7.21f), floattov16(7.22f), floattov16(7.23f), floattov16(7.24f), - floattov16(7.25f), floattov16(7.26f), floattov16(7.27f), floattov16(7.28f), floattov16(7.29f), - floattov16(7.30f), floattov16(7.31f), floattov16(7.32f), floattov16(7.33f), floattov16(7.34f), - floattov16(7.35f), floattov16(7.36f), floattov16(7.37f), floattov16(7.38f), floattov16(7.39f), - floattov16(7.40f), floattov16(7.41f), floattov16(7.42f), floattov16(7.43f), floattov16(7.44f), - floattov16(7.45f), floattov16(7.46f), floattov16(7.47f), floattov16(7.48f), floattov16(7.49f), - floattov16(7.50f), floattov16(7.51f), floattov16(7.52f), floattov16(7.53f), floattov16(7.54f), - floattov16(7.55f), floattov16(7.56f), floattov16(7.57f), floattov16(7.58f), floattov16(7.59f), - floattov16(7.60f), floattov16(7.61f), floattov16(7.62f), floattov16(7.63f), floattov16(7.64f), - floattov16(7.65f), floattov16(7.66f), floattov16(7.67f), floattov16(7.68f), floattov16(7.69f), - floattov16(7.70f), floattov16(7.71f), floattov16(7.72f), floattov16(7.73f), floattov16(7.74f), - floattov16(7.75f), floattov16(7.76f), floattov16(7.77f), floattov16(7.78f), floattov16(7.79f), - floattov16(7.80f), floattov16(7.81f), floattov16(7.82f), floattov16(7.83f), floattov16(7.84f), - floattov16(7.85f), floattov16(7.86f), floattov16(7.87f), floattov16(7.88f), floattov16(7.89f), - floattov16(7.90f), floattov16(7.91f), floattov16(7.92f), floattov16(7.93f), floattov16(7.94f), - floattov16(7.95f), floattov16(7.96f), floattov16(7.97f), floattov16(7.98f), floattov16(7.99f) -}; - +#include +#include "GfxInfo.h" + +/* +const float zvalue[] = +{ + 0.000f, 0.000f, -0.01f, //hitcircle + 0.000f, 0.000f, 0.000f, //hitspinner + -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, //slider ball + 0.015f, -0.01f, 0.000f, 0.000f, //hitslider + 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, //score + -0.005f, -0.005f, //slider score + -0.05f, -0.05f, -0.05f, -0.05f, -0.05f, //scorebar + 0.000f, //verdana9 + 0.000f //white +}; +*/ + +const u16 palette0[] = //circle, circleoverlay, circleapproach, disc, slidertick, sliderreverse, verdana9, white +{ + RGB15(31,0,31), RGB15(31,31,31), RGB15(28,28,28), RGB15(0,0,0) +}; + +const u16 palette1[] = //spinner, spinnerbars, scorebar_bar +{ + RGB15(31,31,31), RGB15(31,0,0), RGB15(31,4,0), RGB15(31,9,0), + RGB15(4,3,3), RGB15(29,14,7), RGB15(31,12,0), RGB15(31,17,0), + RGB15(31,23,7), RGB15(31,26,14), RGB15(31,23,0), RGB15(31,30,23), + RGB15(31,27,0), RGB15(31,31,8), RGB15(31,31,0), RGB15(0,14,22) +}; + +const u16 palette2[] = //spinnerbg +{ + RGB15(31,31,31), RGB15(1,2,5), RGB15(5,5,5), RGB15(0,0,0), + RGB15(5,13,31), RGB15(14,15,16), RGB15(2,5,13), RGB15(1,4,10), + RGB15(3,7,17), RGB15(3,8,21), RGB15(4,10,25), RGB15(1,3,8), + RGB15(5,11,28), RGB15(6,7,7), RGB15(4,5,8), RGB15(8,9,11) +}; + +const u16 palette3[] = //sliderball, sliderfollowcircle +{ + RGB15(31,0,31), RGB15(31,24,0), RGB15(31,0,0), RGB15(31,31,0) +}; + +const u16 palette4[] = //hit300, hit300k, hit300g, hit0 +{ + RGB15(31,0,31), RGB15(31,26,4), RGB15(30,18,1), RGB15(31,30,12), + RGB15(31,31,23), RGB15(9,6,4), RGB15(28,5,1), RGB15(3,3,4), + RGB15(1,1,1), RGB15(2,2,2), RGB15(5,4,4), RGB15(28,2,2), + RGB15(15,7,3), RGB15(13,13,10), RGB15(22,22,17), RGB15(21,17,4) +}; + +const u16 palette5[] = //hit50. hit100, hit100k +{ + RGB15(31,0,31), RGB15(3,3,4), RGB15(12,30,8), RGB15(4,10,3), + RGB15(7,25,3), RGB15(12,15,28), RGB15(19,31,16), RGB15(5,6,11), + RGB15(17,20,30), RGB15(6,9,23), RGB15(5,18,3), RGB15(23,24,29), + RGB15(28,30,29), RGB15(24,31,23), RGB15(12,13,13), RGB15(18,19,19) +}; + +const u16 palette6[] = //slider30, slider10 +{ + RGB15(31,0,31), RGB15(31,7,29), RGB15(0,0,0), RGB15(31,20,30) +}; + +const u16 palette7[] = //scorebar_ki, scorebar_kidanger, scorebar_kidanger2 +{ + RGB15(31,31,31), RGB15(1,0,0), RGB15(20,20,20), RGB15(10,0,0), + RGB15(27,0,0), RGB15(20,0,0), RGB15(7,8,4), RGB15(12,12,0), + RGB15(22,23,9), RGB15(16,17,0), RGB15(20,21,0), RGB15(31,31,9), + RGB15(24,24,0), RGB15(30,31,1), RGB15(27,28,1), RGB15(16,16,6) +}; + +const u16 palette8[] = //scorebar +{ + RGB15(31,31,31), RGB15(0,0,0), RGB15(10,17,31), RGB15(19,17,31), + RGB15(21,23,31), RGB15(11,11,12), RGB15(17,17,31), RGB15(14,19,31), + RGB15(5,5,6), RGB15(18,18,31), RGB15(23,22,31), RGB15(20,18,31), + RGB15(16,19,31), RGB15(19,21,31), RGB15(14,14,18), RGB15(15,16,22) +}; + +const u32 uv8x8[] = { + TEXTURE_PACK(inttot16(0),inttot16(0)), + TEXTURE_PACK(inttot16(8), inttot16(0)), + TEXTURE_PACK(inttot16(8),inttot16(8)), + TEXTURE_PACK(inttot16(0), inttot16(8)) +}; + +const u32 uv16x16[] = { + TEXTURE_PACK(inttot16(0),inttot16(0)), + TEXTURE_PACK(inttot16(16), inttot16(0)), + TEXTURE_PACK(inttot16(16),inttot16(16)), + TEXTURE_PACK(inttot16(0), inttot16(16)) +}; + +const u32 uv32x32[] = { + TEXTURE_PACK(inttot16(0),inttot16(0)), + TEXTURE_PACK(inttot16(32), inttot16(0)), + TEXTURE_PACK(inttot16(32),inttot16(32)), + TEXTURE_PACK(inttot16(0), inttot16(32)) +}; + +const u32 uv64x64[] = { + TEXTURE_PACK(inttot16(0),inttot16(0)), + TEXTURE_PACK(inttot16(64), 0), + TEXTURE_PACK(inttot16(64),inttot16(64)), + TEXTURE_PACK(inttot16(0), inttot16(64)) +}; + +const u32 uv128x128[] = { + TEXTURE_PACK(inttot16(0),inttot16(0)), + TEXTURE_PACK(inttot16(128), inttot16(0)), + TEXTURE_PACK(inttot16(128),inttot16(128)), + TEXTURE_PACK(inttot16(0), inttot16(128)) +}; + +const u32 uv256x16[] = { + TEXTURE_PACK(inttot16(0),inttot16(0)), + TEXTURE_PACK(inttot16(256), inttot16(0)), + TEXTURE_PACK(inttot16(256),inttot16(16)), + TEXTURE_PACK(inttot16(0), inttot16(16)) +}; + +const u32 uv256x192[] = { + TEXTURE_PACK(inttot16(0),inttot16(0)), + TEXTURE_PACK(inttot16(256), inttot16(0)), + TEXTURE_PACK(inttot16(256),inttot16(192)), + TEXTURE_PACK(inttot16(0), inttot16(192)) +}; + +const v16 plu[] = { + floattov16(-2.00f), + floattov16(-1.99f), floattov16(-1.98f), floattov16(-1.97f), floattov16(-1.96f), floattov16(-1.95f), + floattov16(-1.94f), floattov16(-1.93f), floattov16(-1.92f), floattov16(-1.91f), floattov16(-1.90f), + floattov16(-1.89f), floattov16(-1.88f), floattov16(-1.87f), floattov16(-1.86f), floattov16(-1.85f), + floattov16(-1.84f), floattov16(-1.83f), floattov16(-1.82f), floattov16(-1.81f), floattov16(-1.80f), + floattov16(-1.79f), floattov16(-1.78f), floattov16(-1.77f), floattov16(-1.76f), floattov16(-1.75f), + floattov16(-1.74f), floattov16(-1.73f), floattov16(-1.72f), floattov16(-1.71f), floattov16(-1.70f), + floattov16(-1.69f), floattov16(-1.68f), floattov16(-1.67f), floattov16(-1.66f), floattov16(-1.65f), + floattov16(-1.64f), floattov16(-1.63f), floattov16(-1.62f), floattov16(-1.61f), floattov16(-1.60f), + floattov16(-1.59f), floattov16(-1.58f), floattov16(-1.57f), floattov16(-1.56f), floattov16(-1.55f), + floattov16(-1.54f), floattov16(-1.53f), floattov16(-1.52f), floattov16(-1.51f), floattov16(-1.50f), + floattov16(-1.49f), floattov16(-1.48f), floattov16(-1.47f), floattov16(-1.46f), floattov16(-1.45f), + floattov16(-1.44f), floattov16(-1.43f), floattov16(-1.42f), floattov16(-1.41f), floattov16(-1.40f), + floattov16(-1.39f), floattov16(-1.38f), floattov16(-1.37f), floattov16(-1.36f), floattov16(-1.35f), + floattov16(-1.34f), floattov16(-1.33f), floattov16(-1.32f), floattov16(-1.31f), floattov16(-1.30f), + floattov16(-1.29f), floattov16(-1.28f), floattov16(-1.27f), floattov16(-1.26f), floattov16(-1.25f), + floattov16(-1.24f), floattov16(-1.23f), floattov16(-1.22f), floattov16(-1.21f), floattov16(-1.20f), + floattov16(-1.19f), floattov16(-1.18f), floattov16(-1.17f), floattov16(-1.16f), floattov16(-1.15f), + floattov16(-1.14f), floattov16(-1.13f), floattov16(-1.12f), floattov16(-1.11f), floattov16(-1.10f), + floattov16(-1.09f), floattov16(-1.08f), floattov16(-1.07f), floattov16(-1.06f), floattov16(-1.05f), + floattov16(-1.04f), floattov16(-1.03f), floattov16(-1.02f), floattov16(-1.01f), floattov16(-1.00f), + + floattov16(-0.99f), floattov16(-0.98f), floattov16(-0.97f), floattov16(-0.96f), floattov16(-0.95f), + floattov16(-0.94f), floattov16(-0.93f), floattov16(-0.92f), floattov16(-0.91f), floattov16(-0.90f), + floattov16(-0.89f), floattov16(-0.88f), floattov16(-0.87f), floattov16(-0.86f), floattov16(-0.85f), + floattov16(-0.84f), floattov16(-0.83f), floattov16(-0.82f), floattov16(-0.81f), floattov16(-0.80f), + floattov16(-0.79f), floattov16(-0.78f), floattov16(-0.77f), floattov16(-0.76f), floattov16(-0.75f), + floattov16(-0.74f), floattov16(-0.73f), floattov16(-0.72f), floattov16(-0.71f), floattov16(-0.70f), + floattov16(-0.69f), floattov16(-0.68f), floattov16(-0.67f), floattov16(-0.66f), floattov16(-0.65f), + floattov16(-0.64f), floattov16(-0.63f), floattov16(-0.62f), floattov16(-0.61f), floattov16(-0.60f), + floattov16(-0.59f), floattov16(-0.58f), floattov16(-0.57f), floattov16(-0.56f), floattov16(-0.55f), + floattov16(-0.54f), floattov16(-0.53f), floattov16(-0.52f), floattov16(-0.51f), floattov16(-0.50f), + floattov16(-0.49f), floattov16(-0.48f), floattov16(-0.47f), floattov16(-0.46f), floattov16(-0.45f), + floattov16(-0.44f), floattov16(-0.43f), floattov16(-0.42f), floattov16(-0.41f), floattov16(-0.40f), + floattov16(-0.39f), floattov16(-0.38f), floattov16(-0.37f), floattov16(-0.36f), floattov16(-0.35f), + floattov16(-0.34f), floattov16(-0.33f), floattov16(-0.32f), floattov16(-0.31f), floattov16(-0.30f), + floattov16(-0.29f), floattov16(-0.28f), floattov16(-0.27f), floattov16(-0.26f), floattov16(-0.25f), + floattov16(-0.24f), floattov16(-0.23f), floattov16(-0.22f), floattov16(-0.21f), floattov16(-0.20f), + floattov16(-0.19f), floattov16(-0.18f), floattov16(-0.17f), floattov16(-0.16f), floattov16(-0.15f), + floattov16(-0.14f), floattov16(-0.13f), floattov16(-0.12f), floattov16(-0.11f), floattov16(-0.10f), + floattov16(-0.09f), floattov16(-0.08f), floattov16(-0.07f), floattov16(-0.06f), floattov16(-0.05f), + floattov16(-0.04f), floattov16(-0.03f), floattov16(-0.02f), floattov16(-0.01f), + + floattov16(0.00f), floattov16(0.01f), floattov16(0.02f), floattov16(0.03f), floattov16(0.04f), + floattov16(0.05f), floattov16(0.06f), floattov16(0.07f), floattov16(0.08f), floattov16(0.09f), + floattov16(0.10f), floattov16(0.11f), floattov16(0.12f), floattov16(0.13f), floattov16(0.14f), + floattov16(0.15f), floattov16(0.16f), floattov16(0.17f), floattov16(0.18f), floattov16(0.19f), + floattov16(0.20f), floattov16(0.21f), floattov16(0.22f), floattov16(0.23f), floattov16(0.24f), + floattov16(0.25f), floattov16(0.26f), floattov16(0.27f), floattov16(0.28f), floattov16(0.29f), + floattov16(0.30f), floattov16(0.31f), floattov16(0.32f), floattov16(0.33f), floattov16(0.34f), + floattov16(0.35f), floattov16(0.36f), floattov16(0.37f), floattov16(0.38f), floattov16(0.39f), + floattov16(0.40f), floattov16(0.41f), floattov16(0.42f), floattov16(0.43f), floattov16(0.44f), + floattov16(0.45f), floattov16(0.46f), floattov16(0.47f), floattov16(0.48f), floattov16(0.49f), + floattov16(0.50f), floattov16(0.51f), floattov16(0.52f), floattov16(0.53f), floattov16(0.54f), + floattov16(0.55f), floattov16(0.56f), floattov16(0.57f), floattov16(0.58f), floattov16(0.59f), + floattov16(0.60f), floattov16(0.61f), floattov16(0.62f), floattov16(0.63f), floattov16(0.64f), + floattov16(0.65f), floattov16(0.66f), floattov16(0.67f), floattov16(0.68f), floattov16(0.69f), + floattov16(0.70f), floattov16(0.71f), floattov16(0.72f), floattov16(0.73f), floattov16(0.74f), + floattov16(0.75f), floattov16(0.76f), floattov16(0.77f), floattov16(0.78f), floattov16(0.79f), + floattov16(0.80f), floattov16(0.81f), floattov16(0.82f), floattov16(0.83f), floattov16(0.84f), + floattov16(0.85f), floattov16(0.86f), floattov16(0.87f), floattov16(0.88f), floattov16(0.89f), + floattov16(0.90f), floattov16(0.91f), floattov16(0.92f), floattov16(0.93f), floattov16(0.94f), + floattov16(0.95f), floattov16(0.96f), floattov16(0.97f), floattov16(0.98f), floattov16(0.99f), + + floattov16(1.00f), floattov16(1.01f), floattov16(1.02f), floattov16(1.03f), floattov16(1.04f), + floattov16(1.05f), floattov16(1.06f), floattov16(1.07f), floattov16(1.08f), floattov16(1.09f), + floattov16(1.10f), floattov16(1.11f), floattov16(1.12f), floattov16(1.13f), floattov16(1.14f), + floattov16(1.15f), floattov16(1.16f), floattov16(1.17f), floattov16(1.18f), floattov16(1.19f), + floattov16(1.20f), floattov16(1.21f), floattov16(1.22f), floattov16(1.23f), floattov16(1.24f), + floattov16(1.25f), floattov16(1.26f), floattov16(1.27f), floattov16(1.28f), floattov16(1.29f), + floattov16(1.30f), floattov16(1.31f), floattov16(1.32f), floattov16(1.33f), floattov16(1.34f), + floattov16(1.35f), floattov16(1.36f), floattov16(1.37f), floattov16(1.38f), floattov16(1.39f), + floattov16(1.40f), floattov16(1.41f), floattov16(1.42f), floattov16(1.43f), floattov16(1.44f), + floattov16(1.45f), floattov16(1.46f), floattov16(1.47f), floattov16(1.48f), floattov16(1.49f), + floattov16(1.50f), floattov16(1.51f), floattov16(1.52f), floattov16(1.53f), floattov16(1.54f), + floattov16(1.55f), floattov16(1.56f), floattov16(1.57f), floattov16(1.58f), floattov16(1.59f), + floattov16(1.60f), floattov16(1.61f), floattov16(1.62f), floattov16(1.63f), floattov16(1.64f), + floattov16(1.65f), floattov16(1.66f), floattov16(1.67f), floattov16(1.68f), floattov16(1.69f), + floattov16(1.70f), floattov16(1.71f), floattov16(1.72f), floattov16(1.73f), floattov16(1.74f), + floattov16(1.75f), floattov16(1.76f), floattov16(1.77f), floattov16(1.78f), floattov16(1.79f), + floattov16(1.80f), floattov16(1.81f), floattov16(1.82f), floattov16(1.83f), floattov16(1.84f), + floattov16(1.85f), floattov16(1.86f), floattov16(1.87f), floattov16(1.88f), floattov16(1.89f), + floattov16(1.90f), floattov16(1.91f), floattov16(1.92f), floattov16(1.93f), floattov16(1.94f), + floattov16(1.95f), floattov16(1.96f), floattov16(1.97f), floattov16(1.98f), floattov16(1.99f), + + floattov16(2.00f), floattov16(2.01f), floattov16(2.02f), floattov16(2.03f), floattov16(2.04f), + floattov16(2.05f), floattov16(2.06f), floattov16(2.07f), floattov16(2.08f), floattov16(2.09f), + floattov16(2.10f), floattov16(2.11f), floattov16(2.12f), floattov16(2.13f), floattov16(2.14f), + floattov16(2.15f), floattov16(2.16f), floattov16(2.17f), floattov16(2.18f), floattov16(2.19f), + floattov16(2.20f), floattov16(2.21f), floattov16(2.22f), floattov16(2.23f), floattov16(2.24f), + floattov16(2.25f), floattov16(2.26f), floattov16(2.27f), floattov16(2.28f), floattov16(2.29f), + floattov16(2.30f), floattov16(2.31f), floattov16(2.32f), floattov16(2.33f), floattov16(2.34f), + floattov16(2.35f), floattov16(2.36f), floattov16(2.37f), floattov16(2.38f), floattov16(2.39f), + floattov16(2.40f), floattov16(2.41f), floattov16(2.42f), floattov16(2.43f), floattov16(2.44f), + floattov16(2.45f), floattov16(2.46f), floattov16(2.47f), floattov16(2.48f), floattov16(2.49f), + floattov16(2.50f), floattov16(2.51f), floattov16(2.52f), floattov16(2.53f), floattov16(2.54f), + floattov16(2.55f), floattov16(2.56f), floattov16(2.57f), floattov16(2.58f), floattov16(2.59f), + floattov16(2.60f), floattov16(2.61f), floattov16(2.62f), floattov16(2.63f), floattov16(2.64f), + floattov16(2.65f), floattov16(2.66f), floattov16(2.67f), floattov16(2.68f), floattov16(2.69f), + floattov16(2.70f), floattov16(2.71f), floattov16(2.72f), floattov16(2.73f), floattov16(2.74f), + floattov16(2.75f), floattov16(2.76f), floattov16(2.77f), floattov16(2.78f), floattov16(2.79f), + floattov16(2.80f), floattov16(2.81f), floattov16(2.82f), floattov16(2.83f), floattov16(2.84f), + floattov16(2.85f), floattov16(2.86f), floattov16(2.87f), floattov16(2.88f), floattov16(2.89f), + floattov16(2.90f), floattov16(2.91f), floattov16(2.92f), floattov16(2.93f), floattov16(2.94f), + floattov16(2.95f), floattov16(2.96f), floattov16(2.97f), floattov16(2.98f), floattov16(2.99f), + + floattov16(3.00f), floattov16(3.01f), floattov16(3.02f), floattov16(3.03f), floattov16(3.04f), + floattov16(3.05f), floattov16(3.06f), floattov16(3.07f), floattov16(3.08f), floattov16(3.09f), + floattov16(3.10f), floattov16(3.11f), floattov16(3.12f), floattov16(3.13f), floattov16(3.14f), + floattov16(3.15f), floattov16(3.16f), floattov16(3.17f), floattov16(3.18f), floattov16(3.19f), + floattov16(3.20f), floattov16(3.21f), floattov16(3.22f), floattov16(3.23f), floattov16(3.24f), + floattov16(3.25f), floattov16(3.26f), floattov16(3.27f), floattov16(3.28f), floattov16(3.29f), + floattov16(3.30f), floattov16(3.31f), floattov16(3.32f), floattov16(3.33f), floattov16(3.34f), + floattov16(3.35f), floattov16(3.36f), floattov16(3.37f), floattov16(3.38f), floattov16(3.39f), + floattov16(3.40f), floattov16(3.41f), floattov16(3.42f), floattov16(3.43f), floattov16(3.44f), + floattov16(3.45f), floattov16(3.46f), floattov16(3.47f), floattov16(3.48f), floattov16(3.49f), + floattov16(3.50f), floattov16(3.51f), floattov16(3.52f), floattov16(3.53f), floattov16(3.54f), + floattov16(3.55f), floattov16(3.56f), floattov16(3.57f), floattov16(3.58f), floattov16(3.59f), + floattov16(3.60f), floattov16(3.61f), floattov16(3.62f), floattov16(3.63f), floattov16(3.64f), + floattov16(3.65f), floattov16(3.66f), floattov16(3.67f), floattov16(3.68f), floattov16(3.69f), + floattov16(3.70f), floattov16(3.71f), floattov16(3.72f), floattov16(3.73f), floattov16(3.74f), + floattov16(3.75f), floattov16(3.76f), floattov16(3.77f), floattov16(3.78f), floattov16(3.79f), + floattov16(3.80f), floattov16(3.81f), floattov16(3.82f), floattov16(3.83f), floattov16(3.84f), + floattov16(3.85f), floattov16(3.86f), floattov16(3.87f), floattov16(3.88f), floattov16(3.89f), + floattov16(3.90f), floattov16(3.91f), floattov16(3.92f), floattov16(3.93f), floattov16(3.94f), + floattov16(3.95f), floattov16(3.96f), floattov16(3.97f), floattov16(3.98f), floattov16(3.99f), + + floattov16(4.00f), floattov16(4.01f), floattov16(4.02f), floattov16(4.03f), floattov16(4.04f), + floattov16(4.05f), floattov16(4.06f), floattov16(4.07f), floattov16(4.08f), floattov16(4.09f), + floattov16(4.10f), floattov16(4.11f), floattov16(4.12f), floattov16(4.13f), floattov16(4.14f), + floattov16(4.15f), floattov16(4.16f), floattov16(4.17f), floattov16(4.18f), floattov16(4.19f), + floattov16(4.20f), floattov16(4.21f), floattov16(4.22f), floattov16(4.23f), floattov16(4.24f), + floattov16(4.25f), floattov16(4.26f), floattov16(4.27f), floattov16(4.28f), floattov16(4.29f), + floattov16(4.30f), floattov16(4.31f), floattov16(4.32f), floattov16(4.33f), floattov16(4.34f), + floattov16(4.35f), floattov16(4.36f), floattov16(4.37f), floattov16(4.38f), floattov16(4.39f), + floattov16(4.40f), floattov16(4.41f), floattov16(4.42f), floattov16(4.43f), floattov16(4.44f), + floattov16(4.45f), floattov16(4.46f), floattov16(4.47f), floattov16(4.48f), floattov16(4.49f), + floattov16(4.50f), floattov16(4.51f), floattov16(4.52f), floattov16(4.53f), floattov16(4.54f), + floattov16(4.55f), floattov16(4.56f), floattov16(4.57f), floattov16(4.58f), floattov16(4.59f), + floattov16(4.60f), floattov16(4.61f), floattov16(4.62f), floattov16(4.63f), floattov16(4.64f), + floattov16(4.65f), floattov16(4.66f), floattov16(4.67f), floattov16(4.68f), floattov16(4.69f), + floattov16(4.70f), floattov16(4.71f), floattov16(4.72f), floattov16(4.73f), floattov16(4.74f), + floattov16(4.75f), floattov16(4.76f), floattov16(4.77f), floattov16(4.78f), floattov16(4.79f), + floattov16(4.80f), floattov16(4.81f), floattov16(4.82f), floattov16(4.83f), floattov16(4.84f), + floattov16(4.85f), floattov16(4.86f), floattov16(4.87f), floattov16(4.88f), floattov16(4.89f), + floattov16(4.90f), floattov16(4.91f), floattov16(4.92f), floattov16(4.93f), floattov16(4.94f), + floattov16(4.95f), floattov16(4.96f), floattov16(4.97f), floattov16(4.98f), floattov16(4.99f), + + floattov16(5.00f), floattov16(5.01f), floattov16(5.02f), floattov16(5.03f), floattov16(5.04f), + floattov16(5.05f), floattov16(5.06f), floattov16(5.07f), floattov16(5.08f), floattov16(5.09f), + floattov16(5.10f), floattov16(5.11f), floattov16(5.12f), floattov16(5.13f), floattov16(5.14f), + floattov16(5.15f), floattov16(5.16f), floattov16(5.17f), floattov16(5.18f), floattov16(5.19f), + floattov16(5.20f), floattov16(5.21f), floattov16(5.22f), floattov16(5.23f), floattov16(5.24f), + floattov16(5.25f), floattov16(5.26f), floattov16(5.27f), floattov16(5.28f), floattov16(5.29f), + floattov16(5.30f), floattov16(5.31f), floattov16(5.32f), floattov16(5.33f), floattov16(5.34f), + floattov16(5.35f), floattov16(5.36f), floattov16(5.37f), floattov16(5.38f), floattov16(5.39f), + floattov16(5.40f), floattov16(5.41f), floattov16(5.42f), floattov16(5.43f), floattov16(5.44f), + floattov16(5.45f), floattov16(5.46f), floattov16(5.47f), floattov16(5.48f), floattov16(5.49f), + floattov16(5.50f), floattov16(5.51f), floattov16(5.52f), floattov16(5.53f), floattov16(5.54f), + floattov16(5.55f), floattov16(5.56f), floattov16(5.57f), floattov16(5.58f), floattov16(5.59f), + floattov16(5.60f), floattov16(5.61f), floattov16(5.62f), floattov16(5.63f), floattov16(5.64f), + floattov16(5.65f), floattov16(5.66f), floattov16(5.67f), floattov16(5.68f), floattov16(5.69f), + floattov16(5.70f), floattov16(5.71f), floattov16(5.72f), floattov16(5.73f), floattov16(5.74f), + floattov16(5.75f), floattov16(5.76f), floattov16(5.77f), floattov16(5.78f), floattov16(5.79f), + floattov16(5.80f), floattov16(5.81f), floattov16(5.82f), floattov16(5.83f), floattov16(5.84f), + floattov16(5.85f), floattov16(5.86f), floattov16(5.87f), floattov16(5.88f), floattov16(5.89f), + floattov16(5.90f), floattov16(5.91f), floattov16(5.92f), floattov16(5.93f), floattov16(5.94f), + floattov16(5.95f), floattov16(5.96f), floattov16(5.97f), floattov16(5.98f), floattov16(5.99f), + + floattov16(6.00f), floattov16(6.01f), floattov16(6.02f), floattov16(6.03f), floattov16(6.04f), + floattov16(6.05f), floattov16(6.06f), floattov16(6.07f), floattov16(6.08f), floattov16(6.09f), + floattov16(6.10f), floattov16(6.11f), floattov16(6.12f), floattov16(6.13f), floattov16(6.14f), + floattov16(6.15f), floattov16(6.16f), floattov16(6.17f), floattov16(6.18f), floattov16(6.19f), + floattov16(6.20f), floattov16(6.21f), floattov16(6.22f), floattov16(6.23f), floattov16(6.24f), + floattov16(6.25f), floattov16(6.26f), floattov16(6.27f), floattov16(6.28f), floattov16(6.29f), + floattov16(6.30f), floattov16(6.31f), floattov16(6.32f), floattov16(6.33f), floattov16(6.34f), + floattov16(6.35f), floattov16(6.36f), floattov16(6.37f), floattov16(6.38f), floattov16(6.39f), + floattov16(6.40f), floattov16(6.41f), floattov16(6.42f), floattov16(6.43f), floattov16(6.44f), + floattov16(6.45f), floattov16(6.46f), floattov16(6.47f), floattov16(6.48f), floattov16(6.49f), + floattov16(6.50f), floattov16(6.51f), floattov16(6.52f), floattov16(6.53f), floattov16(6.54f), + floattov16(6.55f), floattov16(6.56f), floattov16(6.57f), floattov16(6.58f), floattov16(6.59f), + floattov16(6.60f), floattov16(6.61f), floattov16(6.62f), floattov16(6.63f), floattov16(6.64f), + floattov16(6.65f), floattov16(6.66f), floattov16(6.67f), floattov16(6.68f), floattov16(6.69f), + floattov16(6.70f), floattov16(6.71f), floattov16(6.72f), floattov16(6.73f), floattov16(6.74f), + floattov16(6.75f), floattov16(6.76f), floattov16(6.77f), floattov16(6.78f), floattov16(6.79f), + floattov16(6.80f), floattov16(6.81f), floattov16(6.82f), floattov16(6.83f), floattov16(6.84f), + floattov16(6.85f), floattov16(6.86f), floattov16(6.87f), floattov16(6.88f), floattov16(6.89f), + floattov16(6.90f), floattov16(6.91f), floattov16(6.92f), floattov16(6.93f), floattov16(6.94f), + floattov16(6.95f), floattov16(6.96f), floattov16(6.97f), floattov16(6.98f), floattov16(6.99f), + + floattov16(7.00f), floattov16(7.01f), floattov16(7.02f), floattov16(7.03f), floattov16(7.04f), + floattov16(7.05f), floattov16(7.06f), floattov16(7.07f), floattov16(7.08f), floattov16(7.09f), + floattov16(7.10f), floattov16(7.11f), floattov16(7.12f), floattov16(7.13f), floattov16(7.14f), + floattov16(7.15f), floattov16(7.16f), floattov16(7.17f), floattov16(7.18f), floattov16(7.19f), + floattov16(7.20f), floattov16(7.21f), floattov16(7.22f), floattov16(7.23f), floattov16(7.24f), + floattov16(7.25f), floattov16(7.26f), floattov16(7.27f), floattov16(7.28f), floattov16(7.29f), + floattov16(7.30f), floattov16(7.31f), floattov16(7.32f), floattov16(7.33f), floattov16(7.34f), + floattov16(7.35f), floattov16(7.36f), floattov16(7.37f), floattov16(7.38f), floattov16(7.39f), + floattov16(7.40f), floattov16(7.41f), floattov16(7.42f), floattov16(7.43f), floattov16(7.44f), + floattov16(7.45f), floattov16(7.46f), floattov16(7.47f), floattov16(7.48f), floattov16(7.49f), + floattov16(7.50f), floattov16(7.51f), floattov16(7.52f), floattov16(7.53f), floattov16(7.54f), + floattov16(7.55f), floattov16(7.56f), floattov16(7.57f), floattov16(7.58f), floattov16(7.59f), + floattov16(7.60f), floattov16(7.61f), floattov16(7.62f), floattov16(7.63f), floattov16(7.64f), + floattov16(7.65f), floattov16(7.66f), floattov16(7.67f), floattov16(7.68f), floattov16(7.69f), + floattov16(7.70f), floattov16(7.71f), floattov16(7.72f), floattov16(7.73f), floattov16(7.74f), + floattov16(7.75f), floattov16(7.76f), floattov16(7.77f), floattov16(7.78f), floattov16(7.79f), + floattov16(7.80f), floattov16(7.81f), floattov16(7.82f), floattov16(7.83f), floattov16(7.84f), + floattov16(7.85f), floattov16(7.86f), floattov16(7.87f), floattov16(7.88f), floattov16(7.89f), + floattov16(7.90f), floattov16(7.91f), floattov16(7.92f), floattov16(7.93f), floattov16(7.94f), + floattov16(7.95f), floattov16(7.96f), floattov16(7.97f), floattov16(7.98f), floattov16(7.99f) +}; + diff --git a/arm9/source/Graphics/GfxInfo.h b/source/Graphics/GfxInfo.h similarity index 95% rename from arm9/source/Graphics/GfxInfo.h rename to source/Graphics/GfxInfo.h index e64bf8f..362c0a9 100644 --- a/arm9/source/Graphics/GfxInfo.h +++ b/source/Graphics/GfxInfo.h @@ -1,115 +1,115 @@ -#ifndef __GFXINFO_H__ -#define __GFXINFO_H__ - -#define NUMBER_OF_TEXTURES 37 - -#include "circle_bin.h" -#include "circleoverlay_bin.h" -#include "circleapproach_bin.h" -#include "spinner_bin.h" -#include "spinnerbg_bin.h" -#include "spinnerbars_bin.h" -#include "disc_bin.h" -#include "sliderb0_bin.h" -#include "sliderb1_bin.h" -#include "sliderb2_bin.h" -#include "sliderb3_bin.h" -#include "sliderb4_bin.h" -#include "sliderb5_bin.h" -#include "sliderb6_bin.h" -#include "sliderb7_bin.h" -#include "sliderb8_bin.h" -#include "sliderb9_bin.h" -#include "sliderfollow_bin.h" -#include "slidertick_bin.h" -#include "sliderreverse_bin.h" - -#include "hit0_bin.h" -#include "hit50_bin.h" -#include "hit100_bin.h" -#include "hit100k_bin.h" -#include "hit300_bin.h" -#include "hit300k_bin.h" -#include "hit300g_bin.h" -#include "slider10_bin.h" -#include "slider30_bin.h" - -#include "scorebar_bin.h" -#include "scorebar_colour_bin.h" -#include "scorebar_ki_bin.h" -#include "scorebar_kidanger_bin.h" -#include "scorebar_kidanger2_bin.h" - -#include "white_bin.h" - -//#include "songbg_osu_bin.h" - -typedef enum { - TX_PLAY_CIRCLE, - TX_PLAY_CIRCLEOVERLAY, - TX_PLAY_CIRCLEAPPROACH, - TX_PLAY_SPINNER, - TX_PLAY_SPINNERBG, - TX_PLAY_SPINNERBARS, - TX_PLAY_SLIDERB0, - TX_PLAY_SLIDERB1, - TX_PLAY_SLIDERB2, - TX_PLAY_SLIDERB3, - TX_PLAY_SLIDERB4, - TX_PLAY_SLIDERB5, - TX_PLAY_SLIDERB6, - TX_PLAY_SLIDERB7, - TX_PLAY_SLIDERB8, - TX_PLAY_SLIDERB9, - TX_PLAY_DISC, - TX_PLAY_SLIDERFOLLOW, - TX_PLAY_SLIDERTICK, - TX_PLAY_SLIDERREVERSE, - - TX_PLAY_HIT0, - TX_PLAY_HIT50, - TX_PLAY_HIT100, - TX_PLAY_HIT100K, - TX_PLAY_HIT300, - TX_PLAY_HIT300K, - TX_PLAY_HIT300G, - TX_PLAY_SLIDER10, - TX_PLAY_SLIDER30, - - TX_PLAY_SCOREBAR, - TX_PLAY_SCOREBAR_BAR, - TX_PLAY_SCOREBAR_KI, - TX_PLAY_SCOREBAR_KIDANGER, - TX_PLAY_SCOREBAR_KIDANGER2, - - TX_WHITE, - - TX_SONGSELECT_SONGBG -} TextureType; - -// arrays - -//extern const float zvalue[]; - -extern const u16 palette0[]; -extern const u16 palette1[]; -extern const u16 palette2[]; -extern const u16 palette3[]; -extern const u16 palette4[]; -extern const u16 palette5[]; -extern const u16 palette6[]; -extern const u16 palette7[]; -extern const u16 palette8[]; - -extern const u32 uv8x8[]; -extern const u32 uv16x16[]; -extern const u32 uv32x32[]; -extern const u32 uv64x64[]; -extern const u32 uv128x128[]; -extern const u32 uv256x16[]; -extern const u32 uv256x192[]; - -extern const v16 plu[]; - -#endif - +#ifndef __GFXINFO_H__ +#define __GFXINFO_H__ + +#define NUMBER_OF_TEXTURES 37 + +#include "circle_bin.h" +#include "circleoverlay_bin.h" +#include "circleapproach_bin.h" +#include "spinner_bin.h" +#include "spinnerbg_bin.h" +#include "spinnerbars_bin.h" +#include "disc_bin.h" +#include "sliderb0_bin.h" +#include "sliderb1_bin.h" +#include "sliderb2_bin.h" +#include "sliderb3_bin.h" +#include "sliderb4_bin.h" +#include "sliderb5_bin.h" +#include "sliderb6_bin.h" +#include "sliderb7_bin.h" +#include "sliderb8_bin.h" +#include "sliderb9_bin.h" +#include "sliderfollow_bin.h" +#include "slidertick_bin.h" +#include "sliderreverse_bin.h" + +#include "hit0_bin.h" +#include "hit50_bin.h" +#include "hit100_bin.h" +#include "hit100k_bin.h" +#include "hit300_bin.h" +#include "hit300k_bin.h" +#include "hit300g_bin.h" +#include "slider10_bin.h" +#include "slider30_bin.h" + +#include "scorebar_bin.h" +#include "scorebar_colour_bin.h" +#include "scorebar_ki_bin.h" +#include "scorebar_kidanger_bin.h" +#include "scorebar_kidanger2_bin.h" + +#include "white_bin.h" + +//#include "songbg_osu_bin.h" + +typedef enum { + TX_PLAY_CIRCLE, + TX_PLAY_CIRCLEOVERLAY, + TX_PLAY_CIRCLEAPPROACH, + TX_PLAY_SPINNER, + TX_PLAY_SPINNERBG, + TX_PLAY_SPINNERBARS, + TX_PLAY_SLIDERB0, + TX_PLAY_SLIDERB1, + TX_PLAY_SLIDERB2, + TX_PLAY_SLIDERB3, + TX_PLAY_SLIDERB4, + TX_PLAY_SLIDERB5, + TX_PLAY_SLIDERB6, + TX_PLAY_SLIDERB7, + TX_PLAY_SLIDERB8, + TX_PLAY_SLIDERB9, + TX_PLAY_DISC, + TX_PLAY_SLIDERFOLLOW, + TX_PLAY_SLIDERTICK, + TX_PLAY_SLIDERREVERSE, + + TX_PLAY_HIT0, + TX_PLAY_HIT50, + TX_PLAY_HIT100, + TX_PLAY_HIT100K, + TX_PLAY_HIT300, + TX_PLAY_HIT300K, + TX_PLAY_HIT300G, + TX_PLAY_SLIDER10, + TX_PLAY_SLIDER30, + + TX_PLAY_SCOREBAR, + TX_PLAY_SCOREBAR_BAR, + TX_PLAY_SCOREBAR_KI, + TX_PLAY_SCOREBAR_KIDANGER, + TX_PLAY_SCOREBAR_KIDANGER2, + + TX_WHITE, + + TX_SONGSELECT_SONGBG +} TextureType; + +// arrays + +//extern const float zvalue[]; + +extern const u16 palette0[]; +extern const u16 palette1[]; +extern const u16 palette2[]; +extern const u16 palette3[]; +extern const u16 palette4[]; +extern const u16 palette5[]; +extern const u16 palette6[]; +extern const u16 palette7[]; +extern const u16 palette8[]; + +extern const u32 uv8x8[]; +extern const u32 uv16x16[]; +extern const u32 uv32x32[]; +extern const u32 uv64x64[]; +extern const u32 uv128x128[]; +extern const u32 uv256x16[]; +extern const u32 uv256x192[]; + +extern const v16 plu[]; + +#endif + diff --git a/source/Graphics/GraphicsManager.cpp b/source/Graphics/GraphicsManager.cpp new file mode 100644 index 0000000..b5a0427 --- /dev/null +++ b/source/Graphics/GraphicsManager.cpp @@ -0,0 +1,277 @@ +#include "GraphicsManager.h" +#include + +GraphicsManager GraphicsManager::sGraphicsManager; + +int nextPBlock; + +//--------------------------------------------------------------------------------- +inline uint32 alignVal( uint32 val, uint32 to ) { + return (val & (to-1))? (val & ~(to-1)) + to : val; +} + +//--------------------------------------------------------------------------------- +int getNextPaletteSlot(u16 count, uint8 format) { +//--------------------------------------------------------------------------------- + // ensure the result aligns on a palette block for this format + uint32 result = alignVal(nextPBlock, 1<<(4-(format==GL_RGB4))); + + // convert count to bytes and align to next (smallest format) palette block + count = alignVal( count<<1, 1<<3 ); + + // ensure that end is within palette video mem + if( result+count > 0x10000 ) // VRAM_F - VRAM_E + return -1; + + nextPBlock = result+count; + return (int)result; +} + +//--------------------------------------------------------------------------------- +void glTexLoadPal(const u16* pal, u16 count, u32 addr) { +//--------------------------------------------------------------------------------- + vramSetBankE(VRAM_E_LCD); + swiCopy( pal, &VRAM_E[addr>>1] , count / 2 | COPY_MODE_WORD); + vramSetBankE(VRAM_E_TEX_PALETTE); +} + +//--------------------------------------------------------------------------------- +int gluTexLoadPal(const u16* pal, u16 count, uint8 format) { +//--------------------------------------------------------------------------------- + int addr = getNextPaletteSlot(count, format); + if( addr>=0 ) + glTexLoadPal(pal, count, (u32) addr); + + return addr; +} + +GraphicsManager::GraphicsManager() +{ + videoSetMode(MODE_5_3D); + videoSetModeSub(MODE_5_2D); + + vramSetBankA(VRAM_A_TEXTURE); + vramSetBankC(VRAM_C_SUB_BG); + vramSetBankD(VRAM_D_MAIN_BG_0x06000000); + vramSetBankE(VRAM_E_TEX_PALETTE); + + REG_BG0CNT = 1; + + glInit(); + glEnable(GL_BLEND | GL_TEXTURE_2D | GL_ANTIALIAS); + + // setup the rear plane + glClearColor(20,20,31,31); + glClearPolyID(63); + glClearDepth(0x7FFF); + + glViewport(0,0,255,191); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + //gluPerspective(100.3, 4.0/3.0, 0.1, 100); //fovy, aspect(width/height), zNear, zFar + glOrtho(0.f, 6.40f, 0.f, 4.80f, 0.1f, 100.f); + + // camera is flipped around a bit - x increases left to right, y increases top to bottom (0,0) to (640,480) + gluLookAt( 0, 4.8, -50.0, //camera position + 0, 4.8, 0.0, //look at + 0.0, -1.0, 0.0); //up + + glMatrixMode(GL_MODELVIEW); + + mPolygonId = 0; + + //// LOAD TEXTURES //// + + glGenTextures(NUMBER_OF_TEXTURES, textures); + + int pal0 = gluTexLoadPal(palette0, 4, GL_RGB4); + + LoadGLTexture(TX_PLAY_CIRCLE, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal0, uv64x64, circle_bin); + LoadGLTexture(TX_PLAY_CIRCLEOVERLAY, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal0, uv64x64, circleoverlay_bin); + LoadGLTexture(TX_PLAY_CIRCLEAPPROACH, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal0, uv64x64, circleapproach_bin); + + LoadGLTexture(TX_PLAY_DISC, GL_RGB4, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal0, uv32x32, disc_bin); + LoadGLTexture(TX_PLAY_SLIDERTICK, GL_RGB4, TEXTURE_SIZE_16, TEXTURE_SIZE_16, pal0, uv16x16, slidertick_bin); + LoadGLTexture(TX_PLAY_SLIDERREVERSE, GL_RGB4, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal0, uv32x32, sliderreverse_bin); + + LoadGLTexture(TX_WHITE, GL_RGB4, TEXTURE_SIZE_8, TEXTURE_SIZE_8, pal0, uv8x8, white_bin); + + int pal1 = gluTexLoadPal(palette1, 16, GL_RGB16); + + LoadGLTexture(TX_PLAY_SPINNER, GL_RGB16, TEXTURE_SIZE_128, TEXTURE_SIZE_128, pal1, uv128x128, spinner_bin); + LoadGLTexture(TX_PLAY_SPINNERBARS, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_256, pal1, uv256x192, spinnerbars_bin); + LoadGLTexture(TX_PLAY_SCOREBAR_BAR, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_16, pal1, uv256x16, scorebar_colour_bin); + + int pal2 = gluTexLoadPal(palette2, 16, GL_RGB4); + + LoadGLTexture(TX_PLAY_SPINNERBG, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_256, pal2, uv256x192, spinnerbg_bin); + + int pal3 = gluTexLoadPal(palette3, 4, GL_RGB4); + + LoadGLTexture(TX_PLAY_SLIDERB0, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb0_bin); + LoadGLTexture(TX_PLAY_SLIDERB1, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb1_bin); + LoadGLTexture(TX_PLAY_SLIDERB2, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb2_bin); + LoadGLTexture(TX_PLAY_SLIDERB3, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb3_bin); + LoadGLTexture(TX_PLAY_SLIDERB4, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb4_bin); + LoadGLTexture(TX_PLAY_SLIDERB5, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb5_bin); + LoadGLTexture(TX_PLAY_SLIDERB6, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb6_bin); + LoadGLTexture(TX_PLAY_SLIDERB7, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb7_bin); + LoadGLTexture(TX_PLAY_SLIDERB8, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb8_bin); + LoadGLTexture(TX_PLAY_SLIDERB9, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderb9_bin); + LoadGLTexture(TX_PLAY_SLIDERFOLLOW, GL_RGB4, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal3, uv64x64, sliderfollow_bin); + + int pal4 = gluTexLoadPal(palette4, 16, GL_RGB16); + + LoadGLTexture(TX_PLAY_HIT0, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit0_bin); + LoadGLTexture(TX_PLAY_HIT300, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit300_bin); + LoadGLTexture(TX_PLAY_HIT300K, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit300k_bin); + LoadGLTexture(TX_PLAY_HIT300G, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal4, uv64x64, hit300g_bin); + + int pal5 = gluTexLoadPal(palette5, 16, GL_RGB16); + + LoadGLTexture(TX_PLAY_HIT50, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal5, uv64x64, hit50_bin); + LoadGLTexture(TX_PLAY_HIT100, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal5, uv64x64, hit100_bin); + LoadGLTexture(TX_PLAY_HIT100K, GL_RGB16, TEXTURE_SIZE_64, TEXTURE_SIZE_64, pal5, uv64x64, hit100k_bin); + + int pal6 = gluTexLoadPal(palette6, 4, GL_RGB4); + + LoadGLTexture(TX_PLAY_SLIDER30, GL_RGB4, TEXTURE_SIZE_16, TEXTURE_SIZE_16, pal6, uv16x16, slider30_bin); + LoadGLTexture(TX_PLAY_SLIDER10, GL_RGB4, TEXTURE_SIZE_16, TEXTURE_SIZE_16, pal6, uv16x16, slider10_bin); + + int pal7 = gluTexLoadPal(palette7, 16, GL_RGB16); + + LoadGLTexture(TX_PLAY_SCOREBAR_KI, GL_RGB16, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal7, uv32x32, scorebar_ki_bin); + LoadGLTexture(TX_PLAY_SCOREBAR_KIDANGER, GL_RGB16, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal7, uv32x32, scorebar_kidanger_bin); + LoadGLTexture(TX_PLAY_SCOREBAR_KIDANGER2, GL_RGB16, TEXTURE_SIZE_32, TEXTURE_SIZE_32, pal7, uv32x32, scorebar_kidanger2_bin); + + int pal8 = gluTexLoadPal(palette8, 16, GL_RGB16); + + LoadGLTexture(TX_PLAY_SCOREBAR, GL_RGB16, TEXTURE_SIZE_256, TEXTURE_SIZE_16, pal8, uv256x16, scorebar_bin); + + // 16 bit textures + + //LoadGLTexture(TX_SONGSELECT_SONGBG, GL_RGB, TEXTURE_SIZE_64, TEXTURE_SIZE_512, -1, NULL, songbg_osu_bin); +} + +void GraphicsManager::LoadGLTextureEx(TextureType tex, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int palette, const u32* uv, const u8* texture, u32 size) +{ + /* DON'T TOUCH THIS FUNCTION + * there seems to be some sort of memory problem somewhere, but it's completely eluding me where it is + * the game only loads the textures if this function is the way it is >.> + */ + + void* temp = malloc(size); + + glBindTexture(0, textures[tex]); + glTexImage2D(0, 0, type, sizeX, sizeY, 0, GL_TEXTURE_COLOR0_TRANSPARENT, (u8*)texture); + + free(temp); + + textureInfo[tex].palette = palette; + textureInfo[tex].format = type; + textureInfo[tex].uv = uv; +} + +void GraphicsManager::Draw(TextureType tex, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, s32 angle, float z, const u32* uv) +{ + if (uv == NULL) + uv = textureInfo[tex].uv; + + s32 x1 = 270, x2 = 370, y1 = 190, y2 = 290; + //float z = zvalue[tex] + deltaz; + + if (fieldtype == FIELD_PLAY) + { + x += PlayXOffset; + y += PlayYOffset; + } + + switch (origin) + { + case ORIGIN_TOPLEFT: + x1 = ForceBounds(x); + x2 = ForceBounds(x + width); + y1 = ForceBounds(y); + y2 = ForceBounds(y + height); + break; + + case ORIGIN_CENTER: + width >>= 1; + height >>= 1; + + x1 = ForceBounds(x - width); + x2 = ForceBounds(x + width); + y1 = ForceBounds(y - height); + y2 = ForceBounds(y + height); + break; + + case ORIGIN_BOTTOMLEFT: + x1 = ForceBounds(x); + x2 = ForceBounds(x + width); + y1 = ForceBounds(y - height); + y2 = ForceBounds(y); + break; + + case ORIGIN_TOPRIGHT: + x1 = ForceBounds(x - width); + x2 = ForceBounds(x); + y1 = ForceBounds(y); + y2 = ForceBounds(y + height); + } + + //need to keep rotating polygonid + if (++mPolygonId > 63) + mPolygonId = 0; + + //don't draw things out of the screen + if (x1 > 640 || x2 < 0 || y1 > 480 || y2 < 0) + return; + + glPushMatrix(); + + glPolyFmt(POLY_ALPHA(alpha&31) | POLY_ID(mPolygonId) | POLY_CULL_NONE); + glColor(color); + + if (angle != 0) + { + glTranslatef(x/100.0, y/100.0, 0); + glRotateZi(angle); + glTranslatef(-x/100.0, -y/100.0, 0); + } + + glBindTexture(0, textures[tex]); + + if (textureInfo[tex].palette >= 0) + GFX_PAL_FORMAT = textureInfo[tex].palette >> (4 - (textureInfo[tex].format == GL_RGB4)); + + glBegin(GL_QUADS); + + GFX_TEX_COORD = uv[0]; + glVertex2lu1f(x1, y1, z); + + GFX_TEX_COORD = uv[1]; + glVertex2lu1f(x2, y1, z); + + GFX_TEX_COORD = uv[2]; + glVertex2lu1f(x2, y2, z); + + GFX_TEX_COORD = uv[3]; + glVertex2lu1f(x1, y2, z); + + glEnd(); + + glPopMatrix(1); +} + +s32 GraphicsManager::ForceBounds(s32 value) +{ + if (value < -200) + return -200; + + if (value > 799) + return 799; + + return value; +} + diff --git a/arm9/source/Graphics/GraphicsManager.h b/source/Graphics/GraphicsManager.h similarity index 96% rename from arm9/source/Graphics/GraphicsManager.h rename to source/Graphics/GraphicsManager.h index 9cdd42e..8119daf 100644 --- a/arm9/source/Graphics/GraphicsManager.h +++ b/source/Graphics/GraphicsManager.h @@ -1,62 +1,62 @@ -#include -#include -#include - -#include "GfxInfo.h" - -#ifndef __GRAPHICSMANAGER_H__ -#define __GRAPHICSMANAGER_H__ - -//#define glVertex2lu(x,y) glVertex3v16(plu[(x)+200],plu[(y)+200],0) -//#define glVertex3lu(x,y,z) glVertex3v16(plu[(x)+200],plu[(y)+200],plu[(z)+200]) -#define glVertex2lu1f(x,y,z) glVertex3v16(plu[(x)+200],plu[(y)+200],floattov16(z)) - -#define LoadGLTexture(tex, type, sizeX, sizeY, palette, uv, texture) \ - LoadGLTextureEx(tex, type, sizeX, sizeY, palette, uv, texture, texture##_size) - -typedef struct { - int palette; - u8 format; - const u32* uv; -} TextureInfo; - -typedef enum { - ORIGIN_CENTER, - ORIGIN_TOPLEFT, - ORIGIN_BOTTOMLEFT, - ORIGIN_TOPRIGHT -} DrawOrigin; - -typedef enum { - FIELD_SCREEN, - FIELD_PLAY -} FieldType; - -class GraphicsManager -{ - public: - static GraphicsManager& Graphics() { return sGraphicsManager; } - - void Draw(TextureType tex, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, s32 angle, float z = 0, const u32* uv = NULL); - - static const u32 PlayXOffset = 64; - static const u32 PlayYOffset = 73; - - protected: - void LoadGLTextureEx(TextureType tex, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int palette, const u32* uv, const u8* texture, u32 size); - s32 ForceBounds(s32 value); - - TextureInfo textureInfo[NUMBER_OF_TEXTURES]; - int textures[NUMBER_OF_TEXTURES]; - - static GraphicsManager sGraphicsManager; - - private: - GraphicsManager(); - ~GraphicsManager() {} - - u32 mPolygonId; -}; - -#endif - +#include +#include +#include + +#include "GfxInfo.h" + +#ifndef __GRAPHICSMANAGER_H__ +#define __GRAPHICSMANAGER_H__ + +//#define glVertex2lu(x,y) glVertex3v16(plu[(x)+200],plu[(y)+200],0) +//#define glVertex3lu(x,y,z) glVertex3v16(plu[(x)+200],plu[(y)+200],plu[(z)+200]) +#define glVertex2lu1f(x,y,z) glVertex3v16(plu[(x)+200],plu[(y)+200],floattov16(z)) + +#define LoadGLTexture(tex, type, sizeX, sizeY, palette, uv, texture) \ + LoadGLTextureEx(tex, type, sizeX, sizeY, palette, uv, texture, texture##_size) + +typedef struct { + int palette; + u8 format; + const u32* uv; +} TextureInfo; + +typedef enum { + ORIGIN_CENTER, + ORIGIN_TOPLEFT, + ORIGIN_BOTTOMLEFT, + ORIGIN_TOPRIGHT +} DrawOrigin; + +typedef enum { + FIELD_SCREEN, + FIELD_PLAY +} FieldType; + +class GraphicsManager +{ + public: + static GraphicsManager& Graphics() { return sGraphicsManager; } + + void Draw(TextureType tex, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, s32 angle, float z = 0, const u32* uv = NULL); + + static const u32 PlayXOffset = 64; + static const u32 PlayYOffset = 73; + + protected: + void LoadGLTextureEx(TextureType tex, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int palette, const u32* uv, const u8* texture, u32 size); + s32 ForceBounds(s32 value); + + TextureInfo textureInfo[NUMBER_OF_TEXTURES]; + int textures[NUMBER_OF_TEXTURES]; + + static GraphicsManager sGraphicsManager; + + private: + GraphicsManager(); + ~GraphicsManager() {} + + u32 mPolygonId; +}; + +#endif + diff --git a/arm9/source/Graphics/SpriteContainer.cpp b/source/Graphics/SpriteContainer.cpp similarity index 95% rename from arm9/source/Graphics/SpriteContainer.cpp rename to source/Graphics/SpriteContainer.cpp index 7e03932..bdd17e5 100644 --- a/arm9/source/Graphics/SpriteContainer.cpp +++ b/source/Graphics/SpriteContainer.cpp @@ -1,23 +1,23 @@ -#include "SpriteContainer.h" - -SpriteContainer::~SpriteContainer() -{ - if (mSpriteOwner) - { - for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) - { - if (*it != NULL) - delete *it; - } - } -} - -void SpriteContainer::AddToSpriteManager(SpriteManager& spriteManager) -{ - spriteManager.Add(mSprites); - - //once sprites are added to spritemanager, the memory - //belongs to the spritemanager, and should be deleted by it - mSpriteOwner = false; -} - +#include "SpriteContainer.h" + +SpriteContainer::~SpriteContainer() +{ + if (mSpriteOwner) + { + for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) + { + if (*it != NULL) + delete *it; + } + } +} + +void SpriteContainer::AddToSpriteManager(SpriteManager& spriteManager) +{ + spriteManager.Add(mSprites); + + //once sprites are added to spritemanager, the memory + //belongs to the spritemanager, and should be deleted by it + mSpriteOwner = false; +} + diff --git a/arm9/source/Graphics/SpriteContainer.h b/source/Graphics/SpriteContainer.h similarity index 94% rename from arm9/source/Graphics/SpriteContainer.h rename to source/Graphics/SpriteContainer.h index 486bf72..229f0d1 100644 --- a/arm9/source/Graphics/SpriteContainer.h +++ b/source/Graphics/SpriteContainer.h @@ -1,32 +1,32 @@ -#include -#include -#include - -#include "pSprite.h" -#include "SpriteManager.h" - -#ifndef __SPRITECONTAINER_H__ -#define __SPRITECONTAINER_H__ - -using namespace std; - -typedef vector::iterator spriteIterator; - -/* a generic base class for all objects that require sprites - * sprite cleanup is automatically handled - */ -class SpriteContainer -{ - public: - virtual ~SpriteContainer(); - void AddToSpriteManager(SpriteManager& spriteManager); - - protected: - vector mSprites; - - private: - bool mSpriteOwner; -}; - -#endif - +#include +#include +#include + +#include "pSprite.h" +#include "SpriteManager.h" + +#ifndef __SPRITECONTAINER_H__ +#define __SPRITECONTAINER_H__ + +using namespace std; + +typedef vector::iterator spriteIterator; + +/* a generic base class for all objects that require sprites + * sprite cleanup is automatically handled + */ +class SpriteContainer +{ + public: + virtual ~SpriteContainer(); + void AddToSpriteManager(SpriteManager& spriteManager); + + protected: + vector mSprites; + + private: + bool mSpriteOwner; +}; + +#endif + diff --git a/arm9/source/Graphics/SpriteManager.cpp b/source/Graphics/SpriteManager.cpp similarity index 94% rename from arm9/source/Graphics/SpriteManager.cpp rename to source/Graphics/SpriteManager.cpp index 6859a77..4d7e828 100644 --- a/arm9/source/Graphics/SpriteManager.cpp +++ b/source/Graphics/SpriteManager.cpp @@ -1,78 +1,78 @@ -#include "SpriteManager.h" - -SpriteManager::SpriteManager() -{ -} - -SpriteManager::~SpriteManager() -{ - for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) - { - if (*it != NULL) - delete *it; - } -} - -void SpriteManager::Draw() -{ - u32 i = 0; - vector list; - - for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it, ++i) - { - pSprite* spr = *it; - - //if for some reason sprite is nonexistent then mark for deletion - if (spr == NULL) - { - list.push_back(i); - continue; - } - - spr->Update(); - - //if sprite is dead then mark for deletion - if (spr->Draw() == false) - { - list.push_back(i); - continue; - } - - //no need to draw things you can't see - if (spr->Width == 0 || spr->Height == 0 || spr->Alpha == 0) - continue; - - GraphicsManager::Graphics().Draw( spr->Texture, - spr->X, spr->Y, - spr->Width, spr->Height, - spr->Origin, spr->Field, - spr->Color, spr->Alpha, spr->Angle, - spr->Z, spr->UV); - - } - - //delete dead sprites - while (list.size() > 0) - { - spriteIterator it = mSprites.begin() + list.back(); - - if (*it != NULL) - delete *it; - - mSprites.erase(it); - list.pop_back(); - } -} - -void SpriteManager::Add(pSprite* spr) -{ - mSprites.push_back(spr); -} - -void SpriteManager::Add(const vector& spr) -{ - for (spriteIteratorConst it = spr.begin(); it != spr.end(); ++it) - { - Add(*it); - } -} +#include "SpriteManager.h" + +SpriteManager::SpriteManager() +{ +} + +SpriteManager::~SpriteManager() +{ + for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) + { + if (*it != NULL) + delete *it; + } +} + +void SpriteManager::Draw() +{ + u32 i = 0; + vector list; + + for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it, ++i) + { + pSprite* spr = *it; + + //if for some reason sprite is nonexistent then mark for deletion + if (spr == NULL) + { + list.push_back(i); + continue; + } + + spr->Update(); + + //if sprite is dead then mark for deletion + if (spr->Draw() == false) + { + list.push_back(i); + continue; + } + + //no need to draw things you can't see + if (spr->Width == 0 || spr->Height == 0 || spr->Alpha == 0) + continue; + + GraphicsManager::Graphics().Draw( spr->Texture, + spr->X, spr->Y, + spr->Width, spr->Height, + spr->Origin, spr->Field, + spr->Color, spr->Alpha, spr->Angle, + spr->Z, spr->UV); + + } + + //delete dead sprites + while (list.size() > 0) + { + spriteIterator it = mSprites.begin() + list.back(); + + if (*it != NULL) + delete *it; + + mSprites.erase(it); + list.pop_back(); + } +} + +void SpriteManager::Add(pSprite* spr) +{ + mSprites.push_back(spr); +} + +void SpriteManager::Add(const vector& spr) +{ + for (spriteIteratorConst it = spr.begin(); it != spr.end(); ++it) + { + Add(*it); + } +} diff --git a/arm9/source/Graphics/SpriteManager.h b/source/Graphics/SpriteManager.h similarity index 94% rename from arm9/source/Graphics/SpriteManager.h rename to source/Graphics/SpriteManager.h index c960396..199f9be 100644 --- a/arm9/source/Graphics/SpriteManager.h +++ b/source/Graphics/SpriteManager.h @@ -1,33 +1,33 @@ -#include -#include - -#include "pSprite.h" -#include "GraphicsManager.h" - -#ifndef __SPRITEMANAGER_H__ -#define __SPRITEMANAGER_H__ - -using namespace std; - -typedef vector::iterator spriteIterator; -typedef vector::const_iterator spriteIteratorConst; - -class SpriteManager -{ - public: - SpriteManager(); - virtual ~SpriteManager(); - - void Draw(); - - void Add(pSprite* spr); - void Add(const vector& spr); - - vector& Sprites() { return mSprites; } - - protected: - vector mSprites; -}; - -#endif - +#include +#include + +#include "pSprite.h" +#include "GraphicsManager.h" + +#ifndef __SPRITEMANAGER_H__ +#define __SPRITEMANAGER_H__ + +using namespace std; + +typedef vector::iterator spriteIterator; +typedef vector::const_iterator spriteIteratorConst; + +class SpriteManager +{ + public: + SpriteManager(); + virtual ~SpriteManager(); + + void Draw(); + + void Add(pSprite* spr); + void Add(const vector& spr); + + vector& Sprites() { return mSprites; } + + protected: + vector mSprites; +}; + +#endif + diff --git a/arm9/source/Graphics/Transformation.cpp b/source/Graphics/Transformation.cpp similarity index 94% rename from arm9/source/Graphics/Transformation.cpp rename to source/Graphics/Transformation.cpp index d37e0f8..ed498bb 100644 --- a/arm9/source/Graphics/Transformation.cpp +++ b/source/Graphics/Transformation.cpp @@ -1,53 +1,53 @@ -#include "Transformation.h" - -Transformation::Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue) -{ - this->type = type; - - this->starttime = starttime; - this->endtime = endtime; - - this->startvalue = startvalue; - this->endvalue = endvalue; - - totaltime = endtime-starttime; - totalvalue = endvalue-startvalue; - - currentvalue = startvalue; - - active = false; - lastactive = false; -} - -void Transformation::Update() -{ - s32 time = GameClock::Clock().Time(); - - if (!active) - { - if (time > starttime) - active = true; - else - return; - } - - if (time > endtime) - { - active = false; - currentvalue = endvalue; - lastactive = true; - return; - } - - currentvalue = (s32)(((time-starttime)/(float)totaltime)*totalvalue + startvalue); -} - -bool Transformation::Active() -{ - if (lastactive) - { - lastactive = false; - return true; - } - return active; -} +#include "Transformation.h" + +Transformation::Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue) +{ + this->type = type; + + this->starttime = starttime; + this->endtime = endtime; + + this->startvalue = startvalue; + this->endvalue = endvalue; + + totaltime = endtime-starttime; + totalvalue = endvalue-startvalue; + + currentvalue = startvalue; + + active = false; + lastactive = false; +} + +void Transformation::Update() +{ + s32 time = GameClock::Clock().Time(); + + if (!active) + { + if (time > starttime) + active = true; + else + return; + } + + if (time > endtime) + { + active = false; + currentvalue = endvalue; + lastactive = true; + return; + } + + currentvalue = (s32)(((time-starttime)/(float)totaltime)*totalvalue + startvalue); +} + +bool Transformation::Active() +{ + if (lastactive) + { + lastactive = false; + return true; + } + return active; +} diff --git a/arm9/source/Graphics/Transformation.h b/source/Graphics/Transformation.h similarity index 94% rename from arm9/source/Graphics/Transformation.h rename to source/Graphics/Transformation.h index 2ca99d5..5589b93 100644 --- a/arm9/source/Graphics/Transformation.h +++ b/source/Graphics/Transformation.h @@ -1,42 +1,42 @@ -#include -#include -#include "System/GameClock.h" - -#ifndef __TRANSFORMATION_H__ -#define __TRANSFORMATION_H__ - -typedef enum { - TR_FADE, - TR_MOVEX, - TR_MOVEY, - TR_SCALEX, - TR_SCALEY, - TR_ROTATE, - TR_KILL -} TransformType; - -class Transformation -{ - public: - Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue); - void Update(); - s32 Value() const { return currentvalue; } - bool Active(); - TransformType Type() const { return type; } - - bool Finished() { return GameClock::Clock().Time() > endtime; } - - protected: - TransformType type; - - bool active, lastactive; - - s32 starttime, endtime, totaltime; - - s32 startvalue, endvalue, currentvalue; - s32 totalvalue; -}; - - -#endif - +#include +#include +#include "System/GameClock.h" + +#ifndef __TRANSFORMATION_H__ +#define __TRANSFORMATION_H__ + +typedef enum { + TR_FADE, + TR_MOVEX, + TR_MOVEY, + TR_SCALEX, + TR_SCALEY, + TR_ROTATE, + TR_KILL +} TransformType; + +class Transformation +{ + public: + Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue); + void Update(); + s32 Value() const { return currentvalue; } + bool Active(); + TransformType Type() const { return type; } + + bool Finished() { return GameClock::Clock().Time() > endtime; } + + protected: + TransformType type; + + bool active, lastactive; + + s32 starttime, endtime, totaltime; + + s32 startvalue, endvalue, currentvalue; + s32 totalvalue; +}; + + +#endif + diff --git a/arm9/source/Graphics/pAnimation.cpp b/source/Graphics/pAnimation.cpp similarity index 95% rename from arm9/source/Graphics/pAnimation.cpp rename to source/Graphics/pAnimation.cpp index 3293f5e..e4b7601 100644 --- a/arm9/source/Graphics/pAnimation.cpp +++ b/source/Graphics/pAnimation.cpp @@ -1,30 +1,30 @@ -#include "pAnimation.h" - -pAnimation::pAnimation(TextureType texture, u32 framecount, u32 fps, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType type, rgb color, u32 alpha) - : pSprite(texture, x, y, width, height, origin, type, color, alpha) -{ - mFrameCount = framecount; - mFrameCurrent = 0; - mOrigTexture = texture; - - mUpdatesPerFrame = 60.0 / fps; - mUpdatesWaited = 0; -} - -void pAnimation::Update() -{ - while (mUpdatesWaited >= mUpdatesPerFrame) - { - mUpdatesWaited -= mUpdatesPerFrame; - - ++mFrameCurrent; - if (mFrameCurrent >= mFrameCount) - mFrameCurrent = 0; - - Texture = (TextureType)(mOrigTexture + mFrameCurrent); - } - - ++mUpdatesWaited; - - pSprite::Update(); +#include "pAnimation.h" + +pAnimation::pAnimation(TextureType texture, u32 framecount, u32 fps, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType type, rgb color, u32 alpha) + : pSprite(texture, x, y, width, height, origin, type, color, alpha) +{ + mFrameCount = framecount; + mFrameCurrent = 0; + mOrigTexture = texture; + + mUpdatesPerFrame = 60.0 / fps; + mUpdatesWaited = 0; +} + +void pAnimation::Update() +{ + while (mUpdatesWaited >= mUpdatesPerFrame) + { + mUpdatesWaited -= mUpdatesPerFrame; + + ++mFrameCurrent; + if (mFrameCurrent >= mFrameCount) + mFrameCurrent = 0; + + Texture = (TextureType)(mOrigTexture + mFrameCurrent); + } + + ++mUpdatesWaited; + + pSprite::Update(); } \ No newline at end of file diff --git a/arm9/source/Graphics/pAnimation.h b/source/Graphics/pAnimation.h similarity index 95% rename from arm9/source/Graphics/pAnimation.h rename to source/Graphics/pAnimation.h index 1ead334..7a14091 100644 --- a/arm9/source/Graphics/pAnimation.h +++ b/source/Graphics/pAnimation.h @@ -1,22 +1,22 @@ -#include -#include "pSprite.h" - -#ifndef __PANIMATION_H__ -#define __PANIMATION_H__ - -class pAnimation : public pSprite -{ - public: - pAnimation(TextureType texture, u32 framecount, u32 fps, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType type, rgb color, u32 alpha); - void Update(); - - protected: - TextureType mOrigTexture; - float mUpdatesPerFrame; - float mUpdatesWaited; - u32 mFrameCurrent; - u32 mFrameCount; -}; - -#endif - +#include +#include "pSprite.h" + +#ifndef __PANIMATION_H__ +#define __PANIMATION_H__ + +class pAnimation : public pSprite +{ + public: + pAnimation(TextureType texture, u32 framecount, u32 fps, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType type, rgb color, u32 alpha); + void Update(); + + protected: + TextureType mOrigTexture; + float mUpdatesPerFrame; + float mUpdatesWaited; + u32 mFrameCurrent; + u32 mFrameCount; +}; + +#endif + diff --git a/arm9/source/Graphics/pSprite.cpp b/source/Graphics/pSprite.cpp similarity index 95% rename from arm9/source/Graphics/pSprite.cpp rename to source/Graphics/pSprite.cpp index 20bad22..72ed97d 100644 --- a/arm9/source/Graphics/pSprite.cpp +++ b/source/Graphics/pSprite.cpp @@ -1,193 +1,193 @@ -#include "pSprite.h" - -pSprite::pSprite(TextureType texture, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, float z) -{ - Texture = texture; - X = x; - Y = y; - Width = mOrigWidth = width; - Height = mOrigHeight = height; - Origin = origin; - Field = fieldtype; - Color = color; - Alpha = alpha; - mDraw = true; - Angle = 0; - UV = NULL; - Z = z; -} - -pSprite::~pSprite() -{ - for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) - { - if (*it != NULL) - delete *it; - } - - if (UV != NULL) - delete UV; -} - -void pSprite::Update() -{ - for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) - { - Transformation* tr = (*it); - tr->Update(); - - if (tr->Active()) - { - switch (tr->Type()) - { - case TR_FADE: - Alpha = tr->Value(); - break; - case TR_MOVEX: - X = tr->Value(); - break; - case TR_MOVEY: - Y = tr->Value(); - break; - case TR_SCALEX: - Width = tr->Value(); - break; - case TR_SCALEY: - Height = tr->Value(); - break; - case TR_ROTATE: - Angle = tr->Value(); - break; - case TR_KILL: - mDraw = false; - break; - } - } - } -} - -bool pSprite::InBounds(s32 x, s32 y) -{ - if (Field == FIELD_PLAY) - { - x -= GraphicsManager::PlayXOffset; - y -= GraphicsManager::PlayYOffset; - } - - switch (Origin) - { - case ORIGIN_TOPLEFT: - { - return x >= X && x <= X+Width - && y >= Y && y <= Y+Height; - } - - case ORIGIN_CENTER: - { - s32 halfWidth = Width>>1; - s32 halfHeight = Height>>1; - - return x >= X-halfWidth && x <= X+halfWidth - && y >= Y-halfHeight && y <= Y+halfHeight; - } - - case ORIGIN_BOTTOMLEFT: - { - return x >= X && x <= X+Width - && y >= Y-Height && y <= Y; - } - - default: - return false; - } -} - -void pSprite::Kill(s32 time) -{ - Transform(TR_KILL, time, time, 0, 0); -} - -void pSprite::ClearTransforms() -{ - for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) - { - if (*it != NULL) - delete *it; - } - - mTransformations.clear(); -} - -void pSprite::Transform(Transformation* transform) -{ - mTransformations.push_back(transform); -} - -void pSprite::Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue) -{ - Transform(new Transformation(type, starttime, endtime, startvalue, endvalue)); -} - -void pSprite::Scale(s32 starttime, s32 endtime, float start, float end) -{ - Transform(TR_SCALEX, starttime, endtime, mOrigWidth*start, mOrigWidth*end); - Transform(TR_SCALEY, starttime, endtime, mOrigHeight*start, mOrigHeight*end); -} - -void pSprite::Move(s32 starttime, s32 endtime, s32 startx, s32 starty, s32 endx, s32 endy) -{ - Transform(TR_MOVEX, starttime, endtime, startx, endx); - Transform(TR_MOVEY, starttime, endtime, starty, endy); -} - -void pSprite::Move(s32 starttime, s32 endtime, s32 endx, s32 endy) -{ - Move(starttime, endtime, X, Y, endx, endy); -} - -void pSprite::Move(s32 endx, s32 endy) -{ - X = endx; - Y = endy; -} - -void pSprite::Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda) -{ - Transform(TR_ROTATE, starttime, endtime, starta, enda); -} - -void pSprite::Rotate(s32 angle) -{ - Transform(TR_ROTATE, GameClock::Clock().Time(), GameClock::Clock().Time(), angle, angle); -} - -void pSprite::Show() -{ - Show(GameClock::Clock().Time()); -} - -void pSprite::Show(s32 time) -{ - Transform(TR_FADE, time, time, 31, 31); -} - -void pSprite::Show(s32 starttime, s32 endtime) -{ - Transform(TR_FADE, starttime, endtime, 0, 31); -} - -void pSprite::Hide() -{ - Hide(GameClock::Clock().Time()); -} - -void pSprite::Hide(s32 time) -{ - Transform(TR_FADE, time, time, 0, 0); -} - -void pSprite::Hide(s32 starttime, s32 endtime) -{ - Transform(TR_FADE, starttime, endtime, 31, 0); -} - +#include "pSprite.h" + +pSprite::pSprite(TextureType texture, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, float z) +{ + Texture = texture; + X = x; + Y = y; + Width = mOrigWidth = width; + Height = mOrigHeight = height; + Origin = origin; + Field = fieldtype; + Color = color; + Alpha = alpha; + mDraw = true; + Angle = 0; + UV = NULL; + Z = z; +} + +pSprite::~pSprite() +{ + for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) + { + if (*it != NULL) + delete *it; + } + + if (UV != NULL) + delete UV; +} + +void pSprite::Update() +{ + for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) + { + Transformation* tr = (*it); + tr->Update(); + + if (tr->Active()) + { + switch (tr->Type()) + { + case TR_FADE: + Alpha = tr->Value(); + break; + case TR_MOVEX: + X = tr->Value(); + break; + case TR_MOVEY: + Y = tr->Value(); + break; + case TR_SCALEX: + Width = tr->Value(); + break; + case TR_SCALEY: + Height = tr->Value(); + break; + case TR_ROTATE: + Angle = tr->Value(); + break; + case TR_KILL: + mDraw = false; + break; + } + } + } +} + +bool pSprite::InBounds(s32 x, s32 y) +{ + if (Field == FIELD_PLAY) + { + x -= GraphicsManager::PlayXOffset; + y -= GraphicsManager::PlayYOffset; + } + + switch (Origin) + { + case ORIGIN_TOPLEFT: + { + return x >= X && x <= X+Width + && y >= Y && y <= Y+Height; + } + + case ORIGIN_CENTER: + { + s32 halfWidth = Width>>1; + s32 halfHeight = Height>>1; + + return x >= X-halfWidth && x <= X+halfWidth + && y >= Y-halfHeight && y <= Y+halfHeight; + } + + case ORIGIN_BOTTOMLEFT: + { + return x >= X && x <= X+Width + && y >= Y-Height && y <= Y; + } + + default: + return false; + } +} + +void pSprite::Kill(s32 time) +{ + Transform(TR_KILL, time, time, 0, 0); +} + +void pSprite::ClearTransforms() +{ + for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) + { + if (*it != NULL) + delete *it; + } + + mTransformations.clear(); +} + +void pSprite::Transform(Transformation* transform) +{ + mTransformations.push_back(transform); +} + +void pSprite::Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue) +{ + Transform(new Transformation(type, starttime, endtime, startvalue, endvalue)); +} + +void pSprite::Scale(s32 starttime, s32 endtime, float start, float end) +{ + Transform(TR_SCALEX, starttime, endtime, mOrigWidth*start, mOrigWidth*end); + Transform(TR_SCALEY, starttime, endtime, mOrigHeight*start, mOrigHeight*end); +} + +void pSprite::Move(s32 starttime, s32 endtime, s32 startx, s32 starty, s32 endx, s32 endy) +{ + Transform(TR_MOVEX, starttime, endtime, startx, endx); + Transform(TR_MOVEY, starttime, endtime, starty, endy); +} + +void pSprite::Move(s32 starttime, s32 endtime, s32 endx, s32 endy) +{ + Move(starttime, endtime, X, Y, endx, endy); +} + +void pSprite::Move(s32 endx, s32 endy) +{ + X = endx; + Y = endy; +} + +void pSprite::Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda) +{ + Transform(TR_ROTATE, starttime, endtime, starta, enda); +} + +void pSprite::Rotate(s32 angle) +{ + Transform(TR_ROTATE, GameClock::Clock().Time(), GameClock::Clock().Time(), angle, angle); +} + +void pSprite::Show() +{ + Show(GameClock::Clock().Time()); +} + +void pSprite::Show(s32 time) +{ + Transform(TR_FADE, time, time, 31, 31); +} + +void pSprite::Show(s32 starttime, s32 endtime) +{ + Transform(TR_FADE, starttime, endtime, 0, 31); +} + +void pSprite::Hide() +{ + Hide(GameClock::Clock().Time()); +} + +void pSprite::Hide(s32 time) +{ + Transform(TR_FADE, time, time, 0, 0); +} + +void pSprite::Hide(s32 starttime, s32 endtime) +{ + Transform(TR_FADE, starttime, endtime, 31, 0); +} + diff --git a/arm9/source/Graphics/pSprite.h b/source/Graphics/pSprite.h similarity index 96% rename from arm9/source/Graphics/pSprite.h rename to source/Graphics/pSprite.h index 4edbb4d..de3ad78 100644 --- a/arm9/source/Graphics/pSprite.h +++ b/source/Graphics/pSprite.h @@ -1,103 +1,103 @@ -#include -#include -#include "GraphicsManager.h" -#include "Transformation.h" -#include "System/GameClock.h" - -#ifndef __PSPRITE_H__ -#define __PSPRITE_H__ - -using namespace std; - -typedef vector::iterator transformIterator; - -class pSprite -{ - public: - pSprite(TextureType texture, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, float z = 0); - virtual ~pSprite(); - - virtual void Update(); - bool InBounds(s32 x, s32 y); - void Kill(s32 time); - void ClearTransforms(); - - void Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue); - void Scale(s32 starttime, s32 endtime, float start, float end); - void Move(s32 starttime, s32 endtime, s32 startx, s32 starty, s32 endx, s32 endy); - void Move(s32 starttime, s32 endtime, s32 endx, s32 endy); - void Move(s32 x, s32 y); - void Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda); - void Rotate(s32 angle); - - void Show(); - void Show(s32 time); - void Show(s32 starttime, s32 endtime); - void Hide(); - void Hide(s32 time); - void Hide(s32 starttime, s32 endtime); - - /* - s32 x() { return mX; } - s32 y() { return mY; } - u32 width() { return mWidth; } - u32 height() { return mHeight; } - rgb color() { return mColor; } - u32 alpha() { return mAlpha; } - s32 angle() { return mAngle; } - float deltaz() { return mDeltaZ; } - u32* uv() { return mUV; } - - void SetTexture(Texture tex) { mTexture = tex; } - - //for spinners... a bit hacky but meh -.- - s32& Angle() { return mAngle; } - void SetCustomBounds(u32* uv) { mUV = uv; } - void SetHeight(s32 height) { mHeight = height; } - void SetWidth(s32 width) { mWidth = width; } - - //for score sprites (more hax) - void SetDeltaZ(float z) { mDeltaZ = z; } - u32& Alpha() { return mAlpha; } - - DrawOrigin origin() { return mOrigin; } - FieldType fieldType() { return mFieldType; } - Texture texture() { return mTexture; } - */ - bool Draw() { return mDraw; } - - s32 X, Y; - u32 Width, Height; - rgb Color; - u32 Alpha; - s32 Angle; - float Z; - u32* UV; - - DrawOrigin Origin; - FieldType Field; - TextureType Texture; - - protected: - u32 mOrigWidth, mOrigHeight; - bool mDraw; - /* - s32 mX, mY; - u32 mWidth, mHeight; - rgb mColor; - u32 mAlpha; - s32 mAngle; - float mDeltaZ; - u32* mUV; - - DrawOrigin mOrigin; - FieldType mFieldType; - Texture mTexture; - */ - vector mTransformations; - - void Transform(Transformation* transform); -}; - -#endif - +#include +#include +#include "GraphicsManager.h" +#include "Transformation.h" +#include "System/GameClock.h" + +#ifndef __PSPRITE_H__ +#define __PSPRITE_H__ + +using namespace std; + +typedef vector::iterator transformIterator; + +class pSprite +{ + public: + pSprite(TextureType texture, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, float z = 0); + virtual ~pSprite(); + + virtual void Update(); + bool InBounds(s32 x, s32 y); + void Kill(s32 time); + void ClearTransforms(); + + void Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue); + void Scale(s32 starttime, s32 endtime, float start, float end); + void Move(s32 starttime, s32 endtime, s32 startx, s32 starty, s32 endx, s32 endy); + void Move(s32 starttime, s32 endtime, s32 endx, s32 endy); + void Move(s32 x, s32 y); + void Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda); + void Rotate(s32 angle); + + void Show(); + void Show(s32 time); + void Show(s32 starttime, s32 endtime); + void Hide(); + void Hide(s32 time); + void Hide(s32 starttime, s32 endtime); + + /* + s32 x() { return mX; } + s32 y() { return mY; } + u32 width() { return mWidth; } + u32 height() { return mHeight; } + rgb color() { return mColor; } + u32 alpha() { return mAlpha; } + s32 angle() { return mAngle; } + float deltaz() { return mDeltaZ; } + u32* uv() { return mUV; } + + void SetTexture(Texture tex) { mTexture = tex; } + + //for spinners... a bit hacky but meh -.- + s32& Angle() { return mAngle; } + void SetCustomBounds(u32* uv) { mUV = uv; } + void SetHeight(s32 height) { mHeight = height; } + void SetWidth(s32 width) { mWidth = width; } + + //for score sprites (more hax) + void SetDeltaZ(float z) { mDeltaZ = z; } + u32& Alpha() { return mAlpha; } + + DrawOrigin origin() { return mOrigin; } + FieldType fieldType() { return mFieldType; } + Texture texture() { return mTexture; } + */ + bool Draw() { return mDraw; } + + s32 X, Y; + u32 Width, Height; + rgb Color; + u32 Alpha; + s32 Angle; + float Z; + u32* UV; + + DrawOrigin Origin; + FieldType Field; + TextureType Texture; + + protected: + u32 mOrigWidth, mOrigHeight; + bool mDraw; + /* + s32 mX, mY; + u32 mWidth, mHeight; + rgb mColor; + u32 mAlpha; + s32 mAngle; + float mDeltaZ; + u32* mUV; + + DrawOrigin mOrigin; + FieldType mFieldType; + Texture mTexture; + */ + vector mTransformations; + + void Transform(Transformation* transform); +}; + +#endif + diff --git a/arm9/source/Helpers/AudioManager.cpp b/source/Helpers/AudioManager.cpp similarity index 96% rename from arm9/source/Helpers/AudioManager.cpp rename to source/Helpers/AudioManager.cpp index 7ec89d9..1059f52 100644 --- a/arm9/source/Helpers/AudioManager.cpp +++ b/source/Helpers/AudioManager.cpp @@ -1,196 +1,196 @@ -#include "AudioManager.h" - -AudioManager AudioManager::sEngine; - -AudioManager::AudioManager() -{ - soundEnable(); - - //sound init - ResetSamples(); - - mSampleSets[0] = NULL; //"none" sample set >.> - mSampleSets[1] = &mSampleNormal; - mSampleSets[2] = &mSampleSoft; - - //music init - mChannel = -1; - mBuffer = (u8*)new u32[SIZE*2/4+1]; //div4 because u32 = 4 * u8 - irqEnable(IRQ_TIMER0); - irqSet(IRQ_TIMER0, MusicTimerHandler); -} - -void AudioManager::ResetSamples() -{ - mSampleNormal.hitnormal.data = normal_hitnormal_bin; - mSampleNormal.hitnormal.size = normal_hitnormal_bin_size; - mSampleNormal.hitwhistle.data = normal_hitwhistle_bin; - mSampleNormal.hitwhistle.size = normal_hitwhistle_bin_size; - mSampleNormal.hitfinish.data = normal_hitfinish_bin; - mSampleNormal.hitfinish.size = normal_hitfinish_bin_size; - mSampleNormal.hitclap.data = normal_hitclap_bin; - mSampleNormal.hitclap.size = normal_hitclap_bin_size; - mSampleNormal.slidertick.data = normal_slidertick_bin; - mSampleNormal.slidertick.size = normal_slidertick_bin_size; - mSampleNormal.sliderslide.data = normal_sliderslide_bin; - mSampleNormal.sliderslide.size = normal_sliderslide_bin_size; - mSampleNormal.sliderwhistle.data = normal_sliderwhistle_bin; - mSampleNormal.sliderwhistle.size = normal_sliderwhistle_bin_size; - - mSampleSoft.hitnormal.data = soft_hitnormal_bin; - mSampleSoft.hitnormal.size = soft_hitnormal_bin_size; - mSampleSoft.hitwhistle.data = soft_hitwhistle_bin; - mSampleSoft.hitwhistle.size = soft_hitwhistle_bin_size; - mSampleSoft.hitfinish.data = soft_hitfinish_bin; - mSampleSoft.hitfinish.size = soft_hitfinish_bin_size; - mSampleSoft.hitclap.data = soft_hitclap_bin; - mSampleSoft.hitclap.size = soft_hitclap_bin_size; - mSampleSoft.slidertick.data = soft_slidertick_bin; - mSampleSoft.slidertick.size = soft_slidertick_bin_size; - mSampleSoft.sliderslide.data = soft_sliderslide_bin; - mSampleSoft.sliderslide.size = soft_sliderslide_bin_size; - mSampleSoft.sliderwhistle.data = soft_sliderwhistle_bin; - mSampleSoft.sliderwhistle.size = soft_sliderwhistle_bin_size; -} - -int AudioManager::PlaySample(const u8* data, u32 size, bool loop) -{ - return soundPlaySample(data, SoundFormat_8Bit, size, 22050, 127, 64, loop, 0); -} - -int AudioManager::PlaySample(SampleSetInfo info, bool loop) -{ - return soundPlaySample(info.data, SoundFormat_8Bit, info.size, 22050, 127, 64, loop, 0); -} - -void AudioManager::SetChannelFreq(int channel, u16 freq) -{ - soundSetFreq(channel, freq); -} - -void AudioManager::StopChannel(int channel) -{ - soundKill(channel); -} - -void AudioManager::PlayHitSound(HitObjectSound sound) -{ - SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; - - PlaySample(current->hitnormal); - - if (sound & SND_WHISTLE) - PlaySample(current->hitwhistle); - - if (sound & SND_FINISH) - PlaySample(current->hitfinish); - - if (sound & SND_CLAP) - PlaySample(current->hitclap); -} - -int AudioManager::PlaySliderSound(HitObjectSound sound) -{ - SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; - - if (sound & SND_WHISTLE) - return PlaySample(current->sliderwhistle, true); - else - return PlaySample(current->sliderslide, true); -} - -void AudioManager::PlaySliderTick() -{ - SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; - - PlaySample(current->slidertick); -} - -//music -void MusicTimerHandler() -{ - AudioManager::Engine().fSwap = !AudioManager::Engine().fSwap; - AudioManager::Engine().fFill = true; -} - -int AudioManager::MusicPlay(string& filename) -{ - if (mChannel != -1) - MusicStop(); - - mFile = fopen(filename.c_str(), "rb"); - if (mFile == NULL) - return -1; - - MusicBuffer(); - - return mChannel; -} - -int AudioManager::MusicSkipTo(u32 milliseconds) -{ - if (mChannel == -1) - return -1; - - StopChannel(mChannel); - TIMER0_CR = 0; - fFill = false; - - fseek(mFile, milliseconds*22050/1000.0, SEEK_SET); - MusicBuffer(); - return mChannel; -} - -void AudioManager::MusicBuffer() -{ - fread(mBuffer, 1, SIZE, mFile); - fFill = true; - fSwap = false; - fEof = 0; - - mChannel = soundPlaySample(mBuffer, SoundFormat_8Bit, SIZE*2, 22050, 127, 64, true, 0); //true indicates loop - - //TIMER_FREQ_1024(x) doesn't give required result - mTimerData = -(((u32)(0x2000000*(SIZE/22050.0)))>>10); - - TIMER0_DATA = mTimerData; - TIMER0_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_1024; -} - -void AudioManager::MusicStop() -{ - if (mChannel == -1) - return; - - StopChannel(mChannel); - TIMER0_CR = 0; - fFill = false; - - fclose(mFile); -} - -void AudioManager::MusicUpdate() -{ - if (fFill && mChannel != -1) - { - if (fEof > 0) - { - if (fEof == 2) //count 2 extra loops to allow buffered music to play - MusicStop(); - - ++fEof; - return; - } - - u8* tBufferAddr = fSwap ? mBuffer : mBuffer+SIZE; - - fread(tBufferAddr, 1, SIZE, mFile); - - if (fEof == 0) - fEof = feof(mFile); - - fFill = false; - - //iprintf("\x1b[23;20HVCOUNT:%i ", REG_VCOUNT); - } -} +#include "AudioManager.h" + +AudioManager AudioManager::sEngine; + +AudioManager::AudioManager() +{ + soundEnable(); + + //sound init + ResetSamples(); + + mSampleSets[0] = NULL; //"none" sample set >.> + mSampleSets[1] = &mSampleNormal; + mSampleSets[2] = &mSampleSoft; + + //music init + mChannel = -1; + mBuffer = (u8*)new u32[SIZE*2/4+1]; //div4 because u32 = 4 * u8 + irqEnable(IRQ_TIMER0); + irqSet(IRQ_TIMER0, MusicTimerHandler); +} + +void AudioManager::ResetSamples() +{ + mSampleNormal.hitnormal.data = normal_hitnormal_bin; + mSampleNormal.hitnormal.size = normal_hitnormal_bin_size; + mSampleNormal.hitwhistle.data = normal_hitwhistle_bin; + mSampleNormal.hitwhistle.size = normal_hitwhistle_bin_size; + mSampleNormal.hitfinish.data = normal_hitfinish_bin; + mSampleNormal.hitfinish.size = normal_hitfinish_bin_size; + mSampleNormal.hitclap.data = normal_hitclap_bin; + mSampleNormal.hitclap.size = normal_hitclap_bin_size; + mSampleNormal.slidertick.data = normal_slidertick_bin; + mSampleNormal.slidertick.size = normal_slidertick_bin_size; + mSampleNormal.sliderslide.data = normal_sliderslide_bin; + mSampleNormal.sliderslide.size = normal_sliderslide_bin_size; + mSampleNormal.sliderwhistle.data = normal_sliderwhistle_bin; + mSampleNormal.sliderwhistle.size = normal_sliderwhistle_bin_size; + + mSampleSoft.hitnormal.data = soft_hitnormal_bin; + mSampleSoft.hitnormal.size = soft_hitnormal_bin_size; + mSampleSoft.hitwhistle.data = soft_hitwhistle_bin; + mSampleSoft.hitwhistle.size = soft_hitwhistle_bin_size; + mSampleSoft.hitfinish.data = soft_hitfinish_bin; + mSampleSoft.hitfinish.size = soft_hitfinish_bin_size; + mSampleSoft.hitclap.data = soft_hitclap_bin; + mSampleSoft.hitclap.size = soft_hitclap_bin_size; + mSampleSoft.slidertick.data = soft_slidertick_bin; + mSampleSoft.slidertick.size = soft_slidertick_bin_size; + mSampleSoft.sliderslide.data = soft_sliderslide_bin; + mSampleSoft.sliderslide.size = soft_sliderslide_bin_size; + mSampleSoft.sliderwhistle.data = soft_sliderwhistle_bin; + mSampleSoft.sliderwhistle.size = soft_sliderwhistle_bin_size; +} + +int AudioManager::PlaySample(const u8* data, u32 size, bool loop) +{ + return soundPlaySample(data, SoundFormat_8Bit, size, 22050, 127, 64, loop, 0); +} + +int AudioManager::PlaySample(SampleSetInfo info, bool loop) +{ + return soundPlaySample(info.data, SoundFormat_8Bit, info.size, 22050, 127, 64, loop, 0); +} + +void AudioManager::SetChannelFreq(int channel, u16 freq) +{ + soundSetFreq(channel, freq); +} + +void AudioManager::StopChannel(int channel) +{ + soundKill(channel); +} + +void AudioManager::PlayHitSound(HitObjectSound sound) +{ + SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; + + PlaySample(current->hitnormal); + + if (sound & SND_WHISTLE) + PlaySample(current->hitwhistle); + + if (sound & SND_FINISH) + PlaySample(current->hitfinish); + + if (sound & SND_CLAP) + PlaySample(current->hitclap); +} + +int AudioManager::PlaySliderSound(HitObjectSound sound) +{ + SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; + + if (sound & SND_WHISTLE) + return PlaySample(current->sliderwhistle, true); + else + return PlaySample(current->sliderslide, true); +} + +void AudioManager::PlaySliderTick() +{ + SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; + + PlaySample(current->slidertick); +} + +//music +void MusicTimerHandler() +{ + AudioManager::Engine().fSwap = !AudioManager::Engine().fSwap; + AudioManager::Engine().fFill = true; +} + +int AudioManager::MusicPlay(string& filename) +{ + if (mChannel != -1) + MusicStop(); + + mFile = fopen(filename.c_str(), "rb"); + if (mFile == NULL) + return -1; + + MusicBuffer(); + + return mChannel; +} + +int AudioManager::MusicSkipTo(u32 milliseconds) +{ + if (mChannel == -1) + return -1; + + StopChannel(mChannel); + TIMER0_CR = 0; + fFill = false; + + fseek(mFile, milliseconds*22050/1000.0, SEEK_SET); + MusicBuffer(); + return mChannel; +} + +void AudioManager::MusicBuffer() +{ + fread(mBuffer, 1, SIZE, mFile); + fFill = true; + fSwap = false; + fEof = 0; + + mChannel = soundPlaySample(mBuffer, SoundFormat_8Bit, SIZE*2, 22050, 127, 64, true, 0); //true indicates loop + + //TIMER_FREQ_1024(x) doesn't give required result + mTimerData = -(((u32)(0x2000000*(SIZE/22050.0)))>>10); + + TIMER0_DATA = mTimerData; + TIMER0_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_1024; +} + +void AudioManager::MusicStop() +{ + if (mChannel == -1) + return; + + StopChannel(mChannel); + TIMER0_CR = 0; + fFill = false; + + fclose(mFile); +} + +void AudioManager::MusicUpdate() +{ + if (fFill && mChannel != -1) + { + if (fEof > 0) + { + if (fEof == 2) //count 2 extra loops to allow buffered music to play + MusicStop(); + + ++fEof; + return; + } + + u8* tBufferAddr = fSwap ? mBuffer : mBuffer+SIZE; + + fread(tBufferAddr, 1, SIZE, mFile); + + if (fEof == 0) + fEof = feof(mFile); + + fFill = false; + + //iprintf("\x1b[23;20HVCOUNT:%i ", REG_VCOUNT); + } +} diff --git a/arm9/source/Helpers/AudioManager.h b/source/Helpers/AudioManager.h similarity index 94% rename from arm9/source/Helpers/AudioManager.h rename to source/Helpers/AudioManager.h index d3f1020..8a8dcd4 100644 --- a/arm9/source/Helpers/AudioManager.h +++ b/source/Helpers/AudioManager.h @@ -1,106 +1,106 @@ -#include -#include -#include - -#include "Beatmaps/BeatmapElements.h" - -#ifndef __AUDIOMANAGER_H__ -#define __AUDIOMANAGER_H__ - -#include "normal_hitnormal_bin.h" -#include "normal_hitwhistle_bin.h" -#include "normal_hitfinish_bin.h" -#include "normal_hitclap_bin.h" -#include "normal_slidertick_bin.h" -#include "normal_sliderslide_bin.h" -#include "normal_sliderwhistle_bin.h" - -#include "soft_hitnormal_bin.h" -#include "soft_hitwhistle_bin.h" -#include "soft_hitfinish_bin.h" -#include "soft_hitclap_bin.h" -#include "soft_slidertick_bin.h" -#include "soft_sliderslide_bin.h" -#include "soft_sliderwhistle_bin.h" - -#include "spinnerbonus_bin.h" -#include "spinnerspin_bin.h" - -using namespace std; - -typedef enum { - SND_NORMAL = 0, - SND_WHISTLE = 2, - SND_FINISH = 4, - SND_CLAP = 8 -} HitObjectSound; - -typedef struct { - const u8* data; - u32 size; -} SampleSetInfo; - -typedef struct { - SampleSetInfo hitnormal; - SampleSetInfo hitwhistle; - SampleSetInfo hitfinish; - SampleSetInfo hitclap; - SampleSetInfo slidertick; - SampleSetInfo sliderslide; - SampleSetInfo sliderwhistle; -} SampleSet; - -//intended usage: -//AudioManager::Engine().PlaySample(SOUND_DATA(sound_name), loop) -#define SOUND_DATA(name) name, name##_size - -class AudioManager -{ - public: - static AudioManager& Engine() { return sEngine; } - - int PlaySample(const u8* data, u32 size, bool loop = false); - int PlaySample(SampleSetInfo info, bool loop = false); - void SetChannelFreq(int channel, u16 freq); - void StopChannel(int channel); - - //sounds - void ResetSamples(); - void PlayHitSound(HitObjectSound sound); - int PlaySliderSound(HitObjectSound sound); - void PlaySliderTick(); - - //music - friend void MusicTimerHandler(); - int MusicPlay(string& filename); - int MusicSkipTo(u32 milliseconds); - void MusicStop(); - void MusicUpdate(); //must be called frequently - - protected: - static AudioManager sEngine; - - void MusicBuffer(); - - SampleSet mSampleNormal; - SampleSet mSampleSoft; - SampleSet* mSampleSets[3]; - - //music - static const u32 SIZE = 11025; //size of each HALF of the buffer - u8* mBuffer; - FILE* mFile; - bool fSwap, fFill; - u32 fEof; - int mChannel; - u16 mTimerData; - - private: - AudioManager(); - ~AudioManager() {} -}; - -void MusicTimerHandler(); - -#endif - +#include +#include +#include + +#include "Beatmaps/BeatmapElements.h" + +#ifndef __AUDIOMANAGER_H__ +#define __AUDIOMANAGER_H__ + +#include "normal_hitnormal_bin.h" +#include "normal_hitwhistle_bin.h" +#include "normal_hitfinish_bin.h" +#include "normal_hitclap_bin.h" +#include "normal_slidertick_bin.h" +#include "normal_sliderslide_bin.h" +#include "normal_sliderwhistle_bin.h" + +#include "soft_hitnormal_bin.h" +#include "soft_hitwhistle_bin.h" +#include "soft_hitfinish_bin.h" +#include "soft_hitclap_bin.h" +#include "soft_slidertick_bin.h" +#include "soft_sliderslide_bin.h" +#include "soft_sliderwhistle_bin.h" + +#include "spinnerbonus_bin.h" +#include "spinnerspin_bin.h" + +using namespace std; + +typedef enum { + SND_NORMAL = 1, + SND_WHISTLE = 2, + SND_FINISH = 4, + SND_CLAP = 8 +} HitObjectSound; + +typedef struct { + const u8* data; + u32 size; +} SampleSetInfo; + +typedef struct { + SampleSetInfo hitnormal; + SampleSetInfo hitwhistle; + SampleSetInfo hitfinish; + SampleSetInfo hitclap; + SampleSetInfo slidertick; + SampleSetInfo sliderslide; + SampleSetInfo sliderwhistle; +} SampleSet; + +//intended usage: +//AudioManager::Engine().PlaySample(SOUND_DATA(sound_name), loop) +#define SOUND_DATA(name) name, name##_size + +class AudioManager +{ + public: + static AudioManager& Engine() { return sEngine; } + + int PlaySample(const u8* data, u32 size, bool loop = false); + int PlaySample(SampleSetInfo info, bool loop = false); + void SetChannelFreq(int channel, u16 freq); + void StopChannel(int channel); + + //sounds + void ResetSamples(); + void PlayHitSound(HitObjectSound sound); + int PlaySliderSound(HitObjectSound sound); + void PlaySliderTick(); + + //music + friend void MusicTimerHandler(); + int MusicPlay(string& filename); + int MusicSkipTo(u32 milliseconds); + void MusicStop(); + void MusicUpdate(); //must be called frequently + + protected: + static AudioManager sEngine; + + void MusicBuffer(); + + SampleSet mSampleNormal; + SampleSet mSampleSoft; + SampleSet* mSampleSets[3]; + + //music + static const u32 SIZE = 11025; //size of each HALF of the buffer + u8* mBuffer; + FILE* mFile; + bool fSwap, fFill; + u32 fEof; + int mChannel; + u16 mTimerData; + + private: + AudioManager(); + ~AudioManager() {} +}; + +void MusicTimerHandler(); + +#endif + diff --git a/arm9/source/Helpers/FileReader.cpp b/source/Helpers/FileReader.cpp similarity index 88% rename from arm9/source/Helpers/FileReader.cpp rename to source/Helpers/FileReader.cpp index 67a415d..327dcb9 100644 --- a/arm9/source/Helpers/FileReader.cpp +++ b/source/Helpers/FileReader.cpp @@ -1,165 +1,168 @@ -#include "FileReader.h" - -u32 FileReader::BUFFERSIZE = 1024; - -FileReader::FileReader(u8* source) -{ - Init(NULL, source); -} - -FileReader::FileReader(string& filename) -{ - FILE* handle = fopen(filename.c_str(), "rb"); - Init(handle, NULL); -} - -FileReader::FileReader(const char* filename) -{ - FILE* handle = fopen(filename, "rb"); - Init(handle, NULL); -} - -void FileReader::Init(FILE* handle, u8* buffer) -{ - if (buffer == NULL && handle == NULL) - { - iprintf("\x1b[0;0Hno source"); - mHandle = NULL; - mBuffer = NULL; - - fReady = false; - return; - } - - mBuffer = buffer; - if (buffer == NULL) - mBuffer = new u8[BUFFERSIZE]; - - mHandle = handle; - - Reset(); - fReady = true; -} - -FileReader::~FileReader() -{ - if (mHandle != NULL) - { - fclose(mHandle); - } - - if (mBuffer != NULL) - { - delete[] mBuffer; - } -} - -int FileReader::FillBuffer() const -{ - if (mHandle == NULL || feof(mHandle)) - return -1; - if (pos == 0) - return 0; - - //shift remaining buffer - memcpy(mBuffer, mBuffer+pos, BUFFERSIZE-pos); - int bytesread = fread(mBuffer+BUFFERSIZE-pos, 1, pos, mHandle); - pos = 0; - return bytesread; -} - -void FileReader::PrepareBuffer(u8 datasize) const -{ - //todo: handle eof - if (mHandle != NULL && BUFFERSIZE - datasize < pos) - FillBuffer(); -} - -u8 FileReader::ReadInt8() const -{ - PrepareBuffer(1); - return mBuffer[pos++]; -} - -u16 FileReader::ReadInt16() const -{ - PrepareBuffer(2); - u16 t = mBuffer[pos++]; - t += mBuffer[pos++] << 8; - return t; -} - -u32 FileReader::ReadInt32() const -{ - PrepareBuffer(4); - u32 t = mBuffer[pos++]; - t += mBuffer[pos++] << 8; - t += mBuffer[pos++] << 16; - t += mBuffer[pos++] << 24; - return t; -} - -float FileReader::ReadFloat() const -{ - PrepareBuffer(4); - u8 c[4]; - c[0] = mBuffer[pos++]; - c[1] = mBuffer[pos++]; - c[2] = mBuffer[pos++]; - c[3] = mBuffer[pos++]; - return *reinterpret_cast(c); -} - -u32 FileReader::ReadVarInt() const -{ - PrepareBuffer(4); - u32 value = 0; - u8 i = 0; - u8 b; - do - { - b = mBuffer[pos++]; - value += (b & 0x7F) << (7 * i); - ++i; - } while ((b & 0x80) > 0); - return value; -} - - -string FileReader::ReadString() const -{ - u32 l = ReadVarInt(); - if (l == 0) - return NULL; - - PrepareBuffer(l); - - char* c = new char[l+1]; - for (u32 i=0; i(c); +} + +// Read Integers of variable size, kind of like in midi +u32 FileReader::ReadVarInt() const +{ + PrepareBuffer(4); + u32 value = 0; + u8 i = 0; + u8 b; + do // Bits in the file: 10010101 11000101 00100010 + { // Bits in the Output: 00000000 0010101 1000101 0100010 + b = mBuffer[pos++]; + value += (b & 0x7F) << (7 * i); + ++i; + } while ((b & 0x80) > 0); + + nocashMessage((std::string(" ") + std::to_string(value)).c_str()); + return value; +} + + +string FileReader::ReadString() const +{ + u32 l = ReadVarInt(); + if (l == 0) + return NULL; + + PrepareBuffer(l); + + char* c = new char[l+1]; + for (u32 i=0; i -#include -#include -#include - -#ifndef __FILEREADER_H__ -#define __FILEREADER_H__ - -using namespace std; - -class FileReader -{ - public: - FileReader(u8* source); - FileReader(string& filename); - FileReader(const char* filename); - ~FileReader(); - - u8 ReadInt8() const; - u16 ReadInt16() const; - u32 ReadInt32() const; - float ReadFloat() const; - u32 ReadVarInt() const; - string ReadString() const; - - bool Ready() const { return fReady; } - - void Skip(u32 count) const; - - void Reset() const; - - protected: - u8* mBuffer; - mutable u32 pos; - - static u32 BUFFERSIZE; - - FILE* mHandle; - - int FillBuffer() const; - void PrepareBuffer(u8 datasize) const; - - bool fReady; - - private: - void Init(FILE* handle, u8* buffer); -}; - +#include +#include +#include +#include + +#ifndef __FILEREADER_H__ +#define __FILEREADER_H__ + +using namespace std; + +class FileReader +{ + public: + FileReader(u8* source); + FileReader(string& filename); + FileReader(const char* filename); + ~FileReader(); + + u8 ReadInt8() const; + u16 ReadInt16() const; + u32 ReadInt32() const; + float ReadFloat() const; + u32 ReadVarInt() const; + string ReadString() const; + + bool Ready() const { return fReady; } + + void Skip(u32 count) const; + + void Reset() const; + + protected: + u8* mBuffer; + mutable u32 pos; + + static u32 BUFFERSIZE; + + FILE* mHandle; + + int FillBuffer() const; + void PrepareBuffer(u8 datasize) const; + + bool fReady; + + private: + void Init(FILE* handle, u8* buffer); +}; + #endif \ No newline at end of file diff --git a/arm9/source/Helpers/InputHelper.cpp b/source/Helpers/InputHelper.cpp similarity index 92% rename from arm9/source/Helpers/InputHelper.cpp rename to source/Helpers/InputHelper.cpp index 929c75e..9c8ee8c 100644 --- a/arm9/source/Helpers/InputHelper.cpp +++ b/source/Helpers/InputHelper.cpp @@ -1,29 +1,29 @@ -#include "InputHelper.h" - -touchPosition InputHelper::mTouch; - -bool InputHelper::KeyDown(int key) -{ - return keysDown() & key; -} - -bool InputHelper::KeyHeld(int key) -{ - return keysHeld() & key; -} - -bool InputHelper::KeyUp(int key) -{ - return keysUp() & key; -} - -touchPosition& InputHelper::TouchRead() -{ - touchRead(&mTouch); - - mTouch.px *= 2.5; - mTouch.py *= 2.5; - - return mTouch; -} - +#include "InputHelper.h" + +touchPosition InputHelper::mTouch; + +bool InputHelper::KeyDown(int key) +{ + return keysDown() & key; +} + +bool InputHelper::KeyHeld(int key) +{ + return keysHeld() & key; +} + +bool InputHelper::KeyUp(int key) +{ + return keysUp() & key; +} + +touchPosition& InputHelper::TouchRead() +{ + touchRead(&mTouch); + + mTouch.px *= 2.5; + mTouch.py *= 2.5; + + return mTouch; +} + diff --git a/arm9/source/Helpers/InputHelper.h b/source/Helpers/InputHelper.h similarity index 93% rename from arm9/source/Helpers/InputHelper.h rename to source/Helpers/InputHelper.h index aed9643..e1f7398 100644 --- a/arm9/source/Helpers/InputHelper.h +++ b/source/Helpers/InputHelper.h @@ -1,19 +1,19 @@ -#include - -#ifndef __INPUTHELPER_H__ -#define __INPUTHELPER_H__ - -class InputHelper -{ - public: - static bool KeyDown(int key); - static bool KeyHeld(int key); - static bool KeyUp(int key); - static touchPosition& TouchRead(); - - protected: - static touchPosition mTouch; -}; - -#endif - +#include + +#ifndef __INPUTHELPER_H__ +#define __INPUTHELPER_H__ + +class InputHelper +{ + public: + static bool KeyDown(int key); + static bool KeyHeld(int key); + static bool KeyUp(int key); + static touchPosition& TouchRead(); + + protected: + static touchPosition mTouch; +}; + +#endif + diff --git a/arm9/source/Helpers/MathHelper.cpp b/source/Helpers/MathHelper.cpp similarity index 93% rename from arm9/source/Helpers/MathHelper.cpp rename to source/Helpers/MathHelper.cpp index b23aa55..7c29de9 100644 --- a/arm9/source/Helpers/MathHelper.cpp +++ b/source/Helpers/MathHelper.cpp @@ -1,11 +1,11 @@ -#include "MathHelper.h" - -u16 MathHelper::mSeed = 3246; - -u16 MathHelper::Random(u16 min, u16 max) -{ - mSeed= 1664525*mSeed+1013904223; - return (mSeed % (max-min) + min); -} - - +#include "MathHelper.h" + +u16 MathHelper::mSeed = 3246; + +u16 MathHelper::Random(u16 min, u16 max) +{ + mSeed= 1664525*mSeed+1013904223; + return (mSeed % (max-min) + min); +} + + diff --git a/arm9/source/Helpers/MathHelper.h b/source/Helpers/MathHelper.h similarity index 95% rename from arm9/source/Helpers/MathHelper.h rename to source/Helpers/MathHelper.h index 28cc66f..498b913 100644 --- a/arm9/source/Helpers/MathHelper.h +++ b/source/Helpers/MathHelper.h @@ -1,25 +1,25 @@ -#include -//#include - -#ifndef __MATHHELPER_H__ -#define __MATHHELPER_H__ - -class MathHelper -{ - public: - static u32 Abs(s32 value) { return (value > 0 ? value : -value); } - static s32 Max(s32 value1, s32 value2) { return (value1 > value2 ? value1 : value2); } - static s32 Min(s32 value1, s32 value2) { return (value1 < value2 ? value1 : value2); } - static s32 Sgn(s32 value) { return (value == (s32)Abs(value) ? 1 : -1); } - static float Frc(float value) { return value - (int)value; } - - static u16 Random(u16 min, u16 max); - - protected: - static u16 mSeed; -}; - -#endif - - - +#include +//#include + +#ifndef __MATHHELPER_H__ +#define __MATHHELPER_H__ + +class MathHelper +{ + public: + static u32 Abs(s32 value) { return (value > 0 ? value : -value); } + static s32 Max(s32 value1, s32 value2) { return (value1 > value2 ? value1 : value2); } + static s32 Min(s32 value1, s32 value2) { return (value1 < value2 ? value1 : value2); } + static s32 Sgn(s32 value) { return (value == (s32)Abs(value) ? 1 : -1); } + static float Frc(float value) { return value - (int)value; } + + static u16 Random(u16 min, u16 max); + + protected: + static u16 mSeed; +}; + +#endif + + + diff --git a/arm9/source/HitObjects/HitCircle.cpp b/source/HitObjects/HitCircle.cpp similarity index 95% rename from arm9/source/HitObjects/HitCircle.cpp rename to source/HitObjects/HitCircle.cpp index 0e8596e..6175ddf 100644 --- a/arm9/source/HitObjects/HitCircle.cpp +++ b/source/HitObjects/HitCircle.cpp @@ -1,115 +1,115 @@ -#include "HitCircle.h" - -HitCircle::HitCircle(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound) : HitObject(x, y, time, type, sound) -{ - u32 size = DifficultyManager::GetCircleSize(); - - u32 preempt = DifficultyManager::GetPreemptTime(); - s32 fadeInStart = time - preempt; - s32 fadeInEnd = fadeInStart + (preempt >> 3); - mEndTime = time + DifficultyManager::GetHitWindow50(); - - pSprite* spr; - - spr = new pSprite(TX_PLAY_CIRCLEOVERLAY, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Hide(time, mEndTime); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_CIRCLE, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Hide(time, mEndTime); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_CIRCLEAPPROACH, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Hide(time, mEndTime); - spr->Scale(fadeInStart, time, 4, 1); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - mScoreSpriteId = 1; -} - -bool HitCircle::InBounds(s32 x, s32 y) -{ - //all sprites are the same, it doesn't matter which one - return mSprites[1]->InBounds(x, y); -} - -void HitCircle::OnTouchDown(const touchPosition& touch) -{ - if (InBounds(touch.px, touch.py)) - { - Hit(); - } -} - -void HitCircle::Hit() -{ - s32 now = GameClock::Clock().Time(); - u32 delta = MathHelper::Abs(mTime - now); - - if (delta > DifficultyManager::GetHitWindow()) - { - //too early, give the hitcircle a shake - for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) - { - pSprite* spr = *it; - - spr->Move(now, now+20, mX+5, mY); - spr->Move(now+20, now+40, mX-5, mY); - spr->Move(now+40, now+60, mX+5, mY); - spr->Move(now+60, now+80, mX, mY); - } - } - else - { - if (delta < DifficultyManager::GetHitWindow50()) - { - //if within the window for 50, the person hit it - for (u32 i=0; i<2; ++i) - { - pSprite* spr = mSprites[i]; - - //circle explosion - spr->Transform(TR_FADE, now, now+200, 31, 10); - spr->Transform(TR_FADE, now+200, now+270, 10, 0); - spr->Scale(now, now+150, 1, 1.7); - spr->Scale(now+150, now+270, 1.7, 1.9); - } - //kill the approach circle - mSprites[2]->Kill(now); - - if (delta < DifficultyManager::GetHitWindow300()) - { - IncreaseScore(SCORE_300); - } - else if (delta < DifficultyManager::GetHitWindow100()) - { - IncreaseScore(SCORE_100); - } - else - { - IncreaseScore(SCORE_50); - } - - AudioManager::Engine().PlayHitSound(mSound); - } - else - { - //otherwise missed - for (u32 i=0; i<3; ++i) - { - mSprites[i]->Kill(now); - } - - IncreaseScore(SCORE_MISS); - } - } - - mHit = true; -} - +#include "HitCircle.h" + +HitCircle::HitCircle(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound) : HitObject(x, y, time, type, sound) +{ + u32 size = DifficultyManager::GetCircleSize(); + + u32 preempt = DifficultyManager::GetPreemptTime(); + s32 fadeInStart = time - preempt; + s32 fadeInEnd = fadeInStart + (preempt >> 3); + mEndTime = time + DifficultyManager::GetHitWindow50(); + + pSprite* spr; + + spr = new pSprite(TX_PLAY_CIRCLEOVERLAY, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Hide(time, mEndTime); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_CIRCLE, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Hide(time, mEndTime); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_CIRCLEAPPROACH, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Hide(time, mEndTime); + spr->Scale(fadeInStart, time, 4, 1); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + mScoreSpriteId = 1; +} + +bool HitCircle::InBounds(s32 x, s32 y) +{ + //all sprites are the same, it doesn't matter which one + return mSprites[1]->InBounds(x, y); +} + +void HitCircle::OnTouchDown(const touchPosition& touch) +{ + if (InBounds(touch.px, touch.py)) + { + Hit(); + } +} + +void HitCircle::Hit() +{ + s32 now = GameClock::Clock().Time(); + u32 delta = MathHelper::Abs(mTime - now); + + if (delta > DifficultyManager::GetHitWindow()) + { + //too early, give the hitcircle a shake + for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) + { + pSprite* spr = *it; + + spr->Move(now, now+20, mX+5, mY); + spr->Move(now+20, now+40, mX-5, mY); + spr->Move(now+40, now+60, mX+5, mY); + spr->Move(now+60, now+80, mX, mY); + } + } + else + { + if (delta < DifficultyManager::GetHitWindow50()) + { + //if within the window for 50, the person hit it + for (u32 i=0; i<2; ++i) + { + pSprite* spr = mSprites[i]; + + //circle explosion + spr->Transform(TR_FADE, now, now+200, 31, 10); + spr->Transform(TR_FADE, now+200, now+270, 10, 0); + spr->Scale(now, now+150, 1, 1.7); + spr->Scale(now+150, now+270, 1.7, 1.9); + } + //kill the approach circle + mSprites[2]->Kill(now); + + if (delta < DifficultyManager::GetHitWindow300()) + { + IncreaseScore(SCORE_300); + } + else if (delta < DifficultyManager::GetHitWindow100()) + { + IncreaseScore(SCORE_100); + } + else + { + IncreaseScore(SCORE_50); + } + + AudioManager::Engine().PlayHitSound(mSound); + } + else + { + //otherwise missed + for (u32 i=0; i<3; ++i) + { + mSprites[i]->Kill(now); + } + + IncreaseScore(SCORE_MISS); + } + } + + mHit = true; +} + diff --git a/arm9/source/HitObjects/HitCircle.h b/source/HitObjects/HitCircle.h similarity index 94% rename from arm9/source/HitObjects/HitCircle.h rename to source/HitObjects/HitCircle.h index c55258b..cb75b6d 100644 --- a/arm9/source/HitObjects/HitCircle.h +++ b/source/HitObjects/HitCircle.h @@ -1,21 +1,21 @@ -#include -#include "HitObject.h" - -#ifndef __HITCIRCLE_H__ -#define __HITCIRCLE_H__ - -class HitCircle : public HitObject -{ - public: - HitCircle(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound); - - bool InBounds(s32 x, s32 y); - - void OnTouchDown(const touchPosition& touch); - - void Hit(); -}; - -#endif - - +#include +#include "HitObject.h" + +#ifndef __HITCIRCLE_H__ +#define __HITCIRCLE_H__ + +class HitCircle : public HitObject +{ + public: + HitCircle(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound); + + bool InBounds(s32 x, s32 y); + + void OnTouchDown(const touchPosition& touch); + + void Hit(); +}; + +#endif + + diff --git a/arm9/source/HitObjects/HitObject.cpp b/source/HitObjects/HitObject.cpp similarity index 95% rename from arm9/source/HitObjects/HitObject.cpp rename to source/HitObjects/HitObject.cpp index 3729e0e..0dc9f67 100644 --- a/arm9/source/HitObjects/HitObject.cpp +++ b/source/HitObjects/HitObject.cpp @@ -1,103 +1,103 @@ -#include "HitObject.h" - -rgb HitObject::mColour = 0; -float HitObject::sScoreDeltaZ = 0; -float HitObject::sSliderDeltaZ = 0; -s32 HitObject::sLastSliderTime = 0; -ICallback* HitObject::mScoreCallback = NULL; - -HitObject::HitObject(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound) -{ - mX = x; - mY = y; - mTime = time; - mType = type; - mHit = false; - mSound = sound; - - mScoreSpriteId = 0; - - mComboEnd = false; - - if ((type & HIT_COMBO) > 0) - mColour = BeatmapElements::Element().GetNextColour(); -} - -HitObject::~HitObject() -{ -} - -void HitObject::Hit() -{ - mHit = true; -} - -void HitObject::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation) -{ - IncreaseScore(score, forceNoCombo, forceNoAnimation, mScoreSpriteId); -} - -void HitObject::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, u32 spriteId) -{ - HitObjectPoint point = { - mSprites[spriteId]->X, - mSprites[spriteId]->Y, - 0 - }; - - void** args = new void*[5]; - - ARGS_PUSH(args, 0, score); - ARGS_PUSH(args, 1, forceNoCombo); - ARGS_PUSH(args, 2, forceNoAnimation); - ARGS_PUSH(args, 3, point); - ARGS_PUSH(args, 4, mComboEnd); - - if (mScoreCallback != NULL) - mScoreCallback->DoCallback(args); - - delete[] args; -} - -void HitObject::SetScoreCallback(ICallback* scoreCallback) -{ - //if (mScoreCallback != NULL) - // delete mScoreCallback; - - mScoreCallback = scoreCallback; -} - -void HitObject::SetPostCreateOptions(bool comboend, s32 nextx, s32 nexty) -{ - //set whether this is the last object of a combo - mComboEnd = comboend; - /* - //set score z layering - mScoreDeltaZ = sScoreDeltaZ; - - if (sScoreDeltaZ >= 0.05f || MathHelper::Abs(mSprites[mScoreSpriteId]->x() - nextx) + MathHelper::Abs(mSprites[mScoreSpriteId]->y() - nexty) >= 230) - sScoreDeltaZ = 0; - else - sScoreDeltaZ += 0.001f; - - //set slider z layering - if (sSliderDeltaZ >= 0.05f || mTime - DifficultyManager::GetPreemptTime() > sLastSliderTime) - sSliderDeltaZ = 0; - else - sSliderDeltaZ += 0.004f; - - if ((mType & HIT_SLIDER) > 0) - { - for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) - { - if (*it != NULL) - { - (*it)->SetDeltaZ(sSliderDeltaZ); - } - } - - sLastSliderTime = mEndTime; - } - */ -} - +#include "HitObject.h" + +rgb HitObject::mColour = 0; +float HitObject::sScoreDeltaZ = 0; +float HitObject::sSliderDeltaZ = 0; +s32 HitObject::sLastSliderTime = 0; +ICallback* HitObject::mScoreCallback = NULL; + +HitObject::HitObject(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound) +{ + mX = x; + mY = y; + mTime = time; + mType = type; + mHit = false; + mSound = sound; + + mScoreSpriteId = 0; + + mComboEnd = false; + + if ((type & HIT_COMBO) > 0) + mColour = BeatmapElements::Element().GetNextColour(); +} + +HitObject::~HitObject() +{ +} + +void HitObject::Hit() +{ + mHit = true; +} + +void HitObject::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation) +{ + IncreaseScore(score, forceNoCombo, forceNoAnimation, mScoreSpriteId); +} + +void HitObject::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, u32 spriteId) +{ + HitObjectPoint point = { + mSprites[spriteId]->X, + mSprites[spriteId]->Y, + 0 + }; + + void** args = new void*[5]; + + ARGS_PUSH(args, 0, score); + ARGS_PUSH(args, 1, forceNoCombo); + ARGS_PUSH(args, 2, forceNoAnimation); + ARGS_PUSH(args, 3, point); + ARGS_PUSH(args, 4, mComboEnd); + + if (mScoreCallback != NULL) + mScoreCallback->DoCallback(args); + + delete[] args; +} + +void HitObject::SetScoreCallback(ICallback* scoreCallback) +{ + //if (mScoreCallback != NULL) + // delete mScoreCallback; + + mScoreCallback = scoreCallback; +} + +void HitObject::SetPostCreateOptions(bool comboend, s32 nextx, s32 nexty) +{ + //set whether this is the last object of a combo + mComboEnd = comboend; + /* + //set score z layering + mScoreDeltaZ = sScoreDeltaZ; + + if (sScoreDeltaZ >= 0.05f || MathHelper::Abs(mSprites[mScoreSpriteId]->x() - nextx) + MathHelper::Abs(mSprites[mScoreSpriteId]->y() - nexty) >= 230) + sScoreDeltaZ = 0; + else + sScoreDeltaZ += 0.001f; + + //set slider z layering + if (sSliderDeltaZ >= 0.05f || mTime - DifficultyManager::GetPreemptTime() > sLastSliderTime) + sSliderDeltaZ = 0; + else + sSliderDeltaZ += 0.004f; + + if ((mType & HIT_SLIDER) > 0) + { + for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) + { + if (*it != NULL) + { + (*it)->SetDeltaZ(sSliderDeltaZ); + } + } + + sLastSliderTime = mEndTime; + } + */ +} + diff --git a/arm9/source/HitObjects/HitObject.h b/source/HitObjects/HitObject.h similarity index 95% rename from arm9/source/HitObjects/HitObject.h rename to source/HitObjects/HitObject.h index c648322..c26e21b 100644 --- a/arm9/source/HitObjects/HitObject.h +++ b/source/HitObjects/HitObject.h @@ -1,82 +1,82 @@ -#include -#include - -#include "Beatmaps/BeatmapElements.h" -#include "Beatmaps/DifficultyManager.h" -#include "GameplayElements/ScoreManager.h" -#include "Graphics/pSprite.h" -#include "Graphics/pAnimation.h" -#include "Graphics/GfxInfo.h" -#include "Graphics/SpriteContainer.h" -#include "Helpers/AudioManager.h" -#include "System/ICallback.h" - -#ifndef __HITOBJECT_H__ -#define __HITOBJECT_H__ - -typedef struct { - s32 x, y; - s32 angle; -} HitObjectPoint; - -typedef enum { - HIT_NORMAL = 1, - HIT_SLIDER = 2, - HIT_COMBO = 4, - HIT_SPINNER = 8 -} HitObjectType; - -typedef void (*HitHandler)(ScoreType score, bool forceNoCombo, bool forceNoAnimation, HitObjectPoint point); - -class HitObject : public SpriteContainer -{ - public: - virtual ~HitObject(); - - virtual bool InBounds(s32 x, s32 y) { return true; } - - bool GetHit() { return mHit; } - s32 GetEndTime() { return mEndTime; } - - virtual void Update() {} - - virtual void OnTouchDown(const touchPosition& touch) {} - virtual void OnTouch(const touchPosition& touch) {} - virtual void OnTouchUp(const touchPosition& touch) {} - - virtual void Hit(); - - void SetPostCreateOptions(bool comboend, s32 nextx, s32 nexty); - - static void SetScoreCallback(ICallback* scoreCallback); - - protected: - HitObject(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound); - - s32 mX, mY; - s32 mTime, mEndTime; - HitObjectType mType; - HitObjectSound mSound; - static rgb mColour; - - bool mHit; - bool mComboEnd; - - u32 mScoreSpriteId; - - void IncreaseScore(ScoreType score, bool forceNoCombo = false, bool forceNoAnimation = false); - void IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, u32 spriteId); - - private: - float mScoreDeltaZ; - - static float sScoreDeltaZ; - static float sSliderDeltaZ; - static s32 sLastSliderTime; - - static ICallback* mScoreCallback; -}; - -#endif - - +#include +#include + +#include "Beatmaps/BeatmapElements.h" +#include "Beatmaps/DifficultyManager.h" +#include "GameplayElements/ScoreManager.h" +#include "Graphics/pSprite.h" +#include "Graphics/pAnimation.h" +#include "Graphics/GfxInfo.h" +#include "Graphics/SpriteContainer.h" +#include "Helpers/AudioManager.h" +#include "System/ICallback.h" + +#ifndef __HITOBJECT_H__ +#define __HITOBJECT_H__ + +typedef struct { + s32 x, y; + s32 angle; +} HitObjectPoint; + +typedef enum { + HIT_NORMAL = 1, + HIT_SLIDER = 2, + HIT_COMBO = 4, + HIT_SPINNER = 8 +} HitObjectType; + +typedef void (*HitHandler)(ScoreType score, bool forceNoCombo, bool forceNoAnimation, HitObjectPoint point); + +class HitObject : public SpriteContainer +{ + public: + virtual ~HitObject(); + + virtual bool InBounds(s32 x, s32 y) { return true; } + + bool GetHit() { return mHit; } + s32 GetEndTime() { return mEndTime; } + + virtual void Update() {} + + virtual void OnTouchDown(const touchPosition& touch) {} + virtual void OnTouch(const touchPosition& touch) {} + virtual void OnTouchUp(const touchPosition& touch) {} + + virtual void Hit(); + + void SetPostCreateOptions(bool comboend, s32 nextx, s32 nexty); + + static void SetScoreCallback(ICallback* scoreCallback); + + protected: + HitObject(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound); + + s32 mX, mY; + s32 mTime, mEndTime; + HitObjectType mType; + HitObjectSound mSound; + static rgb mColour; + + bool mHit; + bool mComboEnd; + + u32 mScoreSpriteId; + + void IncreaseScore(ScoreType score, bool forceNoCombo = false, bool forceNoAnimation = false); + void IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, u32 spriteId); + + private: + float mScoreDeltaZ; + + static float sScoreDeltaZ; + static float sSliderDeltaZ; + static s32 sLastSliderTime; + + static ICallback* mScoreCallback; +}; + +#endif + + diff --git a/arm9/source/HitObjects/HitSlider.cpp b/source/HitObjects/HitSlider.cpp similarity index 96% rename from arm9/source/HitObjects/HitSlider.cpp rename to source/HitObjects/HitSlider.cpp index 05d520a..8352c50 100644 --- a/arm9/source/HitObjects/HitSlider.cpp +++ b/source/HitObjects/HitSlider.cpp @@ -1,544 +1,544 @@ -#include "HitSlider.h" - -HitSlider::HitSlider(s32 x, s32 y, s32 time, u32 lengthtime, vector& points, vector& ticks, u32 repeats, HitObjectType type, HitObjectSound sound) - : HitObject(x, y, time, type, sound) -{ - fTouching = false; - fStarted = false; - fFinished = false; - mTimeLast = time; - mChannel = -1; - - u32 pointCount = points.size(); - u32 tickCount = ticks.size(); - - mTickCount = tickCount; - mTicksHit = 0; - mRepeats = repeats; - mRepeatCurrent = 0; - mTicksTarget = (tickCount + 1) * repeats + 1; - - mTicks = new TickSprites[tickCount]; - mTickTimes = new s32[mTicksTarget-1]; - - u32 beatTime = BeatmapElements::Element().GetTimingPoint(time).BeatTime; - - //populate tick times excluding first hit - mTickTime = beatTime / DifficultyManager::SliderTickRate; - u32 specialTickTime = lengthtime - mTickCount*mTickTime; - - //easy if we don't have any ticks, just keep adding lengthtime - if (tickCount == 0) - { - for (u32 i=0; i> 3) * 7; // 7/8 size - u32 tickSize = circleSize >> 2; // 1/4 size - - u32 preempt = DifficultyManager::GetPreemptTime(); - s32 fadeInStart = time - preempt; - s32 fadeInEnd = fadeInStart + (preempt >> 3); - mEndTime = time + (repeats * lengthtime); - mLengthTime = lengthtime; - - pSprite* spr; - - //todo: fix formula - //u32 fps = (u32)(DifficultyManager::SliderMultiplier*3.142*ballSize*1000/beatTime); - u32 fps = 60; - - //slider ball - spr = new pAnimation(TX_PLAY_SLIDERB0, 10, fps, x, y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Show(time); - MapSliderPath(spr, points, time, lengthtime, repeats); - spr->Kill(mEndTime); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_SLIDERFOLLOW, x, y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Scale(time, time+50, 1, 2); - spr->Scale(mEndTime, mEndTime+50, 2, 1.5); - MapSliderPath(spr, points, time, lengthtime, repeats); - spr->Kill(mEndTime+100); - mSprites.push_back(spr); - - if ((repeats&0x1)==1) //if ODD score is at end - { - mScoreSpriteId = 6; - mSecondaryScoreSpriteId = 4; - } - else - { - mScoreSpriteId = 4; - mSecondaryScoreSpriteId = 6; - } - - //slider start - spr = new pSprite(TX_PLAY_CIRCLEAPPROACH, x, y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Hide(time, time+100); - spr->Scale(fadeInStart, time, 4, 1); - spr->Kill(mEndTime); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_CIRCLEOVERLAY, x, y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_CIRCLE, x, y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - //slider end - spr = new pSprite(TX_PLAY_CIRCLEOVERLAY, points[pointCount-1]->x, points[pointCount-1]->y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_CIRCLE, points[pointCount-1]->x, points[pointCount-1]->y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - //slider30 sprites - spr = new pSprite(TX_PLAY_SLIDER30, points[0]->x, points[0]->y, 40, 40, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_SLIDER30, points[pointCount-1]->x, points[pointCount-1]->y, 40, 40, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - //slider repeats - for (u32 i=1; iangle; - //animations shifted until number disappears - tAnimStart = time; - tFadeInEnd = tAnimStart + (preempt >> 3); - } - else //if odd - slider end - { - p = points[pointCount-1]; - tAngle = p->angle + 0x4000; - tAnimStart = fadeInStart; - tFadeInEnd = fadeInEnd; - } - - spr = new pSprite(TX_PLAY_SLIDERREVERSE, p->x, p->y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Show(tAnimStart, tFadeInEnd); - //todo: slider repeat explosion? - spr->Hide(time+(lengthtime*i)); - - //animate arrow - do - { - s32 tAnimEnd = tAnimStart + 500; - spr->Rotate(tAnimStart, tAnimEnd, tAngle, tAngle+3000); - spr->Scale(tAnimStart, tAnimEnd, 1, 0.9); - tAnimStart = tAnimEnd; - } while (tAnimStart < time+(lengthtime*i)); - - spr->Kill(mEndTime); - mSprites.push_back(spr); - } - - //slider ticks & score sprites - for (u32 i=0; ix, ticks[i]->y, tickSize, tickSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); - spr->Show(fadeInStart, fadeInEnd); - spr->Hide(mEndTime, mEndTime+120); - spr->Kill(mEndTime+120); - mSprites.push_back(spr); - - //add to list for tracking ticks - mTicks[i].Tick = spr; - - spr = new pSprite(TX_PLAY_SLIDER10, ticks[i]->x, ticks[i]->y, 40, 40, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31),0); - spr->Kill(mEndTime+1000); - mSprites.push_back(spr); - - //add to list as well - mTicks[i].Score = spr; - } - - //slider path - for (u32 i=0; ix, points[i]->y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0, 0.015f); - spr->Show(fadeInStart+30, fadeInEnd); - spr->Hide(mEndTime-30, mEndTime+70); - spr->Kill(mEndTime+70); - mSprites.push_back(spr); - } -} - -HitSlider::~HitSlider() -{ - delete mTicks; - delete mTickTimes; - - if (mChannel != -1) - AudioManager::Engine().StopChannel(mChannel); -} - -bool HitSlider::InBounds(s32 x, s32 y) -{ - //hit is based on sliderfollowcircle - return mSprites[1]->InBounds(x, y); -} - -void HitSlider::Update() -{ - s32 now = GameClock::Clock().Time(); - - //trigger score calculation once slider is finished - if (now >= mEndTime) - Hit(); - - //process slider behaviour - { - //find the next tick - u32 i = 0; - for (; i < mTicksTarget; ++i) - { - if (mTickTimes[i] > mTimeLast) - break; - } - - //mTickTimes[i] now refers to the time for the next tick - - //any normal tick/slider repeat - if (i < mTicksTarget-2) //why? try it on a piece of paper >.> - { - //if we passed over a tick or repeat - if (mTickTimes[i] <= now) - { - //if it's a tick we hide it and bounce the followcircle - if ((i+1)%(mTickCount+1) != 0) - { - if (fTouching) - { - u32 real; - - //fairly straightfoward if this is the first (or only) repeat - if (mRepeatCurrent == 0) - { - real = i; - } - //when we have repeats, we have to calculate the "real" tick - else - { - real = i - (mRepeatCurrent * (mTickCount+1)); - //however if repeat is ODD we have to count BACKWARDS >.> - if ((mRepeatCurrent & 0x1) == 1) - { - real = (mTickCount-1) - real; - } - } - - ++mTicksHit; - mTicks[real].Tick->Hide(); - mSprites[1]->Scale(now, now+60, 2.5, 2); - - //slider10 animation - mTicks[real].Score->Show(); - mTicks[real].Score->Hide(now+300, now+350); - mTicks[real].Score->Move(now, now+250, - mTicks[real].Tick->X, mTicks[real].Tick->Y, - mTicks[real].Tick->X, mTicks[real].Tick->Y - 20); - mTicks[real].Score->Move(now+250, now+320, - mTicks[real].Tick->X, mTicks[real].Tick->Y - 20, - mTicks[real].Tick->X, mTicks[real].Tick->Y - 30); - - //normal ticks give 10 points - IncreaseScore(SCORE_TICK_10, false, true); - AudioManager::Engine().PlaySliderTick(); - } - else //if we missed a tick - { - IncreaseScore(SCORE_MISS, true, true); - } - } - //otherwise it's a repeat and we'll need to reset the ticks - else - { - if (fTouching) - { - ++mTicksHit; - mSprites[1]->Scale(now, now+60, 2.5, 2); - - u32 tSpriteId; - - if ((mRepeatCurrent&1)==1) //if ODD - tSpriteId = 7; - else - tSpriteId = 8; - - mSprites[tSpriteId]->Show(); - mSprites[tSpriteId]->Hide(now+300, now+350); - mSprites[tSpriteId]->Move(now, now+250, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20); - mSprites[tSpriteId]->Move(now+250, now+320, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20, - mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 30); - mSprites[tSpriteId]->Move(now+350, now+350, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y); - - //repeats give 30 points - IncreaseScore(SCORE_TICK_30, false, true); - AudioManager::Engine().PlayHitSound(mSound); - } - else - { - IncreaseScore(SCORE_MISS, true, true); - } - } - } - } - //slider end - else if (fTouching && !fFinished && i == mTicksTarget-2) //again, try it on a piece of paper if you want to know why >.> - { - if (now >= mEndTime - DifficultyManager::GetHitWindow300()) //hack - seems like we're missing a frame somewhere >.> - { - ++mTicksHit; - - u32 tSpriteId; - - if ((mRepeats&1)==0) //if EVEN - mRepeats is always greater than the maximum value of mRepeatCurrent by 1 - tSpriteId = 7; - else - tSpriteId = 8; - - mSprites[tSpriteId]->Show(); - mSprites[tSpriteId]->Hide(now+300, now+350); - mSprites[tSpriteId]->Move(now, now+250, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20); - mSprites[tSpriteId]->Move(now+250, now+320, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20, - mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 30); - mSprites[tSpriteId]->Move(now+350, now+350, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y); - - IncreaseScore(SCORE_TICK_30, true, true); - fFinished = true; - } - } - } - - //reset ticks if ball goes to a repeat regardless of fTouching - if (now >= mTime + (mLengthTime * (mRepeatCurrent + 1))) - { - for (u32 j=0; jAlpha != 31) - mTicks[j].Tick->Show(now, now+50); - } - ++mRepeatCurrent; - } - - mTimeLast = now; -} - -void HitSlider::OnTouchDown(const touchPosition& touch) -{ - if (InBounds(touch.px, touch.py)) - { - s32 now = GameClock::Clock().Time(); - u32 delta = MathHelper::Abs(mTime - now); - - //slider start - if (delta < DifficultyManager::GetHitWindow() && !fStarted) - { - //fTouching = true; //set in OnTouch() which will always be called if OnTouchDown() is called - fStarted = true; - mSprites[1]->Transform(TR_FADE, now, mEndTime, 31, 31); - mSprites[2]->Kill(now); - - //if it was hit within the window for any amount of points - if (delta < DifficultyManager::GetHitWindow50()) - { - ++mTicksHit; - - mSprites[7]->Show(); - mSprites[7]->Hide(now+300, now+350); - mSprites[7]->Move(now, now+250, mSprites[7]->X, mSprites[7]->Y - 20); - mSprites[7]->Move(now+250, now+320, mSprites[7]->X, mSprites[7]->Y - 20, - mSprites[7]->X, mSprites[7]->Y - 30); - mSprites[7]->Move(now+350, now+350, mSprites[7]->X, mSprites[7]->Y); - - IncreaseScore(SCORE_TICK_30, false, true); - AudioManager::Engine().PlayHitSound(mSound); - } - else - { - IncreaseScore(SCORE_MISS, true, true); - } - } - - if (mChannel == -1) - mChannel = AudioManager::Engine().PlaySliderSound(mSound); - } -} - -void HitSlider::OnTouch(const touchPosition& touch) -{ - s32 now = GameClock::Clock().Time(); - u32 delta = MathHelper::Abs(mTime - now); - - if (InBounds(touch.px, touch.py) && now >= mTime && now <= mEndTime + DifficultyManager::GetHitWindow()) - { - //if we're touching it without tapping it, then we missed the slider start - if (delta < DifficultyManager::GetHitWindow() && !fStarted) - { - fStarted = true; - IncreaseScore(SCORE_MISS, true, true); - } - - mSprites[1]->Transform(TR_FADE, now, mEndTime, 31, 31); - fTouching = true; - //mTimeLast = now; //set in Update() - - if (mChannel == -1) - mChannel = AudioManager::Engine().PlaySliderSound(mSound); - } - else - { - //touching screen but not sprite is the same as not touching at all - OnTouchUp(touch); - } -} - -void HitSlider::OnTouchUp(const touchPosition& touch) -{ - s32 now = GameClock::Clock().Time(); - mSprites[1]->Transform(TR_FADE, now, mEndTime, 0, 0); - - if (mChannel != -1) - { - AudioManager::Engine().StopChannel(mChannel); - mChannel = -1; - } - - fTouching = false; -} - -void HitSlider::Hit() -{ - if (mTicksHit == 0) - { - IncreaseScore(SCORE_MISS); - IncreaseScore(SCORE_MISS, true, false, mSecondaryScoreSpriteId); //miss shows on both slider start and end - - //fade hitcircles - for (u32 i=3; i<=6; ++i) - { - mSprites[i]->Transform(TR_FADE, mEndTime, mEndTime+100, 31, 0); - } - } - else - { - if (mTicksHit == mTicksTarget) - { - IncreaseScore(SCORE_300); - } - else if (mTicksHit >= mTicksTarget>>1) //at least half were hit - { - IncreaseScore(SCORE_100); - } - else if (mTicksHit > 0) - { - IncreaseScore(SCORE_50); - } - - //animate hitcircles - for (u32 i=3; i<=6; ++i) - { - mSprites[i]->Transform(TR_FADE, mEndTime, mEndTime+200, 31, 10); - mSprites[i]->Transform(TR_FADE, mEndTime+200, mEndTime+270, 10, 0); - mSprites[i]->Scale(mEndTime, mEndTime+150, 1, 1.7); - mSprites[i]->Scale(mEndTime+150, mEndTime+270, 1.7, 1.9); - } - - AudioManager::Engine().PlayHitSound(mSound); - - if (mChannel != -1) - { - AudioManager::Engine().StopChannel(mChannel); - mChannel = -1; - } - } - - mHit = true; -} - -void HitSlider::MapSliderPath(pSprite* spr, vector& points, s32 time, u32 lengthtime, u32 repeats) -{ - u32 timeperpoint = lengthtime / points.size(); - - u32 loops = 0; - while (loops < repeats) - { - for (u32 i=0; iMove(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[i]->x, points[i]->y, points[i+1]->x, points[i+1]->y); - spr->Rotate(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[i]->angle, points[i+1]->angle); - } - ++loops; - - if (loops < repeats) - { - for (u32 i=0; iMove(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[points.size()-i-1]->x, points[points.size()-i-1]->y, points[points.size()-i-2]->x, points[points.size()-i-2]->y); - spr->Rotate(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[points.size()-i-1]->angle+0x4000, points[points.size()-i-2]->angle+0x4000); - } - ++loops; - } - } -} - +#include "HitSlider.h" + +HitSlider::HitSlider(s32 x, s32 y, s32 time, u32 lengthtime, vector& points, vector& ticks, u32 repeats, HitObjectType type, HitObjectSound sound) + : HitObject(x, y, time, type, sound) +{ + fTouching = false; + fStarted = false; + fFinished = false; + mTimeLast = time; + mChannel = -1; + + u32 pointCount = points.size(); + u32 tickCount = ticks.size(); + + mTickCount = tickCount; + mTicksHit = 0; + mRepeats = repeats; + mRepeatCurrent = 0; + mTicksTarget = (tickCount + 1) * repeats + 1; + + mTicks = new TickSprites[tickCount]; + mTickTimes = new s32[mTicksTarget-1]; + + u32 beatTime = BeatmapElements::Element().GetTimingPoint(time).BeatTime; + + //populate tick times excluding first hit + mTickTime = beatTime / DifficultyManager::SliderTickRate; + u32 specialTickTime = lengthtime - mTickCount*mTickTime; + + //easy if we don't have any ticks, just keep adding lengthtime + if (tickCount == 0) + { + for (u32 i=0; i> 3) * 7; // 7/8 size + u32 tickSize = circleSize >> 2; // 1/4 size + + u32 preempt = DifficultyManager::GetPreemptTime(); + s32 fadeInStart = time - preempt; + s32 fadeInEnd = fadeInStart + (preempt >> 3); + mEndTime = time + (repeats * lengthtime); + mLengthTime = lengthtime; + + pSprite* spr; + + //todo: fix formula + //u32 fps = (u32)(DifficultyManager::SliderMultiplier*3.142*ballSize*1000/beatTime); + u32 fps = 60; + + //slider ball + spr = new pAnimation(TX_PLAY_SLIDERB0, 10, fps, x, y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Show(time); + MapSliderPath(spr, points, time, lengthtime, repeats); + spr->Kill(mEndTime); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_SLIDERFOLLOW, x, y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Scale(time, time+50, 1, 2); + spr->Scale(mEndTime, mEndTime+50, 2, 1.5); + MapSliderPath(spr, points, time, lengthtime, repeats); + spr->Kill(mEndTime+100); + mSprites.push_back(spr); + + if ((repeats&0x1)==1) //if ODD score is at end + { + mScoreSpriteId = 6; + mSecondaryScoreSpriteId = 4; + } + else + { + mScoreSpriteId = 4; + mSecondaryScoreSpriteId = 6; + } + + //slider start + spr = new pSprite(TX_PLAY_CIRCLEAPPROACH, x, y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Hide(time, time+100); + spr->Scale(fadeInStart, time, 4, 1); + spr->Kill(mEndTime); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_CIRCLEOVERLAY, x, y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_CIRCLE, x, y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + //slider end + spr = new pSprite(TX_PLAY_CIRCLEOVERLAY, points[pointCount-1]->x, points[pointCount-1]->y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_CIRCLE, points[pointCount-1]->x, points[pointCount-1]->y, circleSize, circleSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + //slider30 sprites + spr = new pSprite(TX_PLAY_SLIDER30, points[0]->x, points[0]->y, 40, 40, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_SLIDER30, points[pointCount-1]->x, points[pointCount-1]->y, 40, 40, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + //slider repeats + for (u32 i=1; iangle; + //animations shifted until number disappears + tAnimStart = time; + tFadeInEnd = tAnimStart + (preempt >> 3); + } + else //if odd - slider end + { + p = points[pointCount-1]; + tAngle = p->angle + 0x4000; + tAnimStart = fadeInStart; + tFadeInEnd = fadeInEnd; + } + + spr = new pSprite(TX_PLAY_SLIDERREVERSE, p->x, p->y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Show(tAnimStart, tFadeInEnd); + //todo: slider repeat explosion? + spr->Hide(time+(lengthtime*i)); + + //animate arrow + do + { + s32 tAnimEnd = tAnimStart + 500; + spr->Rotate(tAnimStart, tAnimEnd, tAngle, tAngle+3000); + spr->Scale(tAnimStart, tAnimEnd, 1, 0.9); + tAnimStart = tAnimEnd; + } while (tAnimStart < time+(lengthtime*i)); + + spr->Kill(mEndTime); + mSprites.push_back(spr); + } + + //slider ticks & score sprites + for (u32 i=0; ix, ticks[i]->y, tickSize, tickSize, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0); + spr->Show(fadeInStart, fadeInEnd); + spr->Hide(mEndTime, mEndTime+120); + spr->Kill(mEndTime+120); + mSprites.push_back(spr); + + //add to list for tracking ticks + mTicks[i].Tick = spr; + + spr = new pSprite(TX_PLAY_SLIDER10, ticks[i]->x, ticks[i]->y, 40, 40, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31),0); + spr->Kill(mEndTime+1000); + mSprites.push_back(spr); + + //add to list as well + mTicks[i].Score = spr; + } + + //slider path + for (u32 i=0; ix, points[i]->y, ballSize, ballSize, ORIGIN_CENTER, FIELD_PLAY, mColour, 0, 0.015f); + spr->Show(fadeInStart+30, fadeInEnd); + spr->Hide(mEndTime-30, mEndTime+70); + spr->Kill(mEndTime+70); + mSprites.push_back(spr); + } +} + +HitSlider::~HitSlider() +{ + delete mTicks; + delete mTickTimes; + + if (mChannel != -1) + AudioManager::Engine().StopChannel(mChannel); +} + +bool HitSlider::InBounds(s32 x, s32 y) +{ + //hit is based on sliderfollowcircle + return mSprites[1]->InBounds(x, y); +} + +void HitSlider::Update() +{ + s32 now = GameClock::Clock().Time(); + + //trigger score calculation once slider is finished + if (now >= mEndTime) + Hit(); + + //process slider behaviour + { + //find the next tick + u32 i = 0; + for (; i < mTicksTarget; ++i) + { + if (mTickTimes[i] > mTimeLast) + break; + } + + //mTickTimes[i] now refers to the time for the next tick + + //any normal tick/slider repeat + if (i < mTicksTarget-2) //why? try it on a piece of paper >.> + { + //if we passed over a tick or repeat + if (mTickTimes[i] <= now) + { + //if it's a tick we hide it and bounce the followcircle + if ((i+1)%(mTickCount+1) != 0) + { + if (fTouching) + { + u32 real; + + //fairly straightfoward if this is the first (or only) repeat + if (mRepeatCurrent == 0) + { + real = i; + } + //when we have repeats, we have to calculate the "real" tick + else + { + real = i - (mRepeatCurrent * (mTickCount+1)); + //however if repeat is ODD we have to count BACKWARDS >.> + if ((mRepeatCurrent & 0x1) == 1) + { + real = (mTickCount-1) - real; + } + } + + ++mTicksHit; + mTicks[real].Tick->Hide(); + mSprites[1]->Scale(now, now+60, 2.5, 2); + + //slider10 animation + mTicks[real].Score->Show(); + mTicks[real].Score->Hide(now+300, now+350); + mTicks[real].Score->Move(now, now+250, + mTicks[real].Tick->X, mTicks[real].Tick->Y, + mTicks[real].Tick->X, mTicks[real].Tick->Y - 20); + mTicks[real].Score->Move(now+250, now+320, + mTicks[real].Tick->X, mTicks[real].Tick->Y - 20, + mTicks[real].Tick->X, mTicks[real].Tick->Y - 30); + + //normal ticks give 10 points + IncreaseScore(SCORE_TICK_10, false, true); + AudioManager::Engine().PlaySliderTick(); + } + else //if we missed a tick + { + IncreaseScore(SCORE_MISS, true, true); + } + } + //otherwise it's a repeat and we'll need to reset the ticks + else + { + if (fTouching) + { + ++mTicksHit; + mSprites[1]->Scale(now, now+60, 2.5, 2); + + u32 tSpriteId; + + if ((mRepeatCurrent&1)==1) //if ODD + tSpriteId = 7; + else + tSpriteId = 8; + + mSprites[tSpriteId]->Show(); + mSprites[tSpriteId]->Hide(now+300, now+350); + mSprites[tSpriteId]->Move(now, now+250, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20); + mSprites[tSpriteId]->Move(now+250, now+320, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20, + mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 30); + mSprites[tSpriteId]->Move(now+350, now+350, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y); + + //repeats give 30 points + IncreaseScore(SCORE_TICK_30, false, true); + AudioManager::Engine().PlayHitSound(mSound); + } + else + { + IncreaseScore(SCORE_MISS, true, true); + } + } + } + } + //slider end + else if (fTouching && !fFinished && i == mTicksTarget-2) //again, try it on a piece of paper if you want to know why >.> + { + if (now >= mEndTime - DifficultyManager::GetHitWindow300()) //hack - seems like we're missing a frame somewhere >.> + { + ++mTicksHit; + + u32 tSpriteId; + + if ((mRepeats&1)==0) //if EVEN - mRepeats is always greater than the maximum value of mRepeatCurrent by 1 + tSpriteId = 7; + else + tSpriteId = 8; + + mSprites[tSpriteId]->Show(); + mSprites[tSpriteId]->Hide(now+300, now+350); + mSprites[tSpriteId]->Move(now, now+250, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20); + mSprites[tSpriteId]->Move(now+250, now+320, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 20, + mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y - 30); + mSprites[tSpriteId]->Move(now+350, now+350, mSprites[tSpriteId]->X, mSprites[tSpriteId]->Y); + + IncreaseScore(SCORE_TICK_30, true, true); + fFinished = true; + } + } + } + + //reset ticks if ball goes to a repeat regardless of fTouching + if (now >= mTime + (mLengthTime * (mRepeatCurrent + 1))) + { + for (u32 j=0; jAlpha != 31) + mTicks[j].Tick->Show(now, now+50); + } + ++mRepeatCurrent; + } + + mTimeLast = now; +} + +void HitSlider::OnTouchDown(const touchPosition& touch) +{ + if (InBounds(touch.px, touch.py)) + { + s32 now = GameClock::Clock().Time(); + u32 delta = MathHelper::Abs(mTime - now); + + //slider start + if (delta < DifficultyManager::GetHitWindow() && !fStarted) + { + //fTouching = true; //set in OnTouch() which will always be called if OnTouchDown() is called + fStarted = true; + mSprites[1]->Transform(TR_FADE, now, mEndTime, 31, 31); + mSprites[2]->Kill(now); + + //if it was hit within the window for any amount of points + if (delta < DifficultyManager::GetHitWindow50()) + { + ++mTicksHit; + + mSprites[7]->Show(); + mSprites[7]->Hide(now+300, now+350); + mSprites[7]->Move(now, now+250, mSprites[7]->X, mSprites[7]->Y - 20); + mSprites[7]->Move(now+250, now+320, mSprites[7]->X, mSprites[7]->Y - 20, + mSprites[7]->X, mSprites[7]->Y - 30); + mSprites[7]->Move(now+350, now+350, mSprites[7]->X, mSprites[7]->Y); + + IncreaseScore(SCORE_TICK_30, false, true); + AudioManager::Engine().PlayHitSound(mSound); + } + else + { + IncreaseScore(SCORE_MISS, true, true); + } + } + + if (mChannel == -1) + mChannel = AudioManager::Engine().PlaySliderSound(mSound); + } +} + +void HitSlider::OnTouch(const touchPosition& touch) +{ + s32 now = GameClock::Clock().Time(); + u32 delta = MathHelper::Abs(mTime - now); + + if (InBounds(touch.px, touch.py) && now >= mTime && now <= mEndTime + DifficultyManager::GetHitWindow()) + { + //if we're touching it without tapping it, then we missed the slider start + if (delta < DifficultyManager::GetHitWindow() && !fStarted) + { + fStarted = true; + IncreaseScore(SCORE_MISS, true, true); + } + + mSprites[1]->Transform(TR_FADE, now, mEndTime, 31, 31); + fTouching = true; + //mTimeLast = now; //set in Update() + + if (mChannel == -1) + mChannel = AudioManager::Engine().PlaySliderSound(mSound); + } + else + { + //touching screen but not sprite is the same as not touching at all + OnTouchUp(touch); + } +} + +void HitSlider::OnTouchUp(const touchPosition& touch) +{ + s32 now = GameClock::Clock().Time(); + mSprites[1]->Transform(TR_FADE, now, mEndTime, 0, 0); + + if (mChannel != -1) + { + AudioManager::Engine().StopChannel(mChannel); + mChannel = -1; + } + + fTouching = false; +} + +void HitSlider::Hit() +{ + if (mTicksHit == 0) + { + IncreaseScore(SCORE_MISS); + IncreaseScore(SCORE_MISS, true, false, mSecondaryScoreSpriteId); //miss shows on both slider start and end + + //fade hitcircles + for (u32 i=3; i<=6; ++i) + { + mSprites[i]->Transform(TR_FADE, mEndTime, mEndTime+100, 31, 0); + } + } + else + { + if (mTicksHit == mTicksTarget) + { + IncreaseScore(SCORE_300); + } + else if (mTicksHit >= mTicksTarget>>1) //at least half were hit + { + IncreaseScore(SCORE_100); + } + else if (mTicksHit > 0) + { + IncreaseScore(SCORE_50); + } + + //animate hitcircles + for (u32 i=3; i<=6; ++i) + { + mSprites[i]->Transform(TR_FADE, mEndTime, mEndTime+200, 31, 10); + mSprites[i]->Transform(TR_FADE, mEndTime+200, mEndTime+270, 10, 0); + mSprites[i]->Scale(mEndTime, mEndTime+150, 1, 1.7); + mSprites[i]->Scale(mEndTime+150, mEndTime+270, 1.7, 1.9); + } + + AudioManager::Engine().PlayHitSound(mSound); + + if (mChannel != -1) + { + AudioManager::Engine().StopChannel(mChannel); + mChannel = -1; + } + } + + mHit = true; +} + +void HitSlider::MapSliderPath(pSprite* spr, vector& points, s32 time, u32 lengthtime, u32 repeats) +{ + u32 timeperpoint = lengthtime / points.size(); + + u32 loops = 0; + while (loops < repeats) + { + for (u32 i=0; iMove(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[i]->x, points[i]->y, points[i+1]->x, points[i+1]->y); + spr->Rotate(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[i]->angle, points[i+1]->angle); + } + ++loops; + + if (loops < repeats) + { + for (u32 i=0; iMove(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[points.size()-i-1]->x, points[points.size()-i-1]->y, points[points.size()-i-2]->x, points[points.size()-i-2]->y); + spr->Rotate(time+(loops*lengthtime)+(timeperpoint*i), time+(loops*lengthtime)+(timeperpoint*(i+1)), points[points.size()-i-1]->angle+0x4000, points[points.size()-i-2]->angle+0x4000); + } + ++loops; + } + } +} + diff --git a/arm9/source/HitObjects/HitSlider.h b/source/HitObjects/HitSlider.h similarity index 95% rename from arm9/source/HitObjects/HitSlider.h rename to source/HitObjects/HitSlider.h index 8755c29..6c11819 100644 --- a/arm9/source/HitObjects/HitSlider.h +++ b/source/HitObjects/HitSlider.h @@ -1,51 +1,51 @@ -#include -#include -#include "HitObject.h" - -#ifndef __HITSLIDER_H__ -#define __HITSLIDER_H__ - -using namespace std; - -typedef vector::iterator pointIterator; - -typedef struct { - pSprite* Tick; - pSprite* Score; -} TickSprites; - -class HitSlider : public HitObject -{ - public: - HitSlider(s32 x, s32 y, s32 time, u32 lengthtime, vector& points, vector& ticks, u32 repeats, HitObjectType type, HitObjectSound sound); - ~HitSlider(); - - bool InBounds(s32 x, s32 y); - - void Update(); - - void OnTouchDown(const touchPosition& touch); - void OnTouch(const touchPosition& touch); - void OnTouchUp(const touchPosition& touch); - - void Hit(); - - protected: - static void MapSliderPath(pSprite* spr, vector& points, s32 time, u32 lengthtime, u32 repeats); - - bool fTouching, fStarted, fFinished; - TickSprites* mTicks; - s32* mTickTimes; - u32 mTickTime, mLengthTime; - - u32 mTickCount, mTicksHit, mTicksTarget; - u32 mRepeats, mRepeatCurrent; - s32 mTimeLast; - - u32 mSecondaryScoreSpriteId; - - int mChannel; -}; - -#endif - +#include +#include +#include "HitObject.h" + +#ifndef __HITSLIDER_H__ +#define __HITSLIDER_H__ + +using namespace std; + +typedef vector::iterator pointIterator; + +typedef struct { + pSprite* Tick; + pSprite* Score; +} TickSprites; + +class HitSlider : public HitObject +{ + public: + HitSlider(s32 x, s32 y, s32 time, u32 lengthtime, vector& points, vector& ticks, u32 repeats, HitObjectType type, HitObjectSound sound); + ~HitSlider(); + + bool InBounds(s32 x, s32 y); + + void Update(); + + void OnTouchDown(const touchPosition& touch); + void OnTouch(const touchPosition& touch); + void OnTouchUp(const touchPosition& touch); + + void Hit(); + + protected: + static void MapSliderPath(pSprite* spr, vector& points, s32 time, u32 lengthtime, u32 repeats); + + bool fTouching, fStarted, fFinished; + TickSprites* mTicks; + s32* mTickTimes; + u32 mTickTime, mLengthTime; + + u32 mTickCount, mTicksHit, mTicksTarget; + u32 mRepeats, mRepeatCurrent; + s32 mTimeLast; + + u32 mSecondaryScoreSpriteId; + + int mChannel; +}; + +#endif + diff --git a/arm9/source/HitObjects/HitSpinner.cpp b/source/HitObjects/HitSpinner.cpp similarity index 96% rename from arm9/source/HitObjects/HitSpinner.cpp rename to source/HitObjects/HitSpinner.cpp index 48ea8d2..fe9f38a 100644 --- a/arm9/source/HitObjects/HitSpinner.cpp +++ b/source/HitObjects/HitSpinner.cpp @@ -1,199 +1,199 @@ -#include "HitSpinner.h" - -HitSpinner::HitSpinner(s32 time, s32 endtime, HitObjectSound sound) : HitObject(256, 192, time, HIT_SPINNER, sound) -{ - mEndTime = endtime; - fSpinning = false; - - mDirection = 0; //0 = not set, values -1 and 1 used - mZeroPoint = 0; //point to start counting rotations from - mTotalRotation = 0; //counts rotations in current direction (resets) - mCurrentRotation = 0; //keeps track of which rotation we are at to count - mTotalSpins = 0; //counts total number of spins - mRequiredSpins = (mEndTime - mTime) / DifficultyManager::GetSpinnerTime(); //total spins required - - mUV = new u32[4]; //deleted by pSprite - mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(0)); - mUV[1] = TEXTURE_PACK(inttot16(256),inttot16(0)); - mUV[2] = TEXTURE_PACK(inttot16(256),inttot16(192)); - mUV[3] = TEXTURE_PACK(inttot16(0),inttot16(192)); - - pSprite* spr; - - spr = new pSprite(TX_PLAY_CIRCLEAPPROACH, 256, 192, 440, 440, ORIGIN_CENTER, FIELD_PLAY, RGB15(10,10,31), 0); - spr->Show(time-300, time); - spr->Hide(endtime, endtime+300); - spr->Scale(time-300, endtime, 1, 0); - spr->Kill(endtime+300); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_SPINNER, 256, 192, 400, 400, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0, 0.03f); - spr->Show(time-300, time); - spr->Hide(endtime, endtime+300); - spr->Kill(endtime+300); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_SPINNERBARS, 0, 480, 640, 480, ORIGIN_BOTTOMLEFT, FIELD_SCREEN, RGB15(31,31,31), 0, 0.03f); - spr->Show(time-300, time); - spr->Hide(endtime, endtime+300); - spr->Kill(endtime+300); - mSprites.push_back(spr); - - spr = new pSprite(TX_PLAY_SPINNERBG, 320, 240, 640, 480, ORIGIN_CENTER, FIELD_SCREEN, RGB15(31,31,31), 0, 0.05f); - spr->Show(time-300, time+300); - spr->Hide(endtime, endtime+300); - spr->Kill(endtime+300); - mSprites.push_back(spr); - - mScoreSpriteId = 1; - - mSprites[2]->UV = mUV; - mChannel = -1; -} - -HitSpinner::~HitSpinner() -{ - if (mChannel != -1) - AudioManager::Engine().StopChannel(mChannel); -} - -void HitSpinner::Update() -{ - float ratio = (mTotalSpins + MathHelper::Frc(mTotalRotation)) / mRequiredSpins; - - //set spinner bars - u32 height = MathHelper::Max(0, MathHelper::Min(192, ratio*192) - MathHelper::Random(0,10)); - - mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(192-height)); - mUV[1] = TEXTURE_PACK(inttot16(256),inttot16(192-height)); - mSprites[2]->Height = height*2.5; - - //set spinner sound - if (mChannel == -1 && GameClock::Clock().Time() >= mTime) - mChannel = AudioManager::Engine().PlaySample(SOUND_DATA(spinnerspin_bin), true); - - if (mChannel != -1) - AudioManager::Engine().SetChannelFreq(mChannel, MathHelper::Min((u32)(10000 + (ratio * 30000)), 65535)); - - //trigger score calculation once slider is finished - if (GameClock::Clock().Time() >= mEndTime) - Hit(); -} - -void HitSpinner::OnTouchDown(const touchPosition& touch) -{ - if (GameClock::Clock().Time() >= mTime && GameClock::Clock().Time() <= mEndTime) - { - mLastAngle = GetAngle(touch.px, touch.py); - fSpinning = true; - } -} - -void HitSpinner::OnTouch(const touchPosition& touch) -{ - if (GameClock::Clock().Time() >= mTime && GameClock::Clock().Time() <= mEndTime) - { - if (MathHelper::Abs(touch.px - 320) < 10 && MathHelper::Abs(touch.py - 265) < 10) - { - fSpinning = false; - return; - } - - //work out the new angle - s32 newAngle = GetAngle(touch.px, touch.py); - - if (!fSpinning) - { - mLastAngle = newAngle; - fSpinning = true; - return; - } - - if (newAngle == mLastAngle) - return; - - s32 deltaAngle = newAngle - mLastAngle; - - //hack for passing through line x=320 where y<265 - if (deltaAngle > 16384) - deltaAngle -= 32768; - else if (deltaAngle < -16384) - deltaAngle += 32768; - - mSprites[1]->Angle += deltaAngle; - - //if player changes direction add to total rotations and start count again - if (mDirection != MathHelper::Sgn(deltaAngle)) - { - mDirection = MathHelper::Sgn(deltaAngle); - mZeroPoint = mSprites[1]->Angle; - mTotalRotation = 0; - mCurrentRotation = 0; - } - - mTotalRotation = MathHelper::Abs(mSprites[1]->Angle - mZeroPoint) / 32768.0; - - //if we have made an extra circle (or more) add to total - if (mCurrentRotation < (u32)mTotalRotation) - { - mTotalSpins += (u32)mTotalRotation - mCurrentRotation; - mCurrentRotation = (u32)mTotalRotation; - - IncreaseScore(SCORE_SPIN_100, true, true); - if (mTotalSpins > mRequiredSpins) - { - IncreaseScore(SCORE_SPIN_1000, true, true); - AudioManager::Engine().PlaySample(SOUND_DATA(spinnerbonus_bin)); - } - } - - mLastAngle = newAngle; - } -} - -void HitSpinner::Hit() -{ - if (mRequiredSpins > 0 && (mTotalSpins == 0 || mTotalSpins < MathHelper::Max(0, (s32)(mRequiredSpins - 2)))) - { - IncreaseScore(SCORE_MISS); - } - else - { - //compatibility with osu!pc - if (mRequiredSpins == 0) - { - IncreaseScore(SCORE_50, false, true); //score sprite doesn't show if you score 50 on spinners - } - else if (mTotalSpins >= mRequiredSpins) - { - IncreaseScore(SCORE_300); - } - else if (mTotalSpins == MathHelper::Max(0, (s32)(mRequiredSpins - 1))) - { - IncreaseScore(SCORE_100); - } - else if (mTotalSpins == MathHelper::Max(0, (s32)(mRequiredSpins - 2))) - { - IncreaseScore(SCORE_50, false, true); //score sprite doesn't show if you score 50 on spinners - } - - AudioManager::Engine().PlayHitSound(mSound); - } - - if (mChannel != -1) - AudioManager::Engine().StopChannel(mChannel); - - mHit = true; -} - -s32 HitSpinner::GetAngle(s32 x, s32 y) -{ - float theta = atan((float)(y-265)/(x-320)); - s32 angle = theta*32768/6.2832; - - //hack - let's hope this won't come back to haunt me - if (x < 320) - angle += 16384; - - return angle; +#include "HitSpinner.h" + +HitSpinner::HitSpinner(s32 time, s32 endtime, HitObjectSound sound) : HitObject(256, 192, time, HIT_SPINNER, sound) +{ + mEndTime = endtime; + fSpinning = false; + + mDirection = 0; //0 = not set, values -1 and 1 used + mZeroPoint = 0; //point to start counting rotations from + mTotalRotation = 0; //counts rotations in current direction (resets) + mCurrentRotation = 0; //keeps track of which rotation we are at to count + mTotalSpins = 0; //counts total number of spins + mRequiredSpins = (mEndTime - mTime) / DifficultyManager::GetSpinnerTime(); //total spins required + + mUV = new u32[4]; //deleted by pSprite + mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(0)); + mUV[1] = TEXTURE_PACK(inttot16(256),inttot16(0)); + mUV[2] = TEXTURE_PACK(inttot16(256),inttot16(192)); + mUV[3] = TEXTURE_PACK(inttot16(0),inttot16(192)); + + pSprite* spr; + + spr = new pSprite(TX_PLAY_CIRCLEAPPROACH, 256, 192, 440, 440, ORIGIN_CENTER, FIELD_PLAY, RGB15(10,10,31), 0); + spr->Show(time-300, time); + spr->Hide(endtime, endtime+300); + spr->Scale(time-300, endtime, 1, 0); + spr->Kill(endtime+300); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_SPINNER, 256, 192, 400, 400, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0, 0.03f); + spr->Show(time-300, time); + spr->Hide(endtime, endtime+300); + spr->Kill(endtime+300); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_SPINNERBARS, 0, 480, 640, 480, ORIGIN_BOTTOMLEFT, FIELD_SCREEN, RGB15(31,31,31), 0, 0.03f); + spr->Show(time-300, time); + spr->Hide(endtime, endtime+300); + spr->Kill(endtime+300); + mSprites.push_back(spr); + + spr = new pSprite(TX_PLAY_SPINNERBG, 320, 240, 640, 480, ORIGIN_CENTER, FIELD_SCREEN, RGB15(31,31,31), 0, 0.05f); + spr->Show(time-300, time+300); + spr->Hide(endtime, endtime+300); + spr->Kill(endtime+300); + mSprites.push_back(spr); + + mScoreSpriteId = 1; + + mSprites[2]->UV = mUV; + mChannel = -1; +} + +HitSpinner::~HitSpinner() +{ + if (mChannel != -1) + AudioManager::Engine().StopChannel(mChannel); +} + +void HitSpinner::Update() +{ + float ratio = (mTotalSpins + MathHelper::Frc(mTotalRotation)) / mRequiredSpins; + + //set spinner bars + u32 height = MathHelper::Max(0, MathHelper::Min(192, ratio*192) - MathHelper::Random(0,10)); + + mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(192-height)); + mUV[1] = TEXTURE_PACK(inttot16(256),inttot16(192-height)); + mSprites[2]->Height = height*2.5; + + //set spinner sound + if (mChannel == -1 && GameClock::Clock().Time() >= mTime) + mChannel = AudioManager::Engine().PlaySample(SOUND_DATA(spinnerspin_bin), true); + + if (mChannel != -1) + AudioManager::Engine().SetChannelFreq(mChannel, MathHelper::Min((u32)(10000 + (ratio * 30000)), 65535)); + + //trigger score calculation once slider is finished + if (GameClock::Clock().Time() >= mEndTime) + Hit(); +} + +void HitSpinner::OnTouchDown(const touchPosition& touch) +{ + if (GameClock::Clock().Time() >= mTime && GameClock::Clock().Time() <= mEndTime) + { + mLastAngle = GetAngle(touch.px, touch.py); + fSpinning = true; + } +} + +void HitSpinner::OnTouch(const touchPosition& touch) +{ + if (GameClock::Clock().Time() >= mTime && GameClock::Clock().Time() <= mEndTime) + { + if (MathHelper::Abs(touch.px - 320) < 10 && MathHelper::Abs(touch.py - 265) < 10) + { + fSpinning = false; + return; + } + + //work out the new angle + s32 newAngle = GetAngle(touch.px, touch.py); + + if (!fSpinning) + { + mLastAngle = newAngle; + fSpinning = true; + return; + } + + if (newAngle == mLastAngle) + return; + + s32 deltaAngle = newAngle - mLastAngle; + + //hack for passing through line x=320 where y<265 + if (deltaAngle > 16384) + deltaAngle -= 32768; + else if (deltaAngle < -16384) + deltaAngle += 32768; + + mSprites[1]->Angle += deltaAngle; + + //if player changes direction add to total rotations and start count again + if (mDirection != MathHelper::Sgn(deltaAngle)) + { + mDirection = MathHelper::Sgn(deltaAngle); + mZeroPoint = mSprites[1]->Angle; + mTotalRotation = 0; + mCurrentRotation = 0; + } + + mTotalRotation = MathHelper::Abs(mSprites[1]->Angle - mZeroPoint) / 32768.0; + + //if we have made an extra circle (or more) add to total + if (mCurrentRotation < (u32)mTotalRotation) + { + mTotalSpins += (u32)mTotalRotation - mCurrentRotation; + mCurrentRotation = (u32)mTotalRotation; + + IncreaseScore(SCORE_SPIN_100, true, true); + if (mTotalSpins > mRequiredSpins) + { + IncreaseScore(SCORE_SPIN_1000, true, true); + AudioManager::Engine().PlaySample(SOUND_DATA(spinnerbonus_bin)); + } + } + + mLastAngle = newAngle; + } +} + +void HitSpinner::Hit() +{ + if (mRequiredSpins > 0 && (mTotalSpins == 0 || mTotalSpins < MathHelper::Max(0, (s32)(mRequiredSpins - 2)))) + { + IncreaseScore(SCORE_MISS); + } + else + { + //compatibility with osu!pc + if (mRequiredSpins == 0) + { + IncreaseScore(SCORE_50, false, true); //score sprite doesn't show if you score 50 on spinners + } + else if (mTotalSpins >= mRequiredSpins) + { + IncreaseScore(SCORE_300); + } + else if (mTotalSpins == MathHelper::Max(0, (s32)(mRequiredSpins - 1))) + { + IncreaseScore(SCORE_100); + } + else if (mTotalSpins == MathHelper::Max(0, (s32)(mRequiredSpins - 2))) + { + IncreaseScore(SCORE_50, false, true); //score sprite doesn't show if you score 50 on spinners + } + + AudioManager::Engine().PlayHitSound(mSound); + } + + if (mChannel != -1) + AudioManager::Engine().StopChannel(mChannel); + + mHit = true; +} + +s32 HitSpinner::GetAngle(s32 x, s32 y) +{ + float theta = atan((float)(y-265)/(x-320)); + s32 angle = theta*32768/6.2832; + + //hack - let's hope this won't come back to haunt me + if (x < 320) + angle += 16384; + + return angle; } \ No newline at end of file diff --git a/arm9/source/HitObjects/HitSpinner.h b/source/HitObjects/HitSpinner.h similarity index 94% rename from arm9/source/HitObjects/HitSpinner.h rename to source/HitObjects/HitSpinner.h index fda2407..5eb05e8 100644 --- a/arm9/source/HitObjects/HitSpinner.h +++ b/source/HitObjects/HitSpinner.h @@ -1,39 +1,39 @@ -#include -#include -#include "HitObject.h" - -#ifndef __HITSPINNER_H__ -#define __HITSPINNER_H__ - -class HitSpinner : public HitObject -{ - public: - HitSpinner(s32 time, s32 endtime, HitObjectSound sound); - ~HitSpinner(); - - void Update(); - - void OnTouchDown(const touchPosition& touch); - void OnTouch(const touchPosition& touch); - - void Hit(); - - protected: - s32 GetAngle(s32 x, s32 y); - - s32 mLastAngle; - bool fSpinning; - s32 mDirection, mZeroPoint; - float mTotalRotation; - u32 mCurrentRotation; - u32 mTotalSpins; - u32 mRequiredSpins; - - u32* mUV; - - int mChannel; -}; - -#endif - - +#include +#include +#include "HitObject.h" + +#ifndef __HITSPINNER_H__ +#define __HITSPINNER_H__ + +class HitSpinner : public HitObject +{ + public: + HitSpinner(s32 time, s32 endtime, HitObjectSound sound); + ~HitSpinner(); + + void Update(); + + void OnTouchDown(const touchPosition& touch); + void OnTouch(const touchPosition& touch); + + void Hit(); + + protected: + s32 GetAngle(s32 x, s32 y); + + s32 mLastAngle; + bool fSpinning; + s32 mDirection, mZeroPoint; + float mTotalRotation; + u32 mCurrentRotation; + u32 mTotalSpins; + u32 mRequiredSpins; + + u32* mUV; + + int mChannel; +}; + +#endif + + diff --git a/arm9/source/Libraries/ByteMapFont.c b/source/Libraries/ByteMapFont.c similarity index 95% rename from arm9/source/Libraries/ByteMapFont.c rename to source/Libraries/ByteMapFont.c index 32b0e88..d2217bb 100644 --- a/arm9/source/Libraries/ByteMapFont.c +++ b/source/Libraries/ByteMapFont.c @@ -1,202 +1,202 @@ -#include "ByteMapFont.h" - -void LoadBMFont( BMFont *Fnt, const u8 *data ) -{ - u16 bCount; - u32 lOffset; - u8 bChar; - - if( ( Fnt ) && ( data ) ) - { - Fnt->Head = (BMFHeader *) data; - - Fnt->pal = (BMFRGB *) &data[ 17 ]; - - lOffset = 17 + ( Fnt->Head->bPal * 3 ); - - lOffset += data[ lOffset ] + 1; - - Fnt->wChars = data[ lOffset ] + ( data[ lOffset + 1 ] << 8 ); - - lOffset += 2; - - for( bCount = 0; bCount < 256; bCount ++ ) - { - Fnt->Ltrs[ bCount ] = 0; - } - - for( bCount = 0; bCount < Fnt->wChars; bCount ++ ) - { - bChar = data[ lOffset ]; - - Fnt->Ltrs[ bChar ] = (BMFLetter *) &data[ lOffset + 1 ]; - - lOffset += 6 + ( Fnt->Ltrs[ bChar ]->bWidth * Fnt->Ltrs[ bChar ]->bHeight ); - } - - // echo hack - fix wide spacing of some fonts - //Fnt->Ltrs[32]->bShift = 2; - } -} - -// Make the color bolder - basically makes the color twice as bright -u16 bmfColorIntensityBold( u16 color ) -{ - u32 tcolor; - - tcolor = ( color | ( color << 16 ) ) & 0x03E07C1F; - tcolor <<= 1; - tcolor += 0x00200401; - if( tcolor & 0x00000020 ) tcolor |= 0x0000001F; - if( tcolor & 0x00008000 ) tcolor |= 0x00007C00; - if( tcolor & 0x04000000 ) tcolor |= 0x03E00000; - return ( tcolor | ( tcolor >> 16 ) ) & 0xFFFF; -} - -// Make the color fainter - basically makes the color duller by reducing the intensity by 2 -u16 bmfColorIntensityFaint( u16 color ) -{ - u32 tcolor; - - tcolor = ( color | ( color << 16 ) ) & 0x03E07C1F; - tcolor >>= 1; -// tcolor += 0x00200401; -// if( tcolor & 0x00000020 ) tcolor |= 0x0000001F; -// if( tcolor & 0x00008000 ) tcolor |= 0x00007C00; -// if( tcolor & 0x04000000 ) tcolor |= 0x03E00000; - return ( tcolor | ( tcolor >> 16 ) ) & 0xFFFF; -} - - -void bmfPutCharTransparent( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ) -{ - u8 i, j; - u16 *Offset; - u16 col; - u8 bRed, bGreen, bBlue, bPal; - - if( Fnt->Ltrs[ Ltr ] ) - { - Offset = Buffer + ( ( y + Fnt->Ltrs[ Ltr ]->bRelY ) << 8 ); - - for( i = 0; i < Fnt->Ltrs[ Ltr ]->bHeight; i ++ ) - { - for( j = 0; j < Fnt->Ltrs[ Ltr ]->bWidth; j ++ ) - { - bPal = Fnt->Ltrs[ Ltr ]->bData[ j + ( i * Fnt->Ltrs[ Ltr ]->bWidth ) ]; - - if( bPal > 0 ) - { - bPal --; - - bRed = Fnt->pal[ bPal ].bRed >> 1; - bGreen = Fnt->pal[ bPal ].bGreen >> 1; - bBlue = Fnt->pal[ bPal ].bBlue >> 1; - - col = RGB5( bRed, bGreen, bBlue ) & text; - - Offset[ x + j + Fnt->Ltrs[ Ltr ]->bRelX ] = col | BIT(15); - } - } - - Offset += 256; - } - } -} - -void bmfPutCharOpaque( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ) -{ - s8 i, j; - u16 *Offset; - u16 col; - u8 bRed, bGreen, bBlue, bPal; - s8 bHeight, bWidth, bXOff, bYOff; - u8 *bDataOffset; - - if( Fnt->Ltrs[ Ltr ] ) - { - bDataOffset = Fnt->Ltrs[ Ltr ]->bData; - - bWidth = Fnt->Ltrs[ Ltr ]->bShift; - bHeight = Fnt->Head->bLineHeight; - bXOff = Fnt->Ltrs[ Ltr ]->bRelX; - bYOff = Fnt->Ltrs[ Ltr ]->bRelY; - - Offset = Buffer + ( y << 8 ); - - for( i = 0; i <= bHeight; i ++ ) - { - if( i < bYOff ) - { - for( j = 0; j < bWidth + Fnt->Head->bAddSpace; j ++ ) - { - Offset[ x + j ] = back; - } - } - - if( ( i >= bYOff ) && ( i < bYOff + Fnt->Ltrs[ Ltr ]->bHeight ) ) - { - for( j = 0; j <= bXOff; j ++ ) - Offset[ x + j ] = back; - - for( j = 0; j < Fnt->Ltrs[ Ltr ]->bWidth; j ++ ) - { - bPal = *bDataOffset; - - bDataOffset ++; - - bRed = Fnt->pal[ bPal - 1 ].bRed >> 1; - bGreen = Fnt->pal[ bPal - 1 ].bGreen >> 1; - bBlue = Fnt->pal[ bPal - 1 ].bBlue >> 1; - - col = (RGB15( bRed, bGreen, bBlue ) & text) | BIT(15); - - if( bPal == 0 ) // Normally transparent color - col = back; - - Offset[ x + j + Fnt->Ltrs[ Ltr ]->bRelX ] = col; - } - - for( j = Fnt->Ltrs[ Ltr ]->bWidth + bXOff; j < Fnt->Ltrs[ Ltr ]->bShift + Fnt->Head->bAddSpace; j ++ ) - Offset[ x + j ] = back; - } - - if( i >= bYOff + Fnt->Ltrs[ Ltr ]->bHeight ) - { - for( j = 0; j < Fnt->Ltrs[ Ltr ]->bShift + Fnt->Head->bAddSpace; j ++ ) - { - Offset[ x + j ] = back; - } - } - - Offset += 256; - } - -/* for( i = 0; i < Fnt->Head->bLineHeight; i ++ ) - { - Offset = Buffer + ( ( y + i + Fnt->Ltrs[ Ltr ]->bRelY ) << 8 ); - for( j = 0; j < Fnt->Ltrs[ Ltr ]->bWidth; j ++ ) - { - bPal = Fnt->Ltrs[ Ltr ]->bData[ j + ( i * Fnt->Ltrs[ Ltr ]->bWidth ) ]; - - if( bPal > 0 ) - { - bPal --; - - bRed = Fnt->pal[ bPal ].bRed >> 1; - bGreen = Fnt->pal[ bPal ].bGreen >> 1; - bBlue = Fnt->pal[ bPal ].bBlue >> 1; - - col = RGB5( bRed, bGreen, bBlue ) & text; - } - else - { - col = back; - } - - Offset[ x + j + Fnt->Ltrs[ Ltr ]->bRelX ] = col | BIT(15); - } - } -*/ } - -} +#include "ByteMapFont.h" + +void LoadBMFont( BMFont *Fnt, const u8 *data ) +{ + u16 bCount; + u32 lOffset; + u8 bChar; + + if( ( Fnt ) && ( data ) ) + { + Fnt->Head = (BMFHeader *) data; + + Fnt->pal = (BMFRGB *) &data[ 17 ]; + + lOffset = 17 + ( Fnt->Head->bPal * 3 ); + + lOffset += data[ lOffset ] + 1; + + Fnt->wChars = data[ lOffset ] + ( data[ lOffset + 1 ] << 8 ); + + lOffset += 2; + + for( bCount = 0; bCount < 256; bCount ++ ) + { + Fnt->Ltrs[ bCount ] = 0; + } + + for( bCount = 0; bCount < Fnt->wChars; bCount ++ ) + { + bChar = data[ lOffset ]; + + Fnt->Ltrs[ bChar ] = (BMFLetter *) &data[ lOffset + 1 ]; + + lOffset += 6 + ( Fnt->Ltrs[ bChar ]->bWidth * Fnt->Ltrs[ bChar ]->bHeight ); + } + + // echo hack - fix wide spacing of some fonts + //Fnt->Ltrs[32]->bShift = 2; + } +} + +// Make the color bolder - basically makes the color twice as bright +u16 bmfColorIntensityBold( u16 color ) +{ + u32 tcolor; + + tcolor = ( color | ( color << 16 ) ) & 0x03E07C1F; + tcolor <<= 1; + tcolor += 0x00200401; + if( tcolor & 0x00000020 ) tcolor |= 0x0000001F; + if( tcolor & 0x00008000 ) tcolor |= 0x00007C00; + if( tcolor & 0x04000000 ) tcolor |= 0x03E00000; + return ( tcolor | ( tcolor >> 16 ) ) & 0xFFFF; +} + +// Make the color fainter - basically makes the color duller by reducing the intensity by 2 +u16 bmfColorIntensityFaint( u16 color ) +{ + u32 tcolor; + + tcolor = ( color | ( color << 16 ) ) & 0x03E07C1F; + tcolor >>= 1; +// tcolor += 0x00200401; +// if( tcolor & 0x00000020 ) tcolor |= 0x0000001F; +// if( tcolor & 0x00008000 ) tcolor |= 0x00007C00; +// if( tcolor & 0x04000000 ) tcolor |= 0x03E00000; + return ( tcolor | ( tcolor >> 16 ) ) & 0xFFFF; +} + + +void bmfPutCharTransparent( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ) +{ + u8 i, j; + u16 *Offset; + u16 col; + u8 bRed, bGreen, bBlue, bPal; + + if( Fnt->Ltrs[ Ltr ] ) + { + Offset = Buffer + ( ( y + Fnt->Ltrs[ Ltr ]->bRelY ) << 8 ); + + for( i = 0; i < Fnt->Ltrs[ Ltr ]->bHeight; i ++ ) + { + for( j = 0; j < Fnt->Ltrs[ Ltr ]->bWidth; j ++ ) + { + bPal = Fnt->Ltrs[ Ltr ]->bData[ j + ( i * Fnt->Ltrs[ Ltr ]->bWidth ) ]; + + if( bPal > 0 ) + { + bPal --; + + bRed = Fnt->pal[ bPal ].bRed >> 1; + bGreen = Fnt->pal[ bPal ].bGreen >> 1; + bBlue = Fnt->pal[ bPal ].bBlue >> 1; + + col = RGB5( bRed, bGreen, bBlue ) & text; + + Offset[ x + j + Fnt->Ltrs[ Ltr ]->bRelX ] = col | BIT(15); + } + } + + Offset += 256; + } + } +} + +void bmfPutCharOpaque( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ) +{ + s8 i, j; + u16 *Offset; + u16 col; + u8 bRed, bGreen, bBlue, bPal; + s8 bHeight, bWidth, bXOff, bYOff; + u8 *bDataOffset; + + if( Fnt->Ltrs[ Ltr ] ) + { + bDataOffset = Fnt->Ltrs[ Ltr ]->bData; + + bWidth = Fnt->Ltrs[ Ltr ]->bShift; + bHeight = Fnt->Head->bLineHeight; + bXOff = Fnt->Ltrs[ Ltr ]->bRelX; + bYOff = Fnt->Ltrs[ Ltr ]->bRelY; + + Offset = Buffer + ( y << 8 ); + + for( i = 0; i <= bHeight; i ++ ) + { + if( i < bYOff ) + { + for( j = 0; j < bWidth + Fnt->Head->bAddSpace; j ++ ) + { + Offset[ x + j ] = back; + } + } + + if( ( i >= bYOff ) && ( i < bYOff + Fnt->Ltrs[ Ltr ]->bHeight ) ) + { + for( j = 0; j <= bXOff; j ++ ) + Offset[ x + j ] = back; + + for( j = 0; j < Fnt->Ltrs[ Ltr ]->bWidth; j ++ ) + { + bPal = *bDataOffset; + + bDataOffset ++; + + bRed = Fnt->pal[ bPal - 1 ].bRed >> 1; + bGreen = Fnt->pal[ bPal - 1 ].bGreen >> 1; + bBlue = Fnt->pal[ bPal - 1 ].bBlue >> 1; + + col = (RGB15( bRed, bGreen, bBlue ) & text) | BIT(15); + + if( bPal == 0 ) // Normally transparent color + col = back; + + Offset[ x + j + Fnt->Ltrs[ Ltr ]->bRelX ] = col; + } + + for( j = Fnt->Ltrs[ Ltr ]->bWidth + bXOff; j < Fnt->Ltrs[ Ltr ]->bShift + Fnt->Head->bAddSpace; j ++ ) + Offset[ x + j ] = back; + } + + if( i >= bYOff + Fnt->Ltrs[ Ltr ]->bHeight ) + { + for( j = 0; j < Fnt->Ltrs[ Ltr ]->bShift + Fnt->Head->bAddSpace; j ++ ) + { + Offset[ x + j ] = back; + } + } + + Offset += 256; + } + +/* for( i = 0; i < Fnt->Head->bLineHeight; i ++ ) + { + Offset = Buffer + ( ( y + i + Fnt->Ltrs[ Ltr ]->bRelY ) << 8 ); + for( j = 0; j < Fnt->Ltrs[ Ltr ]->bWidth; j ++ ) + { + bPal = Fnt->Ltrs[ Ltr ]->bData[ j + ( i * Fnt->Ltrs[ Ltr ]->bWidth ) ]; + + if( bPal > 0 ) + { + bPal --; + + bRed = Fnt->pal[ bPal ].bRed >> 1; + bGreen = Fnt->pal[ bPal ].bGreen >> 1; + bBlue = Fnt->pal[ bPal ].bBlue >> 1; + + col = RGB5( bRed, bGreen, bBlue ) & text; + } + else + { + col = back; + } + + Offset[ x + j + Fnt->Ltrs[ Ltr ]->bRelX ] = col | BIT(15); + } + } +*/ } + +} diff --git a/arm9/source/Libraries/ByteMapFont.h b/source/Libraries/ByteMapFont.h similarity index 96% rename from arm9/source/Libraries/ByteMapFont.h rename to source/Libraries/ByteMapFont.h index c8b04c6..20064b5 100644 --- a/arm9/source/Libraries/ByteMapFont.h +++ b/source/Libraries/ByteMapFont.h @@ -1,94 +1,94 @@ -#ifndef __BMFFONT_H__ -#define __BMFFONT_H__ - -#include - -/*! \file ByteMapFont.h - \brief ByteMap Font helper structures and functions. - -
-Provides basic assistance to access ByteMap Font (BMF) files, these can be downloaded from http://bmf.wz.cz - -
- -*/ - -/** - * \struct BMFRGB - * \brief Basic RGB layout within the BMF files - The font palette entries are in the range 0-63, these are bit shifted down when drawing the font. - */ - -typedef struct -{ - u8 bRed; - u8 bGreen; - u8 bBlue; -} BMFRGB; - -/** - * \struct BMFHeader - * \brief The main header of the font files -There is a couple of items after these fields, these are: -
    -
  • Font palette - one BMFRGB entry for each palette entry, except palette 0 -
  • Info length, the length of the information string -
  • Information string - normally the font name, and any other information the author wanted to add -
  • The number of characters in the file -
  • Font data using the BMFLetter structure -
- */ - -typedef struct -{ - u8 bMagic[4]; /*!< Magic number / file identifier it should be (in hex): E1 E6 D5 1A */ - u8 bVersion; /*!< The version number of the file format, currently 11h */ - u8 bLineHeight; /*!< The line height of the font */ - s8 bSizeOver; /*!< The size-over the base line - (-128 - 127) */ - s8 bSizeUnder; /*!< The size-under the base line - (-128 - 127) */ - s8 bAddSpace; /*!< The amount of space to add after each character - (-128 - 127) */ - s8 bSizeInner; /*!< Inner size / non capital size - (-128 - 127) */ - u8 bColours; /*!< Number of colours in the font (maximum of 32 */ - u8 bHighPal; /*!< Highest color used */ - u8 Reserved[4]; /*!< Reserved */ - u8 bPal; /*!< Number of RGB entries */ -} BMFHeader; - -/** - * \struct BMFLetter - * \brief The header for each letter in the font -The byte preceding the first attribute is the letter that the header is for, this is not needed to be stored due to the way the BMFont structure is setup. - */ -typedef struct -{ - u8 bWidth; /*!< Width of the font */ - u8 bHeight; /*!< Height of the font */ - s8 bRelX; /*!< Horizontal offset according to cursor (-128 - 127) */ - s8 bRelY; /*!< Vertical offset according to cursor (-128 - 127) */ - u8 bShift; /*!< Horizontal cursor shift after drawing the font */ - u8 bData[]; /*!< The actual font data stored in 1 byte per pixel format */ -} BMFLetter; - -typedef struct -{ - BMFHeader *Head; /*!< A pointer to the header of the file */ - BMFRGB *pal; /*!< A pointer to the first palette entry */ - u16 wChars; /*!< The number of characters in the font data */ - BMFLetter *Ltrs[256]; /*!< A list of pointer to the actual letter data, if the pointer is NULL then that font is not part of this font file */ -} BMFont; - -#ifdef __cplusplus -extern "C" { -#endif - -void LoadBMFont( BMFont *Fnt, const u8 *data ); -void bmfPutCharTransparent( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ); -void bmfPutCharOpaque( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ); -u16 bmfColorIntensityBold( u16 color ); -u16 bmfColorIntensityFaint( u16 color ); - -#ifdef __cplusplus -} -#endif - +#ifndef __BMFFONT_H__ +#define __BMFFONT_H__ + +#include + +/*! \file ByteMapFont.h + \brief ByteMap Font helper structures and functions. + +
+Provides basic assistance to access ByteMap Font (BMF) files, these can be downloaded from http://bmf.wz.cz + +
+ +*/ + +/** + * \struct BMFRGB + * \brief Basic RGB layout within the BMF files + The font palette entries are in the range 0-63, these are bit shifted down when drawing the font. + */ + +typedef struct +{ + u8 bRed; + u8 bGreen; + u8 bBlue; +} BMFRGB; + +/** + * \struct BMFHeader + * \brief The main header of the font files +There is a couple of items after these fields, these are: +
    +
  • Font palette - one BMFRGB entry for each palette entry, except palette 0 +
  • Info length, the length of the information string +
  • Information string - normally the font name, and any other information the author wanted to add +
  • The number of characters in the file +
  • Font data using the BMFLetter structure +
+ */ + +typedef struct +{ + u8 bMagic[4]; /*!< Magic number / file identifier it should be (in hex): E1 E6 D5 1A */ + u8 bVersion; /*!< The version number of the file format, currently 11h */ + u8 bLineHeight; /*!< The line height of the font */ + s8 bSizeOver; /*!< The size-over the base line - (-128 - 127) */ + s8 bSizeUnder; /*!< The size-under the base line - (-128 - 127) */ + s8 bAddSpace; /*!< The amount of space to add after each character - (-128 - 127) */ + s8 bSizeInner; /*!< Inner size / non capital size - (-128 - 127) */ + u8 bColours; /*!< Number of colours in the font (maximum of 32 */ + u8 bHighPal; /*!< Highest color used */ + u8 Reserved[4]; /*!< Reserved */ + u8 bPal; /*!< Number of RGB entries */ +} BMFHeader; + +/** + * \struct BMFLetter + * \brief The header for each letter in the font +The byte preceding the first attribute is the letter that the header is for, this is not needed to be stored due to the way the BMFont structure is setup. + */ +typedef struct +{ + u8 bWidth; /*!< Width of the font */ + u8 bHeight; /*!< Height of the font */ + s8 bRelX; /*!< Horizontal offset according to cursor (-128 - 127) */ + s8 bRelY; /*!< Vertical offset according to cursor (-128 - 127) */ + u8 bShift; /*!< Horizontal cursor shift after drawing the font */ + u8 bData[]; /*!< The actual font data stored in 1 byte per pixel format */ +} BMFLetter; + +typedef struct +{ + BMFHeader *Head; /*!< A pointer to the header of the file */ + BMFRGB *pal; /*!< A pointer to the first palette entry */ + u16 wChars; /*!< The number of characters in the font data */ + BMFLetter *Ltrs[256]; /*!< A list of pointer to the actual letter data, if the pointer is NULL then that font is not part of this font file */ +} BMFont; + +#ifdef __cplusplus +extern "C" { +#endif + +void LoadBMFont( BMFont *Fnt, const u8 *data ); +void bmfPutCharTransparent( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ); +void bmfPutCharOpaque( BMFont *Fnt, u8 x, u8 y, u16 text, u16 back, u16* Buffer, u8 Ltr ); +u16 bmfColorIntensityBold( u16 color ); +u16 bmfColorIntensityFaint( u16 color ); + +#ifdef __cplusplus +} +#endif + #endif \ No newline at end of file diff --git a/arm9/source/Libraries/gfxconsole.c b/source/Libraries/gfxconsole.c similarity index 96% rename from arm9/source/Libraries/gfxconsole.c rename to source/Libraries/gfxconsole.c index d2b610c..a4b47be 100644 --- a/arm9/source/Libraries/gfxconsole.c +++ b/source/Libraries/gfxconsole.c @@ -1,740 +1,740 @@ -/*--------------------------------------------------------------------------------- - -Copyright (C) 2009 -Steven Harrison - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you -must not claim that you wrote the original software. If you use -this software in a product, an acknowledgment in the product -documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source -distribution. - - - ----------------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "gfxconsole.h" -#include "4x6_a_bmf.h" /*!< Default monospaced font >*/ - - -BMFont gfx_default_font_mono; -//BMFont gfx_default_font_mcol; - - -// default console palette. -const u16 palette[] = { - RGB15( 0, 0, 0), //30 normal black - RGB15(15, 0, 0), //31 normal red - RGB15( 0,15, 0), //32 normal green - RGB15(15,15, 0), //33 normal yellow - - RGB15( 0, 0,15), //34 normal blue - RGB15(15, 0,15), //35 normal magenta - RGB15( 0,15,15), //36 normal cyan - RGB15(24,24,24), //37 normal white - - RGB15(15,15,15), //40 bright black - RGB15(31, 0, 0), //41 bright red - RGB15( 0,31, 0), //42 bright green - RGB15(31,31, 0), //43 bright yellow - - RGB15( 0, 0,31), //44 bright blue - RGB15(31, 0,31), //45 bright magenta - RGB15( 0,31,31), //46 bright cyan - RGB15(31,31,31) //47 & 39 bright white - }; - -gfxPrintConsole gfxdefaultConsole = -{ - //Font: - { - (BMFont *) &gfx_default_font_mono // Font information - Font 0 -// (BMFont *) &gfx_default_font_mcol // Font information - Font 1 - }, - 0, // Current font - 2, // Number of fonts - (u16 *) 0, // Background buffer - RGB5( 31, 31, 31 ) /*| BIT(15)*/, // Text color - warning here - RGB5( 0, 0, 0 ) /*| BIT(15)*/, // Background color - -1, // bg id - false, // Bacground mode - 1, // Use line height for y offsets - 0,0, // cursorX cursorY - 0,0, // prevcursorX prevcursorY - 256, // console width - 192, // console height - 0, // window x - 0, // window y - 256, // window width - 192, // window height - 4, // tab size - 0, // print callback - false, // console initialized - true, // load graphics -}; - -gfxPrintConsole gfxcurrentCopy; - -gfxPrintConsole* gfxcurrentConsole = &gfxcurrentCopy; - -gfxPrintConsole* gfxConsoleGetDefault(void){return &gfxdefaultConsole;} - -void gfxConsolePrintChar(char c); - -//--------------------------------------------------------------------------------- -static void gfxConsoleCls(char mode) { - //--------------------------------------------------------------------------------- - u16 *buf, width, ypos; - - buf = gfxcurrentConsole->buffer; - width = gfxcurrentConsole->windowWidth << 1; - - switch (mode) - { - case '0': - { - // Move the buffer to the line after the cursor, and then clear it - buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; - buf += ( gfxcurrentConsole->cursorY << 8 ) + gfxcurrentConsole->cursorX; - buf += ( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight << 8 ); - - for( ypos = 0; ypos <= ( ( gfxcurrentConsole->windowHeight - gfxcurrentConsole->cursorY ) + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ); ypos ++ ) - { - dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, width ); - buf += 256; - } - - break; - } - case '1': - { - // Move the buffer to the line after the cursor, and then clear it - buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; - - for( ypos = 0; ypos <= gfxcurrentConsole->cursorY; ypos ++ ) - { - dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, width ); - buf += 256; - } - - break; - } - case '2': - { - - buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; - - for( ypos = 0; ypos <= gfxcurrentConsole->windowHeight; ypos ++ ) - { - dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, width ); - buf += 256; - } - - gfxcurrentConsole->cursorY = 0; - gfxcurrentConsole->cursorX = 0; - break; - } - } -} -//--------------------------------------------------------------------------------- -static void gfxConsoleClearLine(char mode) { - //--------------------------------------------------------------------------------- - - u16 *buf, width, i; - - buf = gfxcurrentConsole->buffer; - width = gfxcurrentConsole->windowWidth << 1; - buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; - - switch (mode) - { - case '0': - { - for( i = 0; i < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; i ++ ) { - dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, ( gfxcurrentConsole->cursorX ) << 1 ); - } - break; - } - case '1': - { - for( i = 0; i < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; i ++ ) { - dmaFillHalfWords( gfxcurrentConsole->backcolor, buf, ( gfxcurrentConsole->windowX - gfxcurrentConsole->cursorX ) << 1 ); - } - - break; - } - case '2': - default: - { - for( i = 0; i < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; i ++ ) { - dmaFillHalfWords( gfxcurrentConsole->backcolor, buf, width ); - } - break; - } - } -} - -//--------------------------------------------------------------------------------- -ssize_t gfxnocash_write(struct _reent *r, int fd, const char *ptr, size_t len) { - //--------------------------------------------------------------------------------- - int count = 0; - - if(!ptr || len <= 0) return -1; - - while(count < len) - { - - nocashMessage(ptr + count); - - count += (len - count) > 80 ? 80 : len - count; - - } - - return len; -} - - -//--------------------------------------------------------------------------------- -ssize_t gfxcon_write(struct _reent *r,int fd,const char *ptr, size_t len) { - //--------------------------------------------------------------------------------- - - char chr; - - int i, count = 0; - char *tmp = (char*)ptr; - - if(!tmp || len<=0) return -1; - - i = 0; - - while(*tmp!='\0' && icurFont = 0; - chr = *(tmp++); - i++; count++; - continue; - } else - - ///////////////////////////////////////// - // Font Set G1 (VT-100 escape sequence) - ///////////////////////////////////////// - if ( chr == 0x1b && *tmp == ')' ) { - gfxcurrentConsole->curFont = 1; - chr = *(tmp++); - i++; count++; - continue; - } else - - if ( chr == 0x1b && *tmp == '[' ) { - bool escaping = true; - char *escapeseq = tmp; - int escapelen = 0; - - do { - chr = *(tmp++); - i++; count++; escapelen++; - int parameter, pos, color; - - switch (chr) { - ///////////////////////////////////////// - // Cursor directional movement - ///////////////////////////////////////// - case 'A': - siscanf(escapeseq,"[%dA", ¶meter); - pos = gfxcurrentConsole->lineType ? ( parameter * gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ) : parameter; - gfxcurrentConsole->cursorY = (gfxcurrentConsole->cursorY - pos ) < 0 ? 0 : gfxcurrentConsole->cursorY - pos; - escaping = false; - break; - case 'B': - siscanf(escapeseq,"[%dB", ¶meter); - pos = gfxcurrentConsole->lineType ? ( parameter * gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ) : parameter; - gfxcurrentConsole->cursorY = (gfxcurrentConsole->cursorY + pos ) > gfxcurrentConsole->windowHeight - 1 ? ( gfxcurrentConsole->windowHeight - 1 ) / gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight : gfxcurrentConsole->cursorY + pos; - escaping = false; - break; - case 'C': - siscanf(escapeseq,"[%dC", ¶meter); - gfxcurrentConsole->cursorX = (gfxcurrentConsole->cursorX + parameter) > gfxcurrentConsole->windowWidth - 1 ? gfxcurrentConsole->windowWidth - 1 : gfxcurrentConsole->cursorX + parameter; - escaping = false; - break; - case 'D': - siscanf(escapeseq,"[%dD", ¶meter); - gfxcurrentConsole->cursorX = (gfxcurrentConsole->cursorX - parameter) < 0 ? 0 : gfxcurrentConsole->cursorX - parameter; - escaping = false; - break; - ///////////////////////////////////////// - // Cursor position movement - ///////////////////////////////////////// - case 'H': - case 'f': - siscanf(escapeseq,"[%d;%df", &gfxcurrentConsole->cursorY , &gfxcurrentConsole->cursorX ); - if( gfxcurrentConsole->lineType ) - gfxcurrentConsole->cursorY *= gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; - escaping = false; - break; - - // echo hack: absolute positioning - - case 'X': - siscanf(escapeseq, "[%d;%dX", &gfxcurrentConsole->cursorY, &gfxcurrentConsole->cursorX); - escaping = false; - break; - - // echo hack: positioning only one coordinate - - case 'x': - siscanf(escapeseq, "[%dx", &gfxcurrentConsole->cursorX); - escaping = false; - break; - case 'y': - siscanf(escapeseq, "[%dy", &gfxcurrentConsole->cursorY); - escaping = false; - break; - - - ///////////////////////////////////////// - // Set Scale Unit "ESC[? I" - ///////////////////////////////////////// - case 'I': - if(escapeseq[escapelen-2] == ' ') - { - if(escapeseq[escapelen-3] == '0') - { - gfxcurrentConsole->lineType = 1; - } - else if(escapeseq[escapelen-3] == '7') - { - gfxcurrentConsole->lineType = 0; - } - else - { - gfxcurrentConsole->lineType = 1; - } - } - escaping = false; - break; - ///////////////////////////////////////// - // Screen clear - ///////////////////////////////////////// - case 'J': - gfxConsoleCls(escapeseq[escapelen-2]); - escaping = false; - break; - ///////////////////////////////////////// - // Line clear - ///////////////////////////////////////// - case 'K': - gfxConsoleClearLine(escapeseq[escapelen-2]); - escaping = false; - break; - ///////////////////////////////////////// - // Save cursor position - ///////////////////////////////////////// - case 's': - gfxcurrentConsole->prevCursorX = gfxcurrentConsole->cursorX ; - gfxcurrentConsole->prevCursorY = gfxcurrentConsole->cursorY ; - escaping = false; - break; - ///////////////////////////////////////// - // Load cursor position - ///////////////////////////////////////// - case 'u': - gfxcurrentConsole->cursorX = gfxcurrentConsole->prevCursorX ; - gfxcurrentConsole->cursorY = gfxcurrentConsole->prevCursorY ; - escaping = false; - break; - ///////////////////////////////////////// - // Color scan codes - ///////////////////////////////////////// - case 'm': - pos = 0; - parameter = 0; - - while( pos < escapelen ) { - - if( ( escapeseq[ pos ] >= '0' ) && ( escapeseq[ pos ] <= '9' ) ) { - parameter *= 10; - parameter += escapeseq[ pos ] - '0'; - } - else if( ( escapeseq[ pos ] == ';' ) || ( escapeseq[ pos ] == 'm' ) ) { - switch( parameter ) { - ///////////////////////////////////////// - // Reset all values - ///////////////////////////////////////// - case 0: // Reset all settings - gfxcurrentConsole->textcolor = palette[ 15 ]; - gfxcurrentConsole->backcolor = palette[ 0 ]; - gfxcurrentConsole->backOpaque = false; - break; - case 1: - gfxcurrentConsole->textcolor = bmfColorIntensityBold( gfxcurrentConsole->textcolor ) | BIT(15); - break; - case 2: - gfxcurrentConsole->textcolor = bmfColorIntensityFaint( gfxcurrentConsole->textcolor ) | BIT(15); - break; - case 3: // Italic - break; - case 4: // Underline - break; - case 7: - case 27: - color = gfxcurrentConsole->textcolor; - gfxcurrentConsole->textcolor = gfxcurrentConsole->backcolor; - gfxcurrentConsole->backcolor = color; - break; - case 10: // Primary font - case 11: // Font 1 - case 12: // Font 2 - case 13: // Font 3 - case 14: // Font 4 - case 15: // Font 5 - case 16: // Font 6 - case 17: // Font 7 - case 18: // Font 8 - case 19: // Font 9 - if( gfxcurrentConsole->font[ parameter - 10 ] ) - gfxcurrentConsole->curFont = parameter - 10; - else - gfxcurrentConsole->curFont = 0; - break; - case 21: // Double underline - break; - case 23: // Non Italic - break; - case 24: // Underline off - break; - case 30: - case 31: - case 32: - case 33: - case 34: - case 35: - case 36: - case 37: - gfxcurrentConsole->textcolor = palette[ parameter - 30 ] | BIT(15); - break; - case 39: - gfxcurrentConsole->textcolor = palette[ 15 ] | BIT(15); - break; - case 40: - case 41: - case 42: - case 43: - case 44: - case 45: - case 46: - case 47: - gfxcurrentConsole->backcolor = palette[ parameter - 40 ] | BIT(15); - gfxcurrentConsole->backOpaque = true; - break; - case 49: - gfxcurrentConsole->backcolor = palette[ 0 ]; - gfxcurrentConsole->backOpaque = false; - break; - } - parameter = 0; - } - - pos ++; - } - - escaping = false; - break; - } - } while (escaping); - continue; - } - - gfxConsolePrintChar(chr); - } - - return count; -} - -static const devoptab_t dotab_gfxstdout = { - "con", - 0, - NULL, - NULL, - gfxcon_write, - NULL, - NULL, - NULL -}; - - -static const devoptab_t dotab_gfxstderr = { - "nocash", - 0, - NULL, - NULL, - gfxnocash_write, - NULL, - NULL, - NULL -}; - -gfxPrintConsole* gfxConsoleInit(gfxPrintConsole* console, BgType type, BgSize size, bool mainDisplay, bool loadGraphics){ - - static bool firstConsoleInit = true; - - if(firstConsoleInit) - { - LoadBMFont( &gfx_default_font_mono, _4x6_a_bmf ); -// LoadBMFont( &gfx_default_font_mcol, gc_def_c_bmf ); - - devoptab_list[STD_OUT] = &dotab_gfxstdout; - - setvbuf(stdout, NULL , _IONBF, 0); - - firstConsoleInit = false; - } - - if(console) - { - gfxcurrentConsole = console; - } - else - { - console = gfxcurrentConsole; - } - - *gfxcurrentConsole = gfxdefaultConsole; - - if(mainDisplay) - { - console->bgId = bgInit(3, type, size, 0, 0); - } - else - { - console->bgId = bgInitSub(3, type, size, 0, 0); - } - - console->buffer = (u16*)bgGetGfxPtr(console->bgId); - - console->consoleInitialised = 1; - - gfxConsoleCls('2'); - - return gfxcurrentConsole; - -} -//--------------------------------------------------------------------------------- -void gfxConsoleSelect(gfxPrintConsole* console){ -//--------------------------------------------------------------------------------- - - gfxcurrentConsole = console; -} - -//--------------------------------------------------------------------------------- -void gfxConsoleSetFont(gfxPrintConsole* console, u8 fontNumber){ -//--------------------------------------------------------------------------------- - console->curFont = fontNumber; - - gfxConsoleSelect(console); -} - -//--------------------------------------------------------------------------------- -int gfxConsoleAddFont(gfxPrintConsole* console, BMFont* font){ -//--------------------------------------------------------------------------------- - u8 i, j = 11; - - for( i = 0; i < 10; i++ ) - { - if( gfxcurrentConsole->font[ i ] == 0 ) - { - if( j > i ) - j = i; - } - } - - if( j < 10 ) - gfxcurrentConsole->font[ j ] = font; - else - j = -1; - - gfxConsoleSelect(console); - - return j; -} - -//--------------------------------------------------------------------------------- -void gfxConsoleDebugInit(DebugDevice device){ -//--------------------------------------------------------------------------------- - - if(device & DebugDevice_NOCASH) - { - devoptab_list[STD_ERR] = &dotab_gfxstderr; - setvbuf(stderr, NULL , _IONBF, 0); - } - - if(device & DebugDevice_CONSOLE) - { - devoptab_list[STD_ERR] = &dotab_gfxstdout; - setvbuf(stderr, NULL , _IONBF, 0); - } -} - -////--------------------------------------------------------------------------------- -//// Places the console in a default mode using bg0 of the sub display, and vram c for -//// font and map..this is provided for rapid prototyping and nothing more -gfxPrintConsole* gfxConsoleDemoInit(void) { -//--------------------------------------------------------------------------------- - videoSetModeSub(MODE_5_2D); - vramSetBankC(VRAM_C_SUB_BG); - - return gfxConsoleInit(NULL, BgType_Bmp16, BgSize_B16_256x256, false, true); -} - -//--------------------------------------------------------------------------------- -static void gfxnewRow() { -//--------------------------------------------------------------------------------- - u16 line; - u16 *buf, offset; - - gfxcurrentConsole->cursorY += gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; - - if(gfxcurrentConsole->cursorY >= gfxcurrentConsole->windowHeight ) - { - gfxcurrentConsole->cursorY -= gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; - - buf = gfxcurrentConsole->buffer; - offset = gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight << 8; - - buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; - - for( line = 0; line < gfxcurrentConsole->windowHeight - gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; line ++ ) - { -// dmaFillHalfWords( 0x800F, buf, gfxcurrentConsole->windowWidth << 1 ); - dmaCopy( buf + offset, buf, gfxcurrentConsole->windowWidth << 1 ); - buf += 256; - } - - for( line = 0; line < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; line ++ ) - { -// dmaFillHalfWords( 0x81E0, buf, gfxcurrentConsole->windowWidth << 1 ); - dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, gfxcurrentConsole->windowWidth << 1 ); - buf += 256; - } - -// dmaCopy( gfxcurrentConsole->buffer + ( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight << 8 ), gfxcurrentConsole->buffer, ( 192 - gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ) << 9 ); - -// dmaFillHalfWords( gfxcurrentConsole->backcolor, gfxcurrentConsole->buffer + ( gfxcurrentConsole->cursorY << 8 ), ( 192 - gfxcurrentConsole->cursorY ) << 9 ); - } -} - - -//--------------------------------------------------------------------------------- -void gfxConsolePrintChar( char c ) { - //--------------------------------------------------------------------------------- - - if(gfxcurrentConsole->PrintChar) - if(gfxcurrentConsole->PrintChar(gfxcurrentConsole, c)) - return; - - if( ( gfxcurrentConsole->cursorX + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c]->bShift) > gfxcurrentConsole->windowWidth) { - gfxcurrentConsole->cursorX = 0; - - gfxnewRow(); - } - - switch(c) { - /* - The only special characters we will handle are tab (\t), carriage return (\r), line feed (\n) - and backspace (\b). - Carriage return & line feed will function the same: go to next line and put cursor at the beginning. - For everything else, use VT sequences. - - Reason: VT sequences are more specific to the task of cursor placement. - The special escape sequences \b \f & \v are archaic and non-portable. - */ - case 8: - gfxcurrentConsole->cursorX--; - - if(gfxcurrentConsole->cursorX < 0) - { - if(gfxcurrentConsole->cursorY > 0) - { - gfxcurrentConsole->cursorX = gfxcurrentConsole->windowX - 1; - gfxcurrentConsole->cursorY -= gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; - } - else - { - gfxcurrentConsole->cursorX = 0; - } - } - break; - - case 9: - gfxcurrentConsole->cursorX += gfxcurrentConsole->tabSize; - break; - case 10: - case 13: - gfxnewRow(); - gfxcurrentConsole->cursorX = 0; - break; - default: - if( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c] ) - { - //if( gfxcurrentConsole->backOpaque ) - bmfPutCharOpaque( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ], gfxcurrentConsole->cursorX + gfxcurrentConsole->windowX, gfxcurrentConsole->cursorY + gfxcurrentConsole->windowY, gfxcurrentConsole->textcolor, gfxcurrentConsole->backcolor, gfxcurrentConsole->buffer, c ); - //else - // bmfPutCharTransparent( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ], gfxcurrentConsole->cursorX + gfxcurrentConsole->windowX, gfxcurrentConsole->cursorY + gfxcurrentConsole->windowY, gfxcurrentConsole->textcolor, gfxcurrentConsole->backcolor, gfxcurrentConsole->buffer, c ); - - gfxcurrentConsole->cursorX += gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c]->bShift + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bAddSpace; - } - break; - } -} - -//--------------------------------------------------------------------------------- -void gfxConsoleClear(void) { -//--------------------------------------------------------------------------------- - iprintf("\x1b[2J"); -} - -//--------------------------------------------------------------------------------- -void gfxConsoleSetWindow(gfxPrintConsole* console, int x, int y, int width, int height) { -//--------------------------------------------------------------------------------- - - if(!console) console = gfxcurrentConsole; - - console->windowWidth = width; - console->windowHeight = height; - console->windowX = x; - console->windowY = y; - - console->cursorX = 0; - console->cursorY = -gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bSizeOver; - -} - - +/*--------------------------------------------------------------------------------- + +Copyright (C) 2009 +Steven Harrison + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you +must not claim that you wrote the original software. If you use +this software in a product, an acknowledgment in the product +documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source +distribution. + + + +---------------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "gfxconsole.h" +#include "4x6_a_bmf.h" /*!< Default monospaced font >*/ + + +BMFont gfx_default_font_mono; +//BMFont gfx_default_font_mcol; + + +// default console palette. +const u16 palette[] = { + RGB15( 0, 0, 0), //30 normal black + RGB15(15, 0, 0), //31 normal red + RGB15( 0,15, 0), //32 normal green + RGB15(15,15, 0), //33 normal yellow + + RGB15( 0, 0,15), //34 normal blue + RGB15(15, 0,15), //35 normal magenta + RGB15( 0,15,15), //36 normal cyan + RGB15(24,24,24), //37 normal white + + RGB15(15,15,15), //40 bright black + RGB15(31, 0, 0), //41 bright red + RGB15( 0,31, 0), //42 bright green + RGB15(31,31, 0), //43 bright yellow + + RGB15( 0, 0,31), //44 bright blue + RGB15(31, 0,31), //45 bright magenta + RGB15( 0,31,31), //46 bright cyan + RGB15(31,31,31) //47 & 39 bright white + }; + +gfxPrintConsole gfxdefaultConsole = +{ + //Font: + { + (BMFont *) &gfx_default_font_mono // Font information - Font 0 +// (BMFont *) &gfx_default_font_mcol // Font information - Font 1 + }, + 0, // Current font + 2, // Number of fonts + (u16 *) 0, // Background buffer + RGB5( 31, 31, 31 ) /*| BIT(15)*/, // Text color - warning here + RGB5( 0, 0, 0 ) /*| BIT(15)*/, // Background color + -1, // bg id + false, // Bacground mode + 1, // Use line height for y offsets + 0,0, // cursorX cursorY + 0,0, // prevcursorX prevcursorY + 256, // console width + 192, // console height + 0, // window x + 0, // window y + 256, // window width + 192, // window height + 4, // tab size + 0, // print callback + false, // console initialized + true, // load graphics +}; + +gfxPrintConsole gfxcurrentCopy; + +gfxPrintConsole* gfxcurrentConsole = &gfxcurrentCopy; + +gfxPrintConsole* gfxConsoleGetDefault(void){return &gfxdefaultConsole;} + +void gfxConsolePrintChar(char c); + +//--------------------------------------------------------------------------------- +static void gfxConsoleCls(char mode) { + //--------------------------------------------------------------------------------- + u16 *buf, width, ypos; + + buf = gfxcurrentConsole->buffer; + width = gfxcurrentConsole->windowWidth << 1; + + switch (mode) + { + case '0': + { + // Move the buffer to the line after the cursor, and then clear it + buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; + buf += ( gfxcurrentConsole->cursorY << 8 ) + gfxcurrentConsole->cursorX; + buf += ( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight << 8 ); + + for( ypos = 0; ypos <= ( ( gfxcurrentConsole->windowHeight - gfxcurrentConsole->cursorY ) + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ); ypos ++ ) + { + dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, width ); + buf += 256; + } + + break; + } + case '1': + { + // Move the buffer to the line after the cursor, and then clear it + buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; + + for( ypos = 0; ypos <= gfxcurrentConsole->cursorY; ypos ++ ) + { + dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, width ); + buf += 256; + } + + break; + } + case '2': + { + + buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; + + for( ypos = 0; ypos <= gfxcurrentConsole->windowHeight; ypos ++ ) + { + dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, width ); + buf += 256; + } + + gfxcurrentConsole->cursorY = 0; + gfxcurrentConsole->cursorX = 0; + break; + } + } +} +//--------------------------------------------------------------------------------- +static void gfxConsoleClearLine(char mode) { + //--------------------------------------------------------------------------------- + + u16 *buf, width, i; + + buf = gfxcurrentConsole->buffer; + width = gfxcurrentConsole->windowWidth << 1; + buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; + + switch (mode) + { + case '0': + { + for( i = 0; i < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; i ++ ) { + dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, ( gfxcurrentConsole->cursorX ) << 1 ); + } + break; + } + case '1': + { + for( i = 0; i < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; i ++ ) { + dmaFillHalfWords( gfxcurrentConsole->backcolor, buf, ( gfxcurrentConsole->windowX - gfxcurrentConsole->cursorX ) << 1 ); + } + + break; + } + case '2': + default: + { + for( i = 0; i < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; i ++ ) { + dmaFillHalfWords( gfxcurrentConsole->backcolor, buf, width ); + } + break; + } + } +} + +//--------------------------------------------------------------------------------- +ssize_t gfxnocash_write(struct _reent *r, int fd, const char *ptr, size_t len) { + //--------------------------------------------------------------------------------- + int count = 0; + + if(!ptr || len <= 0) return -1; + + while(count < len) + { + + nocashMessage(ptr + count); + + count += (len - count) > 80 ? 80 : len - count; + + } + + return len; +} + + +//--------------------------------------------------------------------------------- +ssize_t gfxcon_write(struct _reent *r,int fd,const char *ptr, size_t len) { + //--------------------------------------------------------------------------------- + + char chr; + + int i, count = 0; + char *tmp = (char*)ptr; + + if(!tmp || len<=0) return -1; + + i = 0; + + while(*tmp!='\0' && icurFont = 0; + chr = *(tmp++); + i++; count++; + continue; + } else + + ///////////////////////////////////////// + // Font Set G1 (VT-100 escape sequence) + ///////////////////////////////////////// + if ( chr == 0x1b && *tmp == ')' ) { + gfxcurrentConsole->curFont = 1; + chr = *(tmp++); + i++; count++; + continue; + } else + + if ( chr == 0x1b && *tmp == '[' ) { + bool escaping = true; + char *escapeseq = tmp; + int escapelen = 0; + + do { + chr = *(tmp++); + i++; count++; escapelen++; + int parameter, pos, color; + + switch (chr) { + ///////////////////////////////////////// + // Cursor directional movement + ///////////////////////////////////////// + case 'A': + siscanf(escapeseq,"[%dA", ¶meter); + pos = gfxcurrentConsole->lineType ? ( parameter * gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ) : parameter; + gfxcurrentConsole->cursorY = (gfxcurrentConsole->cursorY - pos ) < 0 ? 0 : gfxcurrentConsole->cursorY - pos; + escaping = false; + break; + case 'B': + siscanf(escapeseq,"[%dB", ¶meter); + pos = gfxcurrentConsole->lineType ? ( parameter * gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ) : parameter; + gfxcurrentConsole->cursorY = (gfxcurrentConsole->cursorY + pos ) > gfxcurrentConsole->windowHeight - 1 ? ( gfxcurrentConsole->windowHeight - 1 ) / gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight : gfxcurrentConsole->cursorY + pos; + escaping = false; + break; + case 'C': + siscanf(escapeseq,"[%dC", ¶meter); + gfxcurrentConsole->cursorX = (gfxcurrentConsole->cursorX + parameter) > gfxcurrentConsole->windowWidth - 1 ? gfxcurrentConsole->windowWidth - 1 : gfxcurrentConsole->cursorX + parameter; + escaping = false; + break; + case 'D': + siscanf(escapeseq,"[%dD", ¶meter); + gfxcurrentConsole->cursorX = (gfxcurrentConsole->cursorX - parameter) < 0 ? 0 : gfxcurrentConsole->cursorX - parameter; + escaping = false; + break; + ///////////////////////////////////////// + // Cursor position movement + ///////////////////////////////////////// + case 'H': + case 'f': + siscanf(escapeseq,"[%d;%df", &gfxcurrentConsole->cursorY , &gfxcurrentConsole->cursorX ); + if( gfxcurrentConsole->lineType ) + gfxcurrentConsole->cursorY *= gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; + escaping = false; + break; + + // echo hack: absolute positioning + + case 'X': + siscanf(escapeseq, "[%d;%dX", &gfxcurrentConsole->cursorY, &gfxcurrentConsole->cursorX); + escaping = false; + break; + + // echo hack: positioning only one coordinate + + case 'x': + siscanf(escapeseq, "[%dx", &gfxcurrentConsole->cursorX); + escaping = false; + break; + case 'y': + siscanf(escapeseq, "[%dy", &gfxcurrentConsole->cursorY); + escaping = false; + break; + + + ///////////////////////////////////////// + // Set Scale Unit "ESC[? I" + ///////////////////////////////////////// + case 'I': + if(escapeseq[escapelen-2] == ' ') + { + if(escapeseq[escapelen-3] == '0') + { + gfxcurrentConsole->lineType = 1; + } + else if(escapeseq[escapelen-3] == '7') + { + gfxcurrentConsole->lineType = 0; + } + else + { + gfxcurrentConsole->lineType = 1; + } + } + escaping = false; + break; + ///////////////////////////////////////// + // Screen clear + ///////////////////////////////////////// + case 'J': + gfxConsoleCls(escapeseq[escapelen-2]); + escaping = false; + break; + ///////////////////////////////////////// + // Line clear + ///////////////////////////////////////// + case 'K': + gfxConsoleClearLine(escapeseq[escapelen-2]); + escaping = false; + break; + ///////////////////////////////////////// + // Save cursor position + ///////////////////////////////////////// + case 's': + gfxcurrentConsole->prevCursorX = gfxcurrentConsole->cursorX ; + gfxcurrentConsole->prevCursorY = gfxcurrentConsole->cursorY ; + escaping = false; + break; + ///////////////////////////////////////// + // Load cursor position + ///////////////////////////////////////// + case 'u': + gfxcurrentConsole->cursorX = gfxcurrentConsole->prevCursorX ; + gfxcurrentConsole->cursorY = gfxcurrentConsole->prevCursorY ; + escaping = false; + break; + ///////////////////////////////////////// + // Color scan codes + ///////////////////////////////////////// + case 'm': + pos = 0; + parameter = 0; + + while( pos < escapelen ) { + + if( ( escapeseq[ pos ] >= '0' ) && ( escapeseq[ pos ] <= '9' ) ) { + parameter *= 10; + parameter += escapeseq[ pos ] - '0'; + } + else if( ( escapeseq[ pos ] == ';' ) || ( escapeseq[ pos ] == 'm' ) ) { + switch( parameter ) { + ///////////////////////////////////////// + // Reset all values + ///////////////////////////////////////// + case 0: // Reset all settings + gfxcurrentConsole->textcolor = palette[ 15 ]; + gfxcurrentConsole->backcolor = palette[ 0 ]; + gfxcurrentConsole->backOpaque = false; + break; + case 1: + gfxcurrentConsole->textcolor = bmfColorIntensityBold( gfxcurrentConsole->textcolor ) | BIT(15); + break; + case 2: + gfxcurrentConsole->textcolor = bmfColorIntensityFaint( gfxcurrentConsole->textcolor ) | BIT(15); + break; + case 3: // Italic + break; + case 4: // Underline + break; + case 7: + case 27: + color = gfxcurrentConsole->textcolor; + gfxcurrentConsole->textcolor = gfxcurrentConsole->backcolor; + gfxcurrentConsole->backcolor = color; + break; + case 10: // Primary font + case 11: // Font 1 + case 12: // Font 2 + case 13: // Font 3 + case 14: // Font 4 + case 15: // Font 5 + case 16: // Font 6 + case 17: // Font 7 + case 18: // Font 8 + case 19: // Font 9 + if( gfxcurrentConsole->font[ parameter - 10 ] ) + gfxcurrentConsole->curFont = parameter - 10; + else + gfxcurrentConsole->curFont = 0; + break; + case 21: // Double underline + break; + case 23: // Non Italic + break; + case 24: // Underline off + break; + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + gfxcurrentConsole->textcolor = palette[ parameter - 30 ] | BIT(15); + break; + case 39: + gfxcurrentConsole->textcolor = palette[ 15 ] | BIT(15); + break; + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + gfxcurrentConsole->backcolor = palette[ parameter - 40 ] | BIT(15); + gfxcurrentConsole->backOpaque = true; + break; + case 49: + gfxcurrentConsole->backcolor = palette[ 0 ]; + gfxcurrentConsole->backOpaque = false; + break; + } + parameter = 0; + } + + pos ++; + } + + escaping = false; + break; + } + } while (escaping); + continue; + } + + gfxConsolePrintChar(chr); + } + + return count; +} + +static const devoptab_t dotab_gfxstdout = { + "con", + 0, + NULL, + NULL, + gfxcon_write, + NULL, + NULL, + NULL +}; + + +static const devoptab_t dotab_gfxstderr = { + "nocash", + 0, + NULL, + NULL, + gfxnocash_write, + NULL, + NULL, + NULL +}; + +gfxPrintConsole* gfxConsoleInit(gfxPrintConsole* console, BgType type, BgSize size, bool mainDisplay, bool loadGraphics){ + + static bool firstConsoleInit = true; + + if(firstConsoleInit) + { + LoadBMFont( &gfx_default_font_mono, _4x6_a_bmf ); +// LoadBMFont( &gfx_default_font_mcol, gc_def_c_bmf ); + + devoptab_list[STD_OUT] = &dotab_gfxstdout; + + setvbuf(stdout, NULL , _IONBF, 0); + + firstConsoleInit = false; + } + + if(console) + { + gfxcurrentConsole = console; + } + else + { + console = gfxcurrentConsole; + } + + *gfxcurrentConsole = gfxdefaultConsole; + + if(mainDisplay) + { + console->bgId = bgInit(3, type, size, 0, 0); + } + else + { + console->bgId = bgInitSub(3, type, size, 0, 0); + } + + console->buffer = (u16*)bgGetGfxPtr(console->bgId); + + console->consoleInitialised = 1; + + gfxConsoleCls('2'); + + return gfxcurrentConsole; + +} +//--------------------------------------------------------------------------------- +void gfxConsoleSelect(gfxPrintConsole* console){ +//--------------------------------------------------------------------------------- + + gfxcurrentConsole = console; +} + +//--------------------------------------------------------------------------------- +void gfxConsoleSetFont(gfxPrintConsole* console, u8 fontNumber){ +//--------------------------------------------------------------------------------- + console->curFont = fontNumber; + + gfxConsoleSelect(console); +} + +//--------------------------------------------------------------------------------- +int gfxConsoleAddFont(gfxPrintConsole* console, BMFont* font){ +//--------------------------------------------------------------------------------- + u8 i, j = 11; + + for( i = 0; i < 10; i++ ) + { + if( gfxcurrentConsole->font[ i ] == 0 ) + { + if( j > i ) + j = i; + } + } + + if( j < 10 ) + gfxcurrentConsole->font[ j ] = font; + else + j = -1; + + gfxConsoleSelect(console); + + return j; +} + +//--------------------------------------------------------------------------------- +void gfxConsoleDebugInit(DebugDevice device){ +//--------------------------------------------------------------------------------- + + if(device & DebugDevice_NOCASH) + { + devoptab_list[STD_ERR] = &dotab_gfxstderr; + setvbuf(stderr, NULL , _IONBF, 0); + } + + if(device & DebugDevice_CONSOLE) + { + devoptab_list[STD_ERR] = &dotab_gfxstdout; + setvbuf(stderr, NULL , _IONBF, 0); + } +} + +////--------------------------------------------------------------------------------- +//// Places the console in a default mode using bg0 of the sub display, and vram c for +//// font and map..this is provided for rapid prototyping and nothing more +gfxPrintConsole* gfxConsoleDemoInit(void) { +//--------------------------------------------------------------------------------- + videoSetModeSub(MODE_5_2D); + vramSetBankC(VRAM_C_SUB_BG); + + return gfxConsoleInit(NULL, BgType_Bmp16, BgSize_B16_256x256, false, true); +} + +//--------------------------------------------------------------------------------- +static void gfxnewRow() { +//--------------------------------------------------------------------------------- + u16 line; + u16 *buf, offset; + + gfxcurrentConsole->cursorY += gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; + + if(gfxcurrentConsole->cursorY >= gfxcurrentConsole->windowHeight ) + { + gfxcurrentConsole->cursorY -= gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; + + buf = gfxcurrentConsole->buffer; + offset = gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight << 8; + + buf += ( gfxcurrentConsole->windowY << 8 ) + gfxcurrentConsole->windowX; + + for( line = 0; line < gfxcurrentConsole->windowHeight - gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; line ++ ) + { +// dmaFillHalfWords( 0x800F, buf, gfxcurrentConsole->windowWidth << 1 ); + dmaCopy( buf + offset, buf, gfxcurrentConsole->windowWidth << 1 ); + buf += 256; + } + + for( line = 0; line < gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; line ++ ) + { +// dmaFillHalfWords( 0x81E0, buf, gfxcurrentConsole->windowWidth << 1 ); + dmaFillHalfWords( gfxcurrentConsole->backcolor /*| BIT(15)*/, buf, gfxcurrentConsole->windowWidth << 1 ); + buf += 256; + } + +// dmaCopy( gfxcurrentConsole->buffer + ( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight << 8 ), gfxcurrentConsole->buffer, ( 192 - gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight ) << 9 ); + +// dmaFillHalfWords( gfxcurrentConsole->backcolor, gfxcurrentConsole->buffer + ( gfxcurrentConsole->cursorY << 8 ), ( 192 - gfxcurrentConsole->cursorY ) << 9 ); + } +} + + +//--------------------------------------------------------------------------------- +void gfxConsolePrintChar( char c ) { + //--------------------------------------------------------------------------------- + + if(gfxcurrentConsole->PrintChar) + if(gfxcurrentConsole->PrintChar(gfxcurrentConsole, c)) + return; + + if( ( gfxcurrentConsole->cursorX + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c]->bShift) > gfxcurrentConsole->windowWidth) { + gfxcurrentConsole->cursorX = 0; + + gfxnewRow(); + } + + switch(c) { + /* + The only special characters we will handle are tab (\t), carriage return (\r), line feed (\n) + and backspace (\b). + Carriage return & line feed will function the same: go to next line and put cursor at the beginning. + For everything else, use VT sequences. + + Reason: VT sequences are more specific to the task of cursor placement. + The special escape sequences \b \f & \v are archaic and non-portable. + */ + case 8: + gfxcurrentConsole->cursorX--; + + if(gfxcurrentConsole->cursorX < 0) + { + if(gfxcurrentConsole->cursorY > 0) + { + gfxcurrentConsole->cursorX = gfxcurrentConsole->windowX - 1; + gfxcurrentConsole->cursorY -= gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bLineHeight; + } + else + { + gfxcurrentConsole->cursorX = 0; + } + } + break; + + case 9: + gfxcurrentConsole->cursorX += gfxcurrentConsole->tabSize; + break; + case 10: + case 13: + gfxnewRow(); + gfxcurrentConsole->cursorX = 0; + break; + default: + if( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c] ) + { + //if( gfxcurrentConsole->backOpaque ) + bmfPutCharOpaque( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ], gfxcurrentConsole->cursorX + gfxcurrentConsole->windowX, gfxcurrentConsole->cursorY + gfxcurrentConsole->windowY, gfxcurrentConsole->textcolor, gfxcurrentConsole->backcolor, gfxcurrentConsole->buffer, c ); + //else + // bmfPutCharTransparent( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ], gfxcurrentConsole->cursorX + gfxcurrentConsole->windowX, gfxcurrentConsole->cursorY + gfxcurrentConsole->windowY, gfxcurrentConsole->textcolor, gfxcurrentConsole->backcolor, gfxcurrentConsole->buffer, c ); + + gfxcurrentConsole->cursorX += gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c]->bShift + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bAddSpace; + } + break; + } +} + +//--------------------------------------------------------------------------------- +void gfxConsoleClear(void) { +//--------------------------------------------------------------------------------- + iprintf("\x1b[2J"); +} + +//--------------------------------------------------------------------------------- +void gfxConsoleSetWindow(gfxPrintConsole* console, int x, int y, int width, int height) { +//--------------------------------------------------------------------------------- + + if(!console) console = gfxcurrentConsole; + + console->windowWidth = width; + console->windowHeight = height; + console->windowX = x; + console->windowY = y; + + console->cursorX = 0; + console->cursorY = -gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bSizeOver; + +} + + diff --git a/arm9/source/Libraries/gfxconsole.h b/source/Libraries/gfxconsole.h similarity index 97% rename from arm9/source/Libraries/gfxconsole.h rename to source/Libraries/gfxconsole.h index 70e831c..cdd5739 100644 --- a/arm9/source/Libraries/gfxconsole.h +++ b/source/Libraries/gfxconsole.h @@ -1,231 +1,231 @@ -/*--------------------------------------------------------------------------------- - - Graphic Console functions - - Copyright (C) 2009 - Steven Harrison - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any - damages arising from the use of this software. - - Permission is granted to anyone to use this software for any - purpose, including commercial applications, and to alter it and - redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you - must not claim that you wrote the original software. If you use - this software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and - must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. - - ----------------------------------------------------------------------------------*/ - -/*! \file gfxconsole.h - \brief nds graphical stdio support. - -
-Provides stdio integration for printing to the DS screen as well as debug print -functionality provided by stderr. - -General usage is to initialize the console by: -gfxconsoleDemoInit() -or to customize the console usage by: -gfxconsoleInit() - -The default instance utilizes the sub display, using the graphic mode 5_2D, and -background 3 - -Debug printing is performed by initializing the debug console via gfxconsoleDebugInit() as -follows: - -
-gfxconsoleDebugInit(DebugDevice_NOCASH);
-fprintf(stderr, "debug message in no$gba window %i", stuff);
-
-OR
-
-gfxconsoleDebugInit(DebugDevice_CONSOLE);
-fprintf(stderr, "debug message on DS console screen");
-
- -The print console must be initialized to use DB_CONSOL - -
- -*/ - -#ifndef GFXCONSOLE_H -#define GFXCONSOLE_H - -#include -#include - -// include the header file for the default font data - should be in the data folder -//#include "4x6_a_bmf.h" /*!< Default monospaced font >*/ -//#include "gc_def_c_bmf.h" /*!< Default multicolored font (actualy 13 colors in this font data) >*/ - -#include "ByteMapFont.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern BMFont gfx_default_font_mono; -//extern BMFont gfx_default_font_mcol; - -typedef bool(* gfxConsolePrint)(void* con, char c); - - -/** - * \struct gfxPrintConsole - * \brief console structure used to store the state of a console render context - - Default values from gfxconsoleNew(): -
-gfxPrintConsole gfxdefaultConsole = 
-{
-	//Font:
-	(BMFont *) &gfx_default_font_mono,	// Font information
-	(u16 *) 0,							// Background buffer
-	RGB5( 31, 31, 31 ) | BIT(15),		// Text color - warning here
-	RGB5(  0,  0,  0 ) | BIT(15),		// Background color
-	-1,									// bg id
-	false,								// Bacground mode
-	1,									// Use line height for y offsets
-	0,0,								// cursorX cursorY
-	0,0,								// prevcursorX prevcursorY
-	256,								// console width
-	192,								// console height
-	0,									// window x
-	0,									// window y
-	256,								// window width
-	192,								// window height
-	3,									// tab size
-	0,									// print callback
-	false,								// console initialized
-	true,								// load graphics
-};
-
- - */ -typedef struct -{ - BMFont *font[10]; /*!< Pointer to the font data*/ - u8 curFont; /*!< Current font*/ - u8 numFonts; /*!< Number of fonts loaded into this console*/ - - u16* buffer; /*!< Pointer to the buffer to write to. Is set by bgInit*/ - - u16 textcolor; /*!< The current text color*/ - u16 backcolor; /*!< The current background color*/ - - int bgId; /*!< bgId, should be set with a call to bgInit() or bgInitSub()*/ - - bool backOpaque; /*!< The background mode - Transparent = false, Opaque = true*/ - - u8 lineType; /*!< The line type - 0 = pixel y positions, 1 = line hieght positions*/ - - int cursorX; /*!< Current X location of the cursor (as a tile offset by default)*/ - int cursorY; /*!< Current Y location of the cursor (as a tile offset by default)*/ - - int prevCursorX; /*!< Internal state*/ - int prevCursorY; /*!< Internal state*/ - - int consoleWidth; /*!< Width of the console hardware layer in pixels*/ - int consoleHeight; /*!< Height of the console hardware layer in pixels*/ - - int windowX; /*!< Window X location in pixels (not implemented)*/ - int windowY; /*!< Window Y location in pixels (not implemented)*/ - int windowWidth; /*!< Window width in pixels (not implemented)*/ - int windowHeight; /*!< Window height in pixels (not implemented)*/ - - int tabSize; /*!< Size of a tab*/ - - gfxConsolePrint PrintChar; /*!< callback for printing a character. Should return true if it has handled rendering the graphics (else the print engine will attempt to render via tiles)*/ - - bool consoleInitialised; /*!< True if the console is initialized*/ - bool loadGraphics; /*!< True if consoleInit should attempt to load font graphics into background memory*/ - -} gfxPrintConsole; - -/*! \fn void gfxConsoleSetFont(gfxPrintConsole* console, BMFont* font) - - \brief Loads the font into the specified console - \param console pointer to the print console to update - \param font the font to load - */ -void gfxConsoleSetFont(gfxPrintConsole* console, u8 fontNumber); - -/*! \fn void gfxConsoleAddFont(gfxPrintConsole* console, BMFont* font) - - \brief Adds the font into the specified console - \param console pointer to the print console to update - \param font the font to add - \return the position in the font list. or -1 on error - */ -int gfxConsoleAddFont(gfxPrintConsole* console, BMFont* font); - -/*! \fn void gfxConsoleSetWindow(gfxPrintConsole* console, int x, int y, int width, int height) - - \brief Sets the print window - \param console console to set, if NULL will set current console window - \param x x location of the window - \param y y location of the window - \param width width of the window - \param height height of the window - - */ -void gfxConsoleSetWindow(gfxPrintConsole* console, int x, int y, int width, int height); - -/*! \fn gfxPrintConsole* gfxConsoleGetDefault(void) - \brief Gets a pointer to the default console (this should only be used when using a single console, other wise use consoleNew(PrintsConsole* console) - \return A pointer to the default console -*/ -gfxPrintConsole* gfxConsoleGetDefault(void); - -/*! \fn void gfxConsoleSelect(gfxPrintConsole* console) - \brief Make the specified console the render target - \param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console) -*/ -void gfxConsoleSelect(gfxPrintConsole* console); - -/*! \fn gfxPrintConsole* gfxConsoleInit(gfxPrintConsole* console, BgType type, BgSize size, bool mainDisplay, bool loadGraphics); - - \brief Initialise the console. - \param console A pointer to the console initialze data (if null default console will be used) - \param type the type of the background - \param size the size of the background - \param mainDisplay if true main engine is used, otherwise false - \param loadGraphics if true the default font graphics will be loaded into the layer -*/ -gfxPrintConsole* gfxConsoleInit(gfxPrintConsole* console, BgType type, BgSize size, bool mainDisplay, bool loadGraphics); - -/*! \fn gfxPrintConsole* gfxConsoleDemoInit(void) -\brief Initialize the console to a default state for prototyping. -This function sets the console to use sub display, VRAM_C, and BG0 and enables MODE_5_2D on the -sub display. It is intended for use in prototyping applications which need print ability and not actual -game use. Print functionality can be utilized with just this call. -*/ -gfxPrintConsole* gfxConsoleDemoInit(void); - -/*! \fn void gfxConsoleClear(void) -\brief Clears the screan by iprintf("\x1b[2J"); -*/ -void gfxConsoleClear(void); - -/*! \fn void gfxConsoleDebugInit(DebugDevice device) - \brief Initializes debug console output on stderr to the specified device - \param device The debug device (or devices) to output debug print statements to -*/ -void gfxConsoleDebugInit(DebugDevice device); - -#ifdef __cplusplus -} -#endif - -#endif +/*--------------------------------------------------------------------------------- + + Graphic Console functions + + Copyright (C) 2009 + Steven Harrison + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + + +---------------------------------------------------------------------------------*/ + +/*! \file gfxconsole.h + \brief nds graphical stdio support. + +
+Provides stdio integration for printing to the DS screen as well as debug print +functionality provided by stderr. + +General usage is to initialize the console by: +gfxconsoleDemoInit() +or to customize the console usage by: +gfxconsoleInit() + +The default instance utilizes the sub display, using the graphic mode 5_2D, and +background 3 + +Debug printing is performed by initializing the debug console via gfxconsoleDebugInit() as +follows: + +
+gfxconsoleDebugInit(DebugDevice_NOCASH);
+fprintf(stderr, "debug message in no$gba window %i", stuff);
+
+OR
+
+gfxconsoleDebugInit(DebugDevice_CONSOLE);
+fprintf(stderr, "debug message on DS console screen");
+
+ +The print console must be initialized to use DB_CONSOL + +
+ +*/ + +#ifndef GFXCONSOLE_H +#define GFXCONSOLE_H + +#include +#include + +// include the header file for the default font data - should be in the data folder +//#include "4x6_a_bmf.h" /*!< Default monospaced font >*/ +//#include "gc_def_c_bmf.h" /*!< Default multicolored font (actualy 13 colors in this font data) >*/ + +#include "ByteMapFont.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern BMFont gfx_default_font_mono; +//extern BMFont gfx_default_font_mcol; + +typedef bool(* gfxConsolePrint)(void* con, char c); + + +/** + * \struct gfxPrintConsole + * \brief console structure used to store the state of a console render context + + Default values from gfxconsoleNew(): +
+gfxPrintConsole gfxdefaultConsole = 
+{
+	//Font:
+	(BMFont *) &gfx_default_font_mono,	// Font information
+	(u16 *) 0,							// Background buffer
+	RGB5( 31, 31, 31 ) | BIT(15),		// Text color - warning here
+	RGB5(  0,  0,  0 ) | BIT(15),		// Background color
+	-1,									// bg id
+	false,								// Bacground mode
+	1,									// Use line height for y offsets
+	0,0,								// cursorX cursorY
+	0,0,								// prevcursorX prevcursorY
+	256,								// console width
+	192,								// console height
+	0,									// window x
+	0,									// window y
+	256,								// window width
+	192,								// window height
+	3,									// tab size
+	0,									// print callback
+	false,								// console initialized
+	true,								// load graphics
+};
+
+ + */ +typedef struct +{ + BMFont *font[10]; /*!< Pointer to the font data*/ + u8 curFont; /*!< Current font*/ + u8 numFonts; /*!< Number of fonts loaded into this console*/ + + u16* buffer; /*!< Pointer to the buffer to write to. Is set by bgInit*/ + + u16 textcolor; /*!< The current text color*/ + u16 backcolor; /*!< The current background color*/ + + int bgId; /*!< bgId, should be set with a call to bgInit() or bgInitSub()*/ + + bool backOpaque; /*!< The background mode - Transparent = false, Opaque = true*/ + + u8 lineType; /*!< The line type - 0 = pixel y positions, 1 = line hieght positions*/ + + int cursorX; /*!< Current X location of the cursor (as a tile offset by default)*/ + int cursorY; /*!< Current Y location of the cursor (as a tile offset by default)*/ + + int prevCursorX; /*!< Internal state*/ + int prevCursorY; /*!< Internal state*/ + + int consoleWidth; /*!< Width of the console hardware layer in pixels*/ + int consoleHeight; /*!< Height of the console hardware layer in pixels*/ + + int windowX; /*!< Window X location in pixels (not implemented)*/ + int windowY; /*!< Window Y location in pixels (not implemented)*/ + int windowWidth; /*!< Window width in pixels (not implemented)*/ + int windowHeight; /*!< Window height in pixels (not implemented)*/ + + int tabSize; /*!< Size of a tab*/ + + gfxConsolePrint PrintChar; /*!< callback for printing a character. Should return true if it has handled rendering the graphics (else the print engine will attempt to render via tiles)*/ + + bool consoleInitialised; /*!< True if the console is initialized*/ + bool loadGraphics; /*!< True if consoleInit should attempt to load font graphics into background memory*/ + +} gfxPrintConsole; + +/*! \fn void gfxConsoleSetFont(gfxPrintConsole* console, BMFont* font) + + \brief Loads the font into the specified console + \param console pointer to the print console to update + \param font the font to load + */ +void gfxConsoleSetFont(gfxPrintConsole* console, u8 fontNumber); + +/*! \fn void gfxConsoleAddFont(gfxPrintConsole* console, BMFont* font) + + \brief Adds the font into the specified console + \param console pointer to the print console to update + \param font the font to add + \return the position in the font list. or -1 on error + */ +int gfxConsoleAddFont(gfxPrintConsole* console, BMFont* font); + +/*! \fn void gfxConsoleSetWindow(gfxPrintConsole* console, int x, int y, int width, int height) + + \brief Sets the print window + \param console console to set, if NULL will set current console window + \param x x location of the window + \param y y location of the window + \param width width of the window + \param height height of the window + + */ +void gfxConsoleSetWindow(gfxPrintConsole* console, int x, int y, int width, int height); + +/*! \fn gfxPrintConsole* gfxConsoleGetDefault(void) + \brief Gets a pointer to the default console (this should only be used when using a single console, other wise use consoleNew(PrintsConsole* console) + \return A pointer to the default console +*/ +gfxPrintConsole* gfxConsoleGetDefault(void); + +/*! \fn void gfxConsoleSelect(gfxPrintConsole* console) + \brief Make the specified console the render target + \param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console) +*/ +void gfxConsoleSelect(gfxPrintConsole* console); + +/*! \fn gfxPrintConsole* gfxConsoleInit(gfxPrintConsole* console, BgType type, BgSize size, bool mainDisplay, bool loadGraphics); + + \brief Initialise the console. + \param console A pointer to the console initialze data (if null default console will be used) + \param type the type of the background + \param size the size of the background + \param mainDisplay if true main engine is used, otherwise false + \param loadGraphics if true the default font graphics will be loaded into the layer +*/ +gfxPrintConsole* gfxConsoleInit(gfxPrintConsole* console, BgType type, BgSize size, bool mainDisplay, bool loadGraphics); + +/*! \fn gfxPrintConsole* gfxConsoleDemoInit(void) +\brief Initialize the console to a default state for prototyping. +This function sets the console to use sub display, VRAM_C, and BG0 and enables MODE_5_2D on the +sub display. It is intended for use in prototyping applications which need print ability and not actual +game use. Print functionality can be utilized with just this call. +*/ +gfxPrintConsole* gfxConsoleDemoInit(void); + +/*! \fn void gfxConsoleClear(void) +\brief Clears the screan by iprintf("\x1b[2J"); +*/ +void gfxConsoleClear(void); + +/*! \fn void gfxConsoleDebugInit(DebugDevice device) + \brief Initializes debug console output on stderr to the specified device + \param device The debug device (or devices) to output debug print statements to +*/ +void gfxConsoleDebugInit(DebugDevice device); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/arm9/source/Libraries/nitrofs.c b/source/Libraries/nitrofs.c similarity index 99% rename from arm9/source/Libraries/nitrofs.c rename to source/Libraries/nitrofs.c index 0754218..8e5846e 100644 --- a/arm9/source/Libraries/nitrofs.c +++ b/source/Libraries/nitrofs.c @@ -44,8 +44,8 @@ #include //Globals! -u32 fntOffset; //offset to start of filename table -u32 fatOffset; //offset to start of file alloc table +u32 fntOffset; //offset to start of filename table +u32 fatOffset; //offset to start of file alloc table bool hasLoader; u16 chdirpathid; //default dir path id... FILE *ndsFile; @@ -149,7 +149,7 @@ int nitroFSInit(const char *ndsfile) { } } return(0); -} +} diff --git a/arm9/source/Libraries/nitrofs.h b/source/Libraries/nitrofs.h similarity index 99% rename from arm9/source/Libraries/nitrofs.h rename to source/Libraries/nitrofs.h index 2bbe04e..630fd0c 100644 --- a/arm9/source/Libraries/nitrofs.h +++ b/source/Libraries/nitrofs.h @@ -38,7 +38,7 @@ extern "C" { #ifndef NITROFS_H #define NITROFS_H -#include +#include #include #include diff --git a/arm9/source/Modes/Mode.cpp b/source/Modes/Mode.cpp similarity index 92% rename from arm9/source/Modes/Mode.cpp rename to source/Modes/Mode.cpp index 8c78ecc..c8e077e 100644 --- a/arm9/source/Modes/Mode.cpp +++ b/source/Modes/Mode.cpp @@ -1,14 +1,14 @@ -#include "defines.h" - -#include "Mode.h" - -Mode* Mode::sCurrentMode = NULL; - -void Mode::ChangeToOsuDir() -{ -#ifdef HARDWARE - chdir("fat:/osuds"); -#else - chdir("nitro:/osuds"); -#endif -} +#include "defines.h" + +#include "Mode.h" + +Mode* Mode::sCurrentMode = NULL; + +void Mode::ChangeToOsuDir() +{ +#ifdef HARDWARE + chdir("fat:/osuds"); +#else + chdir("nitro:/osuds"); +#endif +} diff --git a/arm9/source/Modes/Mode.h b/source/Modes/Mode.h similarity index 94% rename from arm9/source/Modes/Mode.h rename to source/Modes/Mode.h index 1cfa527..0a1f0b1 100644 --- a/arm9/source/Modes/Mode.h +++ b/source/Modes/Mode.h @@ -1,38 +1,38 @@ -#include -#include -#include "Libraries/nitrofs.h" -#include "Helpers/InputHelper.h" - -#ifndef __MODE_H__ -#define __MODE_H__ - -typedef enum { - MODE_PLAYER, - MODE_SONGSELECT -} ModeType; - -class Mode -{ - public: - virtual ~Mode() {} - - static Mode& CurrentMode() { return *sCurrentMode; } - friend void ChangeMode(ModeType mode); - - virtual void Update() = 0; - virtual void HandleInput() = 0; - - static void ChangeToOsuDir(); - - protected: - Mode() { ChangeToOsuDir(); } //reset directory for new mode - - private: - static Mode* sCurrentMode; -}; - -void ChangeMode(ModeType mode); - -#endif - - +#include +#include +#include "Libraries/nitrofs.h" +#include "Helpers/InputHelper.h" + +#ifndef __MODE_H__ +#define __MODE_H__ + +typedef enum { + MODE_PLAYER, + MODE_SONGSELECT +} ModeType; + +class Mode +{ + public: + virtual ~Mode() {} + + static Mode& CurrentMode() { return *sCurrentMode; } + friend void ChangeMode(ModeType mode); + + virtual void Update() = 0; + virtual void HandleInput() = 0; + + static void ChangeToOsuDir(); + + protected: + Mode() { ChangeToOsuDir(); } //reset directory for new mode + + private: + static Mode* sCurrentMode; +}; + +void ChangeMode(ModeType mode); + +#endif + + diff --git a/arm9/source/Modes/ModeLoader.cpp b/source/Modes/ModeLoader.cpp similarity index 94% rename from arm9/source/Modes/ModeLoader.cpp rename to source/Modes/ModeLoader.cpp index 08d89a0..20f5cd2 100644 --- a/arm9/source/Modes/ModeLoader.cpp +++ b/source/Modes/ModeLoader.cpp @@ -1,53 +1,53 @@ -#include "Mode.h" -#include "Player.h" -#include "SongSelect.h" -#include "System/GameClock.h" -#include "System/TextManager.h" - -void ChangeMode(ModeType mode) -{ - //dim screen - if (Mode::sCurrentMode != NULL) - { - for (s32 b = 0; b >= -16; --b) - { - setBrightness(1, b); - swiWaitForVBlank(); - } - } - else - { - setBrightness(1, -16); - } - - TextManager::Bottom().Clear(); - TextManager::Top().Clear(); - - //must reset clock before calling constructors - //otherwise bad things happen with sprites - GameClock::Clock().Reset(); - - if (Mode::sCurrentMode != NULL) - delete Mode::sCurrentMode; - - switch (mode) - { - case MODE_PLAYER: - Mode::sCurrentMode = new Player(); - break; - case MODE_SONGSELECT: - Mode::sCurrentMode = new SongSelect(); - break; - } - - swiWaitForVBlank(); - Mode::CurrentMode().Update(); - glFlush(1); - - //return screen to full brightness - for (s32 b = -16; b <= 0; ++b) - { - setBrightness(1, b); - swiWaitForVBlank(); - } -} +#include "Mode.h" +#include "Player.h" +#include "SongSelect.h" +#include "System/GameClock.h" +#include "System/TextManager.h" + +void ChangeMode(ModeType mode) +{ + //dim screen + if (Mode::sCurrentMode != NULL) + { + for (s32 b = 0; b >= -16; --b) + { + setBrightness(1, b); + swiWaitForVBlank(); + } + } + else + { + setBrightness(1, -16); + } + + TextManager::Bottom().Clear(); + TextManager::Top().Clear(); + + //must reset clock before calling constructors + //otherwise bad things happen with sprites + GameClock::Clock().Reset(); + + if (Mode::sCurrentMode != NULL) + delete Mode::sCurrentMode; + + switch (mode) + { + case MODE_PLAYER: + Mode::sCurrentMode = new Player(); + break; + case MODE_SONGSELECT: + Mode::sCurrentMode = new SongSelect(); + break; + } + + swiWaitForVBlank(); + Mode::CurrentMode().Update(); + glFlush(1); + + //return screen to full brightness + for (s32 b = -16; b <= 0; ++b) + { + setBrightness(1, b); + swiWaitForVBlank(); + } +} diff --git a/arm9/source/Modes/Player.cpp b/source/Modes/Player.cpp similarity index 93% rename from arm9/source/Modes/Player.cpp rename to source/Modes/Player.cpp index 0b0c65c..820b4c8 100644 --- a/arm9/source/Modes/Player.cpp +++ b/source/Modes/Player.cpp @@ -1,74 +1,74 @@ -#include "Player.h" - -Player::Player() -{ - //initialisation - mRuleset.Initialize(); - - //load audio - ChangeToSongDir(); - AudioManager::Engine().MusicPlay(BeatmapManager::Current().AudioFilename()); - - //set player to process gameplay - mPlayState = PLAYSTATE_PLAY; -} - -Player::~Player() -{ - //delete mBaseDir; - AudioManager::Engine().MusicStop(); -} - -void Player::Update() -{ - switch (mPlayState) - { - case PLAYSTATE_PLAY: - { - mRuleset.Update(); - - if (BeatmapManager::Current().GameOver()) - { - mPlayState = PLAYSTATE_GAMEOVER; - mRuleset.OnGameOver(); - } - - break; - } - - case PLAYSTATE_GAMEOVER: - { - iprintf("\x1b[0;0HGame over"); - break; - } - - default: - break; - } - - AudioManager::Engine().MusicUpdate(); -} - -void Player::HandleInput() -{ - mRuleset.HandleInput(); - - //handle play mode input - if (InputHelper::KeyDown(KEY_A)) - { - mRuleset.Skip(); - } - - if (InputHelper::KeyDown(KEY_SELECT)) - { - ChangeMode(MODE_SONGSELECT); - return; - } -} - -void Player::ChangeToSongDir() -{ - ChangeToOsuDir(); - chdir(BeatmapManager::Current().BaseDir().c_str()); -} - +#include "Player.h" + +Player::Player() +{ + //initialisation + mRuleset.Initialize(); + + //load audio + ChangeToSongDir(); + AudioManager::Engine().MusicPlay(BeatmapManager::Current().AudioFilename()); + + //set player to process gameplay + mPlayState = PLAYSTATE_PLAY; +} + +Player::~Player() +{ + //delete mBaseDir; + AudioManager::Engine().MusicStop(); +} + +void Player::Update() +{ + switch (mPlayState) + { + case PLAYSTATE_PLAY: + { + mRuleset.Update(); + + if (BeatmapManager::Current().GameOver()) + { + mPlayState = PLAYSTATE_GAMEOVER; + mRuleset.OnGameOver(); + } + + break; + } + + case PLAYSTATE_GAMEOVER: + { + iprintf("\x1b[0;0HGame over"); + break; + } + + default: + break; + } + + AudioManager::Engine().MusicUpdate(); +} + +void Player::HandleInput() +{ + mRuleset.HandleInput(); + + //handle play mode input + if (InputHelper::KeyDown(KEY_A)) + { + mRuleset.Skip(); + } + + if (InputHelper::KeyDown(KEY_SELECT)) + { + ChangeMode(MODE_SONGSELECT); + return; + } +} + +void Player::ChangeToSongDir() +{ + ChangeToOsuDir(); + chdir(BeatmapManager::Current().BaseDir().c_str()); +} + diff --git a/arm9/source/Modes/Player.h b/source/Modes/Player.h similarity index 94% rename from arm9/source/Modes/Player.h rename to source/Modes/Player.h index 6b4adea..399aaa8 100644 --- a/arm9/source/Modes/Player.h +++ b/source/Modes/Player.h @@ -1,41 +1,41 @@ -#include -#include -#include "Mode.h" - -#include "System/GameClock.h" - -#include "GameplayElements/ScoreManager.h" -#include "Graphics/SpriteManager.h" -#include "Helpers/AudioManager.h" -#include "GameplayElements/Lifebar.h" -#include "GameplayElements/HitObjectManager.h" -#include "Rulesets/Ruleset.h" -#include "Rulesets/RulesetOsu.h" - -#ifndef __PLAYER_H__ -#define __PLAYER_H__ - -typedef enum { - PLAYSTATE_PLAY, - PLAYSTATE_GAMEOVER -} PlayState; - -class Player : public Mode -{ - public: - Player(); - ~Player(); - - void Update(); - void HandleInput(); - - protected: - void ChangeToSongDir(); - - RulesetOsu mRuleset; - - PlayState mPlayState; -}; - -#endif - +#include +#include +#include "Mode.h" + +#include "System/GameClock.h" + +#include "GameplayElements/ScoreManager.h" +#include "Graphics/SpriteManager.h" +#include "Helpers/AudioManager.h" +#include "GameplayElements/Lifebar.h" +#include "GameplayElements/HitObjectManager.h" +#include "Rulesets/Ruleset.h" +#include "Rulesets/RulesetOsu.h" + +#ifndef __PLAYER_H__ +#define __PLAYER_H__ + +typedef enum { + PLAYSTATE_PLAY, + PLAYSTATE_GAMEOVER +} PlayState; + +class Player : public Mode +{ + public: + Player(); + ~Player(); + + void Update(); + void HandleInput(); + + protected: + void ChangeToSongDir(); + + RulesetOsu mRuleset; + + PlayState mPlayState; +}; + +#endif + diff --git a/arm9/source/Modes/SongSelect.cpp b/source/Modes/SongSelect.cpp similarity index 95% rename from arm9/source/Modes/SongSelect.cpp rename to source/Modes/SongSelect.cpp index 72ff140..ee2587f 100644 --- a/arm9/source/Modes/SongSelect.cpp +++ b/source/Modes/SongSelect.cpp @@ -1,179 +1,179 @@ -#include "SongSelect.h" - -SongSelect::SongSelect() -{ - for (int i=0; i<8; ++i) - { - pSprite* spr = new pSprite(TX_WHITE, 0, 0, 160, 120, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(4,4,4), 20); - mSpriteManager.Add(spr); - } - - mCurrentX = 0; - mDeltaX = 0; - mIndex = -1; - - mColTarget = 0; - mColCurrent = 0; - mColMax = BeatmapManager::SongCount() / 2; - mColSpill = (BeatmapManager::SongCount() % 6) % 2; - - MoveSongList(mCurrentX); -} - -SongSelect::~SongSelect() -{ -} - -void SongSelect::HandleInput() -{ - if (InputHelper::KeyDown(KEY_LEFT)) - { - MoveSongListLeft(); - } - else if (InputHelper::KeyDown(KEY_RIGHT)) - { - MoveSongListRight(); - } - else if (InputHelper::KeyDown(KEY_TOUCH)) - { - touchPosition pos = InputHelper::TouchRead(); - - // scrolling by touching the edge of the screen - if (pos.py > 120 && pos.py < 360) - { - if (pos.px < 30) - { - MoveSongListLeft(); - } - else if (pos.px > 610) - { - MoveSongListRight(); - } - } - - // calculate vector index (determined by lower right bounding point) - u32 x = (pos.px - mCurrentX) / kSongListSpacing; - u32 y = pos.py / kSongListSpacing; - u32 index = x*2+y; - - // calculate upper left bounding point - u32 left = x * kSongListSpacing + kSongListXOffset + mCurrentX; - u32 top = y * kSongListSpacing + kSongListYOffset; - - // check bounds - if (pos.px >= left && pos.py >= top) - { - // check validity of click - if (mSpriteManager.Sprites()[index]->Alpha == 31) - { - // load beatmap - BeatmapManager::Load(index + mColCurrent*2); // take scrolling offset into account - ChangeMode(MODE_PLAYER); - return; - } - } - } -} - -void SongSelect::Update() -{ - if (mDeltaX != 0) - { - u32 delta = mDeltaX / 6; - - if (delta == 0 && mDeltaX != 0) - delta = MathHelper::Sgn(mDeltaX); - - mDeltaX -= delta; - MoveSongList(delta); - } - - mSpriteManager.Draw(); - - // beatmap names - - TextManager::Bottom().Clear(); - - for (int i=0; i<4; ++i) - { - for (int j=0; j<2; ++j) - { - int index = i*2 + j; - pSprite* spr = mSpriteManager.Sprites()[index]; - - index += mColCurrent*2; - if (index >= BeatmapManager::SongCount()) - break; - Beatmap* map = BeatmapManager::Beatmaps()[index]; - - TextManager::Bottom().SetFont(FONT_CONSOLE); - - TextManager::Bottom().PrintLocate( - spr->X + 2, spr->Y + spr->Height, ORIGIN_BOTTOMLEFT, - "%s\n%s\n%s", map->Artist().c_str(), map->Title().c_str(), map->Version().c_str() - ); - } - } -} - -void SongSelect::MoveSongList(s32 dx) -{ - mCurrentX += dx; - - if (mCurrentX > 0) // scrolled 1 column left - { - mCurrentX -= 200; - mColCurrent -= 1; - } - else if (mCurrentX <= -200) // scrolled 1 column right - { - mCurrentX += 200; - mColCurrent += 1; - } - - // reset visibility - for (int i=0; i<8; i++) - { - mSpriteManager.Sprites()[i]->Alpha = 31; - } - - // if we're on the last page, hide the final icons - if (mColMax - mColCurrent <= 3) - { - for (int i=(mColMax-mColCurrent)*2+mColSpill; i<8; i++) - { - mSpriteManager.Sprites()[i]->Alpha = 0; - } - } - - // calculate positions for each box - for (int i=0; i<4; ++i) - { - for (int j=0; j<2; ++j) - { - mSpriteManager.Sprites()[i*2+j]->Move( - kSongListXOffset + mCurrentX + (i * kSongListSpacing), - kSongListYOffset + (j * kSongListSpacing) - ); - } - } -} - -void SongSelect::MoveSongListLeft() -{ - if (mColTarget > 0) - { - mDeltaX += 600; - mColTarget -= 3; - } -} - -void SongSelect::MoveSongListRight() -{ - if (mColTarget + 3 < mColMax + mColSpill) - { - mDeltaX -= 600; - mColTarget += 3; - } -} - +#include "SongSelect.h" + +SongSelect::SongSelect() +{ + for (int i=0; i<8; ++i) + { + pSprite* spr = new pSprite(TX_WHITE, 0, 0, 160, 120, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(4,4,4), 20); + mSpriteManager.Add(spr); + } + + mCurrentX = 0; + mDeltaX = 0; + mIndex = -1; + + mColTarget = 0; + mColCurrent = 0; + mColMax = BeatmapManager::SongCount() / 2; + mColSpill = (BeatmapManager::SongCount() % 6) % 2; + + MoveSongList(mCurrentX); +} + +SongSelect::~SongSelect() +{ +} + +void SongSelect::HandleInput() +{ + if (InputHelper::KeyDown(KEY_LEFT)) + { + MoveSongListLeft(); + } + else if (InputHelper::KeyDown(KEY_RIGHT)) + { + MoveSongListRight(); + } + else if (InputHelper::KeyDown(KEY_TOUCH)) + { + touchPosition pos = InputHelper::TouchRead(); + + // scrolling by touching the edge of the screen + if (pos.py > 120 && pos.py < 360) + { + if (pos.px < 30) + { + MoveSongListLeft(); + } + else if (pos.px > 610) + { + MoveSongListRight(); + } + } + + // calculate vector index (determined by lower right bounding point) + u32 x = (pos.px - mCurrentX) / kSongListSpacing; + u32 y = pos.py / kSongListSpacing; + u32 index = x*2+y; + + // calculate upper left bounding point + u32 left = x * kSongListSpacing + kSongListXOffset + mCurrentX; + u32 top = y * kSongListSpacing + kSongListYOffset; + + // check bounds + if (pos.px >= left && pos.py >= top) + { + // check validity of click + if (mSpriteManager.Sprites()[index]->Alpha == 31) + { + // load beatmap + BeatmapManager::Load(index + mColCurrent*2); // take scrolling offset into account + ChangeMode(MODE_PLAYER); + return; + } + } + } +} + +void SongSelect::Update() +{ + if (mDeltaX != 0) + { + u32 delta = mDeltaX / 6; + + if (delta == 0 && mDeltaX != 0) + delta = MathHelper::Sgn(mDeltaX); + + mDeltaX -= delta; + MoveSongList(delta); + } + + mSpriteManager.Draw(); + + // beatmap names + + TextManager::Bottom().Clear(); + + for (int i=0; i<4; ++i) + { + for (int j=0; j<2; ++j) + { + int index = i*2 + j; + pSprite* spr = mSpriteManager.Sprites()[index]; + + index += mColCurrent*2; + if (index >= BeatmapManager::SongCount()) + break; + Beatmap* map = BeatmapManager::Beatmaps()[index]; + + TextManager::Bottom().SetFont(FONT_CONSOLE); + + TextManager::Bottom().PrintLocate( + spr->X + 2, spr->Y + spr->Height, ORIGIN_BOTTOMLEFT, + "%s\n%s\n%s", map->Artist().c_str(), map->Title().c_str(), map->Version().c_str() + ); + } + } +} + +void SongSelect::MoveSongList(s32 dx) +{ + mCurrentX += dx; + + if (mCurrentX > 0) // scrolled 1 column left + { + mCurrentX -= 200; + mColCurrent -= 1; + } + else if (mCurrentX <= -200) // scrolled 1 column right + { + mCurrentX += 200; + mColCurrent += 1; + } + + // reset visibility + for (int i=0; i<8; i++) + { + mSpriteManager.Sprites()[i]->Alpha = 31; + } + + // if we're on the last page, hide the final icons + if (mColMax - mColCurrent <= 3) + { + for (int i=(mColMax-mColCurrent)*2+mColSpill; i<8; i++) + { + mSpriteManager.Sprites()[i]->Alpha = 0; + } + } + + // calculate positions for each box + for (int i=0; i<4; ++i) + { + for (int j=0; j<2; ++j) + { + mSpriteManager.Sprites()[i*2+j]->Move( + kSongListXOffset + mCurrentX + (i * kSongListSpacing), + kSongListYOffset + (j * kSongListSpacing) + ); + } + } +} + +void SongSelect::MoveSongListLeft() +{ + if (mColTarget > 0) + { + mDeltaX += 600; + mColTarget -= 3; + } +} + +void SongSelect::MoveSongListRight() +{ + if (mColTarget + 3 < mColMax + mColSpill) + { + mDeltaX -= 600; + mColTarget += 3; + } +} + diff --git a/arm9/source/Modes/SongSelect.h b/source/Modes/SongSelect.h similarity index 94% rename from arm9/source/Modes/SongSelect.h rename to source/Modes/SongSelect.h index 518f003..ec361f1 100644 --- a/arm9/source/Modes/SongSelect.h +++ b/source/Modes/SongSelect.h @@ -1,43 +1,43 @@ -#include -#include - -#include "Mode.h" -#include "Beatmaps/BeatmapManager.h" +#include +#include + +#include "Mode.h" +#include "Beatmaps/BeatmapManager.h" #include "Graphics/SpriteManager.h" -#include "System/TextManager.h" - -#ifndef __SONGSELECT_H__ -#define __SONGSELECT_H__ - -class SongSelect : public Mode -{ - public: - SongSelect(); - ~SongSelect(); - - void Update(); - void HandleInput(); - - protected: - SpriteManager mSpriteManager; - - static const s32 kSongListXOffset = 37; - static const s32 kSongListYOffset = 80; - static const s32 kSongListSpacing = 203; - - s32 mCurrentX; - s32 mDeltaX; - s32 mIndex; - - u32 mColTarget; - u32 mColCurrent; - u32 mColMax; - u32 mColSpill; - - void MoveSongList(s32 x); - void MoveSongListLeft(); - void MoveSongListRight(); -}; - -#endif - +#include "System/TextManager.h" + +#ifndef __SONGSELECT_H__ +#define __SONGSELECT_H__ + +class SongSelect : public Mode +{ + public: + SongSelect(); + ~SongSelect(); + + void Update(); + void HandleInput(); + + protected: + SpriteManager mSpriteManager; + + static const s32 kSongListXOffset = 37; + static const s32 kSongListYOffset = 80; + static const s32 kSongListSpacing = 203; + + s32 mCurrentX; + s32 mDeltaX; + s32 mIndex; + + u32 mColTarget; + u32 mColCurrent; + u32 mColMax; + u32 mColSpill; + + void MoveSongList(s32 x); + void MoveSongListLeft(); + void MoveSongListRight(); +}; + +#endif + diff --git a/arm9/source/Rulesets/Ruleset.cpp b/source/Rulesets/Ruleset.cpp similarity index 95% rename from arm9/source/Rulesets/Ruleset.cpp rename to source/Rulesets/Ruleset.cpp index aa7f2b4..9677738 100644 --- a/arm9/source/Rulesets/Ruleset.cpp +++ b/source/Rulesets/Ruleset.cpp @@ -1,60 +1,60 @@ -#include "Ruleset.h" - -Ruleset::Ruleset() -{ - mLifebar.AddToSpriteManager(mSpriteManager); -} - -void Ruleset::Initialize() -{ - mLifebar.Initialize(); -} - -void Ruleset::Skip() -{ - if (GameClock::Clock().Time() < BeatmapManager::Current().SkipTime()) - { - AudioManager::Engine().MusicSkipTo(BeatmapManager::Current().SkipTime()); - GameClock::Clock().SkipTo(BeatmapManager::Current().SkipTime()); - - // template hook - OnSkip(); - } -} - -void Ruleset::OnGameOver() -{ -} - -void Ruleset::Update() -{ - list hitObjectList; - BeatmapManager::Current().Buffer(hitObjectList); - - for (hitObjectIterator it = hitObjectList.begin(); it != hitObjectList.end(); ++it) - { - HitObject* object = *it; - mHitObjectManager.Add(object); - object->AddToSpriteManager(mSpriteManager); - } - - mLifebar.Update(); - mSpriteManager.Draw(); - - // score/combo output - - TextManager::Bottom().SetFont(FONT_SCORE); - - TextManager::Bottom().PrintLocate(635, 5, ORIGIN_TOPRIGHT, " %08i", mScoreManager.Score()); - - if (mScoreManager.Combo() > 0) - TextManager::Bottom().PrintLocate(5, 475, ORIGIN_BOTTOMLEFT, "%ix ", mScoreManager.Combo()); - else - TextManager::Bottom().PrintLocate(5, 475, ORIGIN_BOTTOMLEFT, " "); -} - -void Ruleset::HandleInput() -{ - mHitObjectManager.HandleInput(); -} - +#include "Ruleset.h" + +Ruleset::Ruleset() +{ + mLifebar.AddToSpriteManager(mSpriteManager); +} + +void Ruleset::Initialize() +{ + mLifebar.Initialize(); +} + +void Ruleset::Skip() +{ + if (GameClock::Clock().Time() < BeatmapManager::Current().SkipTime()) + { + AudioManager::Engine().MusicSkipTo(BeatmapManager::Current().SkipTime()); + GameClock::Clock().SkipTo(BeatmapManager::Current().SkipTime()); + + // template hook + OnSkip(); + } +} + +void Ruleset::OnGameOver() +{ +} + +void Ruleset::Update() +{ + list hitObjectList; + BeatmapManager::Current().Buffer(hitObjectList); + + for (hitObjectIterator it = hitObjectList.begin(); it != hitObjectList.end(); ++it) + { + HitObject* object = *it; + mHitObjectManager.Add(object); + object->AddToSpriteManager(mSpriteManager); + } + + mLifebar.Update(); + mSpriteManager.Draw(); + + // score/combo output + + TextManager::Bottom().SetFont(FONT_SCORE); + + TextManager::Bottom().PrintLocate(635, 5, ORIGIN_TOPRIGHT, " %08i", mScoreManager.Score()); + + if (mScoreManager.Combo() > 0) + TextManager::Bottom().PrintLocate(5, 475, ORIGIN_BOTTOMLEFT, "%ix ", mScoreManager.Combo()); + else + TextManager::Bottom().PrintLocate(5, 475, ORIGIN_BOTTOMLEFT, " "); +} + +void Ruleset::HandleInput() +{ + mHitObjectManager.HandleInput(); +} + diff --git a/arm9/source/Rulesets/Ruleset.h b/source/Rulesets/Ruleset.h similarity index 94% rename from arm9/source/Rulesets/Ruleset.h rename to source/Rulesets/Ruleset.h index 9960dc8..92e41bf 100644 --- a/arm9/source/Rulesets/Ruleset.h +++ b/source/Rulesets/Ruleset.h @@ -1,37 +1,37 @@ -#include -#include - -#include "Beatmaps/BeatmapManager.h" -#include "GameplayElements/ScoreManager.h" -#include "Graphics/SpriteManager.h" -#include "GameplayElements/Lifebar.h" -#include "GameplayElements/HitObjectManager.h" -#include "System/TextManager.h" - -#ifndef __RULESET_H__ -#define __RULESET_H__ - -class Ruleset -{ - public: - Ruleset(); - virtual ~Ruleset() {} - - void Initialize(); - void Skip(); - - virtual void OnGameOver(); - virtual void Update(); - virtual void HandleInput(); - - protected: - ScoreManager mScoreManager; - HitObjectManager mHitObjectManager; - SpriteManager mSpriteManager; - Lifebar mLifebar; - - virtual void OnSkip() = 0; -}; - -#endif - +#include +#include + +#include "Beatmaps/BeatmapManager.h" +#include "GameplayElements/ScoreManager.h" +#include "Graphics/SpriteManager.h" +#include "GameplayElements/Lifebar.h" +#include "GameplayElements/HitObjectManager.h" +#include "System/TextManager.h" + +#ifndef __RULESET_H__ +#define __RULESET_H__ + +class Ruleset +{ + public: + Ruleset(); + virtual ~Ruleset() {} + + void Initialize(); + void Skip(); + + virtual void OnGameOver(); + virtual void Update(); + virtual void HandleInput(); + + protected: + ScoreManager mScoreManager; + HitObjectManager mHitObjectManager; + SpriteManager mSpriteManager; + Lifebar mLifebar; + + virtual void OnSkip() = 0; +}; + +#endif + diff --git a/arm9/source/Rulesets/RulesetOsu.cpp b/source/Rulesets/RulesetOsu.cpp similarity index 95% rename from arm9/source/Rulesets/RulesetOsu.cpp rename to source/Rulesets/RulesetOsu.cpp index 764401a..6a931c2 100644 --- a/arm9/source/Rulesets/RulesetOsu.cpp +++ b/source/Rulesets/RulesetOsu.cpp @@ -1,125 +1,125 @@ -#include "RulesetOsu.h" - -RulesetOsu::RulesetOsu() -{ - HitObject::SetScoreCallback(this); - mScoreZ = 0; - mSpecialScore = 0; -} - -void RulesetOsu::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, HitObjectPoint point, bool comboEnd) -{ - s32 now = GameClock::Clock().Time(); - - TextureType tex; - float hpIncrease; - - switch (score) - { - case SCORE_300: - if (comboEnd) - { - tex = (TextureType)(TX_PLAY_HIT300 + mSpecialScore); - mSpecialScore = 2; - hpIncrease = Lifebar::HP_300 + (mSpecialScore == 2 ? Lifebar::HP_GEKI : (mSpecialScore == 1 ? Lifebar::HP_KATSU : 0)); - } - else - { - tex = TX_PLAY_HIT300; - hpIncrease = Lifebar::HP_300; - } - break; - - case SCORE_100: - mSpecialScore = (mSpecialScore > 1 ? 1 : mSpecialScore); - if (comboEnd) - { - tex = (TextureType)(TX_PLAY_HIT100 + mSpecialScore); - mSpecialScore = 2; - hpIncrease = Lifebar::HP_100 + (mSpecialScore == 1 ? Lifebar::HP_KATSU : 0); - } - else - { - tex = TX_PLAY_HIT100; - hpIncrease = Lifebar::HP_100; - } - break; - - case SCORE_50: - mSpecialScore = (comboEnd ? 2 : 0); - tex = TX_PLAY_HIT50; - hpIncrease = Lifebar::HP_50; - break; - - case SCORE_MISS: - default: - mSpecialScore = (comboEnd ? 2 : 0); - tex = TX_PLAY_HIT0; - hpIncrease = DifficultyManager::GetMissHpDrain(); - break; - - case SCORE_TICK_30: - hpIncrease = Lifebar::HP_SLIDER_REPEAT; - break; - - case SCORE_TICK_10: - hpIncrease = Lifebar::HP_SLIDER_TICK; - break; - - case SCORE_SPIN_100: - hpIncrease = Lifebar::HP_SPINNER_SPIN; - break; - - case SCORE_SPIN_1000: - hpIncrease = Lifebar::HP_SPINNER_BONUS; - break; - } - - mScoreManager.Add(score, forceNoCombo); - mLifebar.Increase(hpIncrease); - - if (!forceNoAnimation) - { - pSprite* spr = new pSprite(tex, point.x, point.y, 160, 160, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0, mScoreZ); - spr->Show(now, now+100); - spr->Hide(now+500, now+1000); - spr->Kill(now+1500); - - //NEGATIVE deltaz to bring to front - mScoreZ -= 0.02f; - - if (tex == TX_PLAY_HIT0) - { - spr->Scale(now, now+100, 2, 1); - } - else - { - spr->Scale(now, now+100, 0.8, 1); - } - - mSpriteManager.Add(spr); - } -} - -void RulesetOsu::OnSkip() -{ - mLifebar.ClearTransforms(); - mLifebar.Increase(Lifebar::MAXHP); -} - -void RulesetOsu::OnGameOver() -{ - //HitObject::SetScoreCallback(NULL); -} - -void RulesetOsu::DoCallback(void** args) -{ - IncreaseScore( - ARGS_POP(args, 0, ScoreType), - ARGS_POP(args, 1, bool), - ARGS_POP(args, 2, bool), - ARGS_POP(args, 3, HitObjectPoint), - ARGS_POP(args, 4, bool) - ); -} - +#include "RulesetOsu.h" + +RulesetOsu::RulesetOsu() +{ + HitObject::SetScoreCallback(this); + mScoreZ = 0; + mSpecialScore = 0; +} + +void RulesetOsu::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, HitObjectPoint point, bool comboEnd) +{ + s32 now = GameClock::Clock().Time(); + + TextureType tex; + float hpIncrease; + + switch (score) + { + case SCORE_300: + if (comboEnd) + { + tex = (TextureType)(TX_PLAY_HIT300 + mSpecialScore); + mSpecialScore = 2; + hpIncrease = Lifebar::HP_300 + (mSpecialScore == 2 ? Lifebar::HP_GEKI : (mSpecialScore == 1 ? Lifebar::HP_KATSU : 0)); + } + else + { + tex = TX_PLAY_HIT300; + hpIncrease = Lifebar::HP_300; + } + break; + + case SCORE_100: + mSpecialScore = (mSpecialScore > 1 ? 1 : mSpecialScore); + if (comboEnd) + { + tex = (TextureType)(TX_PLAY_HIT100 + mSpecialScore); + mSpecialScore = 2; + hpIncrease = Lifebar::HP_100 + (mSpecialScore == 1 ? Lifebar::HP_KATSU : 0); + } + else + { + tex = TX_PLAY_HIT100; + hpIncrease = Lifebar::HP_100; + } + break; + + case SCORE_50: + mSpecialScore = (comboEnd ? 2 : 0); + tex = TX_PLAY_HIT50; + hpIncrease = Lifebar::HP_50; + break; + + case SCORE_MISS: + default: + mSpecialScore = (comboEnd ? 2 : 0); + tex = TX_PLAY_HIT0; + hpIncrease = DifficultyManager::GetMissHpDrain(); + break; + + case SCORE_TICK_30: + hpIncrease = Lifebar::HP_SLIDER_REPEAT; + break; + + case SCORE_TICK_10: + hpIncrease = Lifebar::HP_SLIDER_TICK; + break; + + case SCORE_SPIN_100: + hpIncrease = Lifebar::HP_SPINNER_SPIN; + break; + + case SCORE_SPIN_1000: + hpIncrease = Lifebar::HP_SPINNER_BONUS; + break; + } + + mScoreManager.Add(score, forceNoCombo); + mLifebar.Increase(hpIncrease); + + if (!forceNoAnimation) + { + pSprite* spr = new pSprite(tex, point.x, point.y, 160, 160, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0, mScoreZ); + spr->Show(now, now+100); + spr->Hide(now+500, now+1000); + spr->Kill(now+1500); + + //NEGATIVE deltaz to bring to front + mScoreZ -= 0.02f; + + if (tex == TX_PLAY_HIT0) + { + spr->Scale(now, now+100, 2, 1); + } + else + { + spr->Scale(now, now+100, 0.8, 1); + } + + mSpriteManager.Add(spr); + } +} + +void RulesetOsu::OnSkip() +{ + mLifebar.ClearTransforms(); + mLifebar.Increase(Lifebar::MAXHP); +} + +void RulesetOsu::OnGameOver() +{ + //HitObject::SetScoreCallback(NULL); +} + +void RulesetOsu::DoCallback(void** args) +{ + IncreaseScore( + ARGS_POP(args, 0, ScoreType), + ARGS_POP(args, 1, bool), + ARGS_POP(args, 2, bool), + ARGS_POP(args, 3, HitObjectPoint), + ARGS_POP(args, 4, bool) + ); +} + diff --git a/arm9/source/Rulesets/RulesetOsu.h b/source/Rulesets/RulesetOsu.h similarity index 94% rename from arm9/source/Rulesets/RulesetOsu.h rename to source/Rulesets/RulesetOsu.h index c6dba93..4535151 100644 --- a/arm9/source/Rulesets/RulesetOsu.h +++ b/source/Rulesets/RulesetOsu.h @@ -1,29 +1,29 @@ -#include -#include - -#include "Ruleset.h" -#include "HitObjects/HitObject.h" -#include "System/ICallback.h" - -#ifndef __RULESETOSU_H__ -#define __RULESETOSU_H__ - -class RulesetOsu : public Ruleset, public ICallback -{ - public: - RulesetOsu(); - ~RulesetOsu() {} - - void IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, HitObjectPoint point, bool comboEnd); - void OnSkip(); - void OnGameOver(); - - void DoCallback(void** args); - - protected: - u32 mSpecialScore; - float mScoreZ; -}; - -#endif - +#include +#include + +#include "Ruleset.h" +#include "HitObjects/HitObject.h" +#include "System/ICallback.h" + +#ifndef __RULESETOSU_H__ +#define __RULESETOSU_H__ + +class RulesetOsu : public Ruleset, public ICallback +{ + public: + RulesetOsu(); + ~RulesetOsu() {} + + void IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, HitObjectPoint point, bool comboEnd); + void OnSkip(); + void OnGameOver(); + + void DoCallback(void** args); + + protected: + u32 mSpecialScore; + float mScoreZ; +}; + +#endif + diff --git a/arm9/source/System/GameBase.cpp b/source/System/GameBase.cpp similarity index 94% rename from arm9/source/System/GameBase.cpp rename to source/System/GameBase.cpp index 2a23ac2..9a64e7e 100644 --- a/arm9/source/System/GameBase.cpp +++ b/source/System/GameBase.cpp @@ -1,15 +1,15 @@ -#include "GameBase.h" - -GameBase::GameBase() -{ - BeatmapManager::BuildCollection(); - //ChangeMode(MODE_PLAYER); - ChangeMode(MODE_SONGSELECT); -} - -void GameBase::Update() -{ - Mode::CurrentMode().HandleInput(); - Mode::CurrentMode().Update(); +#include "GameBase.h" + +GameBase::GameBase() +{ + BeatmapManager::BuildCollection(); + //ChangeMode(MODE_PLAYER); + ChangeMode(MODE_SONGSELECT); } - + +void GameBase::Update() +{ + Mode::CurrentMode().HandleInput(); + Mode::CurrentMode().Update(); +} + diff --git a/arm9/source/System/GameBase.h b/source/System/GameBase.h similarity index 92% rename from arm9/source/System/GameBase.h rename to source/System/GameBase.h index fe06947..d17aad9 100644 --- a/arm9/source/System/GameBase.h +++ b/source/System/GameBase.h @@ -1,14 +1,14 @@ -#include -#include - -#include "GameClock.h" -#include "Modes/Mode.h" -#include "Beatmaps/BeatmapManager.h" - -class GameBase -{ - public: - GameBase(); - void Update(); -}; - +#include +#include + +#include "GameClock.h" +#include "Modes/Mode.h" +#include "Beatmaps/BeatmapManager.h" + +class GameBase +{ + public: + GameBase(); + void Update(); +}; + diff --git a/arm9/source/System/GameClock.cpp b/source/System/GameClock.cpp similarity index 93% rename from arm9/source/System/GameClock.cpp rename to source/System/GameClock.cpp index c9dd4b1..c10110b 100644 --- a/arm9/source/System/GameClock.cpp +++ b/source/System/GameClock.cpp @@ -1,74 +1,74 @@ -#include "GameClock.h" - -GameClock GameClock::sClock; - -GameClock::GameClock() -{ - /* - TIMER1_DATA = 32022; - TIMER1_CR = TIMER_DIV_1; - - SkipTo(0); - */ - mTime = 0; - mFraction = 0; -} - -s32 GameClock::Time() -{ - return mTime; -} - -void GameClock::Update() -{ - mTime += kTimeInterval; - mFraction += kFractionInterval; - - if (mFraction > 1000000000) - { - ++mTime; - mFraction -= 1000000000; - } -} - - -/* -void GameClock::CacheTime() -{ - //lock the values when reading - TIMER2_CR &= ~TIMER_ENABLE; - register u16 d2 = TIMER2_DATA; - register u16 d3 = TIMER3_DATA; - TIMER2_DATA = d2; - TIMER2_CR |= TIMER_ENABLE; - - mTime = d2 + (d3 << 16); -} -*/ - -void GameClock::SkipTo(s32 time) -{ - mTime = time; - mFraction = 0; - /* - TIMER2_DATA = (u16)(time & 0xFFFF); - TIMER3_DATA = (u16)(time >> 16); - - TIMER1_CR &= ~TIMER_ENABLE; - - TIMER2_CR = 0; - TIMER2_CR = TIMER_ENABLE | TIMER_CASCADE; - - TIMER3_CR = 0; - TIMER3_CR = TIMER_ENABLE | TIMER_CASCADE; - - TIMER1_CR |= TIMER_ENABLE; - */ -} - -void GameClock::Reset() -{ - SkipTo(0); -} - - +#include "GameClock.h" + +GameClock GameClock::sClock; + +GameClock::GameClock() +{ + /* + TIMER1_DATA = 32022; + TIMER1_CR = TIMER_DIV_1; + + SkipTo(0); + */ + mTime = 0; + mFraction = 0; +} + +s32 GameClock::Time() +{ + return mTime; +} + +void GameClock::Update() +{ + mTime += kTimeInterval; + mFraction += kFractionInterval; + + if (mFraction > 1000000000) + { + ++mTime; + mFraction -= 1000000000; + } +} + + +/* +void GameClock::CacheTime() +{ + //lock the values when reading + TIMER2_CR &= ~TIMER_ENABLE; + register u16 d2 = TIMER2_DATA; + register u16 d3 = TIMER3_DATA; + TIMER2_DATA = d2; + TIMER2_CR |= TIMER_ENABLE; + + mTime = d2 + (d3 << 16); +} +*/ + +void GameClock::SkipTo(s32 time) +{ + mTime = time; + mFraction = 0; + /* + TIMER2_DATA = (u16)(time & 0xFFFF); + TIMER3_DATA = (u16)(time >> 16); + + TIMER1_CR &= ~TIMER_ENABLE; + + TIMER2_CR = 0; + TIMER2_CR = TIMER_ENABLE | TIMER_CASCADE; + + TIMER3_CR = 0; + TIMER3_CR = TIMER_ENABLE | TIMER_CASCADE; + + TIMER1_CR |= TIMER_ENABLE; + */ +} + +void GameClock::Reset() +{ + SkipTo(0); +} + + diff --git a/arm9/source/System/GameClock.h b/source/System/GameClock.h similarity index 93% rename from arm9/source/System/GameClock.h rename to source/System/GameClock.h index 673b4ff..fd8aeec 100644 --- a/arm9/source/System/GameClock.h +++ b/source/System/GameClock.h @@ -1,32 +1,32 @@ -#include - -#ifndef __GAMECLOCK_H__ -#define __GAMECLOCK_H__ - -class GameClock -{ - public: - s32 Time(); - - void Update(); //calls should be synced with vblank - void SkipTo(s32 time); - void Reset(); - - static GameClock& Clock() { return sClock; } - - protected: - s32 mTime; - s32 mFraction; - - static const s32 kTimeInterval = 16; - static const s32 kFractionInterval = 715112635; - - static GameClock sClock; - - private: - GameClock(); - ~GameClock() {} -}; - -#endif - +#include + +#ifndef __GAMECLOCK_H__ +#define __GAMECLOCK_H__ + +class GameClock +{ + public: + s32 Time(); + + void Update(); //calls should be synced with vblank + void SkipTo(s32 time); + void Reset(); + + static GameClock& Clock() { return sClock; } + + protected: + s32 mTime; + s32 mFraction; + + static const s32 kTimeInterval = 16; + static const s32 kFractionInterval = 715112635; + + static GameClock sClock; + + private: + GameClock(); + ~GameClock() {} +}; + +#endif + diff --git a/arm9/source/System/ICallback.h b/source/System/ICallback.h similarity index 94% rename from arm9/source/System/ICallback.h rename to source/System/ICallback.h index 0150000..46db8a2 100644 --- a/arm9/source/System/ICallback.h +++ b/source/System/ICallback.h @@ -1,20 +1,20 @@ -#include -#include -#include - -#ifndef __ICALLBACK_H__ -#define __ICALLBACK_H__ - -#define ARGS_PUSH(array, id, argument) array[id] = (void*)(&argument); -#define ARGS_POP(array, id, type) *((type*)array[id]) - -using namespace std; - -class ICallback -{ - public: - virtual void DoCallback(void** args) = 0; -}; - -#endif - +#include +#include +#include + +#ifndef __ICALLBACK_H__ +#define __ICALLBACK_H__ + +#define ARGS_PUSH(array, id, argument) array[id] = (void*)(&argument); +#define ARGS_POP(array, id, type) *((type*)array[id]) + +using namespace std; + +class ICallback +{ + public: + virtual void DoCallback(void** args) = 0; +}; + +#endif + diff --git a/arm9/source/System/TextManager.cpp b/source/System/TextManager.cpp similarity index 95% rename from arm9/source/System/TextManager.cpp rename to source/System/TextManager.cpp index c00fbb6..d137118 100644 --- a/arm9/source/System/TextManager.cpp +++ b/source/System/TextManager.cpp @@ -1,160 +1,160 @@ -#include "TextManager.h" - -TextManager TextManager::sTop; -TextManager TextManager::sBottom; - -TextManager::TextManager() -{ -} - -void TextManager::Init() -{ - sBottom.mConsole = (gfxPrintConsole*)malloc(sizeof(gfxPrintConsole)); - sTop.mConsole = (gfxPrintConsole*)malloc(sizeof(gfxPrintConsole)); - - gfxConsoleInit(sBottom.mConsole, BgType_Bmp16, BgSize_B16_256x256, true, true); - gfxConsoleInit(sTop.mConsole, BgType_Bmp16, BgSize_B16_256x256, false, true); - - AddFont(FONT_CONSOLE, hoo06_bmf); - AddFont(FONT_SCORE, gomics_bmf); - AddFont(FONT_NUMBERING, _370_bmf); - AddFont(FONT_VERDANA, ver08_bmf); -} - -void TextManager::AddFont(FONT font, const u8* data) -{ - BMFont* bmf = (BMFont*)malloc(sizeof(BMFont)); - LoadBMFont(bmf, data); - sBottom.mFonts[font] = gfxConsoleAddFont(sBottom.mConsole, bmf); - sTop.mFonts[font] = gfxConsoleAddFont(sTop.mConsole, bmf); -} - -void TextManager::Warn(char* format, ...) -{ - gfxConsoleSelect(sTop.mConsole); - iprintf("\x1b[31;1;47;7;1m\n"); - va_list args; - va_start(args, format); - vprintf(format, args); - va_end(args); - iprintf("\n\x1b[0m"); -} - -void TextManager::SetFont(FONT font) -{ - gfxConsoleSetFont(mConsole, mFonts[font]); -} - -void TextManager::PrintFloat(char* format, ...) -{ - gfxConsoleSelect(mConsole); - va_list args; - va_start(args, format); - vprintf(format, args); - va_end(args); -} - -void TextManager::Print(char* format, ...) -{ - gfxConsoleSelect(mConsole); - va_list args; - va_start(args, format); - viprintf(format, args); - va_end(args); -} - -void TextManager::Clear() -{ - gfxConsoleSelect(mConsole); - gfxConsoleClear(); -} - -void TextManager::PrintLocate(int x, int y, DrawOrigin origin, char* format, ...) -{ - gfxConsoleSelect(mConsole); - - // convert from 640x480 (expected values) to 256x192 (internal values) - x = (int)(x/2.5f); - y = (int)(y/2.5f); - - va_list args; - va_start(args, format); - - // if we're printing from top left, we don't need to know width and height - if (origin == ORIGIN_TOPLEFT) - { - iprintf("\x1b[%i;%iX", y, x); - viprintf(format, args); - va_end(args); - return; - } - - // otherwise we need to know the width and height - char* tmp; - - vasiprintf(&tmp, format, args); - va_end(args); - - // for calculating width - vector lines; - lines.reserve(10); - - // height depends on the number of new lines - char* pos = strchr(tmp, '\n'); - while (pos != NULL) - { - *pos = '\0'; - lines.push_back(tmp); - - tmp = pos+1; - pos = strchr(tmp, '\n'); - } - lines.push_back(tmp); - - // multiply by line height for pixel value - int height = lines.size() * mConsole->font[mConsole->curFont]->Head->bLineHeight; - - //width depends on the characters themselves, we use the longest line - int width = 0; - for (u32 i=0; ifont[mConsole->curFont]->Ltrs[tmp[j]]->bShift; - } - - if (current > width) - width = current; - } - - // now that we have x,y,width,height we can calculate the actual location - switch (origin) - { - case ORIGIN_TOPLEFT: - break; // special case - would not reach this point - - case ORIGIN_CENTER: - x -= width >> 1; - y -= height >> 1; - break; - - case ORIGIN_BOTTOMLEFT: - y -= height; - break; - - case ORIGIN_TOPRIGHT: - x -= width; - break; - } - - // move cursor y pos - iprintf("\x1b[%iy", y); - - // dump information with x pos - for (int i=0; i 0 && x + width < 640) - iprintf("\x1b[%ix%s\n", x, lines[i]); -} - +#include "TextManager.h" + +TextManager TextManager::sTop; +TextManager TextManager::sBottom; + +TextManager::TextManager() +{ +} + +void TextManager::Init() +{ + sBottom.mConsole = (gfxPrintConsole*)malloc(sizeof(gfxPrintConsole)); + sTop.mConsole = (gfxPrintConsole*)malloc(sizeof(gfxPrintConsole)); + + gfxConsoleInit(sBottom.mConsole, BgType_Bmp16, BgSize_B16_256x256, true, true); + gfxConsoleInit(sTop.mConsole, BgType_Bmp16, BgSize_B16_256x256, false, true); + + AddFont(FONT_CONSOLE, hoo06_bmf); + AddFont(FONT_SCORE, gomics_bmf); + AddFont(FONT_NUMBERING, _370_bmf); + AddFont(FONT_VERDANA, ver08_bmf); +} + +void TextManager::AddFont(FONT font, const u8* data) +{ + BMFont* bmf = (BMFont*)malloc(sizeof(BMFont)); + LoadBMFont(bmf, data); + sBottom.mFonts[font] = gfxConsoleAddFont(sBottom.mConsole, bmf); + sTop.mFonts[font] = gfxConsoleAddFont(sTop.mConsole, bmf); +} + +void TextManager::Warn(char* format, ...) +{ + gfxConsoleSelect(sTop.mConsole); + iprintf("\x1b[31;1;47;7;1m\n"); + va_list args; + va_start(args, format); + vprintf(format, args); + va_end(args); + iprintf("\n\x1b[0m"); +} + +void TextManager::SetFont(FONT font) +{ + gfxConsoleSetFont(mConsole, mFonts[font]); +} + +void TextManager::PrintFloat(char* format, ...) +{ + gfxConsoleSelect(mConsole); + va_list args; + va_start(args, format); + vprintf(format, args); + va_end(args); +} + +void TextManager::Print(char* format, ...) +{ + gfxConsoleSelect(mConsole); + va_list args; + va_start(args, format); + viprintf(format, args); + va_end(args); +} + +void TextManager::Clear() +{ + gfxConsoleSelect(mConsole); + gfxConsoleClear(); +} + +void TextManager::PrintLocate(int x, int y, DrawOrigin origin, char* format, ...) +{ + gfxConsoleSelect(mConsole); + + // convert from 640x480 (expected values) to 256x192 (internal values) + x = (int)(x/2.5f); + y = (int)(y/2.5f); + + va_list args; + va_start(args, format); + + // if we're printing from top left, we don't need to know width and height + if (origin == ORIGIN_TOPLEFT) + { + iprintf("\x1b[%i;%iX", y, x); + viprintf(format, args); + va_end(args); + return; + } + + // otherwise we need to know the width and height + char* tmp; + + vasiprintf(&tmp, format, args); + va_end(args); + + // for calculating width + vector lines; + lines.reserve(10); + + // height depends on the number of new lines + char* pos = strchr(tmp, '\n'); + while (pos != NULL) + { + *pos = '\0'; + lines.push_back(tmp); + + tmp = pos+1; + pos = strchr(tmp, '\n'); + } + lines.push_back(tmp); + + // multiply by line height for pixel value + int height = lines.size() * mConsole->font[mConsole->curFont]->Head->bLineHeight; + + //width depends on the characters themselves, we use the longest line + int width = 0; + for (u32 i=0; ifont[mConsole->curFont]->Ltrs[tmp[j]]->bShift; + } + + if (current > width) + width = current; + } + + // now that we have x,y,width,height we can calculate the actual location + switch (origin) + { + case ORIGIN_TOPLEFT: + break; // special case - would not reach this point + + case ORIGIN_CENTER: + x -= width >> 1; + y -= height >> 1; + break; + + case ORIGIN_BOTTOMLEFT: + y -= height; + break; + + case ORIGIN_TOPRIGHT: + x -= width; + break; + } + + // move cursor y pos + iprintf("\x1b[%iy", y); + + // dump information with x pos + for (int i=0; i 0 && x + width < 640) + iprintf("\x1b[%ix%s\n", x, lines[i]); +} + diff --git a/arm9/source/System/TextManager.h b/source/System/TextManager.h similarity index 94% rename from arm9/source/System/TextManager.h rename to source/System/TextManager.h index 7fe730a..787c1a0 100644 --- a/arm9/source/System/TextManager.h +++ b/source/System/TextManager.h @@ -1,60 +1,60 @@ -#include -#include -#include -#include - -#include "Graphics/GraphicsManager.h" -#include "Libraries/gfxconsole.h" - -#include "hoo06_bmf.h" -#include "gomics_bmf.h" -#include "370_bmf.h" -#include "ver08_bmf.h" - -#ifndef __TEXTMANAGER_H__ -#define __TEXTMANAGER_H__ - -#define NUMBER_OF_FONTS 4 - -typedef enum { - FONT_CONSOLE, - FONT_SCORE, - FONT_NUMBERING, - FONT_VERDANA -} FONT; - -using namespace std; - -class TextManager -{ - public: - static TextManager& Top() { return sTop; } - static TextManager& Bottom() { return sBottom; } - - static void Init(); - - static void Warn(char* format, ...); - - void SetFont(FONT font); - - void PrintFloat(char* format, ...); - void Print(char* format, ...); - void Clear(); - - void PrintLocate(int x, int y, DrawOrigin origin, char* format, ...); - - protected: - gfxPrintConsole* mConsole; - int mFonts[NUMBER_OF_FONTS]; - - static TextManager sTop, sBottom; - - static void AddFont(FONT font, const u8* data); - - private: - TextManager(); - -}; - -#endif - +#include +#include +#include +#include + +#include "Graphics/GraphicsManager.h" +#include "Libraries/gfxconsole.h" + +#include "hoo06_bmf.h" +#include "gomics_bmf.h" +#include "370_bmf.h" +#include "ver08_bmf.h" + +#ifndef __TEXTMANAGER_H__ +#define __TEXTMANAGER_H__ + +#define NUMBER_OF_FONTS 4 + +typedef enum { + FONT_CONSOLE, + FONT_SCORE, + FONT_NUMBERING, + FONT_VERDANA +} FONT; + +using namespace std; + +class TextManager +{ + public: + static TextManager& Top() { return sTop; } + static TextManager& Bottom() { return sBottom; } + + static void Init(); + + static void Warn(char* format, ...); + + void SetFont(FONT font); + + void PrintFloat(char* format, ...); + void Print(char* format, ...); + void Clear(); + + void PrintLocate(int x, int y, DrawOrigin origin, char* format, ...); + + protected: + gfxPrintConsole* mConsole; + int mFonts[NUMBER_OF_FONTS]; + + static TextManager sTop, sBottom; + + static void AddFont(FONT font, const u8* data); + + private: + TextManager(); + +}; + +#endif + diff --git a/arm9/source/defines.h b/source/defines.h similarity index 94% rename from arm9/source/defines.h rename to source/defines.h index a1546c2..c1d9547 100644 --- a/arm9/source/defines.h +++ b/source/defines.h @@ -1 +1 @@ -#define HARDWARE +#define HARDWARE diff --git a/arm9/source/exception.c b/source/exception.c similarity index 93% rename from arm9/source/exception.c rename to source/exception.c index dd7fc39..279d7a8 100644 --- a/arm9/source/exception.c +++ b/source/exception.c @@ -1,261 +1,261 @@ -/*--------------------------------------------------------------------------------- - - Copyright (C) 2005 - Dave Murphy (WinterMute) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any - damages arising from the use of this software. - - Permission is granted to anyone to use this software for any - purpose, including commercial applications, and to alter it and - redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you - must not claim that you wrote the original software. If you use - this software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and - must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. - ----------------------------------------------------------------------------------*/ -/* -#include -#include - -#include -#include -#include -#include -*/ -#include - -#include - -//--------------------------------------------------------------------------------- -unsigned long ARMShift(unsigned long value,unsigned char shift) { -//--------------------------------------------------------------------------------- - // no shift at all - if (shift == 0x0B) return value ; - int index ; - if (shift & 0x01) { - // shift index is a register - index = exceptionRegisters[(shift >> 4) & 0x0F]; - } else { - // constant shift index - index = ((shift >> 3) & 0x1F) ; - } ; - int i ; - bool isN ; - switch (shift & 0x06) { - case 0x00: - // logical left - return (value << index) ; - case 0x02: - // logical right - return (value >> index) ; - case 0x04: - // arithmetical right - isN = (value & 0x80000000) ; - value = value >> index ; - if (isN) { - for (i=31;i>31-index;i--) { - value = value | (1 << i) ; - } ; - } ; - return value ; - case 0x06: - // rotate right - index = index & 0x1F; - value = (value >> index) | (value << (32-index)); - return value; - }; - return value; -} - - -//--------------------------------------------------------------------------------- -u32 getExceptionAddress( u32 opcodeAddress, u32 thumbState) { -//--------------------------------------------------------------------------------- - - int Rf, Rb, Rd, Rn, Rm; - - if (thumbState) { - // Thumb - - unsigned short opcode = *(unsigned short *)opcodeAddress ; - // ldr r,[pc,###] 01001ddd ffffffff - // ldr r,[r,r] 0101xx0f ffbbbddd - // ldrsh 0101xx1f ffbbbddd - // ldr r,[r,imm] 011xxfff ffbbbddd - // ldrh 1000xfff ffbbbddd - // ldr r,[sp,###] 1001xddd ffffffff - // push 1011x10l llllllll - // ldm 1100xbbb llllllll - - - if ((opcode & 0xF800) == 0x4800) { - // ldr r,[pc,###] - s8 offset = opcode & 0xff; - return exceptionRegisters[15] + offset; - } else if ((opcode & 0xF200) == 0x5000) { - // ldr r,[r,r] - Rb = (opcode >> 3) & 0x07 ; - Rf = (opcode >> 6) & 0x07 ; - return exceptionRegisters[Rb] + exceptionRegisters[Rf]; - - } else if ((opcode & 0xF200) == 0x5200) { - // ldrsh - Rb = (opcode >> 3) & 0x07; - Rf = (opcode >> 6) & 0x03; - return exceptionRegisters[Rb] + exceptionRegisters[Rf]; - - } else if ((opcode & 0xE000) == 0x6000) { - // ldr r,[r,imm] - Rb = (opcode >> 3) & 0x07; - Rf = (opcode >> 6) & 0x1F ; - return exceptionRegisters[Rb] + (Rf << 2); - } else if ((opcode & 0xF000) == 0x8000) { - // ldrh - Rb = (opcode >> 3) & 0x07 ; - Rf = (opcode >> 6) & 0x1F ; - return exceptionRegisters[Rb] + (Rf << 2); - } else if ((opcode & 0xF000) == 0x9000) { - // ldr r,[sp,#imm] - s8 offset = opcode & 0xff; - return exceptionRegisters[13] + offset; - } else if ((opcode & 0xF700) == 0xB500) { - // push/pop - return exceptionRegisters[13]; - } else if ((opcode & 0xF000) == 0xC000) { - // ldm/stm - Rd = (opcode >> 8) & 0x07; - return exceptionRegisters[Rd]; - } - } else { - // arm32 - unsigned long opcode = *(unsigned long *)opcodeAddress ; - - // SWP xxxx0001 0x00nnnn dddd0000 1001mmmm - // STR/LDR xxxx01xx xxxxnnnn ddddffff ffffffff - // STRH/LDRH xxxx000x x0xxnnnn dddd0000 1xx1mmmm - // STRH/LDRH xxxx000x x1xxnnnn ddddffff 1xx1ffff - // STM/LDM xxxx100x xxxxnnnn llllllll llllllll - - if ((opcode & 0x0FB00FF0) == 0x01000090) { - // SWP - Rn = (opcode >> 16) & 0x0F; - return exceptionRegisters[Rn]; - } else if ((opcode & 0x0C000000) == 0x04000000) { - // STR/LDR - Rn = (opcode >> 16) & 0x0F; - if (opcode & 0x02000000) { - // Register offset - Rm = opcode & 0x0F; - if (opcode & 0x01000000) { - unsigned short shift = (unsigned short)((opcode >> 4) & 0xFF) ; - // pre indexing - long Offset = ARMShift(exceptionRegisters[Rm],shift); - // add or sub the offset depending on the U-Bit - return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset); - } else { - // post indexing - return exceptionRegisters[Rn]; - } - } else { - // Immediate offset - unsigned long Offset = (opcode & 0xFFF) ; - if (opcode & 0x01000000) { - // pre indexing - // add or sub the offset depending on the U-Bit - return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset); - } else { - // post indexing - return exceptionRegisters[Rn]; - } - } - } else if ((opcode & 0x0E400F90) == 0x00000090) { - // LDRH/STRH with register Rm - Rn = (opcode >> 16) & 0x0F; - Rd = (opcode >> 12) & 0x0F; - Rm = opcode & 0x0F; - unsigned short shift = (unsigned short)((opcode >> 4) & 0xFF); - long Offset = ARMShift(exceptionRegisters[Rm],shift); - // add or sub the offset depending on the U-Bit - return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset); - } else if ((opcode & 0x0E400F90) == 0x00400090) { - // LDRH/STRH with immediate offset - Rn = (opcode >> 16) & 0x0F; - Rd = (opcode >> 12) & 0x0F; - unsigned long Offset = (opcode & 0xF) | ((opcode & 0xF00)>>8) ; - // add or sub the offset depending on the U-Bit - return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset) ; - } else if ((opcode & 0x0E000000) == 0x08000000) { - // LDM/STM - Rn = (opcode >> 16) & 0x0F; - return exceptionRegisters[Rn]; - } - } - return 0; -} - -static const char *registerNames[] = - { "r0","r1","r2","r3","r4","r5","r6","r7", - "r8 ","r9 ","r10","r11","r12","sp ","lr ","pc " }; - -extern const char __itcm_start[]; -//--------------------------------------------------------------------------------- -void customHandler() { -//--------------------------------------------------------------------------------- - consoleDemoInit(); - - BG_PALETTE[0] = RGB15(31,0,0); - BG_PALETTE[255] = RGB15(31,31,31); - - - iprintf("\x1b[5CGuru Meditation Error!\n"); - u32 currentMode = getCPSR() & 0x1f; - u32 thumbState = ((*(u32*)0x027FFD90) & 0x20); - - u32 codeAddress, exceptionAddress = 0; - - int offset = 8; - - if ( currentMode == 0x17 ) { - iprintf ("\x1b[10Cdata abort!\n\n"); - codeAddress = exceptionRegisters[15] - offset; - if ( (codeAddress > 0x02000000 && codeAddress < 0x02400000) || - (codeAddress > (u32)__itcm_start && codeAddress < (u32)(__itcm_start + 32768)) ) - exceptionAddress = getExceptionAddress( codeAddress, thumbState); - else - exceptionAddress = codeAddress; - - } else { - if (thumbState) - offset = 2; - else - offset = 4; - iprintf("\x1b[5Cundefined instruction!\n\n"); - codeAddress = exceptionRegisters[15] - offset; - exceptionAddress = codeAddress; - } - - iprintf(" pc: %08X addr: %08X\n\n",codeAddress,exceptionAddress); - - int i; - for ( i=0; i < 8; i++ ) { - iprintf( " %s: %08X %s: %08X\n", - registerNames[i], exceptionRegisters[i], - registerNames[i+8],exceptionRegisters[i+8]); - } - iprintf("\x1b[2J"); - u32 *stack = (u32 *)exceptionRegisters[13]; - for ( i=0; i<24; i++ ) { - iprintf( "\x1b[%d;2H%08X: %08X %08X", i, (u32)&stack[i*2],stack[i*2], stack[(i*2)+1] ); - } - while(1) swiWaitForVBlank(); - -} - +/*--------------------------------------------------------------------------------- + + Copyright (C) 2005 + Dave Murphy (WinterMute) + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + +---------------------------------------------------------------------------------*/ +/* +#include +#include + +#include +#include +#include +#include +*/ +#include + +#include + +//--------------------------------------------------------------------------------- +unsigned long ARMShiftO(unsigned long value,unsigned char shift) { +//--------------------------------------------------------------------------------- + // no shift at all + if (shift == 0x0B) return value ; + int index ; + if (shift & 0x01) { + // shift index is a register + index = exceptionRegisters[(shift >> 4) & 0x0F]; + } else { + // constant shift index + index = ((shift >> 3) & 0x1F) ; + } ; + int i ; + bool isN ; + switch (shift & 0x06) { + case 0x00: + // logical left + return (value << index) ; + case 0x02: + // logical right + return (value >> index) ; + case 0x04: + // arithmetical right + isN = (value & 0x80000000) ; + value = value >> index ; + if (isN) { + for (i=31;i>31-index;i--) { + value = value | (1 << i) ; + } ; + } ; + return value ; + case 0x06: + // rotate right + index = index & 0x1F; + value = (value >> index) | (value << (32-index)); + return value; + }; + return value; +} + + +//--------------------------------------------------------------------------------- +u32 getExceptionAddressO( u32 opcodeAddress, u32 thumbState) { +//--------------------------------------------------------------------------------- + + int Rf, Rb, Rd, Rn, Rm; + + if (thumbState) { + // Thumb + + unsigned short opcode = *(unsigned short *)opcodeAddress ; + // ldr r,[pc,###] 01001ddd ffffffff + // ldr r,[r,r] 0101xx0f ffbbbddd + // ldrsh 0101xx1f ffbbbddd + // ldr r,[r,imm] 011xxfff ffbbbddd + // ldrh 1000xfff ffbbbddd + // ldr r,[sp,###] 1001xddd ffffffff + // push 1011x10l llllllll + // ldm 1100xbbb llllllll + + + if ((opcode & 0xF800) == 0x4800) { + // ldr r,[pc,###] + s8 offset = opcode & 0xff; + return exceptionRegisters[15] + offset; + } else if ((opcode & 0xF200) == 0x5000) { + // ldr r,[r,r] + Rb = (opcode >> 3) & 0x07 ; + Rf = (opcode >> 6) & 0x07 ; + return exceptionRegisters[Rb] + exceptionRegisters[Rf]; + + } else if ((opcode & 0xF200) == 0x5200) { + // ldrsh + Rb = (opcode >> 3) & 0x07; + Rf = (opcode >> 6) & 0x03; + return exceptionRegisters[Rb] + exceptionRegisters[Rf]; + + } else if ((opcode & 0xE000) == 0x6000) { + // ldr r,[r,imm] + Rb = (opcode >> 3) & 0x07; + Rf = (opcode >> 6) & 0x1F ; + return exceptionRegisters[Rb] + (Rf << 2); + } else if ((opcode & 0xF000) == 0x8000) { + // ldrh + Rb = (opcode >> 3) & 0x07 ; + Rf = (opcode >> 6) & 0x1F ; + return exceptionRegisters[Rb] + (Rf << 2); + } else if ((opcode & 0xF000) == 0x9000) { + // ldr r,[sp,#imm] + s8 offset = opcode & 0xff; + return exceptionRegisters[13] + offset; + } else if ((opcode & 0xF700) == 0xB500) { + // push/pop + return exceptionRegisters[13]; + } else if ((opcode & 0xF000) == 0xC000) { + // ldm/stm + Rd = (opcode >> 8) & 0x07; + return exceptionRegisters[Rd]; + } + } else { + // arm32 + unsigned long opcode = *(unsigned long *)opcodeAddress ; + + // SWP xxxx0001 0x00nnnn dddd0000 1001mmmm + // STR/LDR xxxx01xx xxxxnnnn ddddffff ffffffff + // STRH/LDRH xxxx000x x0xxnnnn dddd0000 1xx1mmmm + // STRH/LDRH xxxx000x x1xxnnnn ddddffff 1xx1ffff + // STM/LDM xxxx100x xxxxnnnn llllllll llllllll + + if ((opcode & 0x0FB00FF0) == 0x01000090) { + // SWP + Rn = (opcode >> 16) & 0x0F; + return exceptionRegisters[Rn]; + } else if ((opcode & 0x0C000000) == 0x04000000) { + // STR/LDR + Rn = (opcode >> 16) & 0x0F; + if (opcode & 0x02000000) { + // Register offset + Rm = opcode & 0x0F; + if (opcode & 0x01000000) { + unsigned short shift = (unsigned short)((opcode >> 4) & 0xFF) ; + // pre indexing + long Offset = ARMShiftO(exceptionRegisters[Rm],shift); + // add or sub the offset depending on the U-Bit + return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset); + } else { + // post indexing + return exceptionRegisters[Rn]; + } + } else { + // Immediate offset + unsigned long Offset = (opcode & 0xFFF) ; + if (opcode & 0x01000000) { + // pre indexing + // add or sub the offset depending on the U-Bit + return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset); + } else { + // post indexing + return exceptionRegisters[Rn]; + } + } + } else if ((opcode & 0x0E400F90) == 0x00000090) { + // LDRH/STRH with register Rm + Rn = (opcode >> 16) & 0x0F; + Rd = (opcode >> 12) & 0x0F; + Rm = opcode & 0x0F; + unsigned short shift = (unsigned short)((opcode >> 4) & 0xFF); + long Offset = ARMShiftO(exceptionRegisters[Rm],shift); + // add or sub the offset depending on the U-Bit + return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset); + } else if ((opcode & 0x0E400F90) == 0x00400090) { + // LDRH/STRH with immediate offset + Rn = (opcode >> 16) & 0x0F; + Rd = (opcode >> 12) & 0x0F; + unsigned long Offset = (opcode & 0xF) | ((opcode & 0xF00)>>8) ; + // add or sub the offset depending on the U-Bit + return exceptionRegisters[Rn] + ((opcode & 0x00800000)?Offset:-Offset) ; + } else if ((opcode & 0x0E000000) == 0x08000000) { + // LDM/STM + Rn = (opcode >> 16) & 0x0F; + return exceptionRegisters[Rn]; + } + } + return 0; +} + +static const char *registerNames[] = + { "r0","r1","r2","r3","r4","r5","r6","r7", + "r8 ","r9 ","r10","r11","r12","sp ","lr ","pc " }; + +extern const char __itcm_start[]; +//--------------------------------------------------------------------------------- +void customHandler() { +//--------------------------------------------------------------------------------- + consoleDemoInit(); + + BG_PALETTE[0] = RGB15(31,0,0); + BG_PALETTE[255] = RGB15(31,31,31); + + + iprintf("\x1b[5CGuru Meditation Error!\n"); + u32 currentMode = getCPSR() & 0x1f; + u32 thumbState = ((*(u32*)0x027FFD90) & 0x20); + + u32 codeAddress, exceptionAddress = 0; + + int offset = 8; + + if ( currentMode == 0x17 ) { + iprintf ("\x1b[10Cdata abort!\n\n"); + codeAddress = exceptionRegisters[15] - offset; + if ( (codeAddress > 0x02000000 && codeAddress < 0x02400000) || + (codeAddress > (u32)__itcm_start && codeAddress < (u32)(__itcm_start + 32768)) ) + exceptionAddress = getExceptionAddressO( codeAddress, thumbState); + else + exceptionAddress = codeAddress; + + } else { + if (thumbState) + offset = 2; + else + offset = 4; + iprintf("\x1b[5Cundefined instruction!\n\n"); + codeAddress = exceptionRegisters[15] - offset; + exceptionAddress = codeAddress; + } + + iprintf(" pc: %08X addr: %08X\n\n",codeAddress,exceptionAddress); + + int i; + for ( i=0; i < 8; i++ ) { + iprintf( " %s: %08X %s: %08X\n", + registerNames[i], exceptionRegisters[i], + registerNames[i+8],exceptionRegisters[i+8]); + } + iprintf("\x1b[2J"); + u32 *stack = (u32 *)exceptionRegisters[13]; + for ( i=0; i<24; i++ ) { + iprintf( "\x1b[%d;2H%08X: %08X %08X", i, (u32)&stack[i*2],stack[i*2], stack[(i*2)+1] ); + } + while(1) swiWaitForVBlank(); + +} + diff --git a/arm9/source/main.cpp b/source/main.cpp similarity index 100% rename from arm9/source/main.cpp rename to source/main.cpp From f74ff29e29e134ab8e33a9f7c18293e335204d6b Mon Sep 17 00:00:00 2001 From: KonPet <45455208+SkilLP@users.noreply.github.com> Date: Thu, 21 Oct 2021 01:21:15 +0200 Subject: [PATCH 2/2] Update CMakeLists.txt --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14508f3..e20f669 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,10 +15,10 @@ include_directories(${DEVKITPRO}/libnds/include/nds) include_directories(${DEVKITPRO}/libnds/include/nds/arm9) include_directories(${DEVKITPRO}/devkitARM) include_directories(${DEVKITPRO}/devkitARM/arm-none-eabi/include) -include_directories(arm9/source) -include_directories(arm9/fonts) -include_directories(arm9/data) -include_directories(arm9/build) +include_directories(source) +include_directories(fonts) +include_directories(data) +include_directories(build) link_directories(${DEVKITPRO}/libnds/lib) link_directories(${DEVKITPRO}/libnds/include)