Auto full-combo Koibumi2000 in Taiko no Tatsujin CS5
Dependencies: fll mbed-rtos mbed
Diff: taiko.cpp
- Revision:
- 10:79bb44beb08b
- Child:
- 11:21b3b0494baa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taiko.cpp Sun Feb 15 06:53:27 2015 +0000 @@ -0,0 +1,49 @@ +// Toolkit for Taiko no Tatsujin + +#include "fll.h" +#include "taiko.h" + +Serial pc(USBTX, USBRX); + +button_t taiko2button(Taiko t) +{ + switch (t) { + case Don: + return CIRCLE; + case Ka: + return R1; + } + return 0; +} + +TaikoSource::TaikoSource(note** ns, int s, int b) +{ + note_seq = ns; + size = s; + bpm = b; + index = 0; + frame_i = 0; +} + +button_t TaikoSource::await() +{ + if (index >= size) { + index = 0; // XXX: remove this line (for debugging) + return 0; + } + + note* n = note_seq[index]; + float len = n->length * (60 / (float)bpm); // note length (sec) + float passing = frame_i * FRAME; // passing time since the begining of this note (sec) + + frame_i++; + + button_t btn = 0; + if (passing < len / 2) { // in the former of this note + btn = taiko2button(n->taiko); + } else if (passing + FRAME >= len) { // final frame of this note + frame_i = 0; + index++; + } + return btn; +} \ No newline at end of file