Auto full-combo Koibumi2000 in Taiko no Tatsujin CS5

Dependencies:   fll mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers taiko.cpp Source File

taiko.cpp

00001 // Toolkit for Taiko no Tatsujin
00002 
00003 #include "fll.h"
00004 #include "taiko.h"
00005 
00006 button_t taiko2button(Taiko t)
00007 {
00008 
00009     switch (t) {
00010         case Un:
00011             return 0;
00012         case Don:
00013             return CIRCLE;
00014         case Ka:
00015             return R1;
00016         case Renda:
00017             return CIRCLE;
00018         case DonDai:
00019             return CIRCLE|LEFT;
00020         case KaDai:
00021             return L1|R1;
00022     }
00023     return 0;
00024 }
00025 
00026 TaikoSource::TaikoSource(note** ns, int s, float b)
00027 {
00028     note_seq = ns;
00029     size = s;
00030     bpm = b;
00031     index = 0;
00032     frame_i = 0;
00033     lag = 0;
00034 }
00035 
00036 button_t TaikoSource::await()
00037 {
00038     if (index >= size) {
00039         return 0;
00040     }
00041 
00042     note* n = note_seq[index];
00043     float len = n->length * (60 / bpm); // note length (sec)
00044     float passing = frame_i * FRAME; // passing time since the begining of this note (sec)
00045 
00046     frame_i++;
00047 
00048     button_t btn = 0;
00049 
00050     if (n->taiko == Renda) {
00051         if (passing + FRAME >= len - lag) {
00052             frame_i = 0;
00053             index++;
00054             lag = passing + FRAME - (len - lag);
00055         } else {
00056             if (frame_i % 2 == 0) {
00057                 btn = CIRCLE; // TODO
00058             } else {
00059                 btn = LEFT; // TODO
00060             }
00061         }
00062     } else {
00063         if (frame_i < 3) { // in the former of this note
00064             btn = taiko2button(n->taiko);
00065         } else if (passing + FRAME >= len - lag) { // final frame of this note
00066             frame_i = 0;
00067             index++;
00068             lag = passing + FRAME - (len - lag);
00069         }
00070     }
00071     return btn;
00072 }
00073 
00074 bool TaikoSource::is_finished()
00075 {
00076     return index >= size;
00077 }
00078 
00079 void TaikoSource::reset()
00080 {
00081     index = 0;
00082     frame_i = 0;
00083     lag = 0;
00084 }