Initial commit.

This commit is contained in:
Jonathan Chow 2014-05-23 17:04:41 +09:00 committed by Dean Herbert
commit 6d6f274dd9
140 changed files with 7836 additions and 0 deletions

45
Makefile Normal file
View File

@ -0,0 +1,45 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/ds_rules
export TARGET := $(shell basename $(CURDIR))
export TOPDIR := $(CURDIR)
.PHONY: $(TARGET).arm7 $(TARGET).arm9
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
all: $(TARGET).nds
#---------------------------------------------------------------------------------
$(TARGET).nds : $(TARGET).arm7 $(TARGET).arm9
ndstool -c $(TARGET).nds -7 $(TARGET).arm7 -9 $(TARGET).arm9
#---------------------------------------------------------------------------------
$(TARGET).arm7 : arm7/$(TARGET).elf
$(TARGET).arm9 : arm9/$(TARGET).elf
#---------------------------------------------------------------------------------
arm7/$(TARGET).elf:
$(MAKE) -C arm7
#---------------------------------------------------------------------------------
arm9/$(TARGET).elf:
$(MAKE) -C arm9
#---------------------------------------------------------------------------------
clean:
$(MAKE) -C arm9 clean
$(MAKE) -C arm7 clean
rm -f $(TARGET).nds $(TARGET).arm7 $(TARGET).arm9
#---------------------------------------------------------------------------------
emu:
ndstool -c $(TARGET).nds -7 $(TARGET).arm7 -9 $(TARGET).arm9 -d nitro

132
arm7/Makefile Normal file
View File

@ -0,0 +1,132 @@
#---------------------------------------------------------------------------------
.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
#---------------------------------------------------------------------------------------

72
arm7/source/main.cpp Normal file
View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------
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();
}

153
arm9/Makefile Normal file
View File

@ -0,0 +1,153 @@
#---------------------------------------------------------------------------------
.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
#---------------------------------------------------------------------------------------

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
arm9/data/textures/disc.bin Normal file

Binary file not shown.

BIN
arm9/data/textures/hit0.bin Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1 @@
UUUUUUUUUUUUUUUU

BIN
arm9/fonts/370.bmf Normal file

Binary file not shown.

BIN
arm9/fonts/4x6_a.bmf Normal file

Binary file not shown.

BIN
arm9/fonts/gomics.bmf Normal file

Binary file not shown.

BIN
arm9/fonts/hoo06.bmf Normal file

Binary file not shown.

BIN
arm9/fonts/ver08.bmf Normal file

Binary file not shown.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,21 @@
#include "DifficultyManager.h"
u32 DifficultyManager::preemptTime[] = {1800, 1680, 1560, 1440, 1320, 1200, 1050, 900, 750, 600, 450};
//u32 DifficultyManager::circleSize[] = {100, 92, 84, 76, 68, 60, 52, 44, 36, 28, 20};
u32 DifficultyManager::circleSize[] = {100, 92, 84, 76, 68, 60, 52, 52, 52, 52, 52};
//u32 DifficultyManager::circleSize[] = {120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20};
u32 DifficultyManager::hitWindow300[] = {80, 74, 68, 62, 56, 50, 44, 38, 32, 26, 20};
u32 DifficultyManager::hitWindow100[] = {140, 132, 124, 116, 108, 100, 92, 84, 76, 68, 60};
u32 DifficultyManager::hitWindow50[] = {200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100};
u32 DifficultyManager::spinnerTime[] = {525, 480, 435, 390, 345, 300, 270, 240, 210, 180, 150};
s32 DifficultyManager::missHpDrain[] = {-10, -18, -26, -34, -42, -50, -56, -62, -68, -74, -80};
u8 DifficultyManager::DifficultyHpDrain = 5;
u8 DifficultyManager::DifficultyCircleSize = 5;
u8 DifficultyManager::DifficultyOverall = 5;
float DifficultyManager::SliderMultiplier = 1.0;
float DifficultyManager::SliderTickRate = 1.0;
float DifficultyManager::DifficultyHpDrainRate = 1.0;
u8 DifficultyManager::DifficultyPeppyStars = 3;
float DifficultyManager::DifficultyEyupStars = 3.0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,343 @@
#include <nds.h>
#include "GfxInfo.h"
/*
const float zvalue[] =
{
0.000f, 0.000f, -0.01f, //hitcircle
0.000f, 0.000f, 0.000f, //hitspinner
-0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, -0.01f, //slider ball
0.015f, -0.01f, 0.000f, 0.000f, //hitslider
0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, //score
-0.005f, -0.005f, //slider score
-0.05f, -0.05f, -0.05f, -0.05f, -0.05f, //scorebar
0.000f, //verdana9
0.000f //white
};
*/
const u16 palette0[] = //circle, circleoverlay, circleapproach, disc, slidertick, sliderreverse, verdana9, white
{
RGB15(31,0,31), RGB15(31,31,31), RGB15(28,28,28), RGB15(0,0,0)
};
const u16 palette1[] = //spinner, spinnerbars, scorebar_bar
{
RGB15(31,31,31), RGB15(31,0,0), RGB15(31,4,0), RGB15(31,9,0),
RGB15(4,3,3), RGB15(29,14,7), RGB15(31,12,0), RGB15(31,17,0),
RGB15(31,23,7), RGB15(31,26,14), RGB15(31,23,0), RGB15(31,30,23),
RGB15(31,27,0), RGB15(31,31,8), RGB15(31,31,0), RGB15(0,14,22)
};
const u16 palette2[] = //spinnerbg
{
RGB15(31,31,31), RGB15(1,2,5), RGB15(5,5,5), RGB15(0,0,0),
RGB15(5,13,31), RGB15(14,15,16), RGB15(2,5,13), RGB15(1,4,10),
RGB15(3,7,17), RGB15(3,8,21), RGB15(4,10,25), RGB15(1,3,8),
RGB15(5,11,28), RGB15(6,7,7), RGB15(4,5,8), RGB15(8,9,11)
};
const u16 palette3[] = //sliderball, sliderfollowcircle
{
RGB15(31,0,31), RGB15(31,24,0), RGB15(31,0,0), RGB15(31,31,0)
};
const u16 palette4[] = //hit300, hit300k, hit300g, hit0
{
RGB15(31,0,31), RGB15(31,26,4), RGB15(30,18,1), RGB15(31,30,12),
RGB15(31,31,23), RGB15(9,6,4), RGB15(28,5,1), RGB15(3,3,4),
RGB15(1,1,1), RGB15(2,2,2), RGB15(5,4,4), RGB15(28,2,2),
RGB15(15,7,3), RGB15(13,13,10), RGB15(22,22,17), RGB15(21,17,4)
};
const u16 palette5[] = //hit50. hit100, hit100k
{
RGB15(31,0,31), RGB15(3,3,4), RGB15(12,30,8), RGB15(4,10,3),
RGB15(7,25,3), RGB15(12,15,28), RGB15(19,31,16), RGB15(5,6,11),
RGB15(17,20,30), RGB15(6,9,23), RGB15(5,18,3), RGB15(23,24,29),
RGB15(28,30,29), RGB15(24,31,23), RGB15(12,13,13), RGB15(18,19,19)
};
const u16 palette6[] = //slider30, slider10
{
RGB15(31,0,31), RGB15(31,7,29), RGB15(0,0,0), RGB15(31,20,30)
};
const u16 palette7[] = //scorebar_ki, scorebar_kidanger, scorebar_kidanger2
{
RGB15(31,31,31), RGB15(1,0,0), RGB15(20,20,20), RGB15(10,0,0),
RGB15(27,0,0), RGB15(20,0,0), RGB15(7,8,4), RGB15(12,12,0),
RGB15(22,23,9), RGB15(16,17,0), RGB15(20,21,0), RGB15(31,31,9),
RGB15(24,24,0), RGB15(30,31,1), RGB15(27,28,1), RGB15(16,16,6)
};
const u16 palette8[] = //scorebar
{
RGB15(31,31,31), RGB15(0,0,0), RGB15(10,17,31), RGB15(19,17,31),
RGB15(21,23,31), RGB15(11,11,12), RGB15(17,17,31), RGB15(14,19,31),
RGB15(5,5,6), RGB15(18,18,31), RGB15(23,22,31), RGB15(20,18,31),
RGB15(16,19,31), RGB15(19,21,31), RGB15(14,14,18), RGB15(15,16,22)
};
const u32 uv8x8[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(8), inttot16(0)),
TEXTURE_PACK(inttot16(8),inttot16(8)),
TEXTURE_PACK(inttot16(0), inttot16(8))
};
const u32 uv16x16[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(16), inttot16(0)),
TEXTURE_PACK(inttot16(16),inttot16(16)),
TEXTURE_PACK(inttot16(0), inttot16(16))
};
const u32 uv32x32[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(32), inttot16(0)),
TEXTURE_PACK(inttot16(32),inttot16(32)),
TEXTURE_PACK(inttot16(0), inttot16(32))
};
const u32 uv64x64[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(64), 0),
TEXTURE_PACK(inttot16(64),inttot16(64)),
TEXTURE_PACK(inttot16(0), inttot16(64))
};
const u32 uv128x128[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(128), inttot16(0)),
TEXTURE_PACK(inttot16(128),inttot16(128)),
TEXTURE_PACK(inttot16(0), inttot16(128))
};
const u32 uv256x16[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(256), inttot16(0)),
TEXTURE_PACK(inttot16(256),inttot16(16)),
TEXTURE_PACK(inttot16(0), inttot16(16))
};
const u32 uv256x192[] = {
TEXTURE_PACK(inttot16(0),inttot16(0)),
TEXTURE_PACK(inttot16(256), inttot16(0)),
TEXTURE_PACK(inttot16(256),inttot16(192)),
TEXTURE_PACK(inttot16(0), inttot16(192))
};
const v16 plu[] = {
floattov16(-2.00f),
floattov16(-1.99f), floattov16(-1.98f), floattov16(-1.97f), floattov16(-1.96f), floattov16(-1.95f),
floattov16(-1.94f), floattov16(-1.93f), floattov16(-1.92f), floattov16(-1.91f), floattov16(-1.90f),
floattov16(-1.89f), floattov16(-1.88f), floattov16(-1.87f), floattov16(-1.86f), floattov16(-1.85f),
floattov16(-1.84f), floattov16(-1.83f), floattov16(-1.82f), floattov16(-1.81f), floattov16(-1.80f),
floattov16(-1.79f), floattov16(-1.78f), floattov16(-1.77f), floattov16(-1.76f), floattov16(-1.75f),
floattov16(-1.74f), floattov16(-1.73f), floattov16(-1.72f), floattov16(-1.71f), floattov16(-1.70f),
floattov16(-1.69f), floattov16(-1.68f), floattov16(-1.67f), floattov16(-1.66f), floattov16(-1.65f),
floattov16(-1.64f), floattov16(-1.63f), floattov16(-1.62f), floattov16(-1.61f), floattov16(-1.60f),
floattov16(-1.59f), floattov16(-1.58f), floattov16(-1.57f), floattov16(-1.56f), floattov16(-1.55f),
floattov16(-1.54f), floattov16(-1.53f), floattov16(-1.52f), floattov16(-1.51f), floattov16(-1.50f),
floattov16(-1.49f), floattov16(-1.48f), floattov16(-1.47f), floattov16(-1.46f), floattov16(-1.45f),
floattov16(-1.44f), floattov16(-1.43f), floattov16(-1.42f), floattov16(-1.41f), floattov16(-1.40f),
floattov16(-1.39f), floattov16(-1.38f), floattov16(-1.37f), floattov16(-1.36f), floattov16(-1.35f),
floattov16(-1.34f), floattov16(-1.33f), floattov16(-1.32f), floattov16(-1.31f), floattov16(-1.30f),
floattov16(-1.29f), floattov16(-1.28f), floattov16(-1.27f), floattov16(-1.26f), floattov16(-1.25f),
floattov16(-1.24f), floattov16(-1.23f), floattov16(-1.22f), floattov16(-1.21f), floattov16(-1.20f),
floattov16(-1.19f), floattov16(-1.18f), floattov16(-1.17f), floattov16(-1.16f), floattov16(-1.15f),
floattov16(-1.14f), floattov16(-1.13f), floattov16(-1.12f), floattov16(-1.11f), floattov16(-1.10f),
floattov16(-1.09f), floattov16(-1.08f), floattov16(-1.07f), floattov16(-1.06f), floattov16(-1.05f),
floattov16(-1.04f), floattov16(-1.03f), floattov16(-1.02f), floattov16(-1.01f), floattov16(-1.00f),
floattov16(-0.99f), floattov16(-0.98f), floattov16(-0.97f), floattov16(-0.96f), floattov16(-0.95f),
floattov16(-0.94f), floattov16(-0.93f), floattov16(-0.92f), floattov16(-0.91f), floattov16(-0.90f),
floattov16(-0.89f), floattov16(-0.88f), floattov16(-0.87f), floattov16(-0.86f), floattov16(-0.85f),
floattov16(-0.84f), floattov16(-0.83f), floattov16(-0.82f), floattov16(-0.81f), floattov16(-0.80f),
floattov16(-0.79f), floattov16(-0.78f), floattov16(-0.77f), floattov16(-0.76f), floattov16(-0.75f),
floattov16(-0.74f), floattov16(-0.73f), floattov16(-0.72f), floattov16(-0.71f), floattov16(-0.70f),
floattov16(-0.69f), floattov16(-0.68f), floattov16(-0.67f), floattov16(-0.66f), floattov16(-0.65f),
floattov16(-0.64f), floattov16(-0.63f), floattov16(-0.62f), floattov16(-0.61f), floattov16(-0.60f),
floattov16(-0.59f), floattov16(-0.58f), floattov16(-0.57f), floattov16(-0.56f), floattov16(-0.55f),
floattov16(-0.54f), floattov16(-0.53f), floattov16(-0.52f), floattov16(-0.51f), floattov16(-0.50f),
floattov16(-0.49f), floattov16(-0.48f), floattov16(-0.47f), floattov16(-0.46f), floattov16(-0.45f),
floattov16(-0.44f), floattov16(-0.43f), floattov16(-0.42f), floattov16(-0.41f), floattov16(-0.40f),
floattov16(-0.39f), floattov16(-0.38f), floattov16(-0.37f), floattov16(-0.36f), floattov16(-0.35f),
floattov16(-0.34f), floattov16(-0.33f), floattov16(-0.32f), floattov16(-0.31f), floattov16(-0.30f),
floattov16(-0.29f), floattov16(-0.28f), floattov16(-0.27f), floattov16(-0.26f), floattov16(-0.25f),
floattov16(-0.24f), floattov16(-0.23f), floattov16(-0.22f), floattov16(-0.21f), floattov16(-0.20f),
floattov16(-0.19f), floattov16(-0.18f), floattov16(-0.17f), floattov16(-0.16f), floattov16(-0.15f),
floattov16(-0.14f), floattov16(-0.13f), floattov16(-0.12f), floattov16(-0.11f), floattov16(-0.10f),
floattov16(-0.09f), floattov16(-0.08f), floattov16(-0.07f), floattov16(-0.06f), floattov16(-0.05f),
floattov16(-0.04f), floattov16(-0.03f), floattov16(-0.02f), floattov16(-0.01f),
floattov16(0.00f), floattov16(0.01f), floattov16(0.02f), floattov16(0.03f), floattov16(0.04f),
floattov16(0.05f), floattov16(0.06f), floattov16(0.07f), floattov16(0.08f), floattov16(0.09f),
floattov16(0.10f), floattov16(0.11f), floattov16(0.12f), floattov16(0.13f), floattov16(0.14f),
floattov16(0.15f), floattov16(0.16f), floattov16(0.17f), floattov16(0.18f), floattov16(0.19f),
floattov16(0.20f), floattov16(0.21f), floattov16(0.22f), floattov16(0.23f), floattov16(0.24f),
floattov16(0.25f), floattov16(0.26f), floattov16(0.27f), floattov16(0.28f), floattov16(0.29f),
floattov16(0.30f), floattov16(0.31f), floattov16(0.32f), floattov16(0.33f), floattov16(0.34f),
floattov16(0.35f), floattov16(0.36f), floattov16(0.37f), floattov16(0.38f), floattov16(0.39f),
floattov16(0.40f), floattov16(0.41f), floattov16(0.42f), floattov16(0.43f), floattov16(0.44f),
floattov16(0.45f), floattov16(0.46f), floattov16(0.47f), floattov16(0.48f), floattov16(0.49f),
floattov16(0.50f), floattov16(0.51f), floattov16(0.52f), floattov16(0.53f), floattov16(0.54f),
floattov16(0.55f), floattov16(0.56f), floattov16(0.57f), floattov16(0.58f), floattov16(0.59f),
floattov16(0.60f), floattov16(0.61f), floattov16(0.62f), floattov16(0.63f), floattov16(0.64f),
floattov16(0.65f), floattov16(0.66f), floattov16(0.67f), floattov16(0.68f), floattov16(0.69f),
floattov16(0.70f), floattov16(0.71f), floattov16(0.72f), floattov16(0.73f), floattov16(0.74f),
floattov16(0.75f), floattov16(0.76f), floattov16(0.77f), floattov16(0.78f), floattov16(0.79f),
floattov16(0.80f), floattov16(0.81f), floattov16(0.82f), floattov16(0.83f), floattov16(0.84f),
floattov16(0.85f), floattov16(0.86f), floattov16(0.87f), floattov16(0.88f), floattov16(0.89f),
floattov16(0.90f), floattov16(0.91f), floattov16(0.92f), floattov16(0.93f), floattov16(0.94f),
floattov16(0.95f), floattov16(0.96f), floattov16(0.97f), floattov16(0.98f), floattov16(0.99f),
floattov16(1.00f), floattov16(1.01f), floattov16(1.02f), floattov16(1.03f), floattov16(1.04f),
floattov16(1.05f), floattov16(1.06f), floattov16(1.07f), floattov16(1.08f), floattov16(1.09f),
floattov16(1.10f), floattov16(1.11f), floattov16(1.12f), floattov16(1.13f), floattov16(1.14f),
floattov16(1.15f), floattov16(1.16f), floattov16(1.17f), floattov16(1.18f), floattov16(1.19f),
floattov16(1.20f), floattov16(1.21f), floattov16(1.22f), floattov16(1.23f), floattov16(1.24f),
floattov16(1.25f), floattov16(1.26f), floattov16(1.27f), floattov16(1.28f), floattov16(1.29f),
floattov16(1.30f), floattov16(1.31f), floattov16(1.32f), floattov16(1.33f), floattov16(1.34f),
floattov16(1.35f), floattov16(1.36f), floattov16(1.37f), floattov16(1.38f), floattov16(1.39f),
floattov16(1.40f), floattov16(1.41f), floattov16(1.42f), floattov16(1.43f), floattov16(1.44f),
floattov16(1.45f), floattov16(1.46f), floattov16(1.47f), floattov16(1.48f), floattov16(1.49f),
floattov16(1.50f), floattov16(1.51f), floattov16(1.52f), floattov16(1.53f), floattov16(1.54f),
floattov16(1.55f), floattov16(1.56f), floattov16(1.57f), floattov16(1.58f), floattov16(1.59f),
floattov16(1.60f), floattov16(1.61f), floattov16(1.62f), floattov16(1.63f), floattov16(1.64f),
floattov16(1.65f), floattov16(1.66f), floattov16(1.67f), floattov16(1.68f), floattov16(1.69f),
floattov16(1.70f), floattov16(1.71f), floattov16(1.72f), floattov16(1.73f), floattov16(1.74f),
floattov16(1.75f), floattov16(1.76f), floattov16(1.77f), floattov16(1.78f), floattov16(1.79f),
floattov16(1.80f), floattov16(1.81f), floattov16(1.82f), floattov16(1.83f), floattov16(1.84f),
floattov16(1.85f), floattov16(1.86f), floattov16(1.87f), floattov16(1.88f), floattov16(1.89f),
floattov16(1.90f), floattov16(1.91f), floattov16(1.92f), floattov16(1.93f), floattov16(1.94f),
floattov16(1.95f), floattov16(1.96f), floattov16(1.97f), floattov16(1.98f), floattov16(1.99f),
floattov16(2.00f), floattov16(2.01f), floattov16(2.02f), floattov16(2.03f), floattov16(2.04f),
floattov16(2.05f), floattov16(2.06f), floattov16(2.07f), floattov16(2.08f), floattov16(2.09f),
floattov16(2.10f), floattov16(2.11f), floattov16(2.12f), floattov16(2.13f), floattov16(2.14f),
floattov16(2.15f), floattov16(2.16f), floattov16(2.17f), floattov16(2.18f), floattov16(2.19f),
floattov16(2.20f), floattov16(2.21f), floattov16(2.22f), floattov16(2.23f), floattov16(2.24f),
floattov16(2.25f), floattov16(2.26f), floattov16(2.27f), floattov16(2.28f), floattov16(2.29f),
floattov16(2.30f), floattov16(2.31f), floattov16(2.32f), floattov16(2.33f), floattov16(2.34f),
floattov16(2.35f), floattov16(2.36f), floattov16(2.37f), floattov16(2.38f), floattov16(2.39f),
floattov16(2.40f), floattov16(2.41f), floattov16(2.42f), floattov16(2.43f), floattov16(2.44f),
floattov16(2.45f), floattov16(2.46f), floattov16(2.47f), floattov16(2.48f), floattov16(2.49f),
floattov16(2.50f), floattov16(2.51f), floattov16(2.52f), floattov16(2.53f), floattov16(2.54f),
floattov16(2.55f), floattov16(2.56f), floattov16(2.57f), floattov16(2.58f), floattov16(2.59f),
floattov16(2.60f), floattov16(2.61f), floattov16(2.62f), floattov16(2.63f), floattov16(2.64f),
floattov16(2.65f), floattov16(2.66f), floattov16(2.67f), floattov16(2.68f), floattov16(2.69f),
floattov16(2.70f), floattov16(2.71f), floattov16(2.72f), floattov16(2.73f), floattov16(2.74f),
floattov16(2.75f), floattov16(2.76f), floattov16(2.77f), floattov16(2.78f), floattov16(2.79f),
floattov16(2.80f), floattov16(2.81f), floattov16(2.82f), floattov16(2.83f), floattov16(2.84f),
floattov16(2.85f), floattov16(2.86f), floattov16(2.87f), floattov16(2.88f), floattov16(2.89f),
floattov16(2.90f), floattov16(2.91f), floattov16(2.92f), floattov16(2.93f), floattov16(2.94f),
floattov16(2.95f), floattov16(2.96f), floattov16(2.97f), floattov16(2.98f), floattov16(2.99f),
floattov16(3.00f), floattov16(3.01f), floattov16(3.02f), floattov16(3.03f), floattov16(3.04f),
floattov16(3.05f), floattov16(3.06f), floattov16(3.07f), floattov16(3.08f), floattov16(3.09f),
floattov16(3.10f), floattov16(3.11f), floattov16(3.12f), floattov16(3.13f), floattov16(3.14f),
floattov16(3.15f), floattov16(3.16f), floattov16(3.17f), floattov16(3.18f), floattov16(3.19f),
floattov16(3.20f), floattov16(3.21f), floattov16(3.22f), floattov16(3.23f), floattov16(3.24f),
floattov16(3.25f), floattov16(3.26f), floattov16(3.27f), floattov16(3.28f), floattov16(3.29f),
floattov16(3.30f), floattov16(3.31f), floattov16(3.32f), floattov16(3.33f), floattov16(3.34f),
floattov16(3.35f), floattov16(3.36f), floattov16(3.37f), floattov16(3.38f), floattov16(3.39f),
floattov16(3.40f), floattov16(3.41f), floattov16(3.42f), floattov16(3.43f), floattov16(3.44f),
floattov16(3.45f), floattov16(3.46f), floattov16(3.47f), floattov16(3.48f), floattov16(3.49f),
floattov16(3.50f), floattov16(3.51f), floattov16(3.52f), floattov16(3.53f), floattov16(3.54f),
floattov16(3.55f), floattov16(3.56f), floattov16(3.57f), floattov16(3.58f), floattov16(3.59f),
floattov16(3.60f), floattov16(3.61f), floattov16(3.62f), floattov16(3.63f), floattov16(3.64f),
floattov16(3.65f), floattov16(3.66f), floattov16(3.67f), floattov16(3.68f), floattov16(3.69f),
floattov16(3.70f), floattov16(3.71f), floattov16(3.72f), floattov16(3.73f), floattov16(3.74f),
floattov16(3.75f), floattov16(3.76f), floattov16(3.77f), floattov16(3.78f), floattov16(3.79f),
floattov16(3.80f), floattov16(3.81f), floattov16(3.82f), floattov16(3.83f), floattov16(3.84f),
floattov16(3.85f), floattov16(3.86f), floattov16(3.87f), floattov16(3.88f), floattov16(3.89f),
floattov16(3.90f), floattov16(3.91f), floattov16(3.92f), floattov16(3.93f), floattov16(3.94f),
floattov16(3.95f), floattov16(3.96f), floattov16(3.97f), floattov16(3.98f), floattov16(3.99f),
floattov16(4.00f), floattov16(4.01f), floattov16(4.02f), floattov16(4.03f), floattov16(4.04f),
floattov16(4.05f), floattov16(4.06f), floattov16(4.07f), floattov16(4.08f), floattov16(4.09f),
floattov16(4.10f), floattov16(4.11f), floattov16(4.12f), floattov16(4.13f), floattov16(4.14f),
floattov16(4.15f), floattov16(4.16f), floattov16(4.17f), floattov16(4.18f), floattov16(4.19f),
floattov16(4.20f), floattov16(4.21f), floattov16(4.22f), floattov16(4.23f), floattov16(4.24f),
floattov16(4.25f), floattov16(4.26f), floattov16(4.27f), floattov16(4.28f), floattov16(4.29f),
floattov16(4.30f), floattov16(4.31f), floattov16(4.32f), floattov16(4.33f), floattov16(4.34f),
floattov16(4.35f), floattov16(4.36f), floattov16(4.37f), floattov16(4.38f), floattov16(4.39f),
floattov16(4.40f), floattov16(4.41f), floattov16(4.42f), floattov16(4.43f), floattov16(4.44f),
floattov16(4.45f), floattov16(4.46f), floattov16(4.47f), floattov16(4.48f), floattov16(4.49f),
floattov16(4.50f), floattov16(4.51f), floattov16(4.52f), floattov16(4.53f), floattov16(4.54f),
floattov16(4.55f), floattov16(4.56f), floattov16(4.57f), floattov16(4.58f), floattov16(4.59f),
floattov16(4.60f), floattov16(4.61f), floattov16(4.62f), floattov16(4.63f), floattov16(4.64f),
floattov16(4.65f), floattov16(4.66f), floattov16(4.67f), floattov16(4.68f), floattov16(4.69f),
floattov16(4.70f), floattov16(4.71f), floattov16(4.72f), floattov16(4.73f), floattov16(4.74f),
floattov16(4.75f), floattov16(4.76f), floattov16(4.77f), floattov16(4.78f), floattov16(4.79f),
floattov16(4.80f), floattov16(4.81f), floattov16(4.82f), floattov16(4.83f), floattov16(4.84f),
floattov16(4.85f), floattov16(4.86f), floattov16(4.87f), floattov16(4.88f), floattov16(4.89f),
floattov16(4.90f), floattov16(4.91f), floattov16(4.92f), floattov16(4.93f), floattov16(4.94f),
floattov16(4.95f), floattov16(4.96f), floattov16(4.97f), floattov16(4.98f), floattov16(4.99f),
floattov16(5.00f), floattov16(5.01f), floattov16(5.02f), floattov16(5.03f), floattov16(5.04f),
floattov16(5.05f), floattov16(5.06f), floattov16(5.07f), floattov16(5.08f), floattov16(5.09f),
floattov16(5.10f), floattov16(5.11f), floattov16(5.12f), floattov16(5.13f), floattov16(5.14f),
floattov16(5.15f), floattov16(5.16f), floattov16(5.17f), floattov16(5.18f), floattov16(5.19f),
floattov16(5.20f), floattov16(5.21f), floattov16(5.22f), floattov16(5.23f), floattov16(5.24f),
floattov16(5.25f), floattov16(5.26f), floattov16(5.27f), floattov16(5.28f), floattov16(5.29f),
floattov16(5.30f), floattov16(5.31f), floattov16(5.32f), floattov16(5.33f), floattov16(5.34f),
floattov16(5.35f), floattov16(5.36f), floattov16(5.37f), floattov16(5.38f), floattov16(5.39f),
floattov16(5.40f), floattov16(5.41f), floattov16(5.42f), floattov16(5.43f), floattov16(5.44f),
floattov16(5.45f), floattov16(5.46f), floattov16(5.47f), floattov16(5.48f), floattov16(5.49f),
floattov16(5.50f), floattov16(5.51f), floattov16(5.52f), floattov16(5.53f), floattov16(5.54f),
floattov16(5.55f), floattov16(5.56f), floattov16(5.57f), floattov16(5.58f), floattov16(5.59f),
floattov16(5.60f), floattov16(5.61f), floattov16(5.62f), floattov16(5.63f), floattov16(5.64f),
floattov16(5.65f), floattov16(5.66f), floattov16(5.67f), floattov16(5.68f), floattov16(5.69f),
floattov16(5.70f), floattov16(5.71f), floattov16(5.72f), floattov16(5.73f), floattov16(5.74f),
floattov16(5.75f), floattov16(5.76f), floattov16(5.77f), floattov16(5.78f), floattov16(5.79f),
floattov16(5.80f), floattov16(5.81f), floattov16(5.82f), floattov16(5.83f), floattov16(5.84f),
floattov16(5.85f), floattov16(5.86f), floattov16(5.87f), floattov16(5.88f), floattov16(5.89f),
floattov16(5.90f), floattov16(5.91f), floattov16(5.92f), floattov16(5.93f), floattov16(5.94f),
floattov16(5.95f), floattov16(5.96f), floattov16(5.97f), floattov16(5.98f), floattov16(5.99f),
floattov16(6.00f), floattov16(6.01f), floattov16(6.02f), floattov16(6.03f), floattov16(6.04f),
floattov16(6.05f), floattov16(6.06f), floattov16(6.07f), floattov16(6.08f), floattov16(6.09f),
floattov16(6.10f), floattov16(6.11f), floattov16(6.12f), floattov16(6.13f), floattov16(6.14f),
floattov16(6.15f), floattov16(6.16f), floattov16(6.17f), floattov16(6.18f), floattov16(6.19f),
floattov16(6.20f), floattov16(6.21f), floattov16(6.22f), floattov16(6.23f), floattov16(6.24f),
floattov16(6.25f), floattov16(6.26f), floattov16(6.27f), floattov16(6.28f), floattov16(6.29f),
floattov16(6.30f), floattov16(6.31f), floattov16(6.32f), floattov16(6.33f), floattov16(6.34f),
floattov16(6.35f), floattov16(6.36f), floattov16(6.37f), floattov16(6.38f), floattov16(6.39f),
floattov16(6.40f), floattov16(6.41f), floattov16(6.42f), floattov16(6.43f), floattov16(6.44f),
floattov16(6.45f), floattov16(6.46f), floattov16(6.47f), floattov16(6.48f), floattov16(6.49f),
floattov16(6.50f), floattov16(6.51f), floattov16(6.52f), floattov16(6.53f), floattov16(6.54f),
floattov16(6.55f), floattov16(6.56f), floattov16(6.57f), floattov16(6.58f), floattov16(6.59f),
floattov16(6.60f), floattov16(6.61f), floattov16(6.62f), floattov16(6.63f), floattov16(6.64f),
floattov16(6.65f), floattov16(6.66f), floattov16(6.67f), floattov16(6.68f), floattov16(6.69f),
floattov16(6.70f), floattov16(6.71f), floattov16(6.72f), floattov16(6.73f), floattov16(6.74f),
floattov16(6.75f), floattov16(6.76f), floattov16(6.77f), floattov16(6.78f), floattov16(6.79f),
floattov16(6.80f), floattov16(6.81f), floattov16(6.82f), floattov16(6.83f), floattov16(6.84f),
floattov16(6.85f), floattov16(6.86f), floattov16(6.87f), floattov16(6.88f), floattov16(6.89f),
floattov16(6.90f), floattov16(6.91f), floattov16(6.92f), floattov16(6.93f), floattov16(6.94f),
floattov16(6.95f), floattov16(6.96f), floattov16(6.97f), floattov16(6.98f), floattov16(6.99f),
floattov16(7.00f), floattov16(7.01f), floattov16(7.02f), floattov16(7.03f), floattov16(7.04f),
floattov16(7.05f), floattov16(7.06f), floattov16(7.07f), floattov16(7.08f), floattov16(7.09f),
floattov16(7.10f), floattov16(7.11f), floattov16(7.12f), floattov16(7.13f), floattov16(7.14f),
floattov16(7.15f), floattov16(7.16f), floattov16(7.17f), floattov16(7.18f), floattov16(7.19f),
floattov16(7.20f), floattov16(7.21f), floattov16(7.22f), floattov16(7.23f), floattov16(7.24f),
floattov16(7.25f), floattov16(7.26f), floattov16(7.27f), floattov16(7.28f), floattov16(7.29f),
floattov16(7.30f), floattov16(7.31f), floattov16(7.32f), floattov16(7.33f), floattov16(7.34f),
floattov16(7.35f), floattov16(7.36f), floattov16(7.37f), floattov16(7.38f), floattov16(7.39f),
floattov16(7.40f), floattov16(7.41f), floattov16(7.42f), floattov16(7.43f), floattov16(7.44f),
floattov16(7.45f), floattov16(7.46f), floattov16(7.47f), floattov16(7.48f), floattov16(7.49f),
floattov16(7.50f), floattov16(7.51f), floattov16(7.52f), floattov16(7.53f), floattov16(7.54f),
floattov16(7.55f), floattov16(7.56f), floattov16(7.57f), floattov16(7.58f), floattov16(7.59f),
floattov16(7.60f), floattov16(7.61f), floattov16(7.62f), floattov16(7.63f), floattov16(7.64f),
floattov16(7.65f), floattov16(7.66f), floattov16(7.67f), floattov16(7.68f), floattov16(7.69f),
floattov16(7.70f), floattov16(7.71f), floattov16(7.72f), floattov16(7.73f), floattov16(7.74f),
floattov16(7.75f), floattov16(7.76f), floattov16(7.77f), floattov16(7.78f), floattov16(7.79f),
floattov16(7.80f), floattov16(7.81f), floattov16(7.82f), floattov16(7.83f), floattov16(7.84f),
floattov16(7.85f), floattov16(7.86f), floattov16(7.87f), floattov16(7.88f), floattov16(7.89f),
floattov16(7.90f), floattov16(7.91f), floattov16(7.92f), floattov16(7.93f), floattov16(7.94f),
floattov16(7.95f), floattov16(7.96f), floattov16(7.97f), floattov16(7.98f), floattov16(7.99f)
};

View File

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

View File

@ -0,0 +1,234 @@
#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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,19 @@
#include <nds.h>
#ifndef __INPUTHELPER_H__
#define __INPUTHELPER_H__
class InputHelper
{
public:
static bool KeyDown(int key);
static bool KeyHeld(int key);
static bool KeyUp(int key);
static touchPosition& TouchRead();
protected:
static touchPosition mTouch;
};
#endif

View File

@ -0,0 +1,11 @@
#include "MathHelper.h"
u16 MathHelper::mSeed = 3246;
u16 MathHelper::Random(u16 min, u16 max)
{
mSeed= 1664525*mSeed+1013904223;
return (mSeed % (max-min) + min);
}

View File

@ -0,0 +1,25 @@
#include <nds.h>
//#include <math.h>
#ifndef __MATHHELPER_H__
#define __MATHHELPER_H__
class MathHelper
{
public:
static u32 Abs(s32 value) { return (value > 0 ? value : -value); }
static s32 Max(s32 value1, s32 value2) { return (value1 > value2 ? value1 : value2); }
static s32 Min(s32 value1, s32 value2) { return (value1 < value2 ? value1 : value2); }
static s32 Sgn(s32 value) { return (value == (s32)Abs(value) ? 1 : -1); }
static float Frc(float value) { return value - (int)value; }
static u16 Random(u16 min, u16 max);
protected:
static u16 mSeed;
};
#endif

View File

@ -0,0 +1,115 @@
#include "HitCircle.h"
HitCircle::HitCircle(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound) : HitObject(x, y, time, type, sound)
{
u32 size = DifficultyManager::GetCircleSize();
u32 preempt = DifficultyManager::GetPreemptTime();
s32 fadeInStart = time - preempt;
s32 fadeInEnd = fadeInStart + (preempt >> 3);
mEndTime = time + DifficultyManager::GetHitWindow50();
pSprite* spr;
spr = new pSprite(TX_PLAY_CIRCLEOVERLAY, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, RGB15(31,31,31), 0);
spr->Show(fadeInStart, fadeInEnd);
spr->Hide(time, mEndTime);
spr->Kill(mEndTime+1000);
mSprites.push_back(spr);
spr = new pSprite(TX_PLAY_CIRCLE, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, mColour, 0);
spr->Show(fadeInStart, fadeInEnd);
spr->Hide(time, mEndTime);
spr->Kill(mEndTime+1000);
mSprites.push_back(spr);
spr = new pSprite(TX_PLAY_CIRCLEAPPROACH, x, y, size, size, ORIGIN_CENTER, FIELD_PLAY, mColour, 0);
spr->Show(fadeInStart, fadeInEnd);
spr->Hide(time, mEndTime);
spr->Scale(fadeInStart, time, 4, 1);
spr->Kill(mEndTime+1000);
mSprites.push_back(spr);
mScoreSpriteId = 1;
}
bool HitCircle::InBounds(s32 x, s32 y)
{
//all sprites are the same, it doesn't matter which one
return mSprites[1]->InBounds(x, y);
}
void HitCircle::OnTouchDown(const touchPosition& touch)
{
if (InBounds(touch.px, touch.py))
{
Hit();
}
}
void HitCircle::Hit()
{
s32 now = GameClock::Clock().Time();
u32 delta = MathHelper::Abs(mTime - now);
if (delta > DifficultyManager::GetHitWindow())
{
//too early, give the hitcircle a shake
for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it)
{
pSprite* spr = *it;
spr->Move(now, now+20, mX+5, mY);
spr->Move(now+20, now+40, mX-5, mY);
spr->Move(now+40, now+60, mX+5, mY);
spr->Move(now+60, now+80, mX, mY);
}
}
else
{
if (delta < DifficultyManager::GetHitWindow50())
{
//if within the window for 50, the person hit it
for (u32 i=0; i<2; ++i)
{
pSprite* spr = mSprites[i];
//circle explosion
spr->Transform(TR_FADE, now, now+200, 31, 10);
spr->Transform(TR_FADE, now+200, now+270, 10, 0);
spr->Scale(now, now+150, 1, 1.7);
spr->Scale(now+150, now+270, 1.7, 1.9);
}
//kill the approach circle
mSprites[2]->Kill(now);
if (delta < DifficultyManager::GetHitWindow300())
{
IncreaseScore(SCORE_300);
}
else if (delta < DifficultyManager::GetHitWindow100())
{
IncreaseScore(SCORE_100);
}
else
{
IncreaseScore(SCORE_50);
}
AudioManager::Engine().PlayHitSound(mSound);
}
else
{
//otherwise missed
for (u32 i=0; i<3; ++i)
{
mSprites[i]->Kill(now);
}
IncreaseScore(SCORE_MISS);
}
}
mHit = true;
}

View File

@ -0,0 +1,21 @@
#include <nds.h>
#include "HitObject.h"
#ifndef __HITCIRCLE_H__
#define __HITCIRCLE_H__
class HitCircle : public HitObject
{
public:
HitCircle(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound);
bool InBounds(s32 x, s32 y);
void OnTouchDown(const touchPosition& touch);
void Hit();
};
#endif

View File

@ -0,0 +1,103 @@
#include "HitObject.h"
rgb HitObject::mColour = 0;
float HitObject::sScoreDeltaZ = 0;
float HitObject::sSliderDeltaZ = 0;
s32 HitObject::sLastSliderTime = 0;
ICallback* HitObject::mScoreCallback = NULL;
HitObject::HitObject(s32 x, s32 y, s32 time, HitObjectType type, HitObjectSound sound)
{
mX = x;
mY = y;
mTime = time;
mType = type;
mHit = false;
mSound = sound;
mScoreSpriteId = 0;
mComboEnd = false;
if ((type & HIT_COMBO) > 0)
mColour = BeatmapElements::Element().GetNextColour();
}
HitObject::~HitObject()
{
}
void HitObject::Hit()
{
mHit = true;
}
void HitObject::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation)
{
IncreaseScore(score, forceNoCombo, forceNoAnimation, mScoreSpriteId);
}
void HitObject::IncreaseScore(ScoreType score, bool forceNoCombo, bool forceNoAnimation, u32 spriteId)
{
HitObjectPoint point = {
mSprites[spriteId]->X,
mSprites[spriteId]->Y,
0
};
void** args = new void*[5];
ARGS_PUSH(args, 0, score);
ARGS_PUSH(args, 1, forceNoCombo);
ARGS_PUSH(args, 2, forceNoAnimation);
ARGS_PUSH(args, 3, point);
ARGS_PUSH(args, 4, mComboEnd);
if (mScoreCallback != NULL)
mScoreCallback->DoCallback(args);
delete[] args;
}
void HitObject::SetScoreCallback(ICallback* scoreCallback)
{
//if (mScoreCallback != NULL)
// delete mScoreCallback;
mScoreCallback = scoreCallback;
}
void HitObject::SetPostCreateOptions(bool comboend, s32 nextx, s32 nexty)
{
//set whether this is the last object of a combo
mComboEnd = comboend;
/*
//set score z layering
mScoreDeltaZ = sScoreDeltaZ;
if (sScoreDeltaZ >= 0.05f || MathHelper::Abs(mSprites[mScoreSpriteId]->x() - nextx) + MathHelper::Abs(mSprites[mScoreSpriteId]->y() - nexty) >= 230)
sScoreDeltaZ = 0;
else
sScoreDeltaZ += 0.001f;
//set slider z layering
if (sSliderDeltaZ >= 0.05f || mTime - DifficultyManager::GetPreemptTime() > sLastSliderTime)
sSliderDeltaZ = 0;
else
sSliderDeltaZ += 0.004f;
if ((mType & HIT_SLIDER) > 0)
{
for (spriteIterator it = mSprites.begin(); it != mSprites.end(); ++it)
{
if (*it != NULL)
{
(*it)->SetDeltaZ(sSliderDeltaZ);
}
}
sLastSliderTime = mEndTime;
}
*/
}

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