bool CChannelHandlerVRC6::HandleInstrument(int Instrument, bool Trigger, bool NewInstrument) { CFamiTrackerDoc *pDocument = m_pSoundGen->GetDocument(); CInstrumentContainer<CInstrumentVRC6> instContainer(pDocument, Instrument); CInstrumentVRC6 *pInstrument = instContainer(); if (!pInstrument) return false; // Setup instrument for (int i = 0; i < CInstrumentVRC6::SEQUENCE_COUNT; ++i) { const CSequence *pSequence = pDocument->GetSequence(SNDCHIP_VRC6, pInstrument->GetSeqIndex(i), i); if (Trigger || !IsSequenceEqual(i, pSequence) || pInstrument->GetSeqEnable(i) > GetSequenceState(i)) { if (pInstrument->GetSeqEnable(i) == 1) SetupSequence(i, pSequence); else ClearSequence(i); } } return true; }
int main(void) { uint8_t seq_index; // index of currently active RGB sequence rgbt_t* sequence; // pointer to current rgb sequence rgbt_t* rgbt; // pointer to the current target (R,G,B,time) tuple uint8_t temp; InitHardware(); serInit(); // pwmReset(pwm); seq_index = (uint8_t) eeprom_read_word((uint16_t*)EE_SEQ_INDEX); if (seq_index >= SEQENCE_COUNT) { seq_index = DEFAULT_SEQ; sequence = SetupSequence(seq_index); } else { sequence = SetupSequence(seq_index); ocr1a_reload = eeprom_read_word((uint16_t*)EE_SPEED); } rgbt = SetupTransition(sequence, NULL); rgbt = SetupTransition(sequence, rgbt); sei(); // enable interrupts while(1) { switch (button) { case PB_SPEEDUP: // --- double speed --- button = PB_ACK; // acknowledge button event if (ocr1a_reload >= (TIME_FASTEST << 1)) { ocr1a_reload >>= 1; } else { sequence = SetupSequence(seq_index); rgbt = SetupTransition(sequence, NULL); rgbt = SetupTransition(sequence, rgbt); } break; case PB_PREV: // --- previous sequence --- button = PB_ACK; // acknowledge button event if (seq_index > 0) { seq_index--; } else { seq_index = SEQENCE_COUNT - 1; } sequence = SetupSequence(seq_index); rgbt = SetupTransition(sequence, NULL); rgbt = SetupTransition(sequence, rgbt); break; case PB_NEXT: // --- next sequence --- button = PB_ACK; // acknowledge button event if (seq_index < (SEQENCE_COUNT-1)) { seq_index++; } else { seq_index = 0; } sequence = SetupSequence(seq_index); rgbt = SetupTransition(sequence, NULL); rgbt = SetupTransition(sequence, rgbt); break; }