Auto full-combo Koibumi2000 in Taiko no Tatsujin CS5
Dependencies: fll mbed-rtos mbed
main.cpp@7:61b4825304e2, 2015-02-14 (annotated)
- Committer:
- amutake
- Date:
- Sat Feb 14 16:39:53 2015 +0000
- Revision:
- 7:61b4825304e2
- Parent:
- 6:d0348b7a2f05
- Child:
- 8:d16a0fcc2735
English comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
amutake | 0:c80e972b4c59 | 1 | #include "mbed.h" |
amutake | 0:c80e972b4c59 | 2 | #include "rtos.h" |
amutake | 0:c80e972b4c59 | 3 | #include "fll.h" |
amutake | 0:c80e972b4c59 | 4 | |
amutake | 0:c80e972b4c59 | 5 | #define FRAME 1.0 / 60 // 1 frame (sec) |
amutake | 0:c80e972b4c59 | 6 | |
amutake | 7:61b4825304e2 | 7 | // [ Up, Right, Down, ... ] |
amutake | 7:61b4825304e2 | 8 | // +--- OrFoldFlow ---> [ Up|Circle, Right, Down|Triangle, Up, Right|Circle, ... ] |
amutake | 7:61b4825304e2 | 9 | // [ Circle, none, Triangle, none, ... ] |
sierra | 6:d0348b7a2f05 | 10 | class OrFoldFlow : public FoldFlow { |
sierra | 5:130721ce29f7 | 11 | public: |
sierra | 6:d0348b7a2f05 | 12 | OrFoldFlow(Producer **srcs, int srcs_size) : FoldFlow(srcs, srcs_size) {} |
sierra | 5:130721ce29f7 | 13 | virtual button_t fold(button_t *bs, int bs_size) { |
sierra | 5:130721ce29f7 | 14 | button_t b = 0x00; |
sierra | 5:130721ce29f7 | 15 | for(int i = 0; i < bs_size; i++) { |
sierra | 5:130721ce29f7 | 16 | b |= bs[i]; |
sierra | 5:130721ce29f7 | 17 | } |
sierra | 5:130721ce29f7 | 18 | return b; |
sierra | 5:130721ce29f7 | 19 | } |
sierra | 5:130721ce29f7 | 20 | }; |
sierra | 5:130721ce29f7 | 21 | |
sierra | 5:130721ce29f7 | 22 | void invoke_sinkrun(const void *p) { |
amutake | 0:c80e972b4c59 | 23 | ((Sink*)p)->run(); |
amutake | 0:c80e972b4c59 | 24 | } |
amutake | 0:c80e972b4c59 | 25 | |
amutake | 0:c80e972b4c59 | 26 | int main(void) |
amutake | 0:c80e972b4c59 | 27 | { |
sierra | 5:130721ce29f7 | 28 | button_t array0[] = {R1, 0}; |
amutake | 7:61b4825304e2 | 29 | button_t array1[] = {CIRCLE, 0}; |
amutake | 7:61b4825304e2 | 30 | |
amutake | 7:61b4825304e2 | 31 | // fll user must make a Producer |
sierra | 6:d0348b7a2f05 | 32 | Producer* source0 = new RepeaterSource(array0, sizeof(array0)/sizeof(button_t)); |
sierra | 6:d0348b7a2f05 | 33 | Producer* source1 = new RepeaterSource(array1, sizeof(array1)/sizeof(button_t)); |
sierra | 6:d0348b7a2f05 | 34 | Producer* ss[] = {source0, source1}; |
sierra | 6:d0348b7a2f05 | 35 | Producer* source = new OrFoldFlow(ss, 2); |
amutake | 0:c80e972b4c59 | 36 | |
amutake | 0:c80e972b4c59 | 37 | // common pattern |
sierra | 3:edbf31a8589f | 38 | Mail<button_t, MAIL_BOX_SIZE>* mail_box = new Mail<button_t, MAIL_BOX_SIZE>(); |
amutake | 0:c80e972b4c59 | 39 | Mutex* mutex = new Mutex(); |
amutake | 0:c80e972b4c59 | 40 | |
amutake | 2:165723d41023 | 41 | Sink* sink = new Sink(source, mail_box, mutex); |
amutake | 0:c80e972b4c59 | 42 | |
amutake | 0:c80e972b4c59 | 43 | Ticker ticker; |
amutake | 2:165723d41023 | 44 | Output* output = new Output(mail_box); |
amutake | 0:c80e972b4c59 | 45 | |
sierra | 4:9ee673ca05ad | 46 | Thread th(invoke_sinkrun, (void *)sink); |
amutake | 0:c80e972b4c59 | 47 | ticker.attach(output, &Output::run, FRAME); |
amutake | 0:c80e972b4c59 | 48 | |
sierra | 1:1abcd83947bf | 49 | Thread::wait(osWaitForever); |
amutake | 0:c80e972b4c59 | 50 | } |