<ClCompile>\r
<WarningLevel>Level3</WarningLevel>\r
<Optimization>Disabled</Optimization>\r
- <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);WIN32</PreprocessorDefinitions>\r
+ <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);WIN32;FULLSCREEN</PreprocessorDefinitions>\r
</ClCompile>\r
<Link>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
#define NOTEDIST 5
#include <GL/glew.h>
-#include <stdint.h>
+#include <SDL/SDL.h>
+//#include <stdint.h>
#include <iostream>
using namespace std;
class Config
{
public:
- Config(uint8_t buttons, uint32_t timestamp=0, uint32_t endtimestamp=0, uint32_t time=0, uint32_t ticks=0);
+ Config(Uint8 buttons, Uint32 timestamp=0, Uint32 endtimestamp=0, Uint32 time=0, Uint32 ticks=0);
- Config(uint32_t timestamp=0, uint32_t endtimestamp=0, uint32_t time=0, uint32_t ticks=0,
+ Config(Uint32 timestamp=0, Uint32 endtimestamp=0, Uint32 time=0, Uint32 ticks=0,
bool a=false, bool b=false, bool c=false, bool d=false, bool e=false);
Config(const Config &cf);
void remKey(keys k);
void setKeys(bool a, bool b, bool c, bool d, bool e);
- void setTimestamp(uint32_t t) { _timestamp = t; }
- uint32_t getTimestamp() const { return _timestamp; }
+ void setTimestamp(Uint32 t) { _timestamp = t; }
+ Uint32 getTimestamp() const { return _timestamp; }
- void setEndTimestamp(uint32_t t) { _endtimestamp = t; }
- uint32_t getEndTimestamp() const { return _endtimestamp; }
+ void setEndTimestamp(Uint32 t) { _endtimestamp = t; }
+ Uint32 getEndTimestamp() const { return _endtimestamp; }
- void setTime(uint32_t t) { _time = t; }
- uint32_t getTime() const { return _time; }
+ void setTime(Uint32 t) { _time = t; }
+ Uint32 getTime() const { return _time; }
- void setTicks(uint32_t t) { _ticks = t; }
- uint32_t getTicks() const { return _ticks; }
+ void setTicks(Uint32 t) { _ticks = t; }
+ Uint32 getTicks() const { return _ticks; }
void display() const;
void log(const String &type, FILE *file) const;
bool isNone() const { return !(_a || _b || _c || _d || _e ); }
private:
- uint32_t _timestamp, _endtimestamp;
- uint32_t _time, _ticks;
+ Uint32 _timestamp, _endtimestamp;
+ Uint32 _time, _ticks;
bool _a, _b, _c, _d, _e;
};
MIDIReader(const MIDIReader &);
FILE *_file;
- uint16_t _nbtracks;
- uint16_t _timedivision;
+ Uint16 _nbtracks;
+ Uint16 _timedivision;
// unsigned long int _position;
- uint8_t readVariableLength(uint32_t &);
- void readBytes(void *, uint32_t);
- void printBytes(uint8_t *data, uint32_t length);
- uint32_t _position;
+ Uint8 readVariableLength(Uint32 &);
+ void readBytes(void *, Uint32);
+ void printBytes(Uint8 *data, Uint32 length);
+ Uint32 _position;
};
#endif
class Metronome\r
{\r
public:\r
- Metronome(const Track *track, uint32_t nbbeats=4, uint32_t tempo=0, bool activated=false);\r
+ Metronome(const Track *track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=false);\r
virtual ~Metronome(){}\r
\r
virtual void setActive(bool activated) { _activated = activated; }\r
- virtual void setTempo(uint32_t tempo) { _tempo = tempo; }\r
- virtual void setNbBeats(uint32_t nbbeats) {_nbbeats = nbbeats; }\r
+ virtual void setTempo(Uint32 tempo) { _tempo = tempo; }\r
+ virtual void setNbBeats(Uint32 nbbeats) {_nbbeats = nbbeats; }\r
\r
virtual void run()=0;\r
\r
protected:\r
- uint32_t _nbbeats;\r
- uint32_t _tempo;\r
+ Uint32 _nbbeats;\r
+ Uint32 _tempo;\r
bool _activated;\r
const Track *_track;\r
};\r
class MetronomeAudio : public Metronome\r
{ \r
public:\r
- MetronomeAudio(const Track *track, uint32_t nbbeats=4, uint32_t tempo=0, bool activated=true);\r
+ MetronomeAudio(const Track *track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=true);\r
\r
~MetronomeAudio();\r
\r
class MetronomeHaptic : public Metronome\r
{ \r
public:\r
- MetronomeHaptic(const Track *track, uint32_t nbbeats=4, uint32_t tempo=0, bool activated=true);\r
+ MetronomeHaptic(const Track *track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=true);\r
\r
~MetronomeHaptic();\r
\r
- void setTempo(uint32_t tempo);\r
- void setNbBeats(uint32_t nbbeats);\r
+ void setTempo(Uint32 tempo);\r
+ void setNbBeats(Uint32 nbbeats);\r
\r
void run();\r
\r
#define POSITION_EYE 45
#define POSITION_CENTER (-70)
+#include <SDL/SDL.h>
+
#include "Track.hpp"
#include "String.hpp"
void drawCube(float pos, float size, float colorx, float colory, float colorz);
void drawLong(float pos, float size, float length, float colorx, float colory, float colorz);
\r
-void handleKeyOn(keys k, uint32_t currenttime);\r
-void handleKeyOff(keys k, uint32_t currenttime);\r
-void handleKeys(bool a, bool b, bool c, bool d, bool e, uint32_t currenttime);
-void handleStrokeOn(uint32_t currenttime);\r
-void handleStrokeOff(uint32_t currenttime);\r
+void handleKeyOn(keys k, Uint32 currenttime);\r
+void handleKeyOff(keys k, Uint32 currenttime);\r
+void handleKeys(bool a, bool b, bool c, bool d, bool e, Uint32 currenttime);
+void handleStrokeOn(Uint32 currenttime);\r
+void handleStrokeOff(Uint32 currenttime);\r
bool processEvents();
void loop(const Track &tr, const String &songname);
public:
MyWiimote():Wiimote(1){}
- void handleStrumOn(uint32_t currenttime) { handleStrokeOn(currenttime); }
- void handleStrumOff(uint32_t currenttime) { handleStrokeOff(currenttime); }
- void handleButtonOn(int k, uint32_t currenttime) { handleKeyOn(keys(k), currenttime); }
- void handleButtonOff(int k, uint32_t currenttime) { handleKeyOff(keys(k), currenttime); }
- void handleButtons(bool a, bool b, bool c, bool d, bool e, uint32_t currenttime) { handleKeys(a, b, c, d, e, currenttime); }
+ void handleStrumOn(Uint32 currenttime) { handleStrokeOn(currenttime); }
+ void handleStrumOff(Uint32 currenttime) { handleStrokeOff(currenttime); }
+ void handleButtonOn(int k, Uint32 currenttime) { handleKeyOn(keys(k), currenttime); }
+ void handleButtonOff(int k, Uint32 currenttime) { handleKeyOff(keys(k), currenttime); }
+ void handleButtons(bool a, bool b, bool c, bool d, bool e, Uint32 currenttime) { handleKeys(a, b, c, d, e, currenttime); }
};
\r
#endif\r
#include <iostream>\r
using namespace std;\r
+typedef enum
+{
+ REGULAR,
+ TOMSLAW,
+ SPEEDACCURACY
+} GameType;
+
#define MAX(X,Y) (X)>(Y)?(X):(Y)
#define MIN(X,Y) (X)<(Y)?(X):(Y)
#include <list>
#include <map>
-#include <stdint.h>
+#include <SDL/SDL.h>
//temp
#include <iostream>
Track();
Track(const Track &);
//create an empty track with the specified tempo and specified duration
- Track(uint32_t tempo, uint32_t duration);
+ Track(Uint32 tempo, Uint32 duration);
//create a track for speed/accuracy experiments
- Track(uint8_t nbbuttons, uint8_t repetitions, uint8_t nbspeeds, uint32_t *speeds);
+ Track(Uint8 nbbuttons, Uint8 repetitions, Uint8 nbspeeds, Uint32 *speeds);
~Track();
- void addKey(uint32_t time, uint8_t note);
- void remKey(uint32_t time, uint8_t note);
+ void addKey(Uint32 time, Uint8 note);
+ void remKey(Uint32 time, Uint8 note);
- void addTempo(uint32_t tick, uint32_t timestamp, uint32_t t) { _tempo[tick] = Pair<uint32_t, uint32_t>(timestamp, t); }
- void addTimesignature(uint32_t tick, uint32_t timestamp, uint32_t t) { _timesignatures[tick] = Pair<uint32_t, uint32_t>(timestamp, t); }
- const map<uint32_t, Pair<uint32_t, uint32_t> > *getTempos() const { return &_tempo; }
- const map<uint32_t, Pair<uint32_t, uint32_t> > *getTimeSignatures() const { return &_timesignatures; }
+ void addTempo(Uint32 tick, Uint32 timestamp, Uint32 t) { _tempo[tick] = Pair<Uint32, Uint32>(timestamp, t); }
+ void addTimesignature(Uint32 tick, Uint32 timestamp, Uint32 t) { _timesignatures[tick] = Pair<Uint32, Uint32>(timestamp, t); }
+ const map<Uint32, Pair<Uint32, Uint32> > *getTempos() const { return &_tempo; }
+ const map<Uint32, Pair<Uint32, Uint32> > *getTimeSignatures() const { return &_timesignatures; }
// int getTempo() const { return _currenttempo; }
// void setTempo(uint32 t) { _currenttempo = t; }
// uint32 beatsToTicks(uint32 time) { return (time * _currenttempo * 480) / 60000.0; }
-// uint32_t beatsToTicks(uint32_t time, uint32_t tempo) { return (time * tempo * 480) / 60000; }
-// uint32_t ticksToBeats(uint32_t time) { return 60000000 / time; }
+// Uint32 beatsToTicks(Uint32 time, Uint32 tempo) { return (time * tempo * 480) / 60000; }
+// Uint32 ticksToBeats(Uint32 time) { return 60000000 / time; }
void displayTracks();
- void drawFrets(uint32_t postime) const;
- void drawNotes(uint32_t postime, uint8_t difficulty) const;
+ void drawFrets(Uint32 postime) const;
+ void drawNotes(Uint32 postime, Uint8 difficulty) const;
// void checkMetronome(float postime, Metronome *m) const;
- uint32_t getNbNotes(uint32_t k) const { return _nbnotes[k]; }
- uint32_t getTotalLength(uint32_t k) const { return _totallength[k]; }
- uint32_t getTotalNotes(uint32_t k) const { return _totalnotes[k]; }
+ Uint32 getNbNotes(Uint32 k) const { return _nbnotes[k]; }
+ Uint32 getTotalLength(Uint32 k) const { return _totallength[k]; }
+ Uint32 getTotalNotes(Uint32 k) const { return _totalnotes[k]; }
- void setEndOfTrack(uint32_t length) { if (length > _trackSize) _trackSize = length; }
- uint32_t getEndOfTrack() const { return _trackSize; }
+ void setEndOfTrack(Uint32 length) { if (length > _trackSize) _trackSize = length; }
+ Uint32 getEndOfTrack() const { return _trackSize; }
- Config getNote(uint32_t pos, uint8_t difficulty);
- uint32_t getTempo(uint32_t tick);
- uint32_t getTimeSignature(uint32_t tick);
+ Config getNote(Uint32 pos, Uint8 difficulty);
+ Uint32 getTempo(Uint32 tick);
+ Uint32 getTimeSignature(Uint32 tick);
- const list<Pair<uint32_t, uint32_t> > * getBips() const { return &_bips; }
- void addBip(uint32_t tick, uint32_t timestamp) { _bips.push_back(Pair<uint32_t, uint32_t>(tick, timestamp)); }
+ const list<Pair<Uint32, Uint32> > * getBips() const { return &_bips; }
+ void addBip(Uint32 tick, Uint32 timestamp) { _bips.push_back(Pair<Uint32, Uint32>(tick, timestamp)); }
//void computeBips();
private:
//notes : position ; configs
- map<uint32_t, Config> _notes[NBDIFFICULTIES];
- map<uint32_t, Pair<uint32_t, uint32_t> > _tempo; //microseconds per quarter-note
- map<uint32_t, Pair<uint32_t, uint32_t> > _timesignatures;
+ map<Uint32, Config> _notes[NBDIFFICULTIES];
+ map<Uint32, Pair<Uint32, Uint32> > _tempo; //microseconds per quarter-note
+ map<Uint32, Pair<Uint32, Uint32> > _timesignatures;
// (beat, timestamp)
- list<Pair<uint32_t, uint32_t> > _bips;
+ list<Pair<Uint32, Uint32> > _bips;
Config _currentconfig[NBDIFFICULTIES];
- uint32_t _nbnotes[NBDIFFICULTIES];
- uint32_t _totallength[NBDIFFICULTIES];
- uint32_t _totalnotes[128];
- uint32_t _trackSize;
+ Uint32 _nbnotes[NBDIFFICULTIES];
+ Uint32 _totallength[NBDIFFICULTIES];
+ Uint32 _totalnotes[128];
+ Uint32 _trackSize;
bool _active;
};
#ifndef __WIIMOTE__
#define __WIIMOTE__
-#ifndef WIN32
- #include <unistd.h>
-#else
- #include <stdint.h>
-#endif
-
#include <wiiuse.h>
+#include <SDL/SDL.h>
+
#define MAX_WIIMOTES 4
void vibration(int wiimote, int time);
- virtual void handleStrumOn(uint32_t currenttime) = 0;
- virtual void handleStrumOff(uint32_t currenttime) = 0;
- virtual void handleButtonOn(int k, uint32_t currenttime) = 0;
- virtual void handleButtonOff(int k, uint32_t currenttime) = 0;
- virtual void handleButtons(bool a, bool b, bool c, bool d, bool e, uint32_t currenttime) = 0;
+ virtual void handleStrumOn(Uint32 currenttime) = 0;
+ virtual void handleStrumOff(Uint32 currenttime) = 0;
+ virtual void handleButtonOn(int k, Uint32 currenttime) = 0;
+ virtual void handleButtonOff(int k, Uint32 currenttime) = 0;
+ virtual void handleButtons(bool a, bool b, bool c, bool d, bool e, Uint32 currenttime) = 0;
private:
- void handleKey(guitar_hero_3_t* gh3, int key, int button, uint32_t currenttime);
+ void handleKey(guitar_hero_3_t* gh3, int key, int button, Uint32 currenttime);
wiimote **_wiimotes;
int _nb;
bool _strumstate, _keystate[5];
#include "PaintGame.h"
-Config::Config(uint32_t timestamp, uint32_t endtimestamp, uint32_t time, uint32_t ticks, bool a, bool b, bool c, bool d, bool e)
+Config::Config(Uint32 timestamp, Uint32 endtimestamp, Uint32 time, Uint32 ticks, bool a, bool b, bool c, bool d, bool e)
:_timestamp(timestamp), _endtimestamp(endtimestamp), _time(time), _ticks(ticks),
_a(a), _b(b), _c(c), _d(d), _e(e)
{
}
-Config::Config(uint8_t buttons, uint32_t timestamp, uint32_t endtimestamp, uint32_t time, uint32_t ticks)
+Config::Config(Uint8 buttons, Uint32 timestamp, Uint32 endtimestamp, Uint32 time, Uint32 ticks)
:_timestamp(timestamp), _endtimestamp(endtimestamp), _time(time), _ticks(ticks),
_a(buttons & 0x01), _b((buttons >> 1) & 0x01), _c((buttons >> 2) & 0x01), _d((buttons >> 3) & 0x01), _e((buttons >> 4) & 0x01)
{
if (!_file)
return;
- uint8_t temp[4];
+ Uint8 temp[4];
//read the chunk ID
fread((void *)(temp), 1, 4, _file);
}
//read the chunk size
- uint32_t chunksize;
+ Uint32 chunksize;
readBytes(&chunksize, 4);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Header size: %d\n", chunksize);
//read the format
- uint16_t format;
+ Uint16 format;
readBytes(&format, 2);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Format type: %d\n", format);
void MIDIReader::skipTrack()
{
- uint8_t temp[4];
+ Uint8 temp[4];
//read the chunk ID
fread((void *)(temp), 4, 1, _file);
// cerr << temp << endl;
}
//read the chunk size
- uint32_t chunksize;
+ Uint32 chunksize;
readBytes(&chunksize, 4);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Chunk size: %d\n", chunksize);
fseek(_file, chunksize, SEEK_CUR);
void MIDIReader::readTrack(Track &tr, bool addbips)
{
- uint8_t temp[4];
+ Uint8 temp[4];
//read the chunk ID
fread((void *)(temp), 4, 1, _file);
// cerr << temp << endl;
}
//read the chunk size
- uint32_t chunksize;
+ Uint32 chunksize;
readBytes(&chunksize, 4);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Chunk size: %d\n", chunksize);
// readBytes((char *)(&temp2),4);
// printf("TEMP : %0x %0x %0x %0x\n", temp2[0], temp2[1], temp2[2], temp2[3]);
bool end = false;
- uint8_t oldeventandchannel = 0;
- uint32_t ticks = 0;
- uint32_t timestamp = 0;
- uint32_t currenttempo = 60000000/120;
+ Uint8 oldeventandchannel = 0;
+ Uint32 ticks = 0;
+ Uint32 timestamp = 0;
+ Uint32 currenttempo = 60000000/120;
if (addbips)
tr.addBip(0, 0);
// Track example;
- uint32_t delta = 0;
+ Uint32 delta = 0;
//Read the events
while (_position < chunksize)
{
//add bips
if (addbips)
{
- uint32_t lastbiptick = 0;
+ Uint32 lastbiptick = 0;
lastbiptick = tr.getBips()->back().getX();
- uint32_t temptimestamp = timestamp;
+ Uint32 temptimestamp = timestamp;
//manage 1st bip, taking into account the time elapsed since the last event
if (lastbiptick > 0 && ticks >= lastbiptick + 480)
{
tr.addBip(lastbiptick, temptimestamp);
}
//add bips with the current tempo
- for (uint32_t i = lastbiptick + 480 ; i < ticks ; i += 480 )
+ for (Uint32 i = lastbiptick + 480 ; i < ticks ; i += 480 )
{
temptimestamp += currenttempo / 1000;
tr.addBip(i, temptimestamp);
}
}
- timestamp += static_cast<uint32_t>(delta * (currenttempo / 480000.0));
+ timestamp += static_cast<Uint32>(delta * (currenttempo / 480000.0));
- uint8_t eventandchannel, tempevt;
+ Uint8 eventandchannel, tempevt;
// 4 bits for event type, and 4 others for the channel
readBytes(&tempevt, 1);
fseek(_file, -1, SEEK_CUR);
{
if (end)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "EXTRA EVT");
- uint8_t type;
+ Uint8 type;
readBytes(&type, 1);
- uint32_t length;
- /*uint8_t nblus = */readVariableLength(length);
+ Uint32 length;
+ /*Uint8 nblus = */readVariableLength(length);
- uint8_t *data = new uint8_t[length];
+ Uint8 *data = new Uint8[length];
readBytes(data, length);
- uint32_t tempo = 0;
+ Uint32 tempo = 0;
switch(type)
{
end = true;
break;
case 0x51:
- tempo = ((uint32_t(data[2] & 0x000000ff) << 16) + (uint32_t(data[1] & 0x000000ff) << 8) + uint32_t(data[0] & 0x000000ff));
+ tempo = ((Uint32(data[2] & 0x000000ff) << 16) + (Uint32(data[1] & 0x000000ff) << 8) + Uint32(data[0] & 0x000000ff));
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Tempo at %d : x = %d = %d bpm\n", ticks, tempo, 60000000 / tempo);
currenttempo = tempo;
tr.addTempo(ticks, timestamp, tempo);
break;
case 0x58:
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Time signature at %d : %d|%d %d ticks %d x",
- ticks, uint8_t(data[3]), int(pow(float(2), uint8_t(data[2]))), int(data[1]), int(data[0]));
- tr.addTimesignature(ticks, timestamp, uint8_t(data[3]));
+ ticks, Uint8(data[3]), int(pow(float(2), Uint8(data[2]))), int(data[1]), int(data[0]));
+ tr.addTimesignature(ticks, timestamp, Uint8(data[3]));
break;
case 0x59:
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Key signature: %d %d\n", uint8_t(data[1]), uint8_t(data[0]));
+ SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Key signature: %d %d\n", Uint8(data[1]), Uint8(data[0]));
break;
case 0x7F:
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Sequencer stuff!\n");
else if ((eventandchannel & 0xf0) == 0xf0)// || (eventandchannel & 0xff) == 0xf7)
{
//May be something else
- uint32_t length;
+ Uint32 length;
readVariableLength(length);
- uint8_t *data = new uint8_t[length];
+ Uint8 *data = new Uint8[length];
readBytes(data, length);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "System data\n");
delete []data;
else
{
// printf("Evt : %x %x %x\n", eventandchannel & 0xf0, eventandchannel & 0x0f, eventandchannel);
- uint8_t par1, par2;
+ Uint8 par1, par2;
// position += 2;
// char *notenames[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
switch(eventandchannel & 0xf0)
//these are needed if the notes track is longer than the time events track
if (addbips)
{
- uint32_t lastbiptick = 0;
+ Uint32 lastbiptick = 0;
if (!tr.getBips()->empty())
lastbiptick = tr.getBips()->back().getX();
- uint32_t temptimestamp = timestamp;
+ Uint32 temptimestamp = timestamp;
//manage 1st bip, taking into account the time elapsed since the last event
if (lastbiptick > 0)
{
lastbiptick += 480;
- temptimestamp = timestamp + static_cast<uint32_t>((lastbiptick - ticks) * (currenttempo / 480000.0));
+ temptimestamp = timestamp + static_cast<Uint32>((lastbiptick - ticks) * (currenttempo / 480000.0));
tr.addBip(lastbiptick, temptimestamp);
}
//add 1000 bips with the current tempo
- for (uint32_t i = lastbiptick ; i < lastbiptick + 480000 ; i += 480 )
+ for (Uint32 i = lastbiptick ; i < lastbiptick + 480000 ; i += 480 )
{
tr.addBip(i, temptimestamp);
temptimestamp += currenttempo / 1000;
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Total : %d\n");
}
-uint8_t MIDIReader::readVariableLength(uint32_t &nb)
+Uint8 MIDIReader::readVariableLength(Uint32 &nb)
{
- uint8_t nblus = 0;
+ Uint8 nblus = 0;
nb = 0;
- uint8_t temp;
+ Uint8 temp;
do
{
fread((void *)(&temp), 1, 1, _file);
return nblus;
}
-void MIDIReader::readBytes(void *data, uint32_t nb)
+void MIDIReader::readBytes(void *data, Uint32 nb)
{
- uint8_t *temp = new uint8_t[nb];
+ Uint8 *temp = new Uint8[nb];
fread((void *)(temp), nb, 1, _file);
- for (uint32_t i=0 ; i<nb ; i++)
- ((uint8_t *)data)[i] = temp[nb - i - 1];
+ for (Uint32 i=0 ; i<nb ; i++)
+ ((Uint8 *)data)[i] = temp[nb - i - 1];
delete []temp;
_position += nb;
}
-void MIDIReader::printBytes(uint8_t *data, uint32_t length)
+void MIDIReader::printBytes(Uint8 *data, Uint32 length)
{
- for (uint32_t i=0 ; i < length ; i++)
+ for (Uint32 i=0 ; i < length ; i++)
cout << data[length - i - 1];
cout << endl;
}
#include "Metronome.hpp"\r
\r
-Metronome::Metronome(const Track *track, uint32_t nbbeats, uint32_t tempo, bool activated)\r
+Metronome::Metronome(const Track *track, Uint32 nbbeats, Uint32 tempo, bool activated)\r
:_track(track), _nbbeats(nbbeats), _tempo(tempo), _activated(activated)\r
{\r
}\r
#include "Mixer.hpp"
-#ifdef WIN32
-#include <time.h>
-#include <windows.h>
- extern struct { int tv_sec, tv_usec; } start;
-#else
-#include <sys/time.h>
- extern struct timeval start;
-#endif
+extern Uint32 start;
#define BIPLENGTH 10
extern FILE*logfile;
-MetronomeAudio::MetronomeAudio(const Track *track, uint32_t nbbeats, uint32_t tempo, bool activated)
+MetronomeAudio::MetronomeAudio(const Track *track, Uint32 nbbeats, Uint32 tempo, bool activated)
:Metronome(track, nbbeats, tempo, activated), thread(NULL)
{
Mixer::getInstance()->addSound("bip","bip10.wav");
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
- const list<Pair<uint32_t, uint32_t> > *bips = thismetronome->_track->getBips();
- //const map<uint32_t, Pair<float, uint32_t> > *tempo = thismetronome->_track->getTempos();
- const map<uint32_t, Pair<uint32_t, uint32_t> > *timesignatures = thismetronome->_track->getTimeSignatures();
- static list<Pair<uint32_t, uint32_t> >::const_iterator cBips = bips->begin();
- //static map<uint32_t, Pair<float, uint32_t> >::const_iterator cTempo = tempo->begin();
- static map<uint32_t, Pair<uint32_t, uint32_t> >::const_iterator cTimesignature = timesignatures->begin();
+ const list<Pair<Uint32, Uint32> > *bips = thismetronome->_track->getBips();
+ //const map<Uint32, Pair<float, Uint32> > *tempo = thismetronome->_track->getTempos();
+ const map<Uint32, Pair<Uint32, Uint32> > *timesignatures = thismetronome->_track->getTimeSignatures();
+ static list<Pair<Uint32, Uint32> >::const_iterator cBips = bips->begin();
+ //static map<Uint32, Pair<float, Uint32> >::const_iterator cTempo = tempo->begin();
+ static map<Uint32, Pair<Uint32, Uint32> >::const_iterator cTimesignature = timesignatures->begin();
int currentbeat = 0;
-
-#ifdef WIN32
- struct { int tv_sec, tv_usec; } now;//, start;
- DWORD t = timeGetTime ();
-/* start.tv_sec = t / 1000;
- start.tv_usec = (t % 1000) * 1000;*/
-#else
- struct timeval now;/*, start;
- gettimeofday(&start, NULL);*/
-#endif
- uint32_t currenttime = 0;
+ Uint32 currenttime = 0;
float lag = 0.0;
while(thismetronome->_activated)
{
-#ifdef WIN32
- t = timeGetTime () + BIPLENGTH;
- now.tv_sec = t / 1000;
- now.tv_usec = (t % 1000) * 1000;
-#else
- gettimeofday(&now, NULL);
-#endif
- uint32_t currenttime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
+ Uint32 currenttime = SDL_GetTicks() - start;
while (cBips != bips->end() && currenttime >= BIPTIMESTAMP(*cBips))
{
#include "Mixer.hpp"
#ifdef WIN32
-#include <time.h>
-#include <windows.h>
-#include "SerialWindows.hpp"
- extern struct { int tv_sec, tv_usec; } start;
+ #include "SerialWindows.hpp"
#else
-#include <sys/time.h>
-#include "SerialLinux.hpp"
- extern struct timeval start;
+ #include "SerialLinux.hpp"
#endif
+extern Uint32 start;
#define BEFOREDELAY 2000
extern FILE *logfile;
-MetronomeHaptic::MetronomeHaptic(const Track *track, uint32_t nbbeats, uint32_t tempo, bool activated)
+MetronomeHaptic::MetronomeHaptic(const Track *track, Uint32 nbbeats, Uint32 tempo, bool activated)
:Metronome(track, nbbeats, tempo, activated), thread(NULL)
{
try
_comport->WriteData(buffer1, 3);
_comport->WriteData(buffer2, 6);
\r
-/* char INBUFFER[128];\r
- memset(INBUFFER, 0, 128);
- int nbread = _comport->ReadData(INBUFFER, 128);
- stringstream s;
- s << nbread << " read:\n" << INBUFFER << endl;
- OutputDebugString(s.str().c_str());*/\r
- \r
//Tacton 2\r
buffer2[0] = 0x02; //pattern\r
_comport->WriteData(buffer1, 3);
_comport->WriteData(buffer2, 6);
-
-/* memset(INBUFFER, 0, 128);
- nbread = _comport->ReadData(INBUFFER, 128);
- stringstream s2;
- s2 << nbread << " read:\n" << INBUFFER << endl;
- OutputDebugString(s2.str().c_str());*/
- \r
+\r
//Tacton 3\r
buffer2[0] = 0x04; //pattern\r
_comport->WriteData(buffer1, 3);
_comport->WriteData(buffer2, 6);
-
-/* memset(INBUFFER, 0, 128);
- nbread = _comport->ReadData(INBUFFER, 128);
- stringstream s3;
- s3 << nbread << " read:\n" << INBUFFER << endl;
- OutputDebugString(s3.str().c_str());*/
-
+
//Tacton 4\r
buffer2[0] = 0x08; //pattern\r
_comport->WriteData(buffer1, 3);
_comport->WriteData(buffer2, 6);
-
-/* memset(INBUFFER, 0, 128);
- nbread = _comport->ReadData(INBUFFER, 128);
- stringstream s4;
- s4 << nbread << " read:\n" << INBUFFER << endl;
- OutputDebugString(s4.str().c_str());*/
}
MetronomeHaptic::~MetronomeHaptic()
SDL_WaitThread(thread, NULL);
}
-void MetronomeHaptic::setTempo(uint32_t tempo)\r
+void MetronomeHaptic::setTempo(Uint32 tempo)\r
{\r
Metronome::setTempo(tempo);\r
- //send info to Serial Port\r
- //char outBuffer[5];\r
- /*char outBuffer[5];// = {'T', 'A', 'B', 'C', 'D'};\r
- memset(outBuffer, 0, 5);
- sprintf(OUTBUFFER, "T%3d\n", 60000000/tempo);\r
- outBuffer[0] = 'T';\r
- outBuffer[1] = (tempo & 0xff000000) >> 24;\r
- outBuffer[2] = (tempo & 0x00ff0000) >> 16;\r
- outBuffer[3] = (tempo & 0x0000ff00) >> 8;\r
- outBuffer[4] = tempo & 0x000000ff;\r
-
- bool written = _comport->WriteData(outBuffer, 5);\r
-
- char INBUFFER[128];\r
- memset(INBUFFER, 0, 128);
- int nbread = _comport->ReadData(INBUFFER, 128);
- stringstream s;
- s << nbread << " read:\n" << INBUFFER << endl;
- OutputDebugString(s.str().c_str());*/
}\r
-void MetronomeHaptic::setNbBeats(uint32_t nbbeats)
+void MetronomeHaptic::setNbBeats(Uint32 nbbeats)
{
Metronome::setNbBeats(nbbeats);\r
- //send info to Serial Port\r
-/* char outBuffer[5];// = {'B', '5', '6', '7', '8'};\r
- memset(outBuffer, 0, 5);
- sprintf(OUTBUFFER, "B%3d\n", nbbeats);\r
- outBuffer[0] = 'B';\r
- outBuffer[1] = (nbbeats & 0xff000000) >> 24;\r
- outBuffer[2] = (nbbeats & 0x00ff0000) >> 16;\r
- outBuffer[3] = (nbbeats & 0x0000ff00) >> 8;\r
- outBuffer[4] = nbbeats & 0x000000ff;\r
- \r
- bool written = _comport->WriteData(outBuffer, 5);\r
-
- char INBUFFER[128];\r
- memset(INBUFFER, 0, 128);
- int nbread = _comport->ReadData(INBUFFER, 128);
- stringstream s;
- s << nbread << " read:\n" << INBUFFER << endl;
- OutputDebugString(s.str().c_str());*/
}
void MetronomeHaptic::run()
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
- const list<Pair<uint32_t, uint32_t> > *bips = thismetronome->_track->getBips();
- //const map<uint32_t, Pair<float, uint32_t> > *tempo = thismetronome->_track->getTempos();
- const map<uint32_t, Pair<uint32_t, uint32_t> > *timesignatures = thismetronome->_track->getTimeSignatures();
- static list<Pair<uint32_t, uint32_t> >::const_iterator cBips = bips->begin();
- //static map<uint32_t, Pair<float, uint32_t> >::const_iterator cTempo = tempo->begin();
- static map<uint32_t, Pair<uint32_t, uint32_t> >::const_iterator cTimesignature = timesignatures->begin();
-
-#ifdef WIN32
- struct { int tv_sec, tv_usec; } now;//, start
- DWORD t = timeGetTime () + BEFOREDELAY;
-/* start.tv_sec = t / 1000;
- start.tv_usec = (t % 1000) * 1000;*/
-#else
- struct timeval now;/*, start;
- gettimeofday(&start, NULL);*/
-#endif*/
- //float currenttime = 0;
+ const list<Pair<Uint32, Uint32> > *bips = thismetronome->_track->getBips();
+ //const map<Uint32, Pair<float, Uint32> > *tempo = thismetronome->_track->getTempos();
+ const map<Uint32, Pair<Uint32, Uint32> > *timesignatures = thismetronome->_track->getTimeSignatures();
+ static list<Pair<Uint32, Uint32> >::const_iterator cBips = bips->begin();
+ //static map<Uint32, Pair<float, Uint32> >::const_iterator cTempo = tempo->begin();
+ static map<Uint32, Pair<Uint32, Uint32> >::const_iterator cTimesignature = timesignatures->begin();
bool written = thismetronome->_comport->WriteData("S", 1);
unsigned char outBuffer[6];
while(thismetronome->_activated)
{
-#ifdef WIN32
- t = timeGetTime () + BEFOREDELAY;
- now.tv_sec = t / 1000;
- now.tv_usec = (t % 1000) * 1000;
-#else
- gettimeofday(&now, NULL);
-#endif
- uint32_t currenttime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
+ Uint32 currenttime = SDL_GetTicks() - start;
while (cBips != bips->end() && currenttime >= BIPTIMESTAMP(*cBips))
{
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
- const map<uint32_t, Pair<float, uint32_t> > *tempo = thismetronome->_track->getTempos();
- const map<uint32_t, Pair<float, uint32_t> > *timesignatures = thismetronome->_track->getTimeSignatures();
- static map<uint32_t, Pair<float, uint32_t> >::const_iterator cTempo = tempo->begin();
- static map<uint32_t, Pair<float, uint32_t> >::const_iterator cTimesignature = timesignatures->begin();
+ const map<Uint32, Pair<float, Uint32> > *tempo = thismetronome->_track->getTempos();
+ const map<Uint32, Pair<float, Uint32> > *timesignatures = thismetronome->_track->getTimeSignatures();
+ static map<Uint32, Pair<float, Uint32> >::const_iterator cTempo = tempo->begin();
+ static map<Uint32, Pair<float, Uint32> >::const_iterator cTimesignature = timesignatures->begin();
#ifdef WIN32
struct { int tv_sec, tv_usec; } now, start;
#include "Metronome.hpp"
#include "MetronomeAudio.hpp"
#include "MetronomeHaptic.hpp"
+#include "Tools.hpp"
#include <GL/glew.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_image.h>
-#ifdef WIN32
- struct { int tv_sec, tv_usec; } start;
-#else
- struct timeval start;
-#endif
+#define KEY(X) ((keystate[(X)]) != 0)
+
+extern GameType gametype;
+
+Uint32 start;
#include <iostream>
using namespace std;
-int VIEWLENGTH = 250;
+GLfloat VIEWLENGTH = 250.f;
extern float SECONDSIZE;
float posz = 0;
Texture *texturebois, *texturefond, *texturesteel, *texturefrett;
void draw(const Track &t, char diff)
{
-#ifdef WIN32
+/*#ifdef WIN32
struct { int tv_sec, tv_usec; } now;
DWORD tim = timeGetTime ();
now.tv_sec = tim / 1000;
#else
struct timeval now;
gettimeofday(&now, NULL);
-#endif
- uint32_t currenttime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
+#endif*/
+ Uint32 currenttime = SDL_GetTicks() - start;
+ //(now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
posz = -SECONDSIZE * currenttime;
glBegin(GL_QUADS);
glColor3f(0.2f, 0.2f, 0.2f);
glNormal3f(0, 1, 0);
- glVertex3f(NOTEDIST*(i-2), 0, 1);
- glVertex3f(NOTEDIST*(i-2)+.1f, 0.2f, 1);
- glVertex3f(NOTEDIST*(i-2)+.1f, 0.2f,-VIEWLENGTH);
- glVertex3f(NOTEDIST*(i-2), 0, -VIEWLENGTH);
- glVertex3f(NOTEDIST*(i-2)+.1f, 0.2f, 1);
- glVertex3f(NOTEDIST*(i-2)+.2f, 0, 1);
- glVertex3f(NOTEDIST*(i-2)+.2f, 0,-VIEWLENGTH);
- glVertex3f(NOTEDIST*(i-2)+.1f, 0.2f, -VIEWLENGTH);
+ glVertex3f(GLfloat(NOTEDIST*(i-2)), 0.f, 1.f);
+ glVertex3f(GLfloat(NOTEDIST*(i-2))+.1f, 0.2f, 1.f);
+ glVertex3f(GLfloat(NOTEDIST*(i-2))+.1f, 0.2f,-VIEWLENGTH);
+ glVertex3f(GLfloat(NOTEDIST*(i-2)), 0, -VIEWLENGTH);
+ glVertex3f(GLfloat(NOTEDIST*(i-2))+.1f, 0.2f, 1.f);
+ glVertex3f(GLfloat(NOTEDIST*(i-2))+.2f, 0.f, 1.f);
+ glVertex3f(GLfloat(NOTEDIST*(i-2))+.2f, 0.f, -VIEWLENGTH);
+ glVertex3f(GLfloat(NOTEDIST*(i-2))+.1f, 0.2f, -VIEWLENGTH);
glEnd();
}
//Draw the sides
glEnd(); // Done Drawing The Quad
}
-void handleKeyOn(keys k, uint32_t currenttime)
+void handleKeyOn(keys k, Uint32 currenttime)
{
fromKeyboard.addKey(k);
/* switch(k)
}*/
}
-void handleKeyOff(keys k, uint32_t currenttime)
+void handleKeyOff(keys k, Uint32 currenttime)
{
// fromKeyboard.remKey(k);
if (fromKeyboard.getTimestamp() == -1)
fromKeyboard.setEndTimestamp(-1);
}
-void handleKeys(bool a, bool b, bool c, bool d, bool e, uint32_t currenttime)
+void handleKeys(bool a, bool b, bool c, bool d, bool e, Uint32 currenttime)
{
- if (fromKeyboard.isNone())
- fromKeyboard.setTimestamp(-1);
- fromKeyboard.setKeys(a, b, c, d, e);
+ if (gametype == REGULAR)
+ {
+ if (fromKeyboard.isNone())
+ fromKeyboard.setTimestamp(-1);
+ fromKeyboard.setKeys(a, b, c, d, e);
+ }
+ else if (gametype == SPEEDACCURACY)
+ {
+ fromKeyboard.setKeys(a, b, c, d, e);
+ if (fromKeyboard.getTimestamp() != currenttime)
+ {
+ fromKeyboard.setTimestamp(currenttime);
+ fromKeyboard.log("Play", logfile);
+ }
+ }
}
-void handleStrokeOn(uint32_t currenttime)
+void handleStrokeOn(Uint32 currenttime)
{
if (fromKeyboard.getTimestamp() != -1)
{
fromKeyboard.setEndTimestamp(-1);
}
-void handleStrokeOff(uint32_t currenttime)
+void handleStrokeOff(Uint32 currenttime)
{
}
bool processEvents()
{
-#ifdef WIN32
+/*#ifdef WIN32
struct { int tv_sec, tv_usec; } now;
DWORD tim = timeGetTime ();
now.tv_sec = tim / 1000;
#else
struct timeval now;
gettimeofday(&now, NULL);
-#endif
- uint32_t currenttime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
+#endif*/
+ Uint32 currenttime = SDL_GetTicks() - start;
+ //(now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
SDL_Event event;
// bool quitProgram = false;
case SDL_KEYDOWN:
#if SDL_VERSION_ATLEAST(1,3,0)
keystate = SDL_GetKeyboardState(NULL);
- handleKeys(keystate[SDL_SCANCODE_F1], keystate[SDL_SCANCODE_F2], keystate[SDL_SCANCODE_F3], keystate[SDL_SCANCODE_F4], keystate[SDL_SCANCODE_F5], currenttime);
+ if (gametype == REGULAR)
+ handleKeys(KEY(SDL_SCANCODE_F1), KEY(SDL_SCANCODE_F2),KEY(SDL_SCANCODE_F3), KEY(SDL_SCANCODE_F4), KEY(SDL_SCANCODE_F5), currenttime);
+ else if (gametype == SPEEDACCURACY)
+ handleKeys(KEY(SDL_SCANCODE_A), KEY(SDL_SCANCODE_S), false, KEY(SDL_SCANCODE_K), KEY(SDL_SCANCODE_L), currenttime);
#else
keystate = SDL_GetKeyState(NULL);
handleKeys(keystate[SDLK_F1], keystate[SDLK_F2], keystate[SDLK_F3], keystate[SDLK_F4], keystate[SDLK_F5], currenttime);
handleStrokeOn(currenttime);
break;
case SDLK_RCTRL:
- if (logfile)
+ if (logfile && gametype == TOMSLAW)
fprintf(logfile, "PRESS;%d\n", currenttime);
break;
default:
}
#if SDL_VERSION_ATLEAST(1,3,0)
keystate = SDL_GetKeyboardState(NULL);
- handleKeys(keystate[SDL_SCANCODE_F1], keystate[SDL_SCANCODE_F2], keystate[SDL_SCANCODE_F3], keystate[SDL_SCANCODE_F4], keystate[SDL_SCANCODE_F5], currenttime);
+ if (gametype == REGULAR)
+ handleKeys(KEY(SDL_SCANCODE_F1), KEY(SDL_SCANCODE_F2),KEY(SDL_SCANCODE_F3), KEY(SDL_SCANCODE_F4), KEY(SDL_SCANCODE_F5), currenttime);
+ else if (gametype == SPEEDACCURACY)
+ handleKeys(KEY(SDL_SCANCODE_A), KEY(SDL_SCANCODE_S), false, KEY(SDL_SCANCODE_K), KEY(SDL_SCANCODE_L), currenttime);
#else
keystate = SDL_GetKeyState(NULL);
handleKeys(keystate[SDLK_F1], keystate[SDLK_F2], keystate[SDLK_F3], keystate[SDLK_F4], keystate[SDLK_F5], currenttime);
SDL_LogDebug(SDL_LOG_CATEGORY_SYSTEM, "Init paint\n");
initPaint();
- Mixer::getInstance()->loadMusic(songname + "/tout.ogg");
+ if (gametype == REGULAR)
+ Mixer::getInstance()->loadMusic(songname + "/tout.ogg");
//must be done before paint and metronomes
-#ifdef WIN32
+ start = SDL_GetTicks();
+/*#ifdef WIN32
DWORD t = timeGetTime ();
start.tv_sec = t / 1000;
start.tv_usec = (t % 1000) * 1000;
#else
gettimeofday(&start, NULL);
-#endif
+#endif*/
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "LET'S ROCK!\n");
//m->setActive(true);
- Mixer::getInstance()->playMusic();
+ if (gametype == REGULAR)
+ Mixer::getInstance()->playMusic();
if (m)
m->run();
/* Mixer::getInstance()->playSound("guitar");
while(!quitProgram)
{
-/* //compute current time in the loop
-#ifdef WIN32
- struct { int tv_sec, tv_usec; } now;
- DWORD tim = timeGetTime ();
- now.tv_sec = tim / 1000;
- now.tv_usec = (tim % 1000) * 1000;
-#else
- struct timeval now;
- gettimeofday(&now, NULL);
-#endif
- uint32_t currenttime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
- */
// cout << "draw" << endl;
draw(tr, NORMAL);
// cout << "events" << endl;
// cout << "pause" << endl;
SDL_Delay(10);
// check metronome events
-// tr.checkMetronome(currenttime, m);
}
delete m;
extern Texture* texturesteel, *texturefrett;
extern FILE *logfile;
extern float SECONDSIZE;
-extern int VIEWLENGTH;
+extern GLfloat VIEWLENGTH;
Track::Track()
:/*_currenttempo(120)*,_currentpos(0),*/ _trackSize(0), _active(true)
{
- for (uint8_t i = 0 ; i < NBDIFFICULTIES ; i++)
+ for (Uint8 i = 0 ; i < NBDIFFICULTIES ; i++)
{
- _currentconfig[i] = (uint8_t) 0;
+ _currentconfig[i] = (Uint8) 0;
_nbnotes[i] = 0;
_totallength[i] = 0;
}
- for (uint8_t i = 0 ; i < 128 ; i++)
+ for (Uint8 i = 0 ; i < 128 ; i++)
_totalnotes[i] = 0;
}
Track::Track(const Track &tr)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "WARNING: COPYING THE TRACK!\n");
- for (uint8_t i = 0 ; i < NBDIFFICULTIES ; i++)
+ for (Uint8 i = 0 ; i < NBDIFFICULTIES ; i++)
{
_notes[i] = tr._notes[i];
_currentconfig[i] = tr._currentconfig[i];
tempo: beats per minute
duration: track length in ms
*/
-Track::Track(uint32_t tempo, uint32_t duration)
+Track::Track(Uint32 tempo, Uint32 duration)
{
- uint32_t t = 60000000 / tempo;
+ Uint32 t = 60000000 / tempo;
addTempo(0, 0, tempo);
addTimesignature(0, 0, 1);
- for (uint32_t i = 0 ; i < (duration * 1000) / t ; i++)
- _bips.push_back(Pair<uint32_t, uint32_t>(i, i * t / 1000 + 2000));
+ for (Uint32 i = 0 ; i < (duration * 1000) / t ; i++)
+ _bips.push_back(Pair<Uint32, Uint32>(i, i * t / 1000 + 2000));
}
/**
nbspeeds: number of speeds
speeds:
*/
-Track::Track(uint8_t nbbuttons, uint8_t repetitions, uint8_t nbspeeds, uint32_t *speeds)
+Track::Track(Uint8 nbbuttons, Uint8 repetitions, Uint8 nbspeeds, Uint32 *speeds)
{
- uint32_t tick = 0, timestamp = 2000;
+ Uint32 tick = 0, timestamp = 2000;
addTimesignature(0, 0, 1);
for (int n = 0 ; n < nbspeeds ; n++)
{
- uint32_t tempo = 60000000 / speeds[n];
+ Uint32 tempo = 60000000 / speeds[n];
addTempo(tick, timestamp, tempo);
- vector<uint8_t> configs;
+ vector<Uint8> configs;
//creates a block with repetitions of all the patterns (excluding the empty pattern)
for (int i = 1 ; i < (int)pow(2.0, (double)nbbuttons) ; i++)
random_shuffle(configs.begin(), configs.end());
//add the permutation to the note list
- for (vector<uint8_t>::iterator it = configs.begin() ; it != configs.end() ; it++)
+ for (vector<Uint8>::iterator it = configs.begin() ; it != configs.end() ; it++)
{
- uint8_t cfg = ((*it) & 0x03) | (((*it) & 0x0c) << 1);
+ Uint8 cfg = ((*it) & 0x03) | (((*it) & 0x0c) << 1);
for (int d=0 ; d < NBDIFFICULTIES ; d++)
_notes[d][tick] = Config(cfg, timestamp, timestamp+100, tick, 1);
tick++;
108: vocal track (C)
*/
-void Track::addKey(uint32_t time, uint8_t note)
+void Track::addKey(Uint32 time, Uint8 note)
{
// _totalnotes[note]++;
// cout << "addkey begin" << endl;
- uint8_t difficulty = note / 12 - 5;
- uint8_t key = note % 12;
+ Uint8 difficulty = note / 12 - 5;
+ Uint8 key = note % 12;
// cout << "+ diff=" << difficulty+0 << " key=" << key+0 << " note=" << note+0 << endl; //could be note 108 for singer
if (difficulty >= NBDIFFICULTIES || difficulty < 0)
{
// cout << "addkey end" << endl;
}
-void Track::remKey(uint32_t time, uint8_t note)
+void Track::remKey(Uint32 time, Uint8 note)
{
_totalnotes[note]++;
// cout << "remkey begin" << endl;
- uint8_t difficulty = note / 12 - 5;
- uint8_t key = note % 12;
+ Uint8 difficulty = note / 12 - 5;
+ Uint8 key = note % 12;
// cout << "- diff=" << difficulty+0 << " key=" << key+0 << " note=" << note+0 << endl;
if (difficulty >= NBDIFFICULTIES || difficulty + 0 < 0)
{
{
_currentconfig[difficulty].setTicks(time - _currentconfig[difficulty].getTime());
//compute the note duration and position
- uint32_t currenttempo = 0, lasttick = 0;
- map<uint32_t, Pair<uint32_t, uint32_t> >::iterator ti = _tempo.begin();
- uint32_t tickpos = _currentconfig[difficulty].getTime();
+ Uint32 currenttempo = 0, lasttick = 0;
+ map<Uint32, Pair<Uint32, Uint32> >::iterator ti = _tempo.begin();
+ Uint32 tickpos = _currentconfig[difficulty].getTime();
while (ti != _tempo.end() && TICK(*ti) <= tickpos)
{
// _currentconfig[difficulty].setPosition(_currentconfig[difficulty].getPosition() + (TICK(*ti) - lasttick) * (currenttempo / 480000.0));
}
if (tickpos > lasttick)
{
- uint32_t delta = static_cast<uint32_t>((tickpos - lasttick) * (currenttempo / 480000.0));
+ Uint32 delta = static_cast<Uint32>((tickpos - lasttick) * (currenttempo / 480000.0));
_currentconfig[difficulty].setTimestamp(_currentconfig[difficulty].getTimestamp() + delta);
}
{
if (ti != _tempo.end() && TICK(*ti) < time)
{
- uint32_t delta = static_cast<uint32_t>((TICK(*ti) - tickpos) * (currenttempo / 480000.0));
+ Uint32 delta = static_cast<Uint32>((TICK(*ti) - tickpos) * (currenttempo / 480000.0));
_currentconfig[difficulty].setEndTimestamp(_currentconfig[difficulty].getTimestamp() + delta);
_currentconfig[difficulty].setEndTimestamp(TIMESTAMP(*ti));
tickpos = TICK(*ti);
}
else
{
- uint32_t delta = static_cast<uint32_t>((time - tickpos) * (currenttempo / 480000.0));
+ Uint32 delta = static_cast<Uint32>((time - tickpos) * (currenttempo / 480000.0));
_currentconfig[difficulty].setEndTimestamp(_currentconfig[difficulty].getTimestamp() + delta);
tickpos = time;
}
// cout << "remkey end" << endl;
}
-Config Track::getNote(uint32_t pos, uint8_t difficulty)
+Config Track::getNote(Uint32 pos, Uint8 difficulty)
{
if (_notes[difficulty].count(pos) == 0)
throw 0;
return _notes[difficulty][pos];
}
-uint32_t Track::getTempo(uint32_t pos)
+Uint32 Track::getTempo(Uint32 pos)
{
if (_tempo.count(pos) == 0)
throw 0;
return _tempo[pos].getY();
}
-uint32_t Track::getTimeSignature(uint32_t pos)
+Uint32 Track::getTimeSignature(Uint32 pos)
{
if (_timesignatures.count(pos) == 0)
throw 0;
void Track::computeBips()
{
double pos = 0;
- uint32_t currenttempo = 120;
- map<uint32_t,uint32_t>::iterator p = _tempo.begin();
- for (uint32_t i = 0 ; i < getEndOfTrack() ; i += 480)
+ Uint32 currenttempo = 120;
+ map<Uint32,Uint32>::iterator p = _tempo.begin();
+ for (Uint32 i = 0 ; i < getEndOfTrack() ; i += 480)
{
//cout << "Bip @ " << pos << endl;
_bips.push_back(pos);
void Track::displayTracks()
{
cout << "TRACK:" << endl;
- for (uint8_t k=0 ; k < NBDIFFICULTIES ; k++)
+ for (Uint8 k=0 ; k < NBDIFFICULTIES ; k++)
{
cout << "Difficulty " << (k+0) << ":" << endl;
- for(map<uint32_t,Config>::iterator i = _notes[k].begin(); i != _notes[k].end(); ++i)
+ for(map<Uint32,Config>::iterator i = _notes[k].begin(); i != _notes[k].end(); ++i)
cout << (*i).first << ": " << (*i).second << endl;
}
}
void Track::debugTempo()
{
cout << "Tempo changes: " << endl;
- for( map<uint32_t, Pair<uint32_t, uint32_t> >::iterator ii=_tempo.begin(); ii!=_tempo.end(); ++ii)
+ for( map<Uint32, Pair<Uint32, Uint32> >::iterator ii=_tempo.begin(); ii!=_tempo.end(); ++ii)
cout << TICK(*ii) << ": " << TIMESTAMP(*ii) << " (" << VALUE(*ii) << ")" << endl;
//ticksToBeats((*ii).second) << ")" << endl;
}
-void Track::drawFrets(uint32_t postime) const
+void Track::drawFrets(Uint32 postime) const
{
- static list<Pair<uint32_t, uint32_t> >::const_iterator startingbips = _bips.begin();
+ static list<Pair<Uint32, Uint32> >::const_iterator startingbips = _bips.begin();
// on avance tant que les bips sont dépassées
while (startingbips != _bips.end() && BIPTIMESTAMP(*startingbips) < postime)
startingbips++;
}
- list<Pair<uint32_t, uint32_t> >::const_iterator b = startingbips;
+ list<Pair<Uint32, Uint32> >::const_iterator b = startingbips;
glMatrixMode(GL_MODELVIEW);
//glDisable(GL_DEPTH_TEST);
}
}
-void Track::drawNotes(uint32_t postime, uint8_t diff) const
+void Track::drawNotes(Uint32 postime, Uint8 diff) const
{
- static map<uint32_t,Config>::const_iterator startingn = _notes[diff].begin();
+ static map<Uint32,Config>::const_iterator startingn = _notes[diff].begin();
static double startingpos = 0.0;
// cout << "startingpos=" << startingpos << " postime=" << postime << " first note at " << (*startingn).first << ":" << (*startingn).second.getPosition() << endl;
startingn++;
}
- map<uint32_t,Config>::const_iterator n = startingn;
+ map<Uint32,Config>::const_iterator n = startingn;
glMatrixMode(GL_MODELVIEW);
//on dessine les notes jusqu'à 10s
/*
void Track::checkMetronome(float postime, Metronome *m) const
{
- static map<uint32_t, Pair<float, uint32_t> >::const_iterator cTempo = _tempo.begin();
- static map<uint32_t, Pair<float, uint32_t> >::const_iterator cTimesignature = _timesignatures.begin();
+ static map<Uint32, Pair<float, Uint32> >::const_iterator cTempo = _tempo.begin();
+ static map<Uint32, Pair<float, Uint32> >::const_iterator cTimesignature = _timesignatures.begin();
static double startingpos = 0.0;
// on avance tant que les tempos sont dépassées
#define MAX(X,Y) (((X)>(Y))?(X):(Y))
#define MIN(X,Y) (((X)<(Y))?(X):(Y))
-#ifdef WIN32
- extern struct { int tv_sec, tv_usec; } start;
-#else
- extern struct timeval start;
-#endif
+extern Uint32 start;
Wiimote::Wiimote(int nb)
:_wiimotes(wiiuse_init(nb)), _nb(nb), _strumstate(false)
}
}
-void Wiimote::handleKey(guitar_hero_3_t* gh3, int key, int button, uint32_t currenttime)
+void Wiimote::handleKey(guitar_hero_3_t* gh3, int key, int button, Uint32 currenttime)
{
if (_keystate[key])
{
void Wiimote::handleEvents()
{
-#ifdef WIN32
- struct { int tv_sec, tv_usec; } now;
- DWORD tim = timeGetTime ();
- now.tv_sec = tim / 1000;
- now.tv_usec = (tim % 1000) * 1000;
-#else
- struct timeval now;
- gettimeofday(&now, NULL);
-#endif
- uint32_t currenttime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000;
+ Uint32 currenttime = SDL_GetTicks() - start;
if (!wiiuse_poll(_wiimotes, _nb))
return;
#include "Track.hpp"
#include "Mixer.hpp"
#include "PaintGame.h"
+#include "Tools.hpp"
#ifdef WIN32
#include <time.h>
#include <SDL/SDL.h>
#include <SDL/SDL_log.h>
+GameType gametype;
#ifdef WIN32
#include <time.h>
time_t tim = time(NULL);
struct tm *t = gmtime(&tim);
-
+
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Loading song\n");
// v5 = distance
if (argc >= 6)
{
+ gametype = TOMSLAW;
Track tr(atoi(argv[3]), atoi(argv[4]));
SECONDSIZE = atof(argv[5]);
// v4 = nbrepetitions
else if (argc >= 5)
{
- uint32_t speeds[] = {40, 80, 120, 160, 200};
+ gametype = SPEEDACCURACY;
+
+ Uint32 speeds[] = {40, 80, 120, 160, 200};
Track tr(atoi(argv[3]), atoi(argv[4]), 5, speeds);
SECONDSIZE = 0.08;
}
else
{
+ gametype = REGULAR;
+
if (argc >= 3)
{
String logfilename = String(argv[1]) + "-" + String(argv[2]) + "-" + String(1900 + t->tm_year) + "-" + String(t->tm_mon) + "-" + String(t->tm_mday) + "-" + String(t->tm_hour) + "-" + String(t->tm_min) + "-" + String(t->tm_sec);