Merge branch 'master' into force-critical-input-trickle

This commit is contained in:
tildearrow 2023-07-27 00:39:29 -05:00
commit 1fa92c63d0
223 changed files with 4576 additions and 1572 deletions

View file

@ -800,138 +800,138 @@ namespace IGFD
// will be called internally
// will not been exposed to IGFD API
bool IGFD::FilterManager::prFillFileStyle(std::shared_ptr<FileInfos> vFileInfos) const
bool IGFD::FilterManager::prFillFileStyle(FileInfos& vFileInfos) const
{
if (vFileInfos.use_count() && !prFilesStyle.empty())
if (!prFilesStyle.empty())
{
for (const auto& _flag : prFilesStyle)
{
for (const auto& _file : _flag.second)
{
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos->fileType == 'd')
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos.fileType == 'd')
{
if (_file.first.empty()) // for all dirs
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
else if (_file.first == vFileInfos->fileNameExt) // for dirs who are equal to style criteria
else if (_file.first == vFileInfos.fileNameExt) // for dirs who are equal to style criteria
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos->fileType == 'f')
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos.fileType == 'f')
{
if (_file.first.empty()) // for all files
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
else if (_file.first == vFileInfos->fileNameExt) // for files who are equal to style criteria
else if (_file.first == vFileInfos.fileNameExt) // for files who are equal to style criteria
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos->fileType == 'l')
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos.fileType == 'l')
{
if (_file.first.empty()) // for all links
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
else if (_file.first == vFileInfos->fileNameExt) // for links who are equal to style criteria
else if (_file.first == vFileInfos.fileNameExt) // for links who are equal to style criteria
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
if (_flag.first & IGFD_FileStyleByExtention)
{
if (_file.first == vFileInfos->fileExt)
if (_file.first == vFileInfos.fileExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
// can make sense for some dirs like the hidden by ex ".git"
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos->fileType == 'd')
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos.fileType == 'd')
{
if (_file.first == vFileInfos->fileExt)
if (_file.first == vFileInfos.fileExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos->fileType == 'f')
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos.fileType == 'f')
{
if (_file.first == vFileInfos->fileExt)
if (_file.first == vFileInfos.fileExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos->fileType == 'l')
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos.fileType == 'l')
{
if (_file.first == vFileInfos->fileExt)
if (_file.first == vFileInfos.fileExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
}
if (_flag.first & IGFD_FileStyleByFullName)
{
if (_file.first == vFileInfos->fileNameExt)
if (_file.first == vFileInfos.fileNameExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos->fileType == 'd')
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos.fileType == 'd')
{
if (_file.first == vFileInfos->fileNameExt)
if (_file.first == vFileInfos.fileNameExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos->fileType == 'f')
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos.fileType == 'f')
{
if (_file.first == vFileInfos->fileNameExt)
if (_file.first == vFileInfos.fileNameExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos->fileType == 'l')
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos.fileType == 'l')
{
if (_file.first == vFileInfos->fileNameExt)
if (_file.first == vFileInfos.fileNameExt)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
}
if (_flag.first & IGFD_FileStyleByContainedInFullName)
{
if (vFileInfos->fileNameExt.find(_file.first) != std::string::npos)
if (vFileInfos.fileNameExt.find(_file.first) != std::string::npos)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos->fileType == 'd')
if (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos.fileType == 'd')
{
if (vFileInfos->fileNameExt.find(_file.first) != std::string::npos)
if (vFileInfos.fileNameExt.find(_file.first) != std::string::npos)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos->fileType == 'f')
else if (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos.fileType == 'f')
{
if (vFileInfos->fileNameExt.find(_file.first) != std::string::npos)
if (vFileInfos.fileNameExt.find(_file.first) != std::string::npos)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos->fileType == 'l')
else if (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos.fileType == 'l')
{
if (vFileInfos->fileNameExt.find(_file.first) != std::string::npos)
if (vFileInfos.fileNameExt.find(_file.first) != std::string::npos)
{
vFileInfos->fileStyle = _file.second;
vFileInfos.fileStyle = _file.second;
}
}
}
if (vFileInfos->fileStyle.use_count())
if (vFileInfos.fileStyle.use_count())
return true;
}
}
@ -1142,6 +1142,7 @@ namespace IGFD
for (int i=1; i<4; i++) {
puSortingDirection[i]=false;
}
invalidFile.isValid=false;
}
void IGFD::FileManager::OpenCurrentPath(const FileDialogInternal& vFileDialogInternal)
@ -1191,29 +1192,24 @@ namespace IGFD
puHeaderFileName = tableHeaderDescendingIcon + puHeaderFileName;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (a==NULL || b==NULL)
return false;
if (!a.use_count() || !b.use_count())
return false;
// this code fail in c:\\Users with the link "All users". got a invalid comparator
/*
// use code from https://github.com/jackm97/ImGuiFileDialog/commit/bf40515f5a1de3043e60562dc1a494ee7ecd3571
// strict ordering for file/directory types beginning in '.'
// common on Linux platforms
if (a->fileNameExt[0] == '.' && b->fileNameExt[0] != '.')
if (a.fileNameExt[0] == '.' && b.fileNameExt[0] != '.')
return false;
if (a->fileNameExt[0] != '.' && b->fileNameExt[0] == '.')
if (a.fileNameExt[0] != '.' && b.fileNameExt[0] == '.')
return true;
if (a->fileNameExt[0] == '.' && b->fileNameExt[0] == '.')
if (a.fileNameExt[0] == '.' && b.fileNameExt[0] == '.')
{
return (stricmp(a->fileNameExt.c_str(), b->fileNameExt.c_str()) < 0); // sort in insensitive case
return (stricmp(a.fileNameExt.c_str(), b.fileNameExt.c_str()) < 0); // sort in insensitive case
}
*/
if (a->fileType != b->fileType) return (a->fileType == 'd'); // directory in first
return (stricmp(a->fileNameExt.c_str(), b->fileNameExt.c_str()) < 0); // sort in insensitive case
if (a.fileType != b.fileType) return (a.fileType == 'd'); // directory in first
return (stricmp(a.fileNameExt.c_str(), b.fileNameExt.c_str()) < 0); // sort in insensitive case
});
}
else
@ -1222,28 +1218,23 @@ namespace IGFD
puHeaderFileName = tableHeaderAscendingIcon + puHeaderFileName;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (a==NULL || b==NULL)
return false;
if (!a.use_count() || !b.use_count())
return false;
// this code fail in c:\\Users with the link "All users". got a invalid comparator
/*
// use code from https://github.com/jackm97/ImGuiFileDialog/commit/bf40515f5a1de3043e60562dc1a494ee7ecd3571
// strict ordering for file/directory types beginning in '.'
// common on Linux platforms
if (a->fileNameExt[0] == '.' && b->fileNameExt[0] != '.')
if (a.fileNameExt[0] == '.' && b.fileNameExt[0] != '.')
return false;
if (a->fileNameExt[0] != '.' && b->fileNameExt[0] == '.')
if (a.fileNameExt[0] != '.' && b.fileNameExt[0] == '.')
return true;
if (a->fileNameExt[0] == '.' && b->fileNameExt[0] == '.')
if (a.fileNameExt[0] == '.' && b.fileNameExt[0] == '.')
{
return (stricmp(a->fileNameExt.c_str(), b->fileNameExt.c_str()) > 0); // sort in insensitive case
return (stricmp(a.fileNameExt.c_str(), b.fileNameExt.c_str()) > 0); // sort in insensitive case
}
*/
return (stricmp(a->fileNameExt.c_str(), b->fileNameExt.c_str()) > 0); // sort in insensitive case
return (stricmp(a.fileNameExt.c_str(), b.fileNameExt.c_str()) > 0); // sort in insensitive case
});
}
}
@ -1259,13 +1250,10 @@ namespace IGFD
puHeaderFileType = tableHeaderDescendingIcon + puHeaderFileType;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType == 'd'); // directory in first
return (a->fileExt < b->fileExt); // else
if (a.fileType != b.fileType) return (a.fileType == 'd'); // directory in first
return (a.fileExt < b.fileExt); // else
});
}
else
@ -1274,15 +1262,10 @@ namespace IGFD
puHeaderFileType = tableHeaderAscendingIcon + puHeaderFileType;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (a==NULL || b==NULL)
return false;
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType != 'd'); // directory in last
return (a->fileExt > b->fileExt); // else
if (a.fileType != b.fileType) return (a.fileType != 'd'); // directory in last
return (a.fileExt > b.fileExt); // else
});
}
}
@ -1298,15 +1281,10 @@ namespace IGFD
puHeaderFileSize = tableHeaderDescendingIcon + puHeaderFileSize;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (a==NULL || b==NULL)
return false;
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType == 'd'); // directory in first
return (a->fileSize < b->fileSize); // else
if (a.fileType != b.fileType) return (a.fileType == 'd'); // directory in first
return (a.fileSize < b.fileSize); // else
});
}
else
@ -1315,15 +1293,10 @@ namespace IGFD
puHeaderFileSize = tableHeaderAscendingIcon + puHeaderFileSize;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (a==NULL || b==NULL)
return false;
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType != 'd'); // directory in last
return (a->fileSize > b->fileSize); // else
if (a.fileType != b.fileType) return (a.fileType != 'd'); // directory in last
return (a.fileSize > b.fileSize); // else
});
}
}
@ -1339,15 +1312,10 @@ namespace IGFD
puHeaderFileDate = tableHeaderDescendingIcon + puHeaderFileDate;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (a==NULL || b==NULL)
return false;
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType == 'd'); // directory in first
return (a->fileModifDate < b->fileModifDate); // else
if (a.fileType != b.fileType) return (a.fileType == 'd'); // directory in first
return (a.fileModifDate < b.fileModifDate); // else
});
}
else
@ -1356,15 +1324,10 @@ namespace IGFD
puHeaderFileDate = tableHeaderAscendingIcon + puHeaderFileDate;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (a==NULL || b==NULL)
return false;
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType != 'd'); // directory in last
return (a->fileModifDate > b->fileModifDate); // else
if (a.fileType != b.fileType) return (a.fileType != 'd'); // directory in last
return (a.fileModifDate > b.fileModifDate); // else
});
}
}
@ -1384,15 +1347,12 @@ namespace IGFD
puHeaderFileThumbnails = tableHeaderDescendingIcon + puHeaderFileThumbnails;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType == 'd'); // directory in first
if (a->thumbnailInfo.textureWidth == b->thumbnailInfo.textureWidth)
return (a->thumbnailInfo.textureHeight < b->thumbnailInfo.textureHeight);
return (a->thumbnailInfo.textureWidth < b->thumbnailInfo.textureWidth);
if (a.fileType != b.fileType) return (a.fileType == 'd'); // directory in first
if (a.thumbnailInfo.textureWidth == b.thumbnailInfo.textureWidth)
return (a.thumbnailInfo.textureHeight < b.thumbnailInfo.textureHeight);
return (a.thumbnailInfo.textureWidth < b.thumbnailInfo.textureWidth);
});
}
@ -1402,15 +1362,12 @@ namespace IGFD
puHeaderFileThumbnails = tableHeaderAscendingIcon + puHeaderFileThumbnails;
#endif // USE_CUSTOM_SORTING_ICON
std::sort(prFileList.begin(), prFileList.end(),
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
[](const FileInfos& a, const FileInfos& b) -> bool
{
if (!a.use_count() || !b.use_count())
return false;
if (a->fileType != b->fileType) return (a->fileType != 'd'); // directory in last
if (a->thumbnailInfo.textureWidth == b->thumbnailInfo.textureWidth)
return (a->thumbnailInfo.textureHeight > b->thumbnailInfo.textureHeight);
return (a->thumbnailInfo.textureWidth > b->thumbnailInfo.textureWidth);
if (a.fileType != b.fileType) return (a.fileType != 'd'); // directory in last
if (a.thumbnailInfo.textureWidth == b.thumbnailInfo.textureWidth)
return (a.thumbnailInfo.textureHeight > b.thumbnailInfo.textureHeight);
return (a.thumbnailInfo.textureWidth > b.thumbnailInfo.textureWidth);
});
}
}
@ -1441,38 +1398,38 @@ namespace IGFD
return fileNameExt;
}
void IGFD::FileManager::AddFile(const FileDialogInternal& vFileDialogInternal, const std::string& vPath, const std::string& vFileName, const char& vFileType, void* ent)
void IGFD::FileManager::AddFile(const FileDialogInternal& vFileDialogInternal, const std::string& vPath, const std::string& vFileName, char vFileType, void* ent)
{
auto infos = std::make_shared<FileInfos>();
FileInfos infos;
#ifdef _WIN32
struct dirent* dent=(struct dirent*)ent;
#endif
infos->filePath = vPath;
infos->fileNameExt = vFileName;
infos->fileNameExt_optimized = prOptimizeFilenameForSearchOperations(infos->fileNameExt);
infos->fileType = vFileType;
infos.filePath = vPath;
infos.fileNameExt = vFileName;
infos.fileNameExt_optimized = prOptimizeFilenameForSearchOperations(infos.fileNameExt);
infos.fileType = vFileType;
if (infos->fileNameExt.empty() || ((infos->fileNameExt == "." || infos->fileNameExt == "..") && !vFileDialogInternal.puFilterManager.puDLGFilters.empty())) return; // filename empty or filename is the current dir '.' //-V807
if (infos->fileNameExt != ".." && (vFileDialogInternal.puDLGflags & ImGuiFileDialogFlags_DontShowHiddenFiles) && infos->fileNameExt[0] == '.') // dont show hidden files
if (!vFileDialogInternal.puFilterManager.puDLGFilters.empty() || (vFileDialogInternal.puFilterManager.puDLGFilters.empty() && infos->fileNameExt != ".")) // except "." if in directory mode //-V728
if (infos.fileNameExt.empty() || ((infos.fileNameExt == "." || infos.fileNameExt == "..") && !vFileDialogInternal.puFilterManager.puDLGFilters.empty())) return; // filename empty or filename is the current dir '.' //-V807
if (infos.fileNameExt != ".." && (vFileDialogInternal.puDLGflags & ImGuiFileDialogFlags_DontShowHiddenFiles) && infos.fileNameExt[0] == '.') // dont show hidden files
if (!vFileDialogInternal.puFilterManager.puDLGFilters.empty() || (vFileDialogInternal.puFilterManager.puDLGFilters.empty() && infos.fileNameExt != ".")) // except "." if in directory mode //-V728
return;
if (infos->fileType == 'f' ||
infos->fileType == 'l') // link can have the same extention of a file
if (infos.fileType == 'f' ||
infos.fileType == 'l') // link can have the same extention of a file
{
size_t lpt = infos->fileNameExt.find_last_of('.');
size_t lpt = infos.fileNameExt.find_last_of('.');
if (lpt != std::string::npos)
{
infos->fileExt = infos->fileNameExt.substr(lpt);
infos.fileExt = infos.fileNameExt.substr(lpt);
}
for (char& i: infos->fileExt) {
for (char& i: infos.fileExt) {
if (i>='A' && i<='Z') i+='a'-'A';
}
if (!vFileDialogInternal.puFilterManager.IsCoveredByFilters(infos->fileExt))
if (!vFileDialogInternal.puFilterManager.IsCoveredByFilters(infos.fileExt))
{
return;
}
@ -1483,16 +1440,16 @@ namespace IGFD
SYSTEMTIME localTime;
char timebuf[100];
infos->fileSize=dent->dwin_size;
if (FileTimeToSystemTime(&dent->dwin_mtime,&systemTime)==TRUE) {
infos.fileSize=dent.dwin_size;
if (FileTimeToSystemTime(&dent.dwin_mtime,&systemTime)==TRUE) {
if (SystemTimeToTzSpecificLocalTime(NULL,&systemTime,&localTime)==TRUE) {
snprintf(timebuf,99,"%d/%.2d/%.2d %.2d:%.2d",localTime.wYear,localTime.wMonth,localTime.wDay,localTime.wHour,localTime.wMinute);
} else {
snprintf(timebuf,99,"%d/%.2d/%.2d %.2d:%.2d",systemTime.wYear,systemTime.wMonth,systemTime.wDay,systemTime.wHour,systemTime.wMinute);
}
infos->fileModifDate=timebuf;
infos.fileModifDate=timebuf;
} else {
infos->fileModifDate="???";
infos.fileModifDate="???";
}
#endif
@ -1534,7 +1491,7 @@ namespace IGFD
{
struct dirent* ent = files[i];
std::string where = path + std::string(PATH_SEP_STR) + std::string(ent->d_name);
char fileType = 0;
char fileType = 'f';
#if defined(HAVE_DIRENT_TYPE) || defined(_WIN32)
if (ent->d_type != DT_UNKNOWN)
{
@ -1544,7 +1501,7 @@ namespace IGFD
fileType = 'f'; break;
case DT_DIR:
fileType = 'd'; break;
case DT_LNK:
case DT_LNK: {
#ifdef _WIN32
fileType = 'f';
#else
@ -1557,7 +1514,8 @@ namespace IGFD
}
else
{
fileType = 'l';
// why does 'l' make it crash?
fileType = 'f';
}
}
else
@ -1568,6 +1526,9 @@ namespace IGFD
#endif
break;
}
default:
fileType = 'f'; break;
}
}
else
#endif // HAVE_DIRENT_TYPE
@ -1622,12 +1583,12 @@ namespace IGFD
ClearFileLists();
for (auto& drive : drives)
{
auto info = std::make_shared<FileInfos>();
info->fileNameExt = drive;
info->fileNameExt_optimized = prOptimizeFilenameForSearchOperations(drive);
info->fileType = 'd';
FileInfos info;
info.fileNameExt = drive;
info.fileNameExt_optimized = prOptimizeFilenameForSearchOperations(drive);
info.fileType = 'd';
if (!info->fileNameExt.empty())
if (!info.fileNameExt.empty())
{
prFileList.push_back(info);
}
@ -1658,11 +1619,11 @@ namespace IGFD
return prFileList.size();
}
std::shared_ptr<FileInfos> IGFD::FileManager::GetFullFileAt(size_t vIdx)
const FileInfos& IGFD::FileManager::GetFullFileAt(size_t vIdx)
{
if (vIdx < prFileList.size())
return prFileList[vIdx];
return nullptr;
return invalidFile;
}
bool IGFD::FileManager::IsFilteredListEmpty()
@ -1675,11 +1636,11 @@ namespace IGFD
return prFilteredFileList.size();
}
std::shared_ptr<FileInfos> IGFD::FileManager::GetFilteredFileAt(size_t vIdx)
const FileInfos& IGFD::FileManager::GetFilteredFileAt(size_t vIdx)
{
if (vIdx < prFilteredFileList.size())
return prFilteredFileList[vIdx];
return nullptr;
return invalidFile;
}
bool IGFD::FileManager::IsFileNameSelected(const std::string& vFileName)
@ -1706,14 +1667,12 @@ namespace IGFD
void IGFD::FileManager::ApplyFilteringOnFileList(const FileDialogInternal& vFileDialogInternal)
{
prFilteredFileList.clear();
for (const auto& file : prFileList)
for (const FileInfos& file : prFileList)
{
if (!file.use_count())
continue;
bool show = true;
if (!file->IsTagFound(vFileDialogInternal.puSearchManager.puSearchTag)) // if search tag
if (!file.IsTagFound(vFileDialogInternal.puSearchManager.puSearchTag)) // if search tag
show = false;
if (puDLGDirectoryMode && file->fileType != 'd') // directory mode
if (puDLGDirectoryMode && file.fileType != 'd') // directory mode
show = false;
if (show)
prFilteredFileList.push_back(file);
@ -1750,13 +1709,10 @@ namespace IGFD
return "";
}
void IGFD::FileManager::prCompleteFileInfos(const std::shared_ptr<FileInfos>& vInfos)
void IGFD::FileManager::prCompleteFileInfos(FileInfos& vInfos)
{
if (!vInfos.use_count())
return;
if (vInfos->fileNameExt != "." &&
vInfos->fileNameExt != "..")
if (vInfos.fileNameExt != "." &&
vInfos.fileNameExt != "..")
{
// _stat struct :
//dev_t st_dev; /* ID of device containing file */
@ -1781,18 +1737,18 @@ namespace IGFD
#else
std::string fpn;
if (vInfos->fileType == 'f' || vInfos->fileType == 'l' || vInfos->fileType == 'd') // file
fpn = vInfos->filePath + std::string(1u, PATH_SEP) + vInfos->fileNameExt;
if (vInfos.fileType == 'f' || vInfos.fileType == 'l' || vInfos.fileType == 'd') // file
fpn = vInfos.filePath + std::string(1u, PATH_SEP) + vInfos.fileNameExt;
struct stat statInfos = {};
char timebuf[100];
int result = stat(fpn.c_str(), &statInfos);
if (result!=-1)
{
if (vInfos->fileType != 'd')
if (vInfos.fileType != 'd')
{
vInfos->fileSize = (size_t)statInfos.st_size;
vInfos->formatedFileSize = prFormatFileSize(vInfos->fileSize);
vInfos.fileSize = (size_t)statInfos.st_size;
vInfos.formatedFileSize = prFormatFileSize(vInfos.fileSize);
}
size_t len = 0;
@ -1806,12 +1762,12 @@ namespace IGFD
#endif // MSVC
if (len)
{
vInfos->fileModifDate = std::string(timebuf, len);
vInfos.fileModifDate = std::string(timebuf, len);
}
} else {
vInfos->fileSize=0;
vInfos->formatedFileSize = prFormatFileSize(vInfos->fileSize);
vInfos->fileModifDate="???";
vInfos.fileSize=0;
vInfos.formatedFileSize = prFormatFileSize(vInfos.fileSize);
vInfos.fileModifDate="???";
}
#endif
}
@ -1994,14 +1950,11 @@ namespace IGFD
IGFD::Utils::SetBuffer(puFileNameBuffer, MAX_FILE_DIALOG_NAME_BUFFER, vFileName);
}
bool IGFD::FileManager::SelectDirectory(const std::shared_ptr<FileInfos>& vInfos)
bool IGFD::FileManager::SelectDirectory(const FileInfos& vInfos)
{
if (!vInfos.use_count())
return false;
bool pathClick = false;
if (vInfos->fileNameExt == "..")
if (vInfos.fileNameExt == "..")
{
pathClick = SetPathOnParentDirectoryIfAny();
}
@ -2011,23 +1964,23 @@ namespace IGFD
if (puShowDrives)
{
newPath = vInfos->fileNameExt + std::string(1u, PATH_SEP);
newPath = vInfos.fileNameExt + std::string(1u, PATH_SEP);
}
else
{
#ifdef __linux__
if (puFsRoot == prCurrentPath)
newPath = prCurrentPath + vInfos->fileNameExt;
newPath = prCurrentPath + vInfos.fileNameExt;
else
#endif // __linux__
newPath = prCurrentPath + std::string(1u, PATH_SEP) + vInfos->fileNameExt;
newPath = prCurrentPath + std::string(1u, PATH_SEP) + vInfos.fileNameExt;
}
if (IGFD::Utils::IsDirectoryExist(newPath))
{
if (puShowDrives)
{
prCurrentPath = vInfos->fileNameExt;
prCurrentPath = vInfos.fileNameExt;
puFsRoot = prCurrentPath;
}
else
@ -2041,35 +1994,32 @@ namespace IGFD
return pathClick;
}
void IGFD::FileManager::SelectFileName(const FileDialogInternal& vFileDialogInternal, const std::shared_ptr<FileInfos>& vInfos)
void IGFD::FileManager::SelectFileName(const FileDialogInternal& vFileDialogInternal, const FileInfos& vInfos)
{
if (!vInfos.use_count())
return;
if (ImGui::GetIO().KeyCtrl)
{
if (puDLGcountSelectionMax == 0) // infinite selection
{
if (prSelectedFileNames.find(vInfos->fileNameExt) == prSelectedFileNames.end()) // not found +> add
if (prSelectedFileNames.find(vInfos.fileNameExt) == prSelectedFileNames.end()) // not found +> add
{
prAddFileNameInSelection(vInfos->fileNameExt, true);
prAddFileNameInSelection(vInfos.fileNameExt, true);
}
else // found +> remove
{
prRemoveFileNameInSelection(vInfos->fileNameExt);
prRemoveFileNameInSelection(vInfos.fileNameExt);
}
}
else // selection limited by size
{
if (prSelectedFileNames.size() < puDLGcountSelectionMax)
{
if (prSelectedFileNames.find(vInfos->fileNameExt) == prSelectedFileNames.end()) // not found +> add
if (prSelectedFileNames.find(vInfos.fileNameExt) == prSelectedFileNames.end()) // not found +> add
{
prAddFileNameInSelection(vInfos->fileNameExt, true);
prAddFileNameInSelection(vInfos.fileNameExt, true);
}
else // found +> remove
{
prRemoveFileNameInSelection(vInfos->fileNameExt);
prRemoveFileNameInSelection(vInfos.fileNameExt);
}
}
}
@ -2081,18 +2031,15 @@ namespace IGFD
prSelectedFileNames.clear();
// we will iterate filelist and get the last selection after the start selection
bool startMultiSelection = false;
std::string fileNameToSelect = vInfos->fileNameExt;
std::string fileNameToSelect = vInfos.fileNameExt;
std::string savedLastSelectedFileName; // for invert selection mode
for (const auto& file : prFileList)
for (const FileInfos& file : prFileList)
{
if (!file.use_count())
continue;
bool canTake = true;
if (!file->IsTagFound(vFileDialogInternal.puSearchManager.puSearchTag)) canTake = false;
if (!file.IsTagFound(vFileDialogInternal.puSearchManager.puSearchTag)) canTake = false;
if (canTake) // if not filtered, we will take files who are filtered by the dialog
{
if (file->fileNameExt == prLastSelectedFileName)
if (file.fileNameExt == prLastSelectedFileName)
{
startMultiSelection = true;
prAddFileNameInSelection(prLastSelectedFileName, false);
@ -2101,13 +2048,13 @@ namespace IGFD
{
if (puDLGcountSelectionMax == 0) // infinite selection
{
prAddFileNameInSelection(file->fileNameExt, false);
prAddFileNameInSelection(file.fileNameExt, false);
}
else // selection limited by size
{
if (prSelectedFileNames.size() < puDLGcountSelectionMax)
{
prAddFileNameInSelection(file->fileNameExt, false);
prAddFileNameInSelection(file.fileNameExt, false);
}
else
{
@ -2119,7 +2066,7 @@ namespace IGFD
}
}
if (file->fileNameExt == fileNameToSelect)
if (file.fileNameExt == fileNameToSelect)
{
if (!startMultiSelection) // we are before the last Selected FileName, so we must inverse
{
@ -2145,7 +2092,7 @@ namespace IGFD
{
prSelectedFileNames.clear();
IGFD::Utils::ResetBuffer(puFileNameBuffer);
prAddFileNameInSelection(vInfos->fileNameExt, true);
prAddFileNameInSelection(vInfos.fileNameExt, true);
}
}
@ -3922,11 +3869,8 @@ namespace IGFD
}
// returns 0 if not break loop, 1 if break loop, 2 if exit dialog
int IGFD::FileDialog::prSelectableItem(int vidx, std::shared_ptr<FileInfos> vInfos, bool vSelected, const char* vFmt, ...)
int IGFD::FileDialog::prSelectableItem(int vidx, const FileInfos& vInfos, bool vSelected, const char* vFmt, ...)
{
if (!vInfos.use_count())
return 0;
auto& fdi = prFileDialogInternal.puFileManager;
static ImGuiSelectableFlags selectableFlags = ImGuiSelectableFlags_AllowDoubleClick |
@ -3957,7 +3901,7 @@ namespace IGFD
#endif // USE_EXPLORATION_BY_KEYS
if (res)
{
if (vInfos->fileType == 'd')
if (vInfos.fileType == 'd')
{
bool isSelectingDir=false;
// nav system, selectebale cause open directory or select directory
@ -4012,27 +3956,27 @@ namespace IGFD
return 0;
}
void IGFD::FileDialog::prBeginFileColorIconStyle(std::shared_ptr<FileInfos> vFileInfos, bool& vOutShowColor, std::string& vOutStr, ImFont** vOutFont)
void IGFD::FileDialog::prBeginFileColorIconStyle(const FileInfos& vFileInfos, bool& vOutShowColor, std::string& vOutStr, ImFont** vOutFont)
{
vOutStr.clear();
vOutShowColor = false;
if (vFileInfos->fileStyle.use_count()) //-V807 //-V522
if (vFileInfos.fileStyle.use_count()) //-V807 //-V522
{
vOutShowColor = true;
*vOutFont = vFileInfos->fileStyle->font;
*vOutFont = vFileInfos.fileStyle->font;
}
if (vOutShowColor && !vFileInfos->fileStyle->icon.empty()) vOutStr = vFileInfos->fileStyle->icon;
else if (vFileInfos->fileType == 'd') vOutStr = dirEntryString;
else if (vFileInfos->fileType == 'l') vOutStr = linkEntryString;
else if (vFileInfos->fileType == 'f') vOutStr = fileEntryString;
if (vOutShowColor && !vFileInfos.fileStyle->icon.empty()) vOutStr = vFileInfos.fileStyle->icon;
else if (vFileInfos.fileType == 'd') vOutStr = dirEntryString;
else if (vFileInfos.fileType == 'l') vOutStr = linkEntryString;
else if (vFileInfos.fileType == 'f') vOutStr = fileEntryString;
vOutStr += " " + vFileInfos->fileNameExt;
vOutStr += " " + vFileInfos.fileNameExt;
if (vOutShowColor)
ImGui::PushStyleColor(ImGuiCol_Text, vFileInfos->fileStyle->color);
ImGui::PushStyleColor(ImGuiCol_Text, vFileInfos.fileStyle->color);
if (*vOutFont)
ImGui::PushFont(*vOutFont);
}
@ -4126,13 +4070,13 @@ namespace IGFD
{
if (i < 0) continue;
auto infos = fdi.GetFilteredFileAt((size_t)i);
if (!infos.use_count())
const FileInfos& infos = fdi.GetFilteredFileAt((size_t)i);
if (!infos.isValid)
continue;
prBeginFileColorIconStyle(infos, _showColor, _str, &_font);
bool selected = fdi.IsFileNameSelected(infos->fileNameExt); // found
bool selected = fdi.IsFileNameSelected(infos.fileNameExt); // found
ImGui::TableNextRow();
@ -4147,13 +4091,13 @@ namespace IGFD
}
if (ImGui::TableNextColumn()) // file type
{
ImGui::Text("%s", infos->fileExt.c_str());
ImGui::Text("%s", infos.fileExt.c_str());
}
if (ImGui::TableNextColumn()) // file size
{
if (infos->fileType != 'd')
if (infos.fileType != 'd')
{
ImGui::Text("%s ", infos->formatedFileSize.c_str());
ImGui::Text("%s ", infos.formatedFileSize.c_str());
}
else
{
@ -4162,7 +4106,7 @@ namespace IGFD
}
if (ImGui::TableNextColumn()) // file date + time
{
ImGui::Text("%s", infos->fileModifDate.c_str());
ImGui::Text("%s", infos.fileModifDate.c_str());
}
prEndFileColorIconStyle(_showColor, _font);

View file

@ -766,7 +766,7 @@ namespace IGFD
void ParseFilters(const char* vFilters); // Parse filter syntax, detect and parse filter collection
void SetSelectedFilterWithExt(const std::string& vFilter); // Select filter
bool prFillFileStyle(std::shared_ptr<FileInfos> vFileInfos) const; // fill with the good style
bool prFillFileStyle(FileInfos& vFileInfos) const; // fill with the good style
void SetFileStyle(
const IGFD_FileStyleFlags& vFlags,
@ -812,6 +812,7 @@ namespace IGFD
#ifdef USE_THUMBNAILS
IGFD_Thumbnail_Info thumbnailInfo; // structre for the display for image file tetxure
#endif // USE_THUMBNAILS
bool isValid = true;
public:
bool IsTagFound(const std::string& vTag) const;
@ -824,6 +825,7 @@ namespace IGFD
class FileManager
{
public: // types
FileInfos invalidFile;
enum class SortingFieldEnum // sorting for filetering of the file lsit
{
FIELD_NONE = 0, // no sorting preference, result indetermined haha..
@ -839,8 +841,8 @@ namespace IGFD
private:
std::string prCurrentPath; // current path (to be decomposed in prCurrentPathDecomposition
std::vector<std::string> prCurrentPathDecomposition; // part words
std::vector<std::shared_ptr<FileInfos>> prFileList; // base container
std::vector<std::shared_ptr<FileInfos>> prFilteredFileList; // filtered container (search, sorting, etc..)
std::vector<FileInfos> prFileList; // base container
std::vector<FileInfos> prFilteredFileList; // filtered container (search, sorting, etc..)
std::string prLastSelectedFileName; // for shift multi selection
std::set<std::string> prSelectedFileNames; // the user selection of FilePathNames
bool prCreateDirectoryMode = false; // for create directory widget
@ -879,11 +881,11 @@ namespace IGFD
static std::string prRoundNumber(double vvalue, int n); // custom rounding number
static std::string prFormatFileSize(size_t vByteSize); // format file size field
static std::string prOptimizeFilenameForSearchOperations(const std::string& vFileNameExt); // turn all text in lower case for search facilitie
static void prCompleteFileInfos(const std::shared_ptr<FileInfos>& FileInfos); // set time and date infos of a file (detail view mode)
static void prCompleteFileInfos(FileInfos& FileInfos); // set time and date infos of a file (detail view mode)
void prRemoveFileNameInSelection(const std::string& vFileName); // selection : remove a file name
void prAddFileNameInSelection(const std::string& vFileName, bool vSetLastSelectionFileName); // selection : add a file name
void AddFile(const FileDialogInternal& vFileDialogInternal,
const std::string& vPath, const std::string& vFileName, const char& vFileType, void* ent); // add file called by scandir
const std::string& vPath, const std::string& vFileName, char vFileType, void* ent); // add file called by scandir
public:
FileManager();
@ -892,9 +894,9 @@ namespace IGFD
bool IsFileListEmpty();
bool IsFilteredListEmpty();
size_t GetFullFileListSize();
std::shared_ptr<FileInfos> GetFullFileAt(size_t vIdx);
const FileInfos& GetFullFileAt(size_t vIdx);
size_t GetFilteredListSize();
std::shared_ptr<FileInfos> GetFilteredFileAt(size_t vIdx);
const FileInfos& GetFilteredFileAt(size_t vIdx);
bool IsFileNameSelected(const std::string& vFileName);
std::string GetBack();
void ClearComposer();
@ -912,9 +914,9 @@ namespace IGFD
void SetCurrentPath(const std::string& vCurrentPath); // set the current path
static bool IsFileExist(const std::string& vFile);
void SetDefaultFileName(const std::string& vFileName);
bool SelectDirectory(const std::shared_ptr<FileInfos>& vInfos); // enter directory
bool SelectDirectory(const FileInfos& vInfos); // enter directory
void SelectFileName(const FileDialogInternal& vFileDialogInternal,
const std::shared_ptr<FileInfos>& vInfos); // select filename
const FileInfos& vInfos); // select filename
//depend of dirent.h
void SetCurrentDir(const std::string& vPath); // define current directory for scan
@ -1311,7 +1313,7 @@ namespace IGFD
// widgets components
virtual void prDrawSidePane(float vHeight); // draw side pane
virtual int prSelectableItem(int vidx,
std::shared_ptr<FileInfos> vInfos,
const FileInfos& vInfos,
bool vSelected, const char* vFmt, ...); // draw a custom selectable behavior item
virtual bool prDrawFileListView(ImVec2 vSize); // draw file list view (default mode)
@ -1325,7 +1327,7 @@ namespace IGFD
// - prDrawThumbnailsListView
// - prDrawThumbnailsGridView
void prBeginFileColorIconStyle(
std::shared_ptr<FileInfos> vFileInfos,
const FileInfos& vFileInfos,
bool& vOutShowColor,
std::string& vOutStr,
ImFont** vOutFont); // begin style apply of filter with color an icon if any

View file

@ -1236,6 +1236,7 @@ enum ImGuiTableFlags_
ImGuiTableFlags_SortTristate = 1 << 27, // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).
// tildearrow
ImGuiTableFlags_NoBordersInFrozenArea = 1 << 28, // Disable vertical borders in frozen area.
ImGuiTableFlags_NoScrollWithMouse = 1 << 29, // Disable user scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
// [Internal] Combinations and masks
ImGuiTableFlags_SizingMask_ = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_SizingFixedSame | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_SizingStretchSame,

View file

@ -401,6 +401,9 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
// Create scrolling region (without border and zero window padding)
ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None;
if (flags & ImGuiTableFlags_NoScrollWithMouse) {
child_flags |= ImGuiWindowFlags_NoScrollWithMouse;
}
BeginChildEx(name, instance_id, outer_rect.GetSize(), false, child_flags);
table->InnerWindow = g.CurrentWindow;
table->WorkRect = table->InnerWindow->WorkRect;

View file

@ -8,18 +8,19 @@
#include "k053260.hpp"
void k053260_core::tick()
void k053260_core::tick(u32 cycle)
{
m_out[0] = m_out[1] = 0;
if (m_ctrl.sound_en())
{
for (int i = 0; i < 4; i++)
{
m_voice[i].tick();
m_voice[i].tick(cycle);
m_out[0] += m_voice[i].out(0);
m_out[1] += m_voice[i].out(1);
}
}
/*
// dac clock (YM3012 format)
u8 dac_clock = m_dac.clock();
if (bitfield(++dac_clock, 0, 4) == 0)
@ -34,62 +35,58 @@ void k053260_core::tick()
m_dac.set_state(bitfield(dac_state, 0, 2));
}
m_dac.set_clock(bitfield(dac_clock, 0, 4));
*/
}
void k053260_core::voice_t::tick()
void k053260_core::voice_t::tick(u32 cycle)
{
if (m_enable && m_busy)
{
bool update = false;
// update counter
if (bitfield(++m_counter, 0, 12) == 0)
m_counter += cycle;
if (m_counter >= 0x1000)
{
if (m_bitpos < 8)
{
m_bitpos += 8;
m_addr = bitfield(m_addr + 1, 0, 21);
m_addr = m_reverse ? bitfield(m_addr - 1, 0, 21) : bitfield(m_addr + 1, 0, 21);
m_remain--;
if (m_remain < 0) // check end flag
{
if (m_loop)
{
m_addr = m_start;
m_remain = m_length;
m_output = 0;
}
else
{
m_busy = false;
}
}
}
m_data = m_host.m_intf.read_sample(bitfield(m_addr, 0, 21)); // fetch ROM
if (m_adpcm)
{
m_bitpos -= 4;
update = true;
m_bitpos -= 4;
const u8 nibble = bitfield(m_data, m_reverse ? (~m_bitpos & 4) : (m_bitpos & 4), 4); // get nibble from ROM
if (nibble)
{
m_output += m_host.adpcm_lut(nibble);
}
}
else
{
m_bitpos -= 8;
}
m_counter = bitfield(m_pitch, 0, 12);
}
m_data = m_host.m_intf.read_sample(bitfield(m_addr, 0, 21)); // fetch ROM
if (update)
{
const u8 nibble = bitfield(m_data, m_bitpos & 4, 4); // get nibble from ROM
if (nibble)
{
m_adpcm_buf += bitfield(nibble, 3) ? s8(0x80 >> bitfield(nibble, 0, 3))
: (1 << bitfield(nibble - 1, 0, 3));
}
m_counter = (m_counter - 0x1000) + bitfield(m_pitch, 0, 12);
}
if (m_remain < 0) // check end flag
{
if (m_loop)
{
m_addr = m_start;
m_remain = m_length;
m_adpcm_buf = 0;
}
else
{
m_busy = false;
}
}
// calculate output
s32 output = m_adpcm ? m_adpcm_buf : sign_ext<s32>(m_data, 8) * s32(m_volume);
s32 output = (m_adpcm ? m_output : sign_ext<s32>(m_data, 8)) * s32(m_volume);
// use math for now; actually fomula unknown
m_out[0] = (m_pan >= 0) ? s32(output * cos(f64(m_pan) * PI / 180)) : 0;
m_out[1] = (m_pan >= 0) ? s32(output * sin(f64(m_pan) * PI / 180)) : 0;
m_out[0] = (output * m_host.pan_lut(m_pan, 0)) >> 7;
m_out[1] = (output * m_host.pan_lut(m_pan, 1)) >> 7;
}
else
{
@ -172,6 +169,7 @@ void k053260_core::write(u8 address, u8 data)
case 0x28: // keyon/off toggle
for (int i = 0; i < 4; i++)
{
m_voice[i].set_reverse(bitfield(data, 4 + i));
if (bitfield(data, i) && (!m_voice[i].enable()))
{ // rising edge (keyon)
m_voice[i].keyon();
@ -244,8 +242,9 @@ void k053260_core::voice_t::keyon()
m_addr = m_start;
m_remain = m_length;
m_bitpos = 4;
m_adpcm_buf = 0;
std::fill(m_out.begin(), m_out.end(), 0);
m_data = 0;
m_output = 0;
std::fill_n(m_out, 2, 0);
}
// key off trigger
@ -259,34 +258,35 @@ void k053260_core::reset()
elem.reset();
}
m_intf.write_int(0);
//m_intf.write_int(0);
std::fill(m_host2snd.begin(), m_host2snd.end(), 0);
std::fill(m_snd2host.begin(), m_snd2host.end(), 0);
std::fill_n(m_host2snd, 2, 0);
std::fill_n(m_snd2host, 2, 0);
m_ctrl.reset();
m_dac.reset();
//m_dac.reset();
std::fill(m_reg.begin(), m_reg.end(), 0);
std::fill(m_out.begin(), m_out.end(), 0);
std::fill_n(m_reg, 64, 0);
std::fill_n(m_out, 2, 0);
}
// reset voice
void k053260_core::voice_t::reset()
{
m_enable = 0;
m_busy = 0;
m_loop = 0;
m_adpcm = 0;
m_pitch = 0;
m_start = 0;
m_length = 0;
m_volume = 0;
m_pan = -1;
m_counter = 0;
m_addr = 0;
m_remain = 0;
m_bitpos = 4;
m_data = 0;
m_adpcm_buf = 0;
m_enable = 0;
m_busy = 0;
m_loop = 0;
m_adpcm = 0;
m_pitch = 0;
m_reverse = 0;
m_start = 0;
m_length = 0;
m_volume = 0;
m_pan = 4;
m_counter = 0;
m_addr = 0;
m_remain = 0;
m_bitpos = 4;
m_data = 0;
m_output = 0;
m_out[0] = m_out[1] = 0;
}

View file

@ -25,7 +25,7 @@ class k053260_intf : public vgsound_emu_core
virtual u8 read_sample(u32 address) { return 0; } // sample fetch
virtual void write_int(u8 out) {} // timer interrupt
//virtual void write_int(u8 out) {} // timer interrupt
};
class k053260_core : public vgsound_emu_core
@ -33,7 +33,19 @@ class k053260_core : public vgsound_emu_core
friend class k053260_intf; // k053260 specific interface
private:
const int pan_dir[8] = {-1, 0, 24, 35, 45, 55, 66, 90}; // pan direction
const s32 m_pan_lut[8][2] = {
{0x00, 0x00},
{0x7f, 0x00},
{0x74, 0x34},
{0x68, 0x49},
{0x5a, 0x5a},
{0x49, 0x68},
{0x34, 0x74},
{0x00, 0x7f}
}; // pan LUT
const s8 m_adpcm_lut[16] =
{0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1}; // ADPCM LUT
class voice_t : public vgsound_emu_core
{
@ -47,23 +59,24 @@ class k053260_core : public vgsound_emu_core
, m_loop(0)
, m_adpcm(0)
, m_pitch(0)
, m_reverse(0)
, m_start(0)
, m_length(0)
, m_volume(0)
, m_pan(-1)
, m_pan(4)
, m_counter(0)
, m_addr(0)
, m_remain(0)
, m_bitpos(4)
, m_data(0)
, m_adpcm_buf(0)
, m_output(0)
{
m_out.fill(0);
std::fill_n(m_out, 2, 0);
}
// internal state
void reset();
void tick();
void tick(u32 cycle);
// accessors
void write(u8 address, u8 data);
@ -79,9 +92,14 @@ class k053260_core : public vgsound_emu_core
inline void set_adpcm(bool adpcm) { m_adpcm = adpcm ? 1 : 0; }
inline void set_reverse(const bool reverse)
{
m_reverse = reverse ? 1 : 0;
}
inline void length_inc() { m_length = (m_length + 1) & 0xffff; }
inline void set_pan(u8 pan) { m_pan = m_host.pan_dir[pan & 7]; }
inline void set_pan(u8 pan) { m_pan = pan & 7; }
// getters
inline bool enable() { return m_enable; }
@ -97,22 +115,23 @@ class k053260_core : public vgsound_emu_core
private:
// registers
k053260_core &m_host;
u16 m_enable : 1; // enable flag
u16 m_busy : 1; // busy status
u16 m_loop : 1; // loop flag
u16 m_adpcm : 1; // ADPCM flag
u16 m_pitch : 12; // pitch
u32 m_start = 0; // start position
u16 m_length = 0; // source length
u8 m_volume = 0; // master volume
int m_pan = -1; // master pan
u16 m_counter = 0; // frequency counter
u32 m_addr = 0; // current address
s32 m_remain = 0; // remain for end sample
u8 m_bitpos = 4; // bit position for ADPCM decoding
u8 m_data = 0; // current data
s8 m_adpcm_buf = 0; // ADPCM buffer
std::array<s32, 2> m_out; // current output
u16 m_enable : 1; // enable flag
u16 m_busy : 1; // busy status
u16 m_loop : 1; // loop flag
u16 m_adpcm : 1; // ADPCM flag
u16 m_pitch : 12; // pitch
u8 m_reverse : 1; // reverse playback
u32 m_start = 0; // start position
u16 m_length = 0; // source length
u8 m_volume = 0; // master volume
s32 m_pan = 4; // master pan
u16 m_counter = 0; // frequency counter
u32 m_addr = 0; // current address
s32 m_remain = 0; // remain for end sample
u8 m_bitpos = 4; // bit position for ADPCM decoding
u8 m_data = 0; // current data
s8 m_output = 0; // ADPCM buffer
s32 m_out[2]; // current output
};
class ctrl_t
@ -152,6 +171,7 @@ class k053260_core : public vgsound_emu_core
u8 m_input_en : 2; // Input enable
};
/*
class ym3012_t
{
public:
@ -177,7 +197,9 @@ class k053260_core : public vgsound_emu_core
std::array<s32, 2> m_in;
std::array<s32, 2> m_out;
};
*/
/*
class dac_t
{
public:
@ -205,6 +227,7 @@ class k053260_core : public vgsound_emu_core
u8 m_clock : 4; // DAC clock (16 clock)
u8 m_state : 2; // DAC state (4 state - SAM1, SAM2)
};
*/
public:
// constructor
@ -213,13 +236,13 @@ class k053260_core : public vgsound_emu_core
, m_voice{*this, *this, *this, *this}
, m_intf(intf)
, m_ctrl(ctrl_t())
, m_ym3012(ym3012_t())
, m_dac(dac_t())
//, m_ym3012(ym3012_t())
//, m_dac(dac_t())
{
m_host2snd.fill(0);
m_snd2host.fill(0);
m_reg.fill(0);
m_out.fill(0);
std::fill_n(m_host2snd, 2, 0);
std::fill_n(m_snd2host, 2, 0);
std::fill_n(m_reg, 64, 0);
std::fill_n(m_out, 2, 0);
}
// communications
@ -233,7 +256,7 @@ class k053260_core : public vgsound_emu_core
// internal state
void reset();
void tick();
void tick(u32 cycle);
// getters for debug, trackers, etc
inline s32 output(u8 ch) { return m_out[ch & 1]; } // output for each channels
@ -245,20 +268,25 @@ class k053260_core : public vgsound_emu_core
return (voice < 4) ? m_voice[voice].out(ch & 1) : 0;
}
protected:
inline s32 pan_lut(const u8 pan, const u8 out) { return m_pan_lut[pan][out]; }
inline s32 adpcm_lut(const u8 nibble) { return m_adpcm_lut[nibble]; }
private:
std::array<voice_t, 4> m_voice;
voice_t m_voice[4];
k053260_intf &m_intf; // common memory interface
std::array<u8, 2> m_host2snd;
std::array<u8, 2> m_snd2host;
u8 m_host2snd[2];
u8 m_snd2host[2];
ctrl_t m_ctrl; // chip control
ym3012_t m_ym3012; // YM3012 output
dac_t m_dac; // YM3012 interface
//ym3012_t m_ym3012; // YM3012 output
//dac_t m_dac; // YM3012 interface
std::array<u8, 64> m_reg; // register pool
std::array<s32, 2> m_out; // stereo output
u8 m_reg[64]; // register pool
s32 m_out[2]; // stereo output
};
#endif