Auto full-combo Koibumi2000 in Taiko no Tatsujin CS5
Dependencies: fll mbed-rtos mbed
taiko.cpp@18:c5d3a4d6e8e5, 2015-02-16 (annotated)
- Committer:
- amutake
- Date:
- Mon Feb 16 13:03:06 2015 +0000
- Revision:
- 18:c5d3a4d6e8e5
- Parent:
- 16:253d933a7633
- Child:
- 21:9cc452a67382
Add OnetimeSource, DelayFlow, SequentialFlow and menu control, then full combo stablly
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
amutake | 10:79bb44beb08b | 1 | // Toolkit for Taiko no Tatsujin |
amutake | 10:79bb44beb08b | 2 | |
amutake | 10:79bb44beb08b | 3 | #include "fll.h" |
amutake | 10:79bb44beb08b | 4 | #include "taiko.h" |
amutake | 10:79bb44beb08b | 5 | |
amutake | 10:79bb44beb08b | 6 | button_t taiko2button(Taiko t) |
amutake | 10:79bb44beb08b | 7 | { |
amutake | 12:54aeb978fe9d | 8 | |
amutake | 10:79bb44beb08b | 9 | switch (t) { |
amutake | 12:54aeb978fe9d | 10 | case Un: |
amutake | 12:54aeb978fe9d | 11 | return 0; |
amutake | 10:79bb44beb08b | 12 | case Don: |
amutake | 10:79bb44beb08b | 13 | return CIRCLE; |
amutake | 10:79bb44beb08b | 14 | case Ka: |
amutake | 10:79bb44beb08b | 15 | return R1; |
amutake | 12:54aeb978fe9d | 16 | case Renda: |
amutake | 12:54aeb978fe9d | 17 | return CIRCLE; |
amutake | 15:ed0c2da735c2 | 18 | case DonDai: |
amutake | 15:ed0c2da735c2 | 19 | return CIRCLE|LEFT; |
amutake | 15:ed0c2da735c2 | 20 | case KaDai: |
amutake | 15:ed0c2da735c2 | 21 | return L1|R1; |
amutake | 10:79bb44beb08b | 22 | } |
amutake | 10:79bb44beb08b | 23 | return 0; |
amutake | 10:79bb44beb08b | 24 | } |
amutake | 10:79bb44beb08b | 25 | |
amutake | 11:21b3b0494baa | 26 | TaikoSource::TaikoSource(note** ns, int s, float b) |
amutake | 10:79bb44beb08b | 27 | { |
amutake | 10:79bb44beb08b | 28 | note_seq = ns; |
amutake | 10:79bb44beb08b | 29 | size = s; |
amutake | 10:79bb44beb08b | 30 | bpm = b; |
amutake | 10:79bb44beb08b | 31 | index = 0; |
amutake | 10:79bb44beb08b | 32 | frame_i = 0; |
amutake | 11:21b3b0494baa | 33 | lag = 0; |
amutake | 10:79bb44beb08b | 34 | } |
amutake | 10:79bb44beb08b | 35 | |
amutake | 10:79bb44beb08b | 36 | button_t TaikoSource::await() |
amutake | 10:79bb44beb08b | 37 | { |
amutake | 10:79bb44beb08b | 38 | if (index >= size) { |
amutake | 10:79bb44beb08b | 39 | return 0; |
amutake | 10:79bb44beb08b | 40 | } |
amutake | 11:21b3b0494baa | 41 | |
amutake | 10:79bb44beb08b | 42 | note* n = note_seq[index]; |
amutake | 11:21b3b0494baa | 43 | float len = n->length * (60 / bpm); // note length (sec) |
amutake | 10:79bb44beb08b | 44 | float passing = frame_i * FRAME; // passing time since the begining of this note (sec) |
amutake | 11:21b3b0494baa | 45 | |
amutake | 10:79bb44beb08b | 46 | frame_i++; |
amutake | 11:21b3b0494baa | 47 | |
amutake | 10:79bb44beb08b | 48 | button_t btn = 0; |
amutake | 12:54aeb978fe9d | 49 | |
amutake | 12:54aeb978fe9d | 50 | if (n->taiko == Renda) { |
amutake | 12:54aeb978fe9d | 51 | if (passing + FRAME >= len - lag) { |
amutake | 12:54aeb978fe9d | 52 | frame_i = 0; |
amutake | 12:54aeb978fe9d | 53 | index++; |
amutake | 12:54aeb978fe9d | 54 | lag = passing + FRAME - (len - lag); |
amutake | 12:54aeb978fe9d | 55 | } else { |
amutake | 12:54aeb978fe9d | 56 | if (frame_i % 2 == 0) { |
amutake | 14:83af8f502d83 | 57 | btn = CIRCLE; // TODO |
amutake | 12:54aeb978fe9d | 58 | } else { |
amutake | 14:83af8f502d83 | 59 | btn = LEFT; // TODO |
amutake | 12:54aeb978fe9d | 60 | } |
amutake | 12:54aeb978fe9d | 61 | } |
amutake | 12:54aeb978fe9d | 62 | } else { |
amutake | 16:253d933a7633 | 63 | if (frame_i < 3) { // in the former of this note |
amutake | 12:54aeb978fe9d | 64 | btn = taiko2button(n->taiko); |
amutake | 12:54aeb978fe9d | 65 | } else if (passing + FRAME >= len - lag) { // final frame of this note |
amutake | 12:54aeb978fe9d | 66 | frame_i = 0; |
amutake | 12:54aeb978fe9d | 67 | index++; |
amutake | 12:54aeb978fe9d | 68 | lag = passing + FRAME - (len - lag); |
amutake | 12:54aeb978fe9d | 69 | } |
amutake | 10:79bb44beb08b | 70 | } |
amutake | 10:79bb44beb08b | 71 | return btn; |
amutake | 18:c5d3a4d6e8e5 | 72 | } |
amutake | 18:c5d3a4d6e8e5 | 73 | |
amutake | 18:c5d3a4d6e8e5 | 74 | bool TaikoSource::is_finished() { |
amutake | 18:c5d3a4d6e8e5 | 75 | return index >= size; |
amutake | 10:79bb44beb08b | 76 | } |