예제 #1
0
파일: WideVM.cpp 프로젝트: FRex/WideVM
void WideVM::runVmProgram(VMLocation loc, int b, int e)
{
    m_begin = (b == -1)?0:b;
    m_end = (e == -1)?particleCount():e;

    if(loc.Location == -1)
        loc.Location = findStrInVector(loc.Name, m_prognames);

    if(loc.Location == -1) return;

    m_programcounter = m_subprograms[loc.Location];
    while(m_programcounter < m_program.size())
    {
        startLoop(); //in case an opcode uses while loopParticle init counter for it
        const int opcode = fetch();
        switch(opcode)
        {
            case EVO_QUIT:
                opQuit();
                break;
            case EVO_SIN:
                opSin();
                break;
            case EVO_COS:
                opCos();
                break;
            case EVO_COPY:
                opCopy();
                break;
            case EVO_RAND2:
                opRand2();
                break;
            case EVO_MATH2:
                opMath2();
                break;
        } //switch opcodes pc
    } //while pc < opcodes size
}
예제 #2
0
int main ()
{
	slInit("EasyAudio");
	slSetIcon("app-icon.png");
	opInit();
	//opSetCustomEscapeCallback(EnableOptionsMenu);

	// UI
	PlayToggleButton = slCreateBox(slLoadTexture(PLAY_BUTTON_IMGPATH));
	slSetBoxDims(PlayToggleButton,0.42,0.87,0.06,0.06, 17);
	PlayToggleButton->z = 22;
	PlayToggleButton->onclick = TogglePlaying;
	LoopToggleButton = slCreateBox(slLoadTexture(LOOP_BUTTON_IMGPATH));
	slSetBoxDims(LoopToggleButton,0.52,0.87,0.06,0.06, 17);
	LoopToggleButton->z = 22;
	LoopToggleButton->onclick = ToggleLooping;
	ControlsInfoBox = slCreateBox(slLoadTexture("interface/help-card.png"));
	slSetBoxDims(ControlsInfoBox,0.05,0.05,0.9,0.9, 1);
	ControlsInfoBox->z = 18;
	ControlsInfoBox->texbordercolor = {0,0,0,255};
	ControlsInfoBox->onclick = slDoNothing;
	slBox* ControlsHintBox = slCreateBox(slRenderText("Press C to toggle controls info.",{0,0,0,255}));
	slSetBoxDims(ControlsHintBox,0.01,0,0.2,0.05, 1);
	ControlsHintBox->z = 18;
	slBox* ProgressSliderBack = slCreateBox();
	slBox* ProgressSliderMark = slCreateBox();
	slSlider* ProgressSlider = slCreateSlider(ProgressSliderBack,ProgressSliderMark,false,true,false);
	ProgressSliderBack->backcolor = {159,159,159,255};
	ProgressSliderMark->backcolor = {63,63,63,255};
	ProgressSlider->minvalue = 0;
	ProgressSlider->maxvalue = 1;
	slSetBoxDims(ProgressSliderBack,0,0.97,1,0.03, 16);
	slSetBoxDims(ProgressSliderMark,0,0.97,0,0.03, 15);
	ProgressSliderBack->z = 210;
	ProgressSliderMark->z = 209;
	ProgressSlider->onchange = OnProgressAdjust;
	slBox* TempoSliderBack = slCreateBox();
	slBox* TempoSliderMark = slCreateBox();
	slSetBoxDims(TempoSliderBack,(0.42 - 0.35) / 2,0.87,0.35,0.06, 16);
	slSetBoxDims(TempoSliderMark,0,0.87,0.05,0.06, 15);
	slSlider* TempoSlider = slCreateSlider(TempoSliderBack,TempoSliderMark);
	TempoSliderBack->z = 210;
	TempoSliderMark->z = 209;
	TempoSliderBack->backcolor = {191,191,191,255};
	TempoSliderMark->backcolor = {95,95,95,255};
	TempoSlider->onchange = ChangeTempo;
	TempoSlider->minvalue = 40;
	TempoSlider->maxvalue = 220;
	TempoSlider->curvalue = 120.1;
	ChangeTempo(TempoSlider); // Initialize text on slider mark.
	slBox* TempoInfoBox = slCreateBox(slRenderText("TEMPO",BLACK));
	TempoInfoBox->backcolor = TempoSliderBack->backcolor;
	slSetBoxDims(TempoInfoBox,TempoSliderBack->x,0.84,0.07,0.03, 14);

	// Initialization
	slSetCustomDrawStage_Back(DrawBackground);
	slSetCustomDrawStage_Middle(DrawGrid);
	slOpenAudio();
	slSetCustomMixStage(Mix);
	VolAdjInit();

	// Keybindings
  int delete_key, lctrl_key, rctrl_key;
  if (!strcmp(SDL_GetPlatform(), "Mac OS X"))
  {
    delete_key = SDLK_BACKSPACE;
    lctrl_key = SDLK_LGUI;
    rctrl_key = SDLK_RGUI;
  }
  else
  {
    delete_key = SDLK_DELETE;
    lctrl_key = SDLK_LCTRL;
    rctrl_key = SDLK_RCTRL;
  }

	slGetKeyBind("Show/Hide Controls Info",SDLK_c)->onpress = OnControlsPress;
	slGetKeyBind("Append Measure to End",SDLK_m)->onpress = InsertMeasureAtEnd;
	slGetKeyBind("Chop Measure from End",SDLK_n)->onpress = RemoveMeasureFromEnd;
	slKeyBind* dragbind = slGetKeyBind("Drag Note",0,SDL_BUTTON(SDL_BUTTON_LEFT));
	dragbind->onpress = GrabNote;
	dragbind->onrelease = ReleaseNote;
	slGetKeyBind("Toggle Looping",SDLK_l)->onpress = ToggleLooping;
	slGetKeyBind("Toggle Playing",SDLK_SPACE)->onpress = TogglePlaying;
	CreateNoteLengthBind("Whole Note",SDLK_a,8);
	CreateNoteLengthBind("Half Note",SDLK_s,4);
	CreateNoteLengthBind("Quarter Note",SDLK_d,2);
	CreateNoteLengthBind("Eighth Note",SDLK_f,1);
	CreateNoteLengthBind("Sixteenth Note",SDLK_g,0.5);
	CreateNoteLengthBind("Thirty-Second Note",SDLK_h,0.25);
	slGetKeyBind("I Chord", SDLK_1)->onpress = EditChordKeyBind;
	slGetKeyBind("II Chord", SDLK_2)->onpress = EditChordKeyBind;
	slGetKeyBind("III Chord", SDLK_3)->onpress = EditChordKeyBind;
	slGetKeyBind("IV Chord", SDLK_4)->onpress = EditChordKeyBind;
	slGetKeyBind("V Chord", SDLK_5)->onpress = EditChordKeyBind;
	slGetKeyBind("VI Chord", SDLK_6)->onpress = EditChordKeyBind;
	slGetKeyBind("VII Chord", SDLK_7)->onpress = EditChordKeyBind;
	slGetKeyBind("Remove Chord", SDLK_DELETE)->onpress = RemoveChordKeyBind;

	///CreateInstrumentPanel();

	// Loading
	LoadAllInstruments();
	slxEnableFpsCounter(SDLK_F3);
  InsertMeasureAtEnd();

	// Main Loop
	while (!slGetReqt())
	{
	  if (!opGetVisi())
    {
      RepositionNotes();
      RepositionChords();
      UpdateGrabbedNote();
      VolAdjStep();
      slSetSliderValue(ProgressSlider,SongProgress());
    }
    slxRunHooks();
		slCycle();
	}

	// Cleanup
	VolAdjQuit();
	slDestroyBox(PlayToggleButton);
	slDestroyBox(LoopToggleButton);
	opQuit();
	slQuit();
	return 0;
}