got initial impl of stack to save positions working

This commit is contained in:
Narayan
2025-08-19 13:47:03 -07:00
parent 576d320fb7
commit 28e3275bdc

View File

@@ -325,6 +325,13 @@ int main(int argc, char **argv)
playbackInfo.errInfo = &errInfo; playbackInfo.errInfo = &errInfo;
/* position of parent folder in parent directory */
int prevPosition[MAX_DIRECTORIES] = {0};
int prevFrom[MAX_DIRECTORIES] = {0};
/* ensure that all entries are 0 because it must be */
memset(prevPosition, 0, MAX_DIRECTORIES);
memset(prevFrom, 0, MAX_DIRECTORIES);
chdir(DEFAULT_DIR); chdir(DEFAULT_DIR);
chdir("MUSIC"); chdir("MUSIC");
@@ -507,8 +514,15 @@ int main(int argc, char **argv)
consoleClear(); consoleClear();
fileMax = getDir(&dirList); fileMax = getDir(&dirList);
fileNum = 0; fileNum = prevPosition[0];
from = 0; from = prevFrom[0];
for (int i=0; i<MAX_DIRECTORIES-1; i++) {
prevPosition[i] = prevPosition[i+1];
prevFrom[i] = prevFrom[i+1];
}
/* default to first entry */
prevPosition[MAX_DIRECTORIES-1] = 0;
prevFrom[MAX_DIRECTORIES-1] = 0;
if(listDir(from, MAX_LIST, fileNum, dirList) < 0) if(listDir(from, MAX_LIST, fileNum, dirList) < 0)
err_print("Unable to list directory."); err_print("Unable to list directory.");
@@ -523,11 +537,28 @@ int main(int argc, char **argv)
chdir(dirList.directories[fileNum - 1]); chdir(dirList.directories[fileNum - 1]);
consoleClear(); consoleClear();
fileMax = getDir(&dirList); fileMax = getDir(&dirList);
int oldFileNum, oldFrom;
oldFileNum = fileNum;
oldFrom = from;
fileNum = 0; fileNum = 0;
from = 0; from = 0;
if(listDir(from, MAX_LIST, fileNum, dirList) < 0) if(listDir(from, MAX_LIST, fileNum, dirList) < 0)
{
err_print("Unable to list directory."); err_print("Unable to list directory.");
}
else
{
/* save old position in folder */
for (int i=MAX_DIRECTORIES-1; i>0; i--) {
prevPosition[i] = prevPosition[i-1];
prevFrom[i] = prevFrom[i-1];
}
prevPosition[0] = oldFileNum;
prevFrom[0] = oldFrom;
}
continue; continue;
} }
@@ -594,6 +625,13 @@ int main(int argc, char **argv)
continue; continue;
} }
if (kDown || kHeld) {
PrintConsole* prev = consoleSelect(&topScreenLog);
printf("filenum: %d, from: %d\n", fileNum, from);
consoleSelect(prev);
}
/* After 1000ms, update playback time. */ /* After 1000ms, update playback time. */
while(osGetTime() - mill > 1000) while(osGetTime() - mill > 1000)
{ {