forked from 0xtob/nitrotracker
-
Notifications
You must be signed in to change notification settings - Fork 9
(Preliminary) sample cursor (nt) #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
prayerie
wants to merge
7
commits into
NitrousTracker:new
Choose a base branch
from
prayerie:samplecursor-nt
base: new
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5233452
Sample cursor
prayerie 7d5c745
draw fix
prayerie 195a067
Wip sprite stuff
prayerie 4ff0449
WIP loop handles as sprites
prayerie d3c28b1
remove useless debug goto,fix loop handle pos
prayerie ac867e4
Fix buggy loop handle draw on zoom
prayerie ceaad84
a bit of cleanup
prayerie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -450,7 +450,6 @@ void onKeypress(u8 note) | |
|
|
||
| void onKeyrelease(void) | ||
| { | ||
| // stop cursor | ||
| } | ||
|
|
||
| void handleNoteStroke(u8 note) | ||
|
|
@@ -645,7 +644,7 @@ void handleSampleChange(const u16 newsample) | |
| return; | ||
| } | ||
|
|
||
| sampledisplay->setSample(smp); | ||
| sampledisplay->setSample(smp, newsample, lbinstruments->getidx()); | ||
| sampledisplay->hideLoopPoints(); | ||
| nssamplevolume->setValue( (smp->getVolume()+1)/4 ); | ||
| nspanning->setValue(smp->getPanning()/2); | ||
|
|
@@ -657,7 +656,8 @@ void handleSampleChange(const u16 newsample) | |
| else | ||
| rbg_sampleloop->setActive(0); | ||
|
|
||
| updateKeyLabels(); | ||
| if (fxkb->is_visible()) updateKeyLabels(); | ||
|
|
||
| if (!had_changes) setHasUnsavedChanges(false); | ||
| /* | ||
| printf("Selected:"); | ||
|
|
@@ -674,7 +674,6 @@ void handleSampleChange(const u16 newsample) | |
| */ | ||
| } | ||
|
|
||
|
|
||
| void volEnvSetInst(Instrument *inst) | ||
| { | ||
| bool had_unsaved = state->unsaved_changes; | ||
|
|
@@ -748,6 +747,21 @@ void updateTempoAndBpm(void) | |
| nbtempo->setValue(song->getTempo()); | ||
| } | ||
|
|
||
| void cursorTimerHandler(void) | ||
| { | ||
| sampledisplay->calcCursor(); | ||
| } | ||
|
|
||
| void startCursorTimer(void) | ||
| { | ||
| TIMER1_DATA = TIMER_FREQ_64(60); // Call handler every frame | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. per libnds |
||
| TIMER1_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_64; | ||
| irqSet(IRQ_TIMER1, cursorTimerHandler); | ||
| irqEnable(IRQ_TIMER1); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| void setSong(Song *newsong) | ||
| { | ||
| song = newsong; | ||
|
|
@@ -816,7 +830,7 @@ void setSong(Song *newsong) | |
|
|
||
| inst = song->getInstrument(state->instrument); | ||
| if(inst != NULL) { | ||
| sampledisplay->setSample(inst->getSample(state->sample)); | ||
| sampledisplay->setSample(inst->getSample(state->sample), state->sample, state->instrument); | ||
| } | ||
|
|
||
| strncpy(str, song->getName(), sizeof(str)-1); | ||
|
|
@@ -2163,6 +2177,7 @@ void destroyThemeDialog(void) | |
| redrawSubScreen(); | ||
| } | ||
|
|
||
|
|
||
| void reloadSkin(void) | ||
| { | ||
| gui->setTheme(settings->getTheme(), settings->getTheme()->col_bg); | ||
|
|
@@ -2174,6 +2189,7 @@ void reloadSkin(void) | |
| u32 colcol = col | col << 16; | ||
| dmaFillWords(colcol, sub_vram + (256 * y) + 224, (256 - 224) * 2); | ||
| } | ||
|
|
||
| gui->draw(); | ||
| redrawSubScreen(); | ||
| setRecordMode(state->recording); | ||
|
|
@@ -2963,7 +2979,7 @@ void sample_del_selection(void) | |
|
|
||
| DC_FlushAll(); | ||
|
|
||
| sampledisplay->setSample(smp); | ||
| sampledisplay->setSample(smp, state->sample, state->instrument); | ||
| setHasUnsavedChanges(true); | ||
| } | ||
|
|
||
|
|
@@ -2985,7 +3001,7 @@ void sample_fade_in(void) | |
|
|
||
| DC_FlushAll(); | ||
|
|
||
| sampledisplay->setSample(smp); | ||
| sampledisplay->setSample(smp, state->sample, state->instrument); | ||
| setHasUnsavedChanges(true); | ||
| } | ||
|
|
||
|
|
@@ -3007,7 +3023,7 @@ void sample_fade_out(void) | |
|
|
||
| DC_FlushAll(); | ||
|
|
||
| sampledisplay->setSample(smp); | ||
| sampledisplay->setSample(smp, state->sample, state->instrument); | ||
| setHasUnsavedChanges(true); | ||
| } | ||
|
|
||
|
|
@@ -3032,7 +3048,7 @@ void sample_reverse(void) | |
|
|
||
| DC_FlushAll(); | ||
|
|
||
| sampledisplay->setSample(smp); | ||
| sampledisplay->setSample(smp, state->sample, state->instrument); | ||
| setHasUnsavedChanges(true); | ||
| } | ||
|
|
||
|
|
@@ -3367,22 +3383,31 @@ void sampleDrawToggle(bool on) | |
| sampledisplay->setDrawMode(on); | ||
| } | ||
|
|
||
| void handleOverlayWidgetChange(u8 screen, bool visible) | ||
| { | ||
| if (screen == SUB_SCREEN) | ||
| { | ||
| if (visible) oamDisable(&oamSub); | ||
| else oamEnable(&oamSub); | ||
| } | ||
| } | ||
|
|
||
| #define RIGHT_SIDE_BUTTON_WIDTH 30 | ||
| #define RIGHT_SIDE_BUTTON_X 225 | ||
|
|
||
| void setupGUI(bool dldi_enabled) | ||
| { | ||
| gui = new GUI(); | ||
| gui->setTheme(settings->getTheme(), settings->getTheme()->col_bg); | ||
|
|
||
| gui->setOnOverlayChanged(handleOverlayWidgetChange); | ||
| kb = new Piano(0, 152, 224, 40, (uint16*)CHAR_BASE_BLOCK_SUB(0), (uint16*)SCREEN_BASE_BLOCK_SUB(1/*8*/), &sub_vram); | ||
| kb->set_overdraw(false); | ||
| kb->registerNoteCallback(handleNoteStroke); | ||
| kb->registerReleaseCallback(handleNoteRelease); | ||
|
|
||
| fxkb = new FXKeyboard(0, 152, (uint16*)CHAR_BASE_BLOCK_SUB(0), (uint16*)SCREEN_BASE_BLOCK_SUB(1/*8*/), &sub_vram, onFxKeyPressed, false); | ||
| fxkb->set_overdraw(false); | ||
|
|
||
|
|
||
| pixmaplogo = new GradientIcon(98, 1, 80, 17, | ||
| (const u32*) nitrotracker_logo_raw, &sub_vram); | ||
|
|
@@ -4275,6 +4300,9 @@ void VblankHandler(void) | |
| fastscroll = false; | ||
| } | ||
|
|
||
| oamUpdate(&oamSub); | ||
|
|
||
|
|
||
| // Easy Piano pak handling logic | ||
| if (pianoIsInserted()) | ||
| { | ||
|
|
@@ -4428,10 +4456,11 @@ int main(int argc, char **argv) { | |
| videoSetMode(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG2_ACTIVE); | ||
|
|
||
| // Sub screen: Keyboard tiles, Typewriter tiles and ERB | ||
| videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE | DISPLAY_BG2_ACTIVE); | ||
| videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE | DISPLAY_BG2_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D); | ||
|
|
||
| vramSetPrimaryBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, | ||
| VRAM_C_SUB_BG_0x06200000 , VRAM_D_LCD); | ||
| VRAM_C_SUB_BG_0x06200000 , VRAM_D_SUB_SPRITE); | ||
|
|
||
|
|
||
| // SUB_BG0 for Piano Tiles | ||
| videoBgEnableSub(0); | ||
|
|
@@ -4460,6 +4489,20 @@ int main(int argc, char **argv) { | |
| int sub_bg = bgInitSub(2, BgType_Bmp16, BgSize_B16_256x256, 2, 0); | ||
| bgSetPriority(sub_bg, 0); | ||
|
|
||
| // Sample display cursors and loop handles | ||
| oamInit(&oamSub, SpriteMapping_1D_32, false); | ||
|
|
||
| windowEnableSub(WINDOW_0); | ||
|
|
||
| bgWindowEnable(sub_bg, (WINDOW)(WINDOW_0|WINDOW_OUT)); | ||
| bgWindowEnable(piano_bg, (WINDOW)(WINDOW_0|WINDOW_OUT)); | ||
| bgWindowEnable(typewriter_bg, (WINDOW)(WINDOW_0|WINDOW_OUT)); | ||
|
|
||
| windowSetBoundsSub(WINDOW_0, 5, 24, 5+129, 23+61); // sampledisplay x1,y1,x2,y2 | ||
| oamWindowEnable(&oamSub, WINDOW_0); | ||
|
|
||
|
|
||
|
|
||
| // Special effects | ||
| #ifdef DEBUG | ||
| REG_BLDCNT = BLEND_ALPHA | BLEND_SRC_BG0 | BLEND_DST_BG2; | ||
|
|
@@ -4530,9 +4573,18 @@ int main(int argc, char **argv) { | |
| CommandSetSong(song); | ||
|
|
||
| setupGUI(fat_success); | ||
|
|
||
| startCursorTimer(); | ||
| SampleCursor *scursors = (SampleCursor*)ntxm_ccalloc(MAX_CHANNELS, sizeof(SampleCursor)); | ||
| CommandSetCursorPosPtr(scursors); | ||
| sampledisplay->setCursorPosPtr((SampleCursor*)memUncached(scursors)); | ||
|
|
||
| action_buffer->register_change_callback({&actionBufferChangeCallback}); | ||
|
|
||
| applySettings(); | ||
|
|
||
|
|
||
|
|
||
| setSong(song); | ||
|
|
||
| #ifndef DEBUG | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admittedly not much better than just doing this in vblank, although this results in less drift anyway. i tried calculating using ticks but couldn't get it as accurate