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 <epicpkmn11@outlook.com>
Co-Authored-By: Kaisaan <34224128+Kaisaan@users.noreply.github.com>
This commit is contained in:
KonPet 2021-10-21 00:03:39 +02:00
parent fbbd5c897c
commit 183228e28e
138 changed files with 6941 additions and 7100 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
*.o
*.map
*.nds
*.elf
.idea
cmake-build-debug
build

34
CMakeLists.txt Normal file
View File

@ -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})

154
Makefile
View File

@ -1,45 +1,149 @@
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
.SUFFIXES: .SUFFIXES:
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),) ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif endif
include $(DEVKITARM)/ds_rules 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 # main targets
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
all: $(TARGET).nds $(OUTPUT).nds : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(TARGET).nds : $(TARGET).arm7 $(TARGET).arm9 %.bin.o : %.bin
ndstool -c $(TARGET).nds -7 $(TARGET).arm7 -9 $(TARGET).arm9 #---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(TARGET).arm7 : arm7/$(TARGET).elf %.bmf.o : %.bmf
$(TARGET).arm9 : arm9/$(TARGET).elf #---------------------------------------------------------------------------------
# @echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
arm7/$(TARGET).elf: -include $(DEPSDIR)/*.d
$(MAKE) -C arm7
#---------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------- endif
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

View File

@ -1,132 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>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
#---------------------------------------------------------------------------------------

View File

@ -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 <nds.h>
#include <dswifi7.h>
//---------------------------------------------------------------------------------
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();
}

View File

@ -1,153 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>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
#---------------------------------------------------------------------------------------

View File

@ -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;
}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
<pd><ViewState><e p="osuds\osuds" x="true"></e><e p="osuds\osuds\arm9\source\Libraries" x="true"></e><e p="osuds\osuds\arm9\source\Rulesets" x="true"></e><e p="osuds\osuds\arm7\build" x="false"></e><e p="osuds\osuds\arm9\data" x="false"></e><e p="osuds\osuds\arm9\fonts" x="false"></e><e p="osuds\osuds\arm9" x="true"></e><e p="osuds\osuds\arm9\build" x="false"></e><e p="osuds\osuds\arm9\source" x="true"></e><e p="osuds\osuds\arm9\source\GameplayElements" x="true"></e><e p="osuds\osuds\arm9\source\Graphics" x="true"></e><e p="osuds\osuds\nitro" x="false"></e><e p="osuds" x="true"></e><e p="osuds\osuds\arm7\source" x="true"></e><e p="osuds\osuds\arm9\source\HitObjects" x="true"></e><e p="osuds\osuds\arm9\source\Modes" x="true"></e><e p="osuds\osuds\arm7" x="true"></e><e p="osuds\osuds\arm9\source\Beatmaps" x="true"></e><e p="osuds\osuds\arm9\source\Helpers" x="true"></e><e p="osuds\osuds\arm9\source\System" x="true"></e></ViewState></pd>

View File

@ -1 +0,0 @@
<Workspace name="New Project Group"><Project path="osuds.pnproj"></Project></Workspace>

View File

@ -1,238 +1,245 @@
#include "Beatmap.h" #include "Beatmap.h"
Beatmap::Beatmap(const char* filename, const char* basedir) Beatmap::Beatmap(const char* filename, const char* basedir)
{ {
fLoadable = false; fLoadable = false;
mFilename = filename; mFilename = filename;
mBaseDir = basedir; mBaseDir = basedir;
mReader = NULL; mReader = NULL;
FileReader r(filename); FileReader r(filename);
if (r.Ready()) if (r.Ready())
{ {
//check header before processing //check header before processing
char id[4] = { r.ReadInt8(), r.ReadInt8(), r.ReadInt8(), 0 }; char id[4] = { r.ReadInt8(), r.ReadInt8(), r.ReadInt8(), 0 };
if (strcmp(id, "ODS") == 0) if (strcmp(id, "ODS") == 0)
{ {
u8 odsver = r.ReadInt8(); u8 odsver = r.ReadInt8();
mTitle = r.ReadString(); mTitle = r.ReadString();
mArtist = r.ReadString(); mArtist = r.ReadString();
mCreator = r.ReadString(); mCreator = r.ReadString();
mVersion = r.ReadString(); mVersion = r.ReadString();
mAudioFilename = r.ReadString(); mAudioFilename = r.ReadString();
fLoadable = true; fLoadable = true;
} }
} }
fReady = false; fReady = false;
} }
void Beatmap::Initialize() void Beatmap::Initialize()
{ {
if (!fReady) if (!fReady)
{ {
if (!fLoadable) if (!fLoadable)
{ {
iprintf("\x1b[0;0Hcannot load this file"); iprintf("\x1b[0;0Hcannot load this file");
return; return;
} }
chdir(mBaseDir.c_str()); chdir(mBaseDir.c_str());
mReader = new FileReader(mFilename); mReader = new FileReader(mFilename);
//skip header //skip header
mReader->Skip(3); mReader->Skip(3);
u8 odsver = mReader->ReadInt8(); u8 odsver = mReader->ReadInt8();
mTitle = mReader->ReadString(); mTitle = mReader->ReadString();
mArtist = mReader->ReadString(); mArtist = mReader->ReadString();
mCreator = mReader->ReadString(); mCreator = mReader->ReadString();
mVersion = mReader->ReadString(); mVersion = mReader->ReadString();
mAudioFilename = mReader->ReadString(); mAudioFilename = mReader->ReadString();
nocashMessage(mAudioFilename.c_str());
DifficultyManager::DifficultyHpDrain = mReader->ReadInt8();
DifficultyManager::DifficultyCircleSize = mReader->ReadInt8(); DifficultyManager::DifficultyHpDrain = mReader->ReadInt8();
DifficultyManager::DifficultyOverall = mReader->ReadInt8(); DifficultyManager::DifficultyCircleSize = mReader->ReadInt8();
DifficultyManager::SliderMultiplier = mReader->ReadFloat(); DifficultyManager::DifficultyOverall = mReader->ReadInt8();
DifficultyManager::SliderTickRate = mReader->ReadFloat(); DifficultyManager::SliderMultiplier = mReader->ReadFloat();
DifficultyManager::DifficultyHpDrainRate = mReader->ReadFloat(); DifficultyManager::SliderTickRate = mReader->ReadFloat();
DifficultyManager::DifficultyPeppyStars = mReader->ReadInt8(); DifficultyManager::DifficultyHpDrainRate = mReader->ReadFloat();
DifficultyManager::DifficultyEyupStars = mReader->ReadFloat(); DifficultyManager::DifficultyPeppyStars = mReader->ReadInt8();
DifficultyManager::DifficultyEyupStars = mReader->ReadFloat();
u32 tpointcount = mReader->ReadVarInt();
for (u32 j=0; j<tpointcount; ++j) u32 tpointcount = mReader->ReadVarInt();
{ for (u32 j=0; j<tpointcount; ++j)
s32 time = mReader->ReadInt32(); {
float beattime = mReader->ReadFloat(); s32 time = mReader->ReadInt32();
u8 samplesetid = mReader->ReadInt8(); float beattime = mReader->ReadFloat();
u8 samplesetid = mReader->ReadInt8();
BeatmapElements::Element().AddTimingPoint(time, beattime, samplesetid);
} BeatmapElements::Element().AddTimingPoint(time, beattime, samplesetid);
}
u32 breakcount = mReader->ReadVarInt();
for (u32 j=0; j<breakcount; ++j) nocashMessage("hio\n");
{
s32 starttime = mReader->ReadInt32(); u32 breakcount = mReader->ReadVarInt();
s32 endtime = mReader->ReadInt32(); nocashMessage(std::to_string(breakcount).c_str());
for (u32 j=0; j<breakcount; ++j)
BeatmapElements::Element().AddBreakPoint(starttime, endtime); {
} s32 starttime = mReader->ReadInt32();
s32 endtime = mReader->ReadInt32();
iprintf("\x1b[2J");
mHitObjectCount = mReader->ReadVarInt(); BeatmapElements::Element().AddBreakPoint(starttime, endtime);
mHitObjectRead = 0; }
mLastObjectEndTime = 0;
mForceNewCombo = true; nocashMessage("hio\n");
//read ahead iprintf("\x1b[2J");
ReadNextObject(); mHitObjectCount = mReader->ReadVarInt();
mFirstObjectTime = mNextObjectTime; mHitObjectRead = 0;
mLastObjectEndTime = 0;
//the time to skip to is the first object - 8 beats mForceNewCombo = true;
mSkipTime = MathHelper::Max(0, (s32)mNextObjectTime - (BeatmapElements::Element().GetTimingPoint(mNextObjectTime).BeatTime*8));
//read ahead
//strangely calling this in ctor of BeatmapElements causes game to not load :/ ReadNextObject();
BeatmapElements::Element().ResetColours(true); mFirstObjectTime = mNextObjectTime;
//now we can play this map //the time to skip to is the first object - 8 beats
fReady = true; 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);
void Beatmap::CleanUp()
{ //now we can play this map
//set object back to uninitialised state fReady = true;
fReady = false; }
}
if (mReader != NULL)
delete mReader; void Beatmap::CleanUp()
mReader = NULL; {
} //set object back to uninitialised state
fReady = false;
Beatmap::~Beatmap()
{ if (mReader != NULL)
if (mReader != NULL) delete mReader;
delete mReader; mReader = NULL;
} }
void Beatmap::Buffer(list<HitObject*>& hitObjectList) Beatmap::~Beatmap()
{ {
if (!fReady) if (mReader != NULL)
{ delete mReader;
iprintf("\x1b[0;0Hnot ready to buffer"); }
return;
} void Beatmap::Buffer(list<HitObject*>& hitObjectList)
{
//we buffer objects to 10 seconds ahead if (!fReady)
while (mHitObjectRead < mHitObjectCount && mNextObjectTime < GameClock::Clock().Time() + 3000) {
{ iprintf("\x1b[0;0Hnot ready to buffer");
HitObject* object; return;
}
//all coordinates are s16 in file but s32 in RAM
//we buffer objects to 10 seconds ahead
HitObjectType type = mNextObjectType; while (mHitObjectRead < mHitObjectCount && mNextObjectTime < GameClock::Clock().Time() + 3000)
s32 x = mNextObjectX; {
s32 y = mNextObjectY; HitObject* object;
HitObjectSound sound = (HitObjectSound)mReader->ReadInt8();
//all coordinates are s16 in file but s32 in RAM
if (mForceNewCombo)
{ HitObjectType type = mNextObjectType;
type = (HitObjectType)(type|HIT_COMBO); s32 x = mNextObjectX;
mForceNewCombo = false; s32 y = mNextObjectY;
} HitObjectSound sound = (HitObjectSound)mReader->ReadInt8();
switch (type & ~HIT_COMBO) //ignore HIT_COMBO if (mForceNewCombo)
{ {
case HIT_NORMAL: type = (HitObjectType)(type|HIT_COMBO);
{ mForceNewCombo = false;
object = new HitCircle(x, y, mNextObjectTime, type, sound); }
break;
} switch (type & ~HIT_COMBO) //ignore HIT_COMBO
{
case HIT_SLIDER: case HIT_NORMAL:
{ {
u32 repeats = mReader->ReadInt16(); object = new HitCircle(x, y, mNextObjectTime, type, sound);
u32 lengthtime = mReader->ReadInt32(); break;
}
u32 pointcount = mReader->ReadVarInt();
vector<HitObjectPoint*> points; case HIT_SLIDER:
points.reserve(pointcount); {
u32 repeats = mReader->ReadInt16();
for (u32 i=0; i<pointcount; ++i) u32 lengthtime = mReader->ReadInt32();
{
HitObjectPoint* tPoint = new HitObjectPoint(); u32 pointcount = mReader->ReadVarInt();
tPoint->x = (s16)mReader->ReadInt16(); //s32 x vector<HitObjectPoint*> points;
tPoint->y = (s16)mReader->ReadInt16(); //s32 y points.reserve(pointcount);
tPoint->angle = mReader->ReadInt32(); //s32 angle
for (u32 i=0; i<pointcount; ++i)
points.push_back(tPoint); {
} HitObjectPoint* tPoint = new HitObjectPoint();
tPoint->x = (s16)mReader->ReadInt16(); //s32 x
u32 tickcount = mReader->ReadVarInt(); tPoint->y = (s16)mReader->ReadInt16(); //s32 y
vector<HitObjectPoint*> ticks; tPoint->angle = mReader->ReadInt32(); //s32 angle
ticks.reserve(tickcount);
points.push_back(tPoint);
for (u32 i=0; i<tickcount; ++i) }
{
HitObjectPoint* tPoint = new HitObjectPoint(); u32 tickcount = mReader->ReadVarInt();
tPoint->x = (s16)mReader->ReadInt16(); //s32 x vector<HitObjectPoint*> ticks;
tPoint->y = (s16)mReader->ReadInt16(); //s32 y ticks.reserve(tickcount);
ticks.push_back(tPoint); for (u32 i=0; i<tickcount; ++i)
} {
HitObjectPoint* tPoint = new HitObjectPoint();
object = new HitSlider(x, y, mNextObjectTime, lengthtime, points, ticks, repeats, type, sound); tPoint->x = (s16)mReader->ReadInt16(); //s32 x
tPoint->y = (s16)mReader->ReadInt16(); //s32 y
//free allocated memory
for (u32 i=0; i<pointcount; ++i)
delete points[i]; ticks.push_back(tPoint);
}
for (u32 i=0; i<tickcount; ++i)
delete ticks[i]; object = new HitSlider(x, y, mNextObjectTime, lengthtime, points, ticks, repeats, type, sound);
break; //free allocated memory
} for (u32 i=0; i<pointcount; ++i)
delete points[i];
case HIT_SPINNER:
{ for (u32 i=0; i<tickcount; ++i)
s32 endtime = mReader->ReadInt32(); delete ticks[i];
object = new HitSpinner(mNextObjectTime, endtime, sound);
mForceNewCombo = true; break;
break; }
}
} case HIT_SPINNER:
{
//track when the beatmap has ended s32 endtime = mReader->ReadInt32();
mLastObjectEndTime = object->GetEndTime(); object = new HitSpinner(mNextObjectTime, endtime, sound);
mForceNewCombo = true;
//add to list break;
hitObjectList.push_back(object); }
}
++mHitObjectRead;
if (mHitObjectRead < mHitObjectCount) //track when the beatmap has ended
{ mLastObjectEndTime = object->GetEndTime();
ReadNextObject();
object->SetPostCreateOptions((mNextObjectType & HIT_COMBO) | mForceNewCombo, mNextObjectX, mNextObjectY); //add to list
} hitObjectList.push_back(object);
else
{ ++mHitObjectRead;
object->SetPostCreateOptions(true, 0, 0); if (mHitObjectRead < mHitObjectCount)
} {
} ReadNextObject();
} object->SetPostCreateOptions((mNextObjectType & HIT_COMBO) | mForceNewCombo, mNextObjectX, mNextObjectY);
}
void Beatmap::ReadNextObject() else
{ {
mNextObjectTime = mReader->ReadInt32(); object->SetPostCreateOptions(true, 0, 0);
mNextObjectType = (HitObjectType)mReader->ReadInt8(); }
mNextObjectX = (s16)mReader->ReadInt16(); }
mNextObjectY = (s16)mReader->ReadInt16(); }
}
void Beatmap::ReadNextObject()
{
mNextObjectTime = mReader->ReadInt32();
mNextObjectType = (HitObjectType)mReader->ReadInt8();
mNextObjectX = (s16)mReader->ReadInt16();
mNextObjectY = (s16)mReader->ReadInt16();
}

View File

@ -1,79 +1,79 @@
#include <nds.h> #include <nds.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <list> #include <list>
#include <vector> #include <vector>
#include <string> #include <string>
#include "BeatmapElements.h" #include "BeatmapElements.h"
#include "System/GameClock.h" #include "System/GameClock.h"
#include "Helpers/FileReader.h" #include "Helpers/FileReader.h"
#include "Helpers/MathHelper.h" #include "Helpers/MathHelper.h"
#include "HitObjects/HitObject.h" #include "HitObjects/HitObject.h"
#include "HitObjects/HitCircle.h" #include "HitObjects/HitCircle.h"
#include "HitObjects/HitSlider.h" #include "HitObjects/HitSlider.h"
#include "HitObjects/HitSpinner.h" #include "HitObjects/HitSpinner.h"
#include "Graphics/SpriteManager.h" #include "Graphics/SpriteManager.h"
#ifndef __BEATMAP_H__ #ifndef __BEATMAP_H__
#define __BEATMAP_H__ #define __BEATMAP_H__
using namespace std; using namespace std;
//typedef list<HitObject*>::iterator hitObjectIterator; //typedef list<HitObject*>::iterator hitObjectIterator;
class Beatmap class Beatmap
{ {
public: public:
Beatmap(const char* filename, const char* basedir); Beatmap(const char* filename, const char* basedir);
virtual ~Beatmap(); virtual ~Beatmap();
void Initialize(); void Initialize();
void CleanUp(); void CleanUp();
void Buffer(list<HitObject*>& hitObjectList); void Buffer(list<HitObject*>& hitObjectList);
bool GameOver() { return mHitObjectRead == mHitObjectCount && GameClock::Clock().Time() >= mLastObjectEndTime + 3000; } bool GameOver() { return mHitObjectRead == mHitObjectCount && GameClock::Clock().Time() >= mLastObjectEndTime + 3000; }
string& Filename() { return mFilename; } string& Filename() { return mFilename; }
string& Title() { return mTitle; } string& Title() { return mTitle; }
string& Artist() { return mArtist; } string& Artist() { return mArtist; }
string& Creator() { return mCreator; } string& Creator() { return mCreator; }
string& Version() { return mVersion; } string& Version() { return mVersion; }
string& AudioFilename() { return mAudioFilename; } string& AudioFilename() { return mAudioFilename; }
string& BaseDir() { return mBaseDir; } string& BaseDir() { return mBaseDir; }
s32 SkipTime() { return mSkipTime; } s32 SkipTime() { return mSkipTime; }
s32 StartTime() { return mFirstObjectTime; } s32 StartTime() { return mFirstObjectTime; }
protected: protected:
FileReader* mReader; FileReader* mReader;
u32 mHitObjectCount, mHitObjectRead; u32 mHitObjectCount, mHitObjectRead;
s32 mFirstObjectTime, mLastObjectEndTime; s32 mFirstObjectTime, mLastObjectEndTime;
void ReadNextObject(); void ReadNextObject();
s32 mNextObjectTime; s32 mNextObjectTime;
s32 mNextObjectX, mNextObjectY; s32 mNextObjectX, mNextObjectY;
HitObjectType mNextObjectType; HitObjectType mNextObjectType;
s32 mSkipTime; s32 mSkipTime;
bool mForceNewCombo; bool mForceNewCombo;
bool fReady, fLoadable; bool fReady, fLoadable;
string mFilename; string mFilename;
string mTitle; string mTitle;
string mArtist; string mArtist;
string mCreator; string mCreator;
string mVersion; string mVersion;
string mAudioFilename; string mAudioFilename;
string mBaseDir; string mBaseDir;
}; };
#endif #endif

View File

@ -1,82 +1,82 @@
#include "BeatmapElements.h" #include "BeatmapElements.h"
BeatmapElements BeatmapElements::sInstance; BeatmapElements BeatmapElements::sInstance;
const TimingPoint& BeatmapElements::GetTimingPoint(s32 time) const TimingPoint& BeatmapElements::GetTimingPoint(s32 time)
{ {
/* /*
u32 i; u32 i;
for (i=0; i<mTimingPoints.size(); ++i) for (i=0; i<mTimingPoints.size(); ++i)
{ {
if (mTimingPoints[i].Time > time) if (mTimingPoints[i].Time > time)
break; break;
} }
return mTimingPoints[MathHelper::Max(i-1, 0)]; return mTimingPoints[MathHelper::Max(i-1, 0)];
*/ */
u32 i; u32 i;
for ( for (
i = mTimingPoints.size() - 1; i = mTimingPoints.size() - 1;
i > 0 && mTimingPoints[i].Time > time; i > 0 && mTimingPoints[i].Time > time;
--i --i
); );
return mTimingPoints[i]; return mTimingPoints[i];
} }
const TimingPoint& BeatmapElements::GetTimingPoint() const TimingPoint& BeatmapElements::GetTimingPoint()
{ {
return GetTimingPoint(GameClock::Clock().Time()); return GetTimingPoint(GameClock::Clock().Time());
} }
const bool BeatmapElements::IsBreak() const bool BeatmapElements::IsBreak()
{ {
for (u32 i=0; i<mBreakPoints.size(); ++i) for (u32 i=0; i<mBreakPoints.size(); ++i)
{ {
if (GameClock::Clock().Time() > mBreakPoints[i].StartTime && GameClock::Clock().Time() < mBreakPoints[i].EndTime) if (GameClock::Clock().Time() > mBreakPoints[i].StartTime && GameClock::Clock().Time() < mBreakPoints[i].EndTime)
return true; return true;
} }
return false; return false;
} }
rgb BeatmapElements::GetNextColour() rgb BeatmapElements::GetNextColour()
{ {
//backwards compatibility - increase counter BEFORE returning //backwards compatibility - increase counter BEFORE returning
if (++mCurrentColour >= mColours.size()) if (++mCurrentColour >= mColours.size())
mCurrentColour = 0; mCurrentColour = 0;
return mColours[mCurrentColour]; return mColours[mCurrentColour];
} }
void BeatmapElements::AddTimingPoint(s32 time, float beattime, u8 samplesetid) void BeatmapElements::AddTimingPoint(s32 time, float beattime, u8 samplesetid)
{ {
TimingPoint tPoint = { TimingPoint tPoint = {
time, time,
beattime, beattime,
samplesetid samplesetid
}; };
mTimingPoints.push_back(tPoint); mTimingPoints.push_back(tPoint);
} }
void BeatmapElements::AddBreakPoint(s32 start, s32 end) void BeatmapElements::AddBreakPoint(s32 start, s32 end)
{ {
BreakPoint bPoint = { BreakPoint bPoint = {
start, start,
end end
}; };
mBreakPoints.push_back(bPoint); mBreakPoints.push_back(bPoint);
} }
void BeatmapElements::ResetColours(bool fill) void BeatmapElements::ResetColours(bool fill)
{ {
mColours.clear(); mColours.clear();
mCurrentColour = 0; mCurrentColour = 0;
if (fill) if (fill)
{ {
mColours.push_back(RGB15(31,18,0)); mColours.push_back(RGB15(31,18,0));
mColours.push_back(RGB15(1,30,1)); mColours.push_back(RGB15(1,30,1));
mColours.push_back(RGB15(1,1,30)); mColours.push_back(RGB15(1,1,30));
mColours.push_back(RGB15(30,1,1)); mColours.push_back(RGB15(30,1,1));
} }
} }

View File

@ -1,53 +1,53 @@
#include <nds.h> #include <nds.h>
#include <vector> #include <vector>
#include "Helpers/MathHelper.h" #include "Helpers/MathHelper.h"
#include "System/GameClock.h" #include "System/GameClock.h"
#ifndef __BEATMAPELEMENTS_H__ #ifndef __BEATMAPELEMENTS_H__
#define __BEATMAPELEMENTS_H__ #define __BEATMAPELEMENTS_H__
using namespace std; using namespace std;
typedef struct { typedef struct {
s32 Time; s32 Time;
float BeatTime; float BeatTime;
u8 SampleSetId; u8 SampleSetId;
} TimingPoint; } TimingPoint;
typedef struct { typedef struct {
s32 StartTime; s32 StartTime;
s32 EndTime; s32 EndTime;
} BreakPoint; } BreakPoint;
class BeatmapElements class BeatmapElements
{ {
public: public:
static BeatmapElements& Element() { return sInstance; } static BeatmapElements& Element() { return sInstance; }
const TimingPoint& GetTimingPoint(s32 time); const TimingPoint& GetTimingPoint(s32 time);
const TimingPoint& GetTimingPoint(); const TimingPoint& GetTimingPoint();
const bool IsBreak(); const bool IsBreak();
rgb GetNextColour(); rgb GetNextColour();
void AddTimingPoint(s32 time, float beattime, u8 samplesetid); void AddTimingPoint(s32 time, float beattime, u8 samplesetid);
void AddBreakPoint(s32 start, s32 end); void AddBreakPoint(s32 start, s32 end);
void ResetColours(bool fill); void ResetColours(bool fill);
protected: protected:
static BeatmapElements sInstance; static BeatmapElements sInstance;
vector<TimingPoint> mTimingPoints; vector<TimingPoint> mTimingPoints;
vector<BreakPoint> mBreakPoints; vector<BreakPoint> mBreakPoints;
vector<rgb> mColours; vector<rgb> mColours;
u32 mCurrentColour; u32 mCurrentColour;
private: private:
BeatmapElements() {} BeatmapElements() {}
~BeatmapElements() {} ~BeatmapElements() {}
}; };
#endif #endif

View File

@ -1,82 +1,84 @@
#include "BeatmapManager.h" #include "BeatmapManager.h"
Beatmap* BeatmapManager::mBeatmapCurrent = NULL; Beatmap* BeatmapManager::mBeatmapCurrent = NULL;
vector<Beatmap*> BeatmapManager::mBeatmaps; vector<Beatmap*> BeatmapManager::mBeatmaps;
void BeatmapManager::Load(u32 index) void BeatmapManager::Load(u32 index)
{ {
if (mBeatmapCurrent != NULL) if (mBeatmapCurrent != NULL)
mBeatmapCurrent->CleanUp(); mBeatmapCurrent->CleanUp();
Mode::ChangeToOsuDir(); Mode::ChangeToOsuDir();
mBeatmapCurrent = mBeatmaps[index]; mBeatmapCurrent = mBeatmaps[index];
mBeatmapCurrent->Initialize(); mBeatmapCurrent->Initialize();
} }
void BeatmapManager::BuildCollection() void BeatmapManager::BuildCollection()
{ {
Mode::ChangeToOsuDir(); Mode::ChangeToOsuDir();
DIR* dir = opendir("."); DIR* dir = opendir(".");
struct dirent* entry; struct dirent* entry;
while ((entry = readdir(dir)) != NULL) while ((entry = readdir(dir)) != NULL)
{ {
//ignore generic names //ignore generic names
//if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) //if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
if (entry->d_name[0] == '.') if (entry->d_name[0] == '.')
continue; continue;
chdir(entry->d_name); chdir(entry->d_name);
DIR* subdir = opendir("."); DIR* subdir = opendir(".");
//if this is a folder, find all the .ods files inside //if this is a folder, find all the .ods files inside
if (subdir != NULL) if (subdir != NULL)
{ {
struct dirent* subentry; struct dirent* subentry;
while ((subentry = readdir(subdir)) != NULL) while ((subentry = readdir(subdir)) != NULL)
{ {
DIR* filetest = opendir(subentry->d_name); DIR* filetest = opendir(subentry->d_name);
if (filetest == NULL) if (filetest == NULL)
{ {
char* ext = subentry->d_name; char* ext = subentry->d_name;
int length = strlen(ext); int length = strlen(ext);
if (length < 4) if (length < 4)
continue; continue;
//ext is now the extension of the current file nocashMessage(ext);
ext += length - 4;
//ext is now the extension of the current file
//if we have on our hands a .ods file, add it to our collection ext += length - 4;
if (strcmp(ext, ".ods") == 0)
{ //if we have on our hands a .ods file, add it to our collection
mBeatmaps.push_back(new Beatmap(subentry->d_name, entry->d_name)); if (strcmp(ext, ".ods") == 0)
} {
} mBeatmaps.push_back(new Beatmap(subentry->d_name, entry->d_name));
else }
{ }
closedir(filetest); else
} {
} closedir(filetest);
} }
}
closedir(subdir); }
chdir("..");
} closedir(subdir);
chdir("..");
closedir(dir); }
}
closedir(dir);
u32 BeatmapManager::MapCount() }
{
return 8;//mBeatmaps.size(); u32 BeatmapManager::MapCount()
} {
return 8;//mBeatmaps.size();
u32 BeatmapManager::SongCount() }
{
//TODO: algorithm plz u32 BeatmapManager::SongCount()
return mBeatmaps.size(); {
//TODO: algorithm plz
return mBeatmaps.size();
} }

View File

@ -1,39 +1,39 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <dirent.h> #include <dirent.h>
#include <string.h> #include <string.h>
#include <vector> #include <vector>
#include "Beatmap.h" #include "Beatmap.h"
#include "BeatmapElements.h" #include "BeatmapElements.h"
#include "DifficultyManager.h" #include "DifficultyManager.h"
#include "Modes/Mode.h" #include "Modes/Mode.h"
#ifndef __BEATMAPMANAGER_H__ #ifndef __BEATMAPMANAGER_H__
#define __BEATMAPMANAGER_H__ #define __BEATMAPMANAGER_H__
using namespace std; using namespace std;
typedef vector<Beatmap*>::iterator beatmapIterator; typedef vector<Beatmap*>::iterator beatmapIterator;
class BeatmapManager class BeatmapManager
{ {
public: public:
static Beatmap& Current() { return *mBeatmapCurrent; } static Beatmap& Current() { return *mBeatmapCurrent; }
static void BuildCollection(); static void BuildCollection();
static void Load(u32 index); static void Load(u32 index);
static u32 MapCount(); static u32 MapCount();
static u32 SongCount(); static u32 SongCount();
static vector<Beatmap*>& Beatmaps() { return mBeatmaps; } static vector<Beatmap*>& Beatmaps() { return mBeatmaps; }
protected: protected:
static Beatmap* mBeatmapCurrent; static Beatmap* mBeatmapCurrent;
static vector<Beatmap*> mBeatmaps; static vector<Beatmap*> mBeatmaps;
}; };
#endif #endif

View File

@ -1,21 +1,21 @@
#include "DifficultyManager.h" #include "DifficultyManager.h"
u32 DifficultyManager::preemptTime[] = {1800, 1680, 1560, 1440, 1320, 1200, 1050, 900, 750, 600, 450}; 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, 44, 36, 28, 20};
u32 DifficultyManager::circleSize[] = {100, 92, 84, 76, 68, 60, 52, 52, 52, 52, 52}; 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::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::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::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::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}; 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}; s32 DifficultyManager::missHpDrain[] = {-10, -18, -26, -34, -42, -50, -56, -62, -68, -74, -80};
u8 DifficultyManager::DifficultyHpDrain = 5; u8 DifficultyManager::DifficultyHpDrain = 5;
u8 DifficultyManager::DifficultyCircleSize = 5; u8 DifficultyManager::DifficultyCircleSize = 5;
u8 DifficultyManager::DifficultyOverall = 5; u8 DifficultyManager::DifficultyOverall = 5;
float DifficultyManager::SliderMultiplier = 1.0; float DifficultyManager::SliderMultiplier = 1.0;
float DifficultyManager::SliderTickRate = 1.0; float DifficultyManager::SliderTickRate = 1.0;
float DifficultyManager::DifficultyHpDrainRate = 1.0; float DifficultyManager::DifficultyHpDrainRate = 1.0;
u8 DifficultyManager::DifficultyPeppyStars = 3; u8 DifficultyManager::DifficultyPeppyStars = 3;
float DifficultyManager::DifficultyEyupStars = 3.0; float DifficultyManager::DifficultyEyupStars = 3.0;

View File

@ -1,39 +1,39 @@
#include <nds.h> #include <nds.h>
#ifndef __DIFFICULTYMANAGER_H__ #ifndef __DIFFICULTYMANAGER_H__
#define __DIFFICULTYMANAGER_H__ #define __DIFFICULTYMANAGER_H__
class DifficultyManager class DifficultyManager
{ {
public: public:
static u8 DifficultyHpDrain; static u8 DifficultyHpDrain;
static u8 DifficultyCircleSize; static u8 DifficultyCircleSize;
static u8 DifficultyOverall; static u8 DifficultyOverall;
static float SliderMultiplier; static float SliderMultiplier;
static float SliderTickRate; static float SliderTickRate;
static float DifficultyHpDrainRate; static float DifficultyHpDrainRate;
static u8 DifficultyPeppyStars; static u8 DifficultyPeppyStars;
static float DifficultyEyupStars; static float DifficultyEyupStars;
//inline //inline
static u32 GetCircleSize() { return circleSize[DifficultyCircleSize]; } //possibly *1.2 static u32 GetCircleSize() { return circleSize[DifficultyCircleSize]; } //possibly *1.2
static u32 GetPreemptTime() { return preemptTime[DifficultyOverall]; } static u32 GetPreemptTime() { return preemptTime[DifficultyOverall]; }
static u32 GetHitWindow300() { return hitWindow300[DifficultyOverall]; } static u32 GetHitWindow300() { return hitWindow300[DifficultyOverall]; }
static u32 GetHitWindow100() { return hitWindow100[DifficultyOverall]; } static u32 GetHitWindow100() { return hitWindow100[DifficultyOverall]; }
static u32 GetHitWindow50() { return hitWindow50[DifficultyOverall]; } static u32 GetHitWindow50() { return hitWindow50[DifficultyOverall]; }
static u32 GetHitWindow() { return hitWindow50[DifficultyOverall] << 1; } static u32 GetHitWindow() { return hitWindow50[DifficultyOverall] << 1; }
static u32 GetSpinnerTime() { return spinnerTime[DifficultyOverall]; } static u32 GetSpinnerTime() { return spinnerTime[DifficultyOverall]; }
static s32 GetMissHpDrain() { return missHpDrain[DifficultyHpDrain]; } static s32 GetMissHpDrain() { return missHpDrain[DifficultyHpDrain]; }
protected: protected:
static u32 preemptTime[]; static u32 preemptTime[];
static u32 circleSize[]; static u32 circleSize[];
static u32 hitWindow300[]; static u32 hitWindow300[];
static u32 hitWindow100[]; static u32 hitWindow100[];
static u32 hitWindow50[]; static u32 hitWindow50[];
static u32 spinnerTime[]; static u32 spinnerTime[];
static s32 missHpDrain[]; static s32 missHpDrain[];
}; };
#endif #endif

View File

@ -1,104 +1,104 @@
#include "HitObjectManager.h" #include "HitObjectManager.h"
HitObjectManager::~HitObjectManager() HitObjectManager::~HitObjectManager()
{ {
//delete hitobjects //delete hitobjects
for (hitObjectIterator it = mHitObjects.begin(); it != mHitObjects.end(); ++it) for (hitObjectIterator it = mHitObjects.begin(); it != mHitObjects.end(); ++it)
{ {
if (*it != NULL) if (*it != NULL)
delete *it; delete *it;
} }
} }
void HitObjectManager::Add(HitObject* object) void HitObjectManager::Add(HitObject* object)
{ {
mHitObjects.push_back(object); mHitObjects.push_back(object);
} }
void HitObjectManager::HandleInput() void HitObjectManager::HandleInput()
{ {
touchPosition touch = InputHelper::TouchRead(); touchPosition touch = InputHelper::TouchRead();
HitObject* hitObject; HitObject* hitObject;
// remove all hitobjects before the current time and all hitobjects that have been hit // remove all hitobjects before the current time and all hitobjects that have been hit
bool process = true; bool process = true;
while (process) while (process)
{ {
process = false; process = false;
if (mHitObjects.size() == 0) if (mHitObjects.size() == 0)
return; return;
// process hitobjects one at a time // process hitobjects one at a time
hitObject = mHitObjects.front(); hitObject = mHitObjects.front();
if (hitObject->GetEndTime() <= GameClock::Clock().Time() || hitObject->GetHit() == true) if (hitObject->GetEndTime() <= GameClock::Clock().Time() || hitObject->GetHit() == true)
{ {
// sprites are handled by spritemanager and will not be deleted (see HitObject.h) // 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 // 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) if (GameClock::Clock().Time() - hitObject->GetEndTime() < 1000 && hitObject->GetHit() == false)
hitObject->Hit(); hitObject->Hit();
mHitObjects.pop_front(); mHitObjects.pop_front();
delete hitObject; delete hitObject;
process = true; process = true;
} }
} }
// now we are left with the next hitobject that can react to user interaction // now we are left with the next hitobject that can react to user interaction
if (InputHelper::KeyDown(KEY_TOUCH)) if (InputHelper::KeyDown(KEY_TOUCH))
hitObject->OnTouchDown(touch); hitObject->OnTouchDown(touch);
if (InputHelper::KeyHeld(KEY_TOUCH)) if (InputHelper::KeyHeld(KEY_TOUCH))
hitObject->OnTouch(touch); hitObject->OnTouch(touch);
if (InputHelper::KeyUp(KEY_TOUCH)) if (InputHelper::KeyUp(KEY_TOUCH))
hitObject->OnTouchUp(touch); hitObject->OnTouchUp(touch);
hitObject->Update(); hitObject->Update();
/* /*
//get the first unhit hitobject //get the first unhit hitobject
if (mHitObjects.size() == 0) if (mHitObjects.size() == 0)
return; return;
HitObject* hitObject = mHitObjects.front(); HitObject* hitObject = mHitObjects.front();
//only the topmost object can be hit at any time //only the topmost object can be hit at any time
if (hitObject->GetEndTime() <= GameClock::Clock().Time() && hitObject->GetHit() == false) if (hitObject->GetEndTime() <= GameClock::Clock().Time() && hitObject->GetHit() == false)
{ {
hitObject->Hit(); hitObject->Hit();
} }
if (hitObject->GetHit() == true) if (hitObject->GetHit() == true)
{ {
//sprites are handled by spritemanager and will not be deleted (see HitObject.h) //sprites are handled by spritemanager and will not be deleted (see HitObject.h)
delete hitObject; delete hitObject;
mHitObjects.pop_front(); mHitObjects.pop_front();
if (mHitObjects.size() == 0) if (mHitObjects.size() == 0)
return; return;
hitObject = mHitObjects.front(); hitObject = mHitObjects.front();
} }
//at this point hitObject is pointing to the topmost unhit object if such an object exists //at this point hitObject is pointing to the topmost unhit object if such an object exists
if (hitObject != NULL) if (hitObject != NULL)
{ {
if (InputHelper::KeyDown(KEY_TOUCH)) if (InputHelper::KeyDown(KEY_TOUCH))
hitObject->OnTouchDown(touch); hitObject->OnTouchDown(touch);
if (InputHelper::KeyHeld(KEY_TOUCH)) if (InputHelper::KeyHeld(KEY_TOUCH))
hitObject->OnTouch(touch); hitObject->OnTouch(touch);
if (InputHelper::KeyUp(KEY_TOUCH)) if (InputHelper::KeyUp(KEY_TOUCH))
hitObject->OnTouchUp(touch); hitObject->OnTouchUp(touch);
hitObject->Update(); hitObject->Update();
} }
*/ */
} }

View File

@ -1,31 +1,31 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include <list> #include <list>
#include "HitObjects/HitObject.h" #include "HitObjects/HitObject.h"
#include "HitObjects/HitCircle.h" #include "HitObjects/HitCircle.h"
#include "HitObjects/HitSlider.h" #include "HitObjects/HitSlider.h"
#include "HitObjects/HitSpinner.h" #include "HitObjects/HitSpinner.h"
#include "Helpers/InputHelper.h" #include "Helpers/InputHelper.h"
#ifndef __HITOBJECTMANAGER_H__ #ifndef __HITOBJECTMANAGER_H__
#define __HITOBJECTMANAGER_H__ #define __HITOBJECTMANAGER_H__
using namespace std; using namespace std;
typedef list<HitObject*>::iterator hitObjectIterator; typedef list<HitObject*>::iterator hitObjectIterator;
class HitObjectManager class HitObjectManager
{ {
public: public:
~HitObjectManager(); ~HitObjectManager();
void Add(HitObject* object); void Add(HitObject* object);
void HandleInput(); void HandleInput();
protected: protected:
list<HitObject*> mHitObjects; list<HitObject*> mHitObjects;
}; };
#endif #endif

View File

@ -1,115 +1,115 @@
#include "Lifebar.h" #include "Lifebar.h"
Lifebar::Lifebar() Lifebar::Lifebar()
{ {
pSprite* spr; 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);
spr = new pSprite(TX_PLAY_SCOREBAR_KI, 400, 18, 80, 80, ORIGIN_CENTER, FIELD_SCREEN, RGB15(31,31,31), 31, -0.02f); spr = new pSprite(TX_PLAY_SCOREBAR, 0, 0, 640, 42, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(31,31,31), 31);
mSprites.push_back(spr); mSprites.push_back(spr);
mUV = new u32[4]; //deleted by pSprite spr = new pSprite(TX_PLAY_SCOREBAR_BAR, 0, 0, 400, 40, ORIGIN_TOPLEFT, FIELD_SCREEN, RGB15(31,31,31), 31, -0.01f);
mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(0)); mSprites.push_back(spr);
mUV[1] = TEXTURE_PACK(inttot16(160),inttot16(0));
mUV[2] = TEXTURE_PACK(inttot16(160),inttot16(16)); spr = new pSprite(TX_PLAY_SCOREBAR_KI, 400, 18, 80, 80, ORIGIN_CENTER, FIELD_SCREEN, RGB15(31,31,31), 31, -0.02f);
mUV[3] = TEXTURE_PACK(inttot16(0),inttot16(16)); mSprites.push_back(spr);
mSprites[1]->UV = mUV; mUV = new u32[4]; //deleted by pSprite
} mUV[0] = TEXTURE_PACK(inttot16(0),inttot16(0));
mUV[1] = TEXTURE_PACK(inttot16(160),inttot16(0));
//can only be called after beatmap has been loaded mUV[2] = TEXTURE_PACK(inttot16(160),inttot16(16));
void Lifebar::Initialize() mUV[3] = TEXTURE_PACK(inttot16(0),inttot16(16));
{
mHpLossPerMs = DifficultyManager::DifficultyHpDrainRate * 2; //units are hp/ms based off a 200 point scale mSprites[1]->UV = mUV;
mHpCurrent = 0; }
mHpDisplay = 0;
//can only be called after beatmap has been loaded
mTimeLastUpdate = GameClock::Clock().Time(); void Lifebar::Initialize()
mFillTime = MathHelper::Min(10000, BeatmapManager::Current().StartTime()); {
mFillRate = MAXHP/((mFillTime-700)/(float)1000*60); mHpLossPerMs = DifficultyManager::DifficultyHpDrainRate * 2; //units are hp/ms based off a 200 point scale
mHpCurrent = 0;
for (u32 time = BeatmapManager::Current().StartTime() - mFillTime; mHpDisplay = 0;
time < BeatmapManager::Current().StartTime()-700; time += 150)
{ mTimeLastUpdate = GameClock::Clock().Time();
mSprites[2]->Scale(time, time+90, 1.5, 1); mFillTime = MathHelper::Min(10000, BeatmapManager::Current().StartTime());
} mFillRate = MAXHP/((mFillTime-700)/(float)1000*60);
}
for (u32 time = BeatmapManager::Current().StartTime() - mFillTime;
void Lifebar::Update() time < BeatmapManager::Current().StartTime()-700; time += 150)
{ {
s32 now = GameClock::Clock().Time(); mSprites[2]->Scale(time, time+90, 1.5, 1);
s32 startTime = BeatmapManager::Current().StartTime(); }
}
if (now > startTime && BeatmapElements::Element().IsBreak() == false)
{ void Lifebar::Update()
mHpCurrent -= (now - mTimeLastUpdate) * mHpLossPerMs; {
if (mHpCurrent < 0) s32 now = GameClock::Clock().Time();
mHpCurrent = 0; s32 startTime = BeatmapManager::Current().StartTime();
}
//intro animation if (now > startTime && BeatmapElements::Element().IsBreak() == false)
else if (now > startTime - mFillTime && now < startTime) {
{ mHpCurrent -= (now - mTimeLastUpdate) * mHpLossPerMs;
Set(mHpCurrent + mFillRate, false); if (mHpCurrent < 0)
} mHpCurrent = 0;
}
int dhp = mHpCurrent - mHpDisplay; //intro animation
if (MathHelper::Abs(dhp) > MAXCHANGE) else if (now > startTime - mFillTime && now < startTime)
dhp = MathHelper::Sgn(dhp) * MAXCHANGE; {
mHpDisplay += dhp; Set(mHpCurrent + mFillRate, false);
}
//mHpDisplay represents the required width of the sprite
mSprites[2]->Move(mHpDisplay, 18); int dhp = mHpCurrent - mHpDisplay;
if (mHpDisplay >= 200) if (MathHelper::Abs(dhp) > MAXCHANGE)
mSprites[2]->Texture = TX_PLAY_SCOREBAR_KI; dhp = MathHelper::Sgn(dhp) * MAXCHANGE;
else if (mHpDisplay >= 70) mHpDisplay += dhp;
mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER;
else //mHpDisplay represents the required width of the sprite
mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER2; mSprites[2]->Move(mHpDisplay, 18);
if (mHpDisplay >= 200)
mSprites[1]->Width = (u32)mHpDisplay; mSprites[2]->Texture = TX_PLAY_SCOREBAR_KI;
mUV[1] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(0)); else if (mHpDisplay >= 70)
mUV[2] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(16)); mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER;
else
mTimeLastUpdate = now; mSprites[2]->Texture = TX_PLAY_SCOREBAR_KIDANGER2;
}
mSprites[1]->Width = (u32)mHpDisplay;
void Lifebar::Set(float value, bool limit) mUV[1] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(0));
{ mUV[2] = TEXTURE_PACK(inttot16((u32)(mHpDisplay/2.5)),inttot16(16));
if (value < 0) value = 0;
if (value > MAXHP) value = MAXHP; mTimeLastUpdate = now;
}
mHpCurrent = value;
if (!limit) void Lifebar::Set(float value, bool limit)
mHpDisplay = value; {
mTimeLastUpdate = GameClock::Clock().Time(); if (value < 0) value = 0;
} if (value > MAXHP) value = MAXHP;
void Lifebar::Increase(float value) mHpCurrent = value;
{ if (!limit)
Set(mHpCurrent + value); mHpDisplay = value;
mTimeLastUpdate = GameClock::Clock().Time();
//animate ki icon :D }
if (value > 0)
Bulge(); void Lifebar::Increase(float value)
} {
Set(mHpCurrent + value);
void Lifebar::Bulge()
{ //animate ki icon :D
s32 now = GameClock::Clock().Time(); if (value > 0)
Bulge();
mSprites[2]->Scale(now, now+90, 1.5, 1); }
}
void Lifebar::Bulge()
void Lifebar::ClearTransforms() {
{ s32 now = GameClock::Clock().Time();
for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it)
{ mSprites[2]->Scale(now, now+90, 1.5, 1);
(*it)->ClearTransforms(); }
}
} void Lifebar::ClearTransforms()
{
for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it)
{
(*it)->ClearTransforms();
}
}

View File

@ -1,51 +1,51 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include "ScoreManager.h" #include "ScoreManager.h"
#include "System/GameClock.h" #include "System/GameClock.h"
#include "Graphics/SpriteContainer.h" #include "Graphics/SpriteContainer.h"
#include "Beatmaps/BeatmapManager.h" #include "Beatmaps/BeatmapManager.h"
#ifndef __LIFEBAR_H__ #ifndef __LIFEBAR_H__
#define __LIFEBAR_H__ #define __LIFEBAR_H__
class Lifebar : public SpriteContainer class Lifebar : public SpriteContainer
{ {
public: public:
Lifebar(); Lifebar();
void Initialize(); void Initialize();
void Update(); void Update();
void Set(float value, bool limit = true); void Set(float value, bool limit = true);
void Increase(float value); void Increase(float value);
void ClearTransforms(); void ClearTransforms();
static const u32 MAXHP = 400; //matches with actual width of sprite static const u32 MAXHP = 400; //matches with actual width of sprite
static const u32 MAXCHANGE = 10; static const u32 MAXCHANGE = 10;
//values for increase //values for increase
static const u32 HP_300 = 12; static const u32 HP_300 = 12;
static const u32 HP_100 = 5; static const u32 HP_100 = 5;
static const u32 HP_50 = 1; static const u32 HP_50 = 1;
static const u32 HP_GEKI = 28; static const u32 HP_GEKI = 28;
static const u32 HP_KATSU = 20; static const u32 HP_KATSU = 20;
static const u32 HP_SLIDER_REPEAT = 8; static const u32 HP_SLIDER_REPEAT = 8;
static const u32 HP_SLIDER_TICK = 6; static const u32 HP_SLIDER_TICK = 6;
static const u32 HP_SPINNER_SPIN = 4; static const u32 HP_SPINNER_SPIN = 4;
static const u32 HP_SPINNER_BONUS = 5; static const u32 HP_SPINNER_BONUS = 5;
protected: protected:
float mHpCurrent; float mHpCurrent;
float mHpDisplay; float mHpDisplay;
float mHpLossPerMs; float mHpLossPerMs;
s32 mFillTime; s32 mFillTime;
float mFillRate; float mFillRate;
s32 mTimeLastUpdate; s32 mTimeLastUpdate;
u32* mUV; u32* mUV;
void Bulge(); void Bulge();
}; };
#endif #endif

View File

@ -1,36 +1,36 @@
#include "ScoreManager.h" #include "ScoreManager.h"
ScoreManager::ScoreManager() ScoreManager::ScoreManager()
{ {
mScore = 0; mScore = 0;
mCombo = 0; mCombo = 0;
} }
void ScoreManager::Add(ScoreType score, bool forceNoCombo) void ScoreManager::Add(ScoreType score, bool forceNoCombo)
{ {
if (score == SCORE_MISS) if (score == SCORE_MISS)
{ {
mCombo = 0; mCombo = 0;
} }
else if (score == SCORE_SPIN_100 || score == SCORE_SPIN_1000) else if (score == SCORE_SPIN_100 || score == SCORE_SPIN_1000)
{ {
if (score == SCORE_SPIN_100) if (score == SCORE_SPIN_100)
mScore += 100; mScore += 100;
else else
mScore += score; mScore += score;
} }
else if (score == SCORE_TICK_30 || score == SCORE_TICK_10) else if (score == SCORE_TICK_30 || score == SCORE_TICK_10)
{ {
mScore += score; mScore += score;
if (!forceNoCombo) if (!forceNoCombo)
++mCombo; ++mCombo;
} }
else else
{ {
mScore += score + MathHelper::Max(0, mCombo-1) * (score/25) * DifficultyManager::DifficultyPeppyStars; mScore += score + MathHelper::Max(0, mCombo-1) * (score/25) * DifficultyManager::DifficultyPeppyStars;
if (!forceNoCombo) if (!forceNoCombo)
++mCombo; ++mCombo;
} }
} }

View File

@ -1,36 +1,36 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include "Helpers/MathHelper.h" #include "Helpers/MathHelper.h"
#include "Beatmaps/DifficultyManager.h" #include "Beatmaps/DifficultyManager.h"
#ifndef __SCOREMANAGER_H__ #ifndef __SCOREMANAGER_H__
#define __SCOREMANAGER_H__ #define __SCOREMANAGER_H__
typedef enum { typedef enum {
SCORE_300 = 300, SCORE_300 = 300,
SCORE_100 = 100, SCORE_100 = 100,
SCORE_50 = 50, SCORE_50 = 50,
SCORE_TICK_30 = 30, SCORE_TICK_30 = 30,
SCORE_TICK_10 = 10, SCORE_TICK_10 = 10,
SCORE_SPIN_100 = 101,//should be 100 but conflicts with SCORE_100 SCORE_SPIN_100 = 101,//should be 100 but conflicts with SCORE_100
SCORE_SPIN_1000 = 1000, SCORE_SPIN_1000 = 1000,
SCORE_MISS = 0 SCORE_MISS = 0
} ScoreType; } ScoreType;
class ScoreManager class ScoreManager
{ {
public: public:
ScoreManager(); ScoreManager();
void Add(ScoreType score, bool forceNoCombo = false); void Add(ScoreType score, bool forceNoCombo = false);
u32 Score() { return mScore; } u32 Score() { return mScore; }
u32 Combo() { return mCombo; } u32 Combo() { return mCombo; }
protected: protected:
u32 mScore; u32 mScore;
u32 mCombo; u32 mCombo;
}; };
#endif #endif

View File

@ -1,343 +1,343 @@
#include <nds.h> #include <nds.h>
#include "GfxInfo.h" #include "GfxInfo.h"
/* /*
const float zvalue[] = const float zvalue[] =
{ {
0.000f, 0.000f, -0.01f, //hitcircle 0.000f, 0.000f, -0.01f, //hitcircle
0.000f, 0.000f, 0.000f, //hitspinner 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.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.015f, -0.01f, 0.000f, 0.000f, //hitslider
0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, //score 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, //score
-0.005f, -0.005f, //slider score -0.005f, -0.005f, //slider score
-0.05f, -0.05f, -0.05f, -0.05f, -0.05f, //scorebar -0.05f, -0.05f, -0.05f, -0.05f, -0.05f, //scorebar
0.000f, //verdana9 0.000f, //verdana9
0.000f //white 0.000f //white
}; };
*/ */
const u16 palette0[] = //circle, circleoverlay, circleapproach, disc, slidertick, sliderreverse, verdana9, 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) RGB15(31,0,31), RGB15(31,31,31), RGB15(28,28,28), RGB15(0,0,0)
}; };
const u16 palette1[] = //spinner, spinnerbars, scorebar_bar const u16 palette1[] = //spinner, spinnerbars, scorebar_bar
{ {
RGB15(31,31,31), RGB15(31,0,0), RGB15(31,4,0), RGB15(31,9,0), 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(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,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) RGB15(31,27,0), RGB15(31,31,8), RGB15(31,31,0), RGB15(0,14,22)
}; };
const u16 palette2[] = //spinnerbg const u16 palette2[] = //spinnerbg
{ {
RGB15(31,31,31), RGB15(1,2,5), RGB15(5,5,5), RGB15(0,0,0), 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(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(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) RGB15(5,11,28), RGB15(6,7,7), RGB15(4,5,8), RGB15(8,9,11)
}; };
const u16 palette3[] = //sliderball, sliderfollowcircle const u16 palette3[] = //sliderball, sliderfollowcircle
{ {
RGB15(31,0,31), RGB15(31,24,0), RGB15(31,0,0), RGB15(31,31,0) RGB15(31,0,31), RGB15(31,24,0), RGB15(31,0,0), RGB15(31,31,0)
}; };
const u16 palette4[] = //hit300, hit300k, hit300g, hit0 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,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(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(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) RGB15(15,7,3), RGB15(13,13,10), RGB15(22,22,17), RGB15(21,17,4)
}; };
const u16 palette5[] = //hit50. hit100, hit100k const u16 palette5[] = //hit50. hit100, hit100k
{ {
RGB15(31,0,31), RGB15(3,3,4), RGB15(12,30,8), RGB15(4,10,3), 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(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(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) RGB15(28,30,29), RGB15(24,31,23), RGB15(12,13,13), RGB15(18,19,19)
}; };
const u16 palette6[] = //slider30, slider10 const u16 palette6[] = //slider30, slider10
{ {
RGB15(31,0,31), RGB15(31,7,29), RGB15(0,0,0), RGB15(31,20,30) 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 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(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(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(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) RGB15(24,24,0), RGB15(30,31,1), RGB15(27,28,1), RGB15(16,16,6)
}; };
const u16 palette8[] = //scorebar const u16 palette8[] = //scorebar
{ {
RGB15(31,31,31), RGB15(0,0,0), RGB15(10,17,31), RGB15(19,17,31), 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(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(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) RGB15(16,19,31), RGB15(19,21,31), RGB15(14,14,18), RGB15(15,16,22)
}; };
const u32 uv8x8[] = { const u32 uv8x8[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)), TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(8), inttot16(0)), TEXTURE_PACK(inttot16(8), inttot16(0)),
TEXTURE_PACK(inttot16(8),inttot16(8)), TEXTURE_PACK(inttot16(8),inttot16(8)),
TEXTURE_PACK(inttot16(0), inttot16(8)) TEXTURE_PACK(inttot16(0), inttot16(8))
}; };
const u32 uv16x16[] = { const u32 uv16x16[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)), TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(16), inttot16(0)), TEXTURE_PACK(inttot16(16), inttot16(0)),
TEXTURE_PACK(inttot16(16),inttot16(16)), TEXTURE_PACK(inttot16(16),inttot16(16)),
TEXTURE_PACK(inttot16(0), inttot16(16)) TEXTURE_PACK(inttot16(0), inttot16(16))
}; };
const u32 uv32x32[] = { const u32 uv32x32[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)), TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(32), inttot16(0)), TEXTURE_PACK(inttot16(32), inttot16(0)),
TEXTURE_PACK(inttot16(32),inttot16(32)), TEXTURE_PACK(inttot16(32),inttot16(32)),
TEXTURE_PACK(inttot16(0), inttot16(32)) TEXTURE_PACK(inttot16(0), inttot16(32))
}; };
const u32 uv64x64[] = { const u32 uv64x64[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)), TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(64), 0), TEXTURE_PACK(inttot16(64), 0),
TEXTURE_PACK(inttot16(64),inttot16(64)), TEXTURE_PACK(inttot16(64),inttot16(64)),
TEXTURE_PACK(inttot16(0), inttot16(64)) TEXTURE_PACK(inttot16(0), inttot16(64))
}; };
const u32 uv128x128[] = { const u32 uv128x128[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)), TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(128), inttot16(0)), TEXTURE_PACK(inttot16(128), inttot16(0)),
TEXTURE_PACK(inttot16(128),inttot16(128)), TEXTURE_PACK(inttot16(128),inttot16(128)),
TEXTURE_PACK(inttot16(0), inttot16(128)) TEXTURE_PACK(inttot16(0), inttot16(128))
}; };
const u32 uv256x16[] = { const u32 uv256x16[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)), TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(256), inttot16(0)), TEXTURE_PACK(inttot16(256), inttot16(0)),
TEXTURE_PACK(inttot16(256),inttot16(16)), TEXTURE_PACK(inttot16(256),inttot16(16)),
TEXTURE_PACK(inttot16(0), inttot16(16)) TEXTURE_PACK(inttot16(0), inttot16(16))
}; };
const u32 uv256x192[] = { const u32 uv256x192[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)), TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(256), inttot16(0)), TEXTURE_PACK(inttot16(256), inttot16(0)),
TEXTURE_PACK(inttot16(256),inttot16(192)), TEXTURE_PACK(inttot16(256),inttot16(192)),
TEXTURE_PACK(inttot16(0), inttot16(192)) TEXTURE_PACK(inttot16(0), inttot16(192))
}; };
const v16 plu[] = { const v16 plu[] = {
floattov16(-2.00f), floattov16(-2.00f),
floattov16(-1.99f), floattov16(-1.98f), floattov16(-1.97f), floattov16(-1.96f), floattov16(-1.95f), 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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(-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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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) floattov16(7.95f), floattov16(7.96f), floattov16(7.97f), floattov16(7.98f), floattov16(7.99f)
}; };

View File

@ -1,115 +1,115 @@
#ifndef __GFXINFO_H__ #ifndef __GFXINFO_H__
#define __GFXINFO_H__ #define __GFXINFO_H__
#define NUMBER_OF_TEXTURES 37 #define NUMBER_OF_TEXTURES 37
#include "circle_bin.h" #include "circle_bin.h"
#include "circleoverlay_bin.h" #include "circleoverlay_bin.h"
#include "circleapproach_bin.h" #include "circleapproach_bin.h"
#include "spinner_bin.h" #include "spinner_bin.h"
#include "spinnerbg_bin.h" #include "spinnerbg_bin.h"
#include "spinnerbars_bin.h" #include "spinnerbars_bin.h"
#include "disc_bin.h" #include "disc_bin.h"
#include "sliderb0_bin.h" #include "sliderb0_bin.h"
#include "sliderb1_bin.h" #include "sliderb1_bin.h"
#include "sliderb2_bin.h" #include "sliderb2_bin.h"
#include "sliderb3_bin.h" #include "sliderb3_bin.h"
#include "sliderb4_bin.h" #include "sliderb4_bin.h"
#include "sliderb5_bin.h" #include "sliderb5_bin.h"
#include "sliderb6_bin.h" #include "sliderb6_bin.h"
#include "sliderb7_bin.h" #include "sliderb7_bin.h"
#include "sliderb8_bin.h" #include "sliderb8_bin.h"
#include "sliderb9_bin.h" #include "sliderb9_bin.h"
#include "sliderfollow_bin.h" #include "sliderfollow_bin.h"
#include "slidertick_bin.h" #include "slidertick_bin.h"
#include "sliderreverse_bin.h" #include "sliderreverse_bin.h"
#include "hit0_bin.h" #include "hit0_bin.h"
#include "hit50_bin.h" #include "hit50_bin.h"
#include "hit100_bin.h" #include "hit100_bin.h"
#include "hit100k_bin.h" #include "hit100k_bin.h"
#include "hit300_bin.h" #include "hit300_bin.h"
#include "hit300k_bin.h" #include "hit300k_bin.h"
#include "hit300g_bin.h" #include "hit300g_bin.h"
#include "slider10_bin.h" #include "slider10_bin.h"
#include "slider30_bin.h" #include "slider30_bin.h"
#include "scorebar_bin.h" #include "scorebar_bin.h"
#include "scorebar_colour_bin.h" #include "scorebar_colour_bin.h"
#include "scorebar_ki_bin.h" #include "scorebar_ki_bin.h"
#include "scorebar_kidanger_bin.h" #include "scorebar_kidanger_bin.h"
#include "scorebar_kidanger2_bin.h" #include "scorebar_kidanger2_bin.h"
#include "white_bin.h" #include "white_bin.h"
//#include "songbg_osu_bin.h" //#include "songbg_osu_bin.h"
typedef enum { typedef enum {
TX_PLAY_CIRCLE, TX_PLAY_CIRCLE,
TX_PLAY_CIRCLEOVERLAY, TX_PLAY_CIRCLEOVERLAY,
TX_PLAY_CIRCLEAPPROACH, TX_PLAY_CIRCLEAPPROACH,
TX_PLAY_SPINNER, TX_PLAY_SPINNER,
TX_PLAY_SPINNERBG, TX_PLAY_SPINNERBG,
TX_PLAY_SPINNERBARS, TX_PLAY_SPINNERBARS,
TX_PLAY_SLIDERB0, TX_PLAY_SLIDERB0,
TX_PLAY_SLIDERB1, TX_PLAY_SLIDERB1,
TX_PLAY_SLIDERB2, TX_PLAY_SLIDERB2,
TX_PLAY_SLIDERB3, TX_PLAY_SLIDERB3,
TX_PLAY_SLIDERB4, TX_PLAY_SLIDERB4,
TX_PLAY_SLIDERB5, TX_PLAY_SLIDERB5,
TX_PLAY_SLIDERB6, TX_PLAY_SLIDERB6,
TX_PLAY_SLIDERB7, TX_PLAY_SLIDERB7,
TX_PLAY_SLIDERB8, TX_PLAY_SLIDERB8,
TX_PLAY_SLIDERB9, TX_PLAY_SLIDERB9,
TX_PLAY_DISC, TX_PLAY_DISC,
TX_PLAY_SLIDERFOLLOW, TX_PLAY_SLIDERFOLLOW,
TX_PLAY_SLIDERTICK, TX_PLAY_SLIDERTICK,
TX_PLAY_SLIDERREVERSE, TX_PLAY_SLIDERREVERSE,
TX_PLAY_HIT0, TX_PLAY_HIT0,
TX_PLAY_HIT50, TX_PLAY_HIT50,
TX_PLAY_HIT100, TX_PLAY_HIT100,
TX_PLAY_HIT100K, TX_PLAY_HIT100K,
TX_PLAY_HIT300, TX_PLAY_HIT300,
TX_PLAY_HIT300K, TX_PLAY_HIT300K,
TX_PLAY_HIT300G, TX_PLAY_HIT300G,
TX_PLAY_SLIDER10, TX_PLAY_SLIDER10,
TX_PLAY_SLIDER30, TX_PLAY_SLIDER30,
TX_PLAY_SCOREBAR, TX_PLAY_SCOREBAR,
TX_PLAY_SCOREBAR_BAR, TX_PLAY_SCOREBAR_BAR,
TX_PLAY_SCOREBAR_KI, TX_PLAY_SCOREBAR_KI,
TX_PLAY_SCOREBAR_KIDANGER, TX_PLAY_SCOREBAR_KIDANGER,
TX_PLAY_SCOREBAR_KIDANGER2, TX_PLAY_SCOREBAR_KIDANGER2,
TX_WHITE, TX_WHITE,
TX_SONGSELECT_SONGBG TX_SONGSELECT_SONGBG
} TextureType; } TextureType;
// arrays // arrays
//extern const float zvalue[]; //extern const float zvalue[];
extern const u16 palette0[]; extern const u16 palette0[];
extern const u16 palette1[]; extern const u16 palette1[];
extern const u16 palette2[]; extern const u16 palette2[];
extern const u16 palette3[]; extern const u16 palette3[];
extern const u16 palette4[]; extern const u16 palette4[];
extern const u16 palette5[]; extern const u16 palette5[];
extern const u16 palette6[]; extern const u16 palette6[];
extern const u16 palette7[]; extern const u16 palette7[];
extern const u16 palette8[]; extern const u16 palette8[];
extern const u32 uv8x8[]; extern const u32 uv8x8[];
extern const u32 uv16x16[]; extern const u32 uv16x16[];
extern const u32 uv32x32[]; extern const u32 uv32x32[];
extern const u32 uv64x64[]; extern const u32 uv64x64[];
extern const u32 uv128x128[]; extern const u32 uv128x128[];
extern const u32 uv256x16[]; extern const u32 uv256x16[];
extern const u32 uv256x192[]; extern const u32 uv256x192[];
extern const v16 plu[]; extern const v16 plu[];
#endif #endif

View File

@ -0,0 +1,277 @@
#include "GraphicsManager.h"
#include <string>
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;
}

View File

@ -1,62 +1,62 @@
#include <nds.h> #include <nds.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "GfxInfo.h" #include "GfxInfo.h"
#ifndef __GRAPHICSMANAGER_H__ #ifndef __GRAPHICSMANAGER_H__
#define __GRAPHICSMANAGER_H__ #define __GRAPHICSMANAGER_H__
//#define glVertex2lu(x,y) glVertex3v16(plu[(x)+200],plu[(y)+200],0) //#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 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 glVertex2lu1f(x,y,z) glVertex3v16(plu[(x)+200],plu[(y)+200],floattov16(z))
#define LoadGLTexture(tex, type, sizeX, sizeY, palette, uv, texture) \ #define LoadGLTexture(tex, type, sizeX, sizeY, palette, uv, texture) \
LoadGLTextureEx(tex, type, sizeX, sizeY, palette, uv, texture, texture##_size) LoadGLTextureEx(tex, type, sizeX, sizeY, palette, uv, texture, texture##_size)
typedef struct { typedef struct {
int palette; int palette;
u8 format; u8 format;
const u32* uv; const u32* uv;
} TextureInfo; } TextureInfo;
typedef enum { typedef enum {
ORIGIN_CENTER, ORIGIN_CENTER,
ORIGIN_TOPLEFT, ORIGIN_TOPLEFT,
ORIGIN_BOTTOMLEFT, ORIGIN_BOTTOMLEFT,
ORIGIN_TOPRIGHT ORIGIN_TOPRIGHT
} DrawOrigin; } DrawOrigin;
typedef enum { typedef enum {
FIELD_SCREEN, FIELD_SCREEN,
FIELD_PLAY FIELD_PLAY
} FieldType; } FieldType;
class GraphicsManager class GraphicsManager
{ {
public: public:
static GraphicsManager& Graphics() { return sGraphicsManager; } 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); 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 PlayXOffset = 64;
static const u32 PlayYOffset = 73; static const u32 PlayYOffset = 73;
protected: protected:
void LoadGLTextureEx(TextureType tex, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int palette, const u32* uv, const u8* texture, u32 size); 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); s32 ForceBounds(s32 value);
TextureInfo textureInfo[NUMBER_OF_TEXTURES]; TextureInfo textureInfo[NUMBER_OF_TEXTURES];
int textures[NUMBER_OF_TEXTURES]; int textures[NUMBER_OF_TEXTURES];
static GraphicsManager sGraphicsManager; static GraphicsManager sGraphicsManager;
private: private:
GraphicsManager(); GraphicsManager();
~GraphicsManager() {} ~GraphicsManager() {}
u32 mPolygonId; u32 mPolygonId;
}; };
#endif #endif

View File

@ -1,23 +1,23 @@
#include "SpriteContainer.h" #include "SpriteContainer.h"
SpriteContainer::~SpriteContainer() SpriteContainer::~SpriteContainer()
{ {
if (mSpriteOwner) if (mSpriteOwner)
{ {
for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it)
{ {
if (*it != NULL) if (*it != NULL)
delete *it; delete *it;
} }
} }
} }
void SpriteContainer::AddToSpriteManager(SpriteManager& spriteManager) void SpriteContainer::AddToSpriteManager(SpriteManager& spriteManager)
{ {
spriteManager.Add(mSprites); spriteManager.Add(mSprites);
//once sprites are added to spritemanager, the memory //once sprites are added to spritemanager, the memory
//belongs to the spritemanager, and should be deleted by it //belongs to the spritemanager, and should be deleted by it
mSpriteOwner = false; mSpriteOwner = false;
} }

View File

@ -1,32 +1,32 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include <vector> #include <vector>
#include "pSprite.h" #include "pSprite.h"
#include "SpriteManager.h" #include "SpriteManager.h"
#ifndef __SPRITECONTAINER_H__ #ifndef __SPRITECONTAINER_H__
#define __SPRITECONTAINER_H__ #define __SPRITECONTAINER_H__
using namespace std; using namespace std;
typedef vector<pSprite*>::iterator spriteIterator; typedef vector<pSprite*>::iterator spriteIterator;
/* a generic base class for all objects that require sprites /* a generic base class for all objects that require sprites
* sprite cleanup is automatically handled * sprite cleanup is automatically handled
*/ */
class SpriteContainer class SpriteContainer
{ {
public: public:
virtual ~SpriteContainer(); virtual ~SpriteContainer();
void AddToSpriteManager(SpriteManager& spriteManager); void AddToSpriteManager(SpriteManager& spriteManager);
protected: protected:
vector<pSprite*> mSprites; vector<pSprite*> mSprites;
private: private:
bool mSpriteOwner; bool mSpriteOwner;
}; };
#endif #endif

View File

@ -1,78 +1,78 @@
#include "SpriteManager.h" #include "SpriteManager.h"
SpriteManager::SpriteManager() SpriteManager::SpriteManager()
{ {
} }
SpriteManager::~SpriteManager() SpriteManager::~SpriteManager()
{ {
for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it) for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it)
{ {
if (*it != NULL) if (*it != NULL)
delete *it; delete *it;
} }
} }
void SpriteManager::Draw() void SpriteManager::Draw()
{ {
u32 i = 0; u32 i = 0;
vector<u32> list; vector<u32> list;
for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it, ++i) for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it, ++i)
{ {
pSprite* spr = *it; pSprite* spr = *it;
//if for some reason sprite is nonexistent then mark for deletion //if for some reason sprite is nonexistent then mark for deletion
if (spr == NULL) if (spr == NULL)
{ {
list.push_back(i); list.push_back(i);
continue; continue;
} }
spr->Update(); spr->Update();
//if sprite is dead then mark for deletion //if sprite is dead then mark for deletion
if (spr->Draw() == false) if (spr->Draw() == false)
{ {
list.push_back(i); list.push_back(i);
continue; continue;
} }
//no need to draw things you can't see //no need to draw things you can't see
if (spr->Width == 0 || spr->Height == 0 || spr->Alpha == 0) if (spr->Width == 0 || spr->Height == 0 || spr->Alpha == 0)
continue; continue;
GraphicsManager::Graphics().Draw( spr->Texture, GraphicsManager::Graphics().Draw( spr->Texture,
spr->X, spr->Y, spr->X, spr->Y,
spr->Width, spr->Height, spr->Width, spr->Height,
spr->Origin, spr->Field, spr->Origin, spr->Field,
spr->Color, spr->Alpha, spr->Angle, spr->Color, spr->Alpha, spr->Angle,
spr->Z, spr->UV); spr->Z, spr->UV);
} }
//delete dead sprites //delete dead sprites
while (list.size() > 0) while (list.size() > 0)
{ {
spriteIterator it = mSprites.begin() + list.back(); spriteIterator it = mSprites.begin() + list.back();
if (*it != NULL) if (*it != NULL)
delete *it; delete *it;
mSprites.erase(it); mSprites.erase(it);
list.pop_back(); list.pop_back();
} }
} }
void SpriteManager::Add(pSprite* spr) void SpriteManager::Add(pSprite* spr)
{ {
mSprites.push_back(spr); mSprites.push_back(spr);
} }
void SpriteManager::Add(const vector<pSprite*>& spr) void SpriteManager::Add(const vector<pSprite*>& spr)
{ {
for (spriteIteratorConst it = spr.begin(); it != spr.end(); ++it) for (spriteIteratorConst it = spr.begin(); it != spr.end(); ++it)
{ {
Add(*it); Add(*it);
} }
} }

View File

@ -1,33 +1,33 @@
#include <nds.h> #include <nds.h>
#include <vector> #include <vector>
#include "pSprite.h" #include "pSprite.h"
#include "GraphicsManager.h" #include "GraphicsManager.h"
#ifndef __SPRITEMANAGER_H__ #ifndef __SPRITEMANAGER_H__
#define __SPRITEMANAGER_H__ #define __SPRITEMANAGER_H__
using namespace std; using namespace std;
typedef vector<pSprite*>::iterator spriteIterator; typedef vector<pSprite*>::iterator spriteIterator;
typedef vector<pSprite*>::const_iterator spriteIteratorConst; typedef vector<pSprite*>::const_iterator spriteIteratorConst;
class SpriteManager class SpriteManager
{ {
public: public:
SpriteManager(); SpriteManager();
virtual ~SpriteManager(); virtual ~SpriteManager();
void Draw(); void Draw();
void Add(pSprite* spr); void Add(pSprite* spr);
void Add(const vector<pSprite*>& spr); void Add(const vector<pSprite*>& spr);
vector<pSprite*>& Sprites() { return mSprites; } vector<pSprite*>& Sprites() { return mSprites; }
protected: protected:
vector<pSprite*> mSprites; vector<pSprite*> mSprites;
}; };
#endif #endif

View File

@ -1,53 +1,53 @@
#include "Transformation.h" #include "Transformation.h"
Transformation::Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue) Transformation::Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue)
{ {
this->type = type; this->type = type;
this->starttime = starttime; this->starttime = starttime;
this->endtime = endtime; this->endtime = endtime;
this->startvalue = startvalue; this->startvalue = startvalue;
this->endvalue = endvalue; this->endvalue = endvalue;
totaltime = endtime-starttime; totaltime = endtime-starttime;
totalvalue = endvalue-startvalue; totalvalue = endvalue-startvalue;
currentvalue = startvalue; currentvalue = startvalue;
active = false; active = false;
lastactive = false; lastactive = false;
} }
void Transformation::Update() void Transformation::Update()
{ {
s32 time = GameClock::Clock().Time(); s32 time = GameClock::Clock().Time();
if (!active) if (!active)
{ {
if (time > starttime) if (time > starttime)
active = true; active = true;
else else
return; return;
} }
if (time > endtime) if (time > endtime)
{ {
active = false; active = false;
currentvalue = endvalue; currentvalue = endvalue;
lastactive = true; lastactive = true;
return; return;
} }
currentvalue = (s32)(((time-starttime)/(float)totaltime)*totalvalue + startvalue); currentvalue = (s32)(((time-starttime)/(float)totaltime)*totalvalue + startvalue);
} }
bool Transformation::Active() bool Transformation::Active()
{ {
if (lastactive) if (lastactive)
{ {
lastactive = false; lastactive = false;
return true; return true;
} }
return active; return active;
} }

View File

@ -1,42 +1,42 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include "System/GameClock.h" #include "System/GameClock.h"
#ifndef __TRANSFORMATION_H__ #ifndef __TRANSFORMATION_H__
#define __TRANSFORMATION_H__ #define __TRANSFORMATION_H__
typedef enum { typedef enum {
TR_FADE, TR_FADE,
TR_MOVEX, TR_MOVEX,
TR_MOVEY, TR_MOVEY,
TR_SCALEX, TR_SCALEX,
TR_SCALEY, TR_SCALEY,
TR_ROTATE, TR_ROTATE,
TR_KILL TR_KILL
} TransformType; } TransformType;
class Transformation class Transformation
{ {
public: public:
Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue); Transformation(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue);
void Update(); void Update();
s32 Value() const { return currentvalue; } s32 Value() const { return currentvalue; }
bool Active(); bool Active();
TransformType Type() const { return type; } TransformType Type() const { return type; }
bool Finished() { return GameClock::Clock().Time() > endtime; } bool Finished() { return GameClock::Clock().Time() > endtime; }
protected: protected:
TransformType type; TransformType type;
bool active, lastactive; bool active, lastactive;
s32 starttime, endtime, totaltime; s32 starttime, endtime, totaltime;
s32 startvalue, endvalue, currentvalue; s32 startvalue, endvalue, currentvalue;
s32 totalvalue; s32 totalvalue;
}; };
#endif #endif

View File

@ -1,30 +1,30 @@
#include "pAnimation.h" #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) 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) : pSprite(texture, x, y, width, height, origin, type, color, alpha)
{ {
mFrameCount = framecount; mFrameCount = framecount;
mFrameCurrent = 0; mFrameCurrent = 0;
mOrigTexture = texture; mOrigTexture = texture;
mUpdatesPerFrame = 60.0 / fps; mUpdatesPerFrame = 60.0 / fps;
mUpdatesWaited = 0; mUpdatesWaited = 0;
} }
void pAnimation::Update() void pAnimation::Update()
{ {
while (mUpdatesWaited >= mUpdatesPerFrame) while (mUpdatesWaited >= mUpdatesPerFrame)
{ {
mUpdatesWaited -= mUpdatesPerFrame; mUpdatesWaited -= mUpdatesPerFrame;
++mFrameCurrent; ++mFrameCurrent;
if (mFrameCurrent >= mFrameCount) if (mFrameCurrent >= mFrameCount)
mFrameCurrent = 0; mFrameCurrent = 0;
Texture = (TextureType)(mOrigTexture + mFrameCurrent); Texture = (TextureType)(mOrigTexture + mFrameCurrent);
} }
++mUpdatesWaited; ++mUpdatesWaited;
pSprite::Update(); pSprite::Update();
} }

View File

@ -1,22 +1,22 @@
#include <nds.h> #include <nds.h>
#include "pSprite.h" #include "pSprite.h"
#ifndef __PANIMATION_H__ #ifndef __PANIMATION_H__
#define __PANIMATION_H__ #define __PANIMATION_H__
class pAnimation : public pSprite class pAnimation : public pSprite
{ {
public: public:
pAnimation(TextureType texture, u32 framecount, u32 fps, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType type, rgb color, u32 alpha); 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(); void Update();
protected: protected:
TextureType mOrigTexture; TextureType mOrigTexture;
float mUpdatesPerFrame; float mUpdatesPerFrame;
float mUpdatesWaited; float mUpdatesWaited;
u32 mFrameCurrent; u32 mFrameCurrent;
u32 mFrameCount; u32 mFrameCount;
}; };
#endif #endif

View File

@ -1,193 +1,193 @@
#include "pSprite.h" #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) pSprite::pSprite(TextureType texture, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, float z)
{ {
Texture = texture; Texture = texture;
X = x; X = x;
Y = y; Y = y;
Width = mOrigWidth = width; Width = mOrigWidth = width;
Height = mOrigHeight = height; Height = mOrigHeight = height;
Origin = origin; Origin = origin;
Field = fieldtype; Field = fieldtype;
Color = color; Color = color;
Alpha = alpha; Alpha = alpha;
mDraw = true; mDraw = true;
Angle = 0; Angle = 0;
UV = NULL; UV = NULL;
Z = z; Z = z;
} }
pSprite::~pSprite() pSprite::~pSprite()
{ {
for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it)
{ {
if (*it != NULL) if (*it != NULL)
delete *it; delete *it;
} }
if (UV != NULL) if (UV != NULL)
delete UV; delete UV;
} }
void pSprite::Update() void pSprite::Update()
{ {
for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it)
{ {
Transformation* tr = (*it); Transformation* tr = (*it);
tr->Update(); tr->Update();
if (tr->Active()) if (tr->Active())
{ {
switch (tr->Type()) switch (tr->Type())
{ {
case TR_FADE: case TR_FADE:
Alpha = tr->Value(); Alpha = tr->Value();
break; break;
case TR_MOVEX: case TR_MOVEX:
X = tr->Value(); X = tr->Value();
break; break;
case TR_MOVEY: case TR_MOVEY:
Y = tr->Value(); Y = tr->Value();
break; break;
case TR_SCALEX: case TR_SCALEX:
Width = tr->Value(); Width = tr->Value();
break; break;
case TR_SCALEY: case TR_SCALEY:
Height = tr->Value(); Height = tr->Value();
break; break;
case TR_ROTATE: case TR_ROTATE:
Angle = tr->Value(); Angle = tr->Value();
break; break;
case TR_KILL: case TR_KILL:
mDraw = false; mDraw = false;
break; break;
} }
} }
} }
} }
bool pSprite::InBounds(s32 x, s32 y) bool pSprite::InBounds(s32 x, s32 y)
{ {
if (Field == FIELD_PLAY) if (Field == FIELD_PLAY)
{ {
x -= GraphicsManager::PlayXOffset; x -= GraphicsManager::PlayXOffset;
y -= GraphicsManager::PlayYOffset; y -= GraphicsManager::PlayYOffset;
} }
switch (Origin) switch (Origin)
{ {
case ORIGIN_TOPLEFT: case ORIGIN_TOPLEFT:
{ {
return x >= X && x <= X+Width return x >= X && x <= X+Width
&& y >= Y && y <= Y+Height; && y >= Y && y <= Y+Height;
} }
case ORIGIN_CENTER: case ORIGIN_CENTER:
{ {
s32 halfWidth = Width>>1; s32 halfWidth = Width>>1;
s32 halfHeight = Height>>1; s32 halfHeight = Height>>1;
return x >= X-halfWidth && x <= X+halfWidth return x >= X-halfWidth && x <= X+halfWidth
&& y >= Y-halfHeight && y <= Y+halfHeight; && y >= Y-halfHeight && y <= Y+halfHeight;
} }
case ORIGIN_BOTTOMLEFT: case ORIGIN_BOTTOMLEFT:
{ {
return x >= X && x <= X+Width return x >= X && x <= X+Width
&& y >= Y-Height && y <= Y; && y >= Y-Height && y <= Y;
} }
default: default:
return false; return false;
} }
} }
void pSprite::Kill(s32 time) void pSprite::Kill(s32 time)
{ {
Transform(TR_KILL, time, time, 0, 0); Transform(TR_KILL, time, time, 0, 0);
} }
void pSprite::ClearTransforms() void pSprite::ClearTransforms()
{ {
for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it) for (transformIterator it = mTransformations.begin(); it != mTransformations.end(); ++it)
{ {
if (*it != NULL) if (*it != NULL)
delete *it; delete *it;
} }
mTransformations.clear(); mTransformations.clear();
} }
void pSprite::Transform(Transformation* transform) void pSprite::Transform(Transformation* transform)
{ {
mTransformations.push_back(transform); mTransformations.push_back(transform);
} }
void pSprite::Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue) void pSprite::Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue)
{ {
Transform(new Transformation(type, starttime, endtime, startvalue, endvalue)); Transform(new Transformation(type, starttime, endtime, startvalue, endvalue));
} }
void pSprite::Scale(s32 starttime, s32 endtime, float start, float end) void pSprite::Scale(s32 starttime, s32 endtime, float start, float end)
{ {
Transform(TR_SCALEX, starttime, endtime, mOrigWidth*start, mOrigWidth*end); Transform(TR_SCALEX, starttime, endtime, mOrigWidth*start, mOrigWidth*end);
Transform(TR_SCALEY, starttime, endtime, mOrigHeight*start, mOrigHeight*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) void pSprite::Move(s32 starttime, s32 endtime, s32 startx, s32 starty, s32 endx, s32 endy)
{ {
Transform(TR_MOVEX, starttime, endtime, startx, endx); Transform(TR_MOVEX, starttime, endtime, startx, endx);
Transform(TR_MOVEY, starttime, endtime, starty, endy); Transform(TR_MOVEY, starttime, endtime, starty, endy);
} }
void pSprite::Move(s32 starttime, s32 endtime, s32 endx, s32 endy) void pSprite::Move(s32 starttime, s32 endtime, s32 endx, s32 endy)
{ {
Move(starttime, endtime, X, Y, endx, endy); Move(starttime, endtime, X, Y, endx, endy);
} }
void pSprite::Move(s32 endx, s32 endy) void pSprite::Move(s32 endx, s32 endy)
{ {
X = endx; X = endx;
Y = endy; Y = endy;
} }
void pSprite::Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda) void pSprite::Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda)
{ {
Transform(TR_ROTATE, starttime, endtime, starta, enda); Transform(TR_ROTATE, starttime, endtime, starta, enda);
} }
void pSprite::Rotate(s32 angle) void pSprite::Rotate(s32 angle)
{ {
Transform(TR_ROTATE, GameClock::Clock().Time(), GameClock::Clock().Time(), angle, angle); Transform(TR_ROTATE, GameClock::Clock().Time(), GameClock::Clock().Time(), angle, angle);
} }
void pSprite::Show() void pSprite::Show()
{ {
Show(GameClock::Clock().Time()); Show(GameClock::Clock().Time());
} }
void pSprite::Show(s32 time) void pSprite::Show(s32 time)
{ {
Transform(TR_FADE, time, time, 31, 31); Transform(TR_FADE, time, time, 31, 31);
} }
void pSprite::Show(s32 starttime, s32 endtime) void pSprite::Show(s32 starttime, s32 endtime)
{ {
Transform(TR_FADE, starttime, endtime, 0, 31); Transform(TR_FADE, starttime, endtime, 0, 31);
} }
void pSprite::Hide() void pSprite::Hide()
{ {
Hide(GameClock::Clock().Time()); Hide(GameClock::Clock().Time());
} }
void pSprite::Hide(s32 time) void pSprite::Hide(s32 time)
{ {
Transform(TR_FADE, time, time, 0, 0); Transform(TR_FADE, time, time, 0, 0);
} }
void pSprite::Hide(s32 starttime, s32 endtime) void pSprite::Hide(s32 starttime, s32 endtime)
{ {
Transform(TR_FADE, starttime, endtime, 31, 0); Transform(TR_FADE, starttime, endtime, 31, 0);
} }

View File

@ -1,103 +1,103 @@
#include <nds.h> #include <nds.h>
#include <vector> #include <vector>
#include "GraphicsManager.h" #include "GraphicsManager.h"
#include "Transformation.h" #include "Transformation.h"
#include "System/GameClock.h" #include "System/GameClock.h"
#ifndef __PSPRITE_H__ #ifndef __PSPRITE_H__
#define __PSPRITE_H__ #define __PSPRITE_H__
using namespace std; using namespace std;
typedef vector<Transformation*>::iterator transformIterator; typedef vector<Transformation*>::iterator transformIterator;
class pSprite class pSprite
{ {
public: public:
pSprite(TextureType texture, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType fieldtype, rgb color, u32 alpha, float z = 0); 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 ~pSprite();
virtual void Update(); virtual void Update();
bool InBounds(s32 x, s32 y); bool InBounds(s32 x, s32 y);
void Kill(s32 time); void Kill(s32 time);
void ClearTransforms(); void ClearTransforms();
void Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue); void Transform(TransformType type, s32 starttime, s32 endtime, s32 startvalue, s32 endvalue);
void Scale(s32 starttime, s32 endtime, float start, float end); 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 startx, s32 starty, s32 endx, s32 endy);
void Move(s32 starttime, s32 endtime, s32 endx, s32 endy); void Move(s32 starttime, s32 endtime, s32 endx, s32 endy);
void Move(s32 x, s32 y); void Move(s32 x, s32 y);
void Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda); void Rotate(s32 starttime, s32 endtime, s32 starta, s32 enda);
void Rotate(s32 angle); void Rotate(s32 angle);
void Show(); void Show();
void Show(s32 time); void Show(s32 time);
void Show(s32 starttime, s32 endtime); void Show(s32 starttime, s32 endtime);
void Hide(); void Hide();
void Hide(s32 time); void Hide(s32 time);
void Hide(s32 starttime, s32 endtime); void Hide(s32 starttime, s32 endtime);
/* /*
s32 x() { return mX; } s32 x() { return mX; }
s32 y() { return mY; } s32 y() { return mY; }
u32 width() { return mWidth; } u32 width() { return mWidth; }
u32 height() { return mHeight; } u32 height() { return mHeight; }
rgb color() { return mColor; } rgb color() { return mColor; }
u32 alpha() { return mAlpha; } u32 alpha() { return mAlpha; }
s32 angle() { return mAngle; } s32 angle() { return mAngle; }
float deltaz() { return mDeltaZ; } float deltaz() { return mDeltaZ; }
u32* uv() { return mUV; } u32* uv() { return mUV; }
void SetTexture(Texture tex) { mTexture = tex; } void SetTexture(Texture tex) { mTexture = tex; }
//for spinners... a bit hacky but meh -.- //for spinners... a bit hacky but meh -.-
s32& Angle() { return mAngle; } s32& Angle() { return mAngle; }
void SetCustomBounds(u32* uv) { mUV = uv; } void SetCustomBounds(u32* uv) { mUV = uv; }
void SetHeight(s32 height) { mHeight = height; } void SetHeight(s32 height) { mHeight = height; }
void SetWidth(s32 width) { mWidth = width; } void SetWidth(s32 width) { mWidth = width; }
//for score sprites (more hax) //for score sprites (more hax)
void SetDeltaZ(float z) { mDeltaZ = z; } void SetDeltaZ(float z) { mDeltaZ = z; }
u32& Alpha() { return mAlpha; } u32& Alpha() { return mAlpha; }
DrawOrigin origin() { return mOrigin; } DrawOrigin origin() { return mOrigin; }
FieldType fieldType() { return mFieldType; } FieldType fieldType() { return mFieldType; }
Texture texture() { return mTexture; } Texture texture() { return mTexture; }
*/ */
bool Draw() { return mDraw; } bool Draw() { return mDraw; }
s32 X, Y; s32 X, Y;
u32 Width, Height; u32 Width, Height;
rgb Color; rgb Color;
u32 Alpha; u32 Alpha;
s32 Angle; s32 Angle;
float Z; float Z;
u32* UV; u32* UV;
DrawOrigin Origin; DrawOrigin Origin;
FieldType Field; FieldType Field;
TextureType Texture; TextureType Texture;
protected: protected:
u32 mOrigWidth, mOrigHeight; u32 mOrigWidth, mOrigHeight;
bool mDraw; bool mDraw;
/* /*
s32 mX, mY; s32 mX, mY;
u32 mWidth, mHeight; u32 mWidth, mHeight;
rgb mColor; rgb mColor;
u32 mAlpha; u32 mAlpha;
s32 mAngle; s32 mAngle;
float mDeltaZ; float mDeltaZ;
u32* mUV; u32* mUV;
DrawOrigin mOrigin; DrawOrigin mOrigin;
FieldType mFieldType; FieldType mFieldType;
Texture mTexture; Texture mTexture;
*/ */
vector<Transformation*> mTransformations; vector<Transformation*> mTransformations;
void Transform(Transformation* transform); void Transform(Transformation* transform);
}; };
#endif #endif

View File

@ -1,196 +1,196 @@
#include "AudioManager.h" #include "AudioManager.h"
AudioManager AudioManager::sEngine; AudioManager AudioManager::sEngine;
AudioManager::AudioManager() AudioManager::AudioManager()
{ {
soundEnable(); soundEnable();
//sound init //sound init
ResetSamples(); ResetSamples();
mSampleSets[0] = NULL; //"none" sample set >.> mSampleSets[0] = NULL; //"none" sample set >.>
mSampleSets[1] = &mSampleNormal; mSampleSets[1] = &mSampleNormal;
mSampleSets[2] = &mSampleSoft; mSampleSets[2] = &mSampleSoft;
//music init //music init
mChannel = -1; mChannel = -1;
mBuffer = (u8*)new u32[SIZE*2/4+1]; //div4 because u32 = 4 * u8 mBuffer = (u8*)new u32[SIZE*2/4+1]; //div4 because u32 = 4 * u8
irqEnable(IRQ_TIMER0); irqEnable(IRQ_TIMER0);
irqSet(IRQ_TIMER0, MusicTimerHandler); irqSet(IRQ_TIMER0, MusicTimerHandler);
} }
void AudioManager::ResetSamples() void AudioManager::ResetSamples()
{ {
mSampleNormal.hitnormal.data = normal_hitnormal_bin; mSampleNormal.hitnormal.data = normal_hitnormal_bin;
mSampleNormal.hitnormal.size = normal_hitnormal_bin_size; mSampleNormal.hitnormal.size = normal_hitnormal_bin_size;
mSampleNormal.hitwhistle.data = normal_hitwhistle_bin; mSampleNormal.hitwhistle.data = normal_hitwhistle_bin;
mSampleNormal.hitwhistle.size = normal_hitwhistle_bin_size; mSampleNormal.hitwhistle.size = normal_hitwhistle_bin_size;
mSampleNormal.hitfinish.data = normal_hitfinish_bin; mSampleNormal.hitfinish.data = normal_hitfinish_bin;
mSampleNormal.hitfinish.size = normal_hitfinish_bin_size; mSampleNormal.hitfinish.size = normal_hitfinish_bin_size;
mSampleNormal.hitclap.data = normal_hitclap_bin; mSampleNormal.hitclap.data = normal_hitclap_bin;
mSampleNormal.hitclap.size = normal_hitclap_bin_size; mSampleNormal.hitclap.size = normal_hitclap_bin_size;
mSampleNormal.slidertick.data = normal_slidertick_bin; mSampleNormal.slidertick.data = normal_slidertick_bin;
mSampleNormal.slidertick.size = normal_slidertick_bin_size; mSampleNormal.slidertick.size = normal_slidertick_bin_size;
mSampleNormal.sliderslide.data = normal_sliderslide_bin; mSampleNormal.sliderslide.data = normal_sliderslide_bin;
mSampleNormal.sliderslide.size = normal_sliderslide_bin_size; mSampleNormal.sliderslide.size = normal_sliderslide_bin_size;
mSampleNormal.sliderwhistle.data = normal_sliderwhistle_bin; mSampleNormal.sliderwhistle.data = normal_sliderwhistle_bin;
mSampleNormal.sliderwhistle.size = normal_sliderwhistle_bin_size; mSampleNormal.sliderwhistle.size = normal_sliderwhistle_bin_size;
mSampleSoft.hitnormal.data = soft_hitnormal_bin; mSampleSoft.hitnormal.data = soft_hitnormal_bin;
mSampleSoft.hitnormal.size = soft_hitnormal_bin_size; mSampleSoft.hitnormal.size = soft_hitnormal_bin_size;
mSampleSoft.hitwhistle.data = soft_hitwhistle_bin; mSampleSoft.hitwhistle.data = soft_hitwhistle_bin;
mSampleSoft.hitwhistle.size = soft_hitwhistle_bin_size; mSampleSoft.hitwhistle.size = soft_hitwhistle_bin_size;
mSampleSoft.hitfinish.data = soft_hitfinish_bin; mSampleSoft.hitfinish.data = soft_hitfinish_bin;
mSampleSoft.hitfinish.size = soft_hitfinish_bin_size; mSampleSoft.hitfinish.size = soft_hitfinish_bin_size;
mSampleSoft.hitclap.data = soft_hitclap_bin; mSampleSoft.hitclap.data = soft_hitclap_bin;
mSampleSoft.hitclap.size = soft_hitclap_bin_size; mSampleSoft.hitclap.size = soft_hitclap_bin_size;
mSampleSoft.slidertick.data = soft_slidertick_bin; mSampleSoft.slidertick.data = soft_slidertick_bin;
mSampleSoft.slidertick.size = soft_slidertick_bin_size; mSampleSoft.slidertick.size = soft_slidertick_bin_size;
mSampleSoft.sliderslide.data = soft_sliderslide_bin; mSampleSoft.sliderslide.data = soft_sliderslide_bin;
mSampleSoft.sliderslide.size = soft_sliderslide_bin_size; mSampleSoft.sliderslide.size = soft_sliderslide_bin_size;
mSampleSoft.sliderwhistle.data = soft_sliderwhistle_bin; mSampleSoft.sliderwhistle.data = soft_sliderwhistle_bin;
mSampleSoft.sliderwhistle.size = soft_sliderwhistle_bin_size; mSampleSoft.sliderwhistle.size = soft_sliderwhistle_bin_size;
} }
int AudioManager::PlaySample(const u8* data, u32 size, bool loop) int AudioManager::PlaySample(const u8* data, u32 size, bool loop)
{ {
return soundPlaySample(data, SoundFormat_8Bit, size, 22050, 127, 64, loop, 0); return soundPlaySample(data, SoundFormat_8Bit, size, 22050, 127, 64, loop, 0);
} }
int AudioManager::PlaySample(SampleSetInfo info, bool loop) int AudioManager::PlaySample(SampleSetInfo info, bool loop)
{ {
return soundPlaySample(info.data, SoundFormat_8Bit, info.size, 22050, 127, 64, loop, 0); return soundPlaySample(info.data, SoundFormat_8Bit, info.size, 22050, 127, 64, loop, 0);
} }
void AudioManager::SetChannelFreq(int channel, u16 freq) void AudioManager::SetChannelFreq(int channel, u16 freq)
{ {
soundSetFreq(channel, freq); soundSetFreq(channel, freq);
} }
void AudioManager::StopChannel(int channel) void AudioManager::StopChannel(int channel)
{ {
soundKill(channel); soundKill(channel);
} }
void AudioManager::PlayHitSound(HitObjectSound sound) void AudioManager::PlayHitSound(HitObjectSound sound)
{ {
SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId];
PlaySample(current->hitnormal); PlaySample(current->hitnormal);
if (sound & SND_WHISTLE) if (sound & SND_WHISTLE)
PlaySample(current->hitwhistle); PlaySample(current->hitwhistle);
if (sound & SND_FINISH) if (sound & SND_FINISH)
PlaySample(current->hitfinish); PlaySample(current->hitfinish);
if (sound & SND_CLAP) if (sound & SND_CLAP)
PlaySample(current->hitclap); PlaySample(current->hitclap);
} }
int AudioManager::PlaySliderSound(HitObjectSound sound) int AudioManager::PlaySliderSound(HitObjectSound sound)
{ {
SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId];
if (sound & SND_WHISTLE) if (sound & SND_WHISTLE)
return PlaySample(current->sliderwhistle, true); return PlaySample(current->sliderwhistle, true);
else else
return PlaySample(current->sliderslide, true); return PlaySample(current->sliderslide, true);
} }
void AudioManager::PlaySliderTick() void AudioManager::PlaySliderTick()
{ {
SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId]; SampleSet* current = mSampleSets[BeatmapElements::Element().GetTimingPoint().SampleSetId];
PlaySample(current->slidertick); PlaySample(current->slidertick);
} }
//music //music
void MusicTimerHandler() void MusicTimerHandler()
{ {
AudioManager::Engine().fSwap = !AudioManager::Engine().fSwap; AudioManager::Engine().fSwap = !AudioManager::Engine().fSwap;
AudioManager::Engine().fFill = true; AudioManager::Engine().fFill = true;
} }
int AudioManager::MusicPlay(string& filename) int AudioManager::MusicPlay(string& filename)
{ {
if (mChannel != -1) if (mChannel != -1)
MusicStop(); MusicStop();
mFile = fopen(filename.c_str(), "rb"); mFile = fopen(filename.c_str(), "rb");
if (mFile == NULL) if (mFile == NULL)
return -1; return -1;
MusicBuffer(); MusicBuffer();
return mChannel; return mChannel;
} }
int AudioManager::MusicSkipTo(u32 milliseconds) int AudioManager::MusicSkipTo(u32 milliseconds)
{ {
if (mChannel == -1) if (mChannel == -1)
return -1; return -1;
StopChannel(mChannel); StopChannel(mChannel);
TIMER0_CR = 0; TIMER0_CR = 0;
fFill = false; fFill = false;
fseek(mFile, milliseconds*22050/1000.0, SEEK_SET); fseek(mFile, milliseconds*22050/1000.0, SEEK_SET);
MusicBuffer(); MusicBuffer();
return mChannel; return mChannel;
} }
void AudioManager::MusicBuffer() void AudioManager::MusicBuffer()
{ {
fread(mBuffer, 1, SIZE, mFile); fread(mBuffer, 1, SIZE, mFile);
fFill = true; fFill = true;
fSwap = false; fSwap = false;
fEof = 0; fEof = 0;
mChannel = soundPlaySample(mBuffer, SoundFormat_8Bit, SIZE*2, 22050, 127, 64, true, 0); //true indicates loop mChannel = soundPlaySample(mBuffer, SoundFormat_8Bit, SIZE*2, 22050, 127, 64, true, 0); //true indicates loop
//TIMER_FREQ_1024(x) doesn't give required result //TIMER_FREQ_1024(x) doesn't give required result
mTimerData = -(((u32)(0x2000000*(SIZE/22050.0)))>>10); mTimerData = -(((u32)(0x2000000*(SIZE/22050.0)))>>10);
TIMER0_DATA = mTimerData; TIMER0_DATA = mTimerData;
TIMER0_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_1024; TIMER0_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_1024;
} }
void AudioManager::MusicStop() void AudioManager::MusicStop()
{ {
if (mChannel == -1) if (mChannel == -1)
return; return;
StopChannel(mChannel); StopChannel(mChannel);
TIMER0_CR = 0; TIMER0_CR = 0;
fFill = false; fFill = false;
fclose(mFile); fclose(mFile);
} }
void AudioManager::MusicUpdate() void AudioManager::MusicUpdate()
{ {
if (fFill && mChannel != -1) if (fFill && mChannel != -1)
{ {
if (fEof > 0) if (fEof > 0)
{ {
if (fEof == 2) //count 2 extra loops to allow buffered music to play if (fEof == 2) //count 2 extra loops to allow buffered music to play
MusicStop(); MusicStop();
++fEof; ++fEof;
return; return;
} }
u8* tBufferAddr = fSwap ? mBuffer : mBuffer+SIZE; u8* tBufferAddr = fSwap ? mBuffer : mBuffer+SIZE;
fread(tBufferAddr, 1, SIZE, mFile); fread(tBufferAddr, 1, SIZE, mFile);
if (fEof == 0) if (fEof == 0)
fEof = feof(mFile); fEof = feof(mFile);
fFill = false; fFill = false;
//iprintf("\x1b[23;20HVCOUNT:%i ", REG_VCOUNT); //iprintf("\x1b[23;20HVCOUNT:%i ", REG_VCOUNT);
} }
} }

View File

@ -1,106 +1,106 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include "Beatmaps/BeatmapElements.h" #include "Beatmaps/BeatmapElements.h"
#ifndef __AUDIOMANAGER_H__ #ifndef __AUDIOMANAGER_H__
#define __AUDIOMANAGER_H__ #define __AUDIOMANAGER_H__
#include "normal_hitnormal_bin.h" #include "normal_hitnormal_bin.h"
#include "normal_hitwhistle_bin.h" #include "normal_hitwhistle_bin.h"
#include "normal_hitfinish_bin.h" #include "normal_hitfinish_bin.h"
#include "normal_hitclap_bin.h" #include "normal_hitclap_bin.h"
#include "normal_slidertick_bin.h" #include "normal_slidertick_bin.h"
#include "normal_sliderslide_bin.h" #include "normal_sliderslide_bin.h"
#include "normal_sliderwhistle_bin.h" #include "normal_sliderwhistle_bin.h"
#include "soft_hitnormal_bin.h" #include "soft_hitnormal_bin.h"
#include "soft_hitwhistle_bin.h" #include "soft_hitwhistle_bin.h"
#include "soft_hitfinish_bin.h" #include "soft_hitfinish_bin.h"
#include "soft_hitclap_bin.h" #include "soft_hitclap_bin.h"
#include "soft_slidertick_bin.h" #include "soft_slidertick_bin.h"
#include "soft_sliderslide_bin.h" #include "soft_sliderslide_bin.h"
#include "soft_sliderwhistle_bin.h" #include "soft_sliderwhistle_bin.h"
#include "spinnerbonus_bin.h" #include "spinnerbonus_bin.h"
#include "spinnerspin_bin.h" #include "spinnerspin_bin.h"
using namespace std; using namespace std;
typedef enum { typedef enum {
SND_NORMAL = 0, SND_NORMAL = 1,
SND_WHISTLE = 2, SND_WHISTLE = 2,
SND_FINISH = 4, SND_FINISH = 4,
SND_CLAP = 8 SND_CLAP = 8
} HitObjectSound; } HitObjectSound;
typedef struct { typedef struct {
const u8* data; const u8* data;
u32 size; u32 size;
} SampleSetInfo; } SampleSetInfo;
typedef struct { typedef struct {
SampleSetInfo hitnormal; SampleSetInfo hitnormal;
SampleSetInfo hitwhistle; SampleSetInfo hitwhistle;
SampleSetInfo hitfinish; SampleSetInfo hitfinish;
SampleSetInfo hitclap; SampleSetInfo hitclap;
SampleSetInfo slidertick; SampleSetInfo slidertick;
SampleSetInfo sliderslide; SampleSetInfo sliderslide;
SampleSetInfo sliderwhistle; SampleSetInfo sliderwhistle;
} SampleSet; } SampleSet;
//intended usage: //intended usage:
//AudioManager::Engine().PlaySample(SOUND_DATA(sound_name), loop) //AudioManager::Engine().PlaySample(SOUND_DATA(sound_name), loop)
#define SOUND_DATA(name) name, name##_size #define SOUND_DATA(name) name, name##_size
class AudioManager class AudioManager
{ {
public: public:
static AudioManager& Engine() { return sEngine; } static AudioManager& Engine() { return sEngine; }
int PlaySample(const u8* data, u32 size, bool loop = false); int PlaySample(const u8* data, u32 size, bool loop = false);
int PlaySample(SampleSetInfo info, bool loop = false); int PlaySample(SampleSetInfo info, bool loop = false);
void SetChannelFreq(int channel, u16 freq); void SetChannelFreq(int channel, u16 freq);
void StopChannel(int channel); void StopChannel(int channel);
//sounds //sounds
void ResetSamples(); void ResetSamples();
void PlayHitSound(HitObjectSound sound); void PlayHitSound(HitObjectSound sound);
int PlaySliderSound(HitObjectSound sound); int PlaySliderSound(HitObjectSound sound);
void PlaySliderTick(); void PlaySliderTick();
//music //music
friend void MusicTimerHandler(); friend void MusicTimerHandler();
int MusicPlay(string& filename); int MusicPlay(string& filename);
int MusicSkipTo(u32 milliseconds); int MusicSkipTo(u32 milliseconds);
void MusicStop(); void MusicStop();
void MusicUpdate(); //must be called frequently void MusicUpdate(); //must be called frequently
protected: protected:
static AudioManager sEngine; static AudioManager sEngine;
void MusicBuffer(); void MusicBuffer();
SampleSet mSampleNormal; SampleSet mSampleNormal;
SampleSet mSampleSoft; SampleSet mSampleSoft;
SampleSet* mSampleSets[3]; SampleSet* mSampleSets[3];
//music //music
static const u32 SIZE = 11025; //size of each HALF of the buffer static const u32 SIZE = 11025; //size of each HALF of the buffer
u8* mBuffer; u8* mBuffer;
FILE* mFile; FILE* mFile;
bool fSwap, fFill; bool fSwap, fFill;
u32 fEof; u32 fEof;
int mChannel; int mChannel;
u16 mTimerData; u16 mTimerData;
private: private:
AudioManager(); AudioManager();
~AudioManager() {} ~AudioManager() {}
}; };
void MusicTimerHandler(); void MusicTimerHandler();
#endif #endif

View File

@ -1,165 +1,168 @@
#include "FileReader.h" #include "FileReader.h"
u32 FileReader::BUFFERSIZE = 1024; u32 FileReader::BUFFERSIZE = 1024;
FileReader::FileReader(u8* source) FileReader::FileReader(u8* source)
{ {
Init(NULL, source); Init(NULL, source);
} }
FileReader::FileReader(string& filename) FileReader::FileReader(string& filename)
{ {
FILE* handle = fopen(filename.c_str(), "rb"); FILE* handle = fopen(filename.c_str(), "rb");
Init(handle, NULL); Init(handle, NULL);
} }
FileReader::FileReader(const char* filename) FileReader::FileReader(const char* filename)
{ {
FILE* handle = fopen(filename, "rb"); FILE* handle = fopen(filename, "rb");
Init(handle, NULL); Init(handle, NULL);
} }
void FileReader::Init(FILE* handle, u8* buffer) void FileReader::Init(FILE* handle, u8* buffer)
{ {
if (buffer == NULL && handle == NULL) if (buffer == NULL && handle == NULL)
{ {
iprintf("\x1b[0;0Hno source"); iprintf("\x1b[0;0Hno source");
mHandle = NULL; mHandle = NULL;
mBuffer = NULL; mBuffer = NULL;
fReady = false; fReady = false;
return; return;
} }
mBuffer = buffer; mBuffer = buffer;
if (buffer == NULL) if (buffer == NULL)
mBuffer = new u8[BUFFERSIZE]; mBuffer = new u8[BUFFERSIZE];
mHandle = handle; mHandle = handle;
Reset(); Reset();
fReady = true; fReady = true;
} }
FileReader::~FileReader() FileReader::~FileReader()
{ {
if (mHandle != NULL) if (mHandle != NULL)
{ {
fclose(mHandle); fclose(mHandle);
} }
if (mBuffer != NULL) if (mBuffer != NULL)
{ {
delete[] mBuffer; delete[] mBuffer;
} }
} }
int FileReader::FillBuffer() const int FileReader::FillBuffer() const
{ {
if (mHandle == NULL || feof(mHandle)) if (mHandle == NULL || feof(mHandle))
return -1; return -1;
if (pos == 0) if (pos == 0)
return 0; return 0;
//shift remaining buffer //shift remaining buffer
memcpy(mBuffer, mBuffer+pos, BUFFERSIZE-pos); memcpy(mBuffer, mBuffer+pos, BUFFERSIZE-pos);
int bytesread = fread(mBuffer+BUFFERSIZE-pos, 1, pos, mHandle); int bytesread = fread(mBuffer+BUFFERSIZE-pos, 1, pos, mHandle);
pos = 0; pos = 0;
return bytesread; return bytesread;
} }
void FileReader::PrepareBuffer(u8 datasize) const void FileReader::PrepareBuffer(u8 datasize) const
{ {
//todo: handle eof //todo: handle eof
if (mHandle != NULL && BUFFERSIZE - datasize < pos) if (mHandle != NULL && BUFFERSIZE - datasize < pos)
FillBuffer(); FillBuffer();
} }
u8 FileReader::ReadInt8() const u8 FileReader::ReadInt8() const
{ {
PrepareBuffer(1); PrepareBuffer(1);
return mBuffer[pos++]; return mBuffer[pos++];
} }
u16 FileReader::ReadInt16() const u16 FileReader::ReadInt16() const
{ {
PrepareBuffer(2); PrepareBuffer(2);
u16 t = mBuffer[pos++]; u16 t = mBuffer[pos++];
t += mBuffer[pos++] << 8; t += mBuffer[pos++] << 8;
return t; return t;
} }
u32 FileReader::ReadInt32() const u32 FileReader::ReadInt32() const
{ {
PrepareBuffer(4); PrepareBuffer(4);
u32 t = mBuffer[pos++]; u32 t = mBuffer[pos++];
t += mBuffer[pos++] << 8; t += mBuffer[pos++] << 8;
t += mBuffer[pos++] << 16; t += mBuffer[pos++] << 16;
t += mBuffer[pos++] << 24; t += mBuffer[pos++] << 24;
return t; return t;
} }
float FileReader::ReadFloat() const float FileReader::ReadFloat() const
{ {
PrepareBuffer(4); PrepareBuffer(4);
u8 c[4]; u8 c[4];
c[0] = mBuffer[pos++]; c[0] = mBuffer[pos++];
c[1] = mBuffer[pos++]; c[1] = mBuffer[pos++];
c[2] = mBuffer[pos++]; c[2] = mBuffer[pos++];
c[3] = mBuffer[pos++]; c[3] = mBuffer[pos++];
return *reinterpret_cast<float*>(c); return *reinterpret_cast<float*>(c);
} }
u32 FileReader::ReadVarInt() const // Read Integers of variable size, kind of like in midi
{ u32 FileReader::ReadVarInt() const
PrepareBuffer(4); {
u32 value = 0; PrepareBuffer(4);
u8 i = 0; u32 value = 0;
u8 b; u8 i = 0;
do u8 b;
{ do // Bits in the file: 10010101 11000101 00100010
b = mBuffer[pos++]; { // Bits in the Output: 00000000 0010101 1000101 0100010
value += (b & 0x7F) << (7 * i); b = mBuffer[pos++];
++i; value += (b & 0x7F) << (7 * i);
} while ((b & 0x80) > 0); ++i;
return value; } 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) string FileReader::ReadString() const
return NULL; {
u32 l = ReadVarInt();
PrepareBuffer(l); if (l == 0)
return NULL;
char* c = new char[l+1];
for (u32 i=0; i<l; ++i) PrepareBuffer(l);
c[i] = mBuffer[pos++];
c[l] = '\0'; char* c = new char[l+1];
for (u32 i=0; i<l; ++i)
string s(c); c[i] = mBuffer[pos++];
return s; c[l] = '\0';
}
string s(c);
void FileReader::Reset() const return s;
{ }
if (mHandle == NULL)
{ void FileReader::Reset() const
pos = 0; {
} if (mHandle == NULL)
else {
{ pos = 0;
pos = BUFFERSIZE; }
rewind(mHandle); else
} {
} pos = BUFFERSIZE;
rewind(mHandle);
void FileReader::Skip(u32 count) const }
{ }
PrepareBuffer(count);
pos += count; void FileReader::Skip(u32 count) const
} {
PrepareBuffer(count);
pos += count;
}

View File

@ -1,49 +1,49 @@
#include <nds.h> #include <nds.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <string> #include <string>
#ifndef __FILEREADER_H__ #ifndef __FILEREADER_H__
#define __FILEREADER_H__ #define __FILEREADER_H__
using namespace std; using namespace std;
class FileReader class FileReader
{ {
public: public:
FileReader(u8* source); FileReader(u8* source);
FileReader(string& filename); FileReader(string& filename);
FileReader(const char* filename); FileReader(const char* filename);
~FileReader(); ~FileReader();
u8 ReadInt8() const; u8 ReadInt8() const;
u16 ReadInt16() const; u16 ReadInt16() const;
u32 ReadInt32() const; u32 ReadInt32() const;
float ReadFloat() const; float ReadFloat() const;
u32 ReadVarInt() const; u32 ReadVarInt() const;
string ReadString() const; string ReadString() const;
bool Ready() const { return fReady; } bool Ready() const { return fReady; }
void Skip(u32 count) const; void Skip(u32 count) const;
void Reset() const; void Reset() const;
protected: protected:
u8* mBuffer; u8* mBuffer;
mutable u32 pos; mutable u32 pos;
static u32 BUFFERSIZE; static u32 BUFFERSIZE;
FILE* mHandle; FILE* mHandle;
int FillBuffer() const; int FillBuffer() const;
void PrepareBuffer(u8 datasize) const; void PrepareBuffer(u8 datasize) const;
bool fReady; bool fReady;
private: private:
void Init(FILE* handle, u8* buffer); void Init(FILE* handle, u8* buffer);
}; };
#endif #endif

View File

@ -1,29 +1,29 @@
#include "InputHelper.h" #include "InputHelper.h"
touchPosition InputHelper::mTouch; touchPosition InputHelper::mTouch;
bool InputHelper::KeyDown(int key) bool InputHelper::KeyDown(int key)
{ {
return keysDown() & key; return keysDown() & key;
} }
bool InputHelper::KeyHeld(int key) bool InputHelper::KeyHeld(int key)
{ {
return keysHeld() & key; return keysHeld() & key;
} }
bool InputHelper::KeyUp(int key) bool InputHelper::KeyUp(int key)
{ {
return keysUp() & key; return keysUp() & key;
} }
touchPosition& InputHelper::TouchRead() touchPosition& InputHelper::TouchRead()
{ {
touchRead(&mTouch); touchRead(&mTouch);
mTouch.px *= 2.5; mTouch.px *= 2.5;
mTouch.py *= 2.5; mTouch.py *= 2.5;
return mTouch; return mTouch;
} }

Some files were not shown because too many files have changed in this diff Show More