Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/RaspberryPiOS_armhf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
deb [arch=armhf] http://ports.ubuntu.com/ ${FLAVOR}-updates universe
deb [arch=armhf] http://ports.ubuntu.com/ ${FLAVOR} multiverse
deb [arch=armhf] http://ports.ubuntu.com/ ${FLAVOR}-updates multiverse
deb [arch=armhf] http://ports.ubuntu.com/ ${FLAVOR}-security main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ ${FLAVOR}-backports main restricted universe multiverse
LIST
sudo sed -E -i 's/deb (http|file|mirror)/deb [arch=amd64,i386] \1/' /etc/apt/sources.list
Expand Down
8 changes: 5 additions & 3 deletions Builder/Windows/XM8.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@
<ClCompile Include="..\..\Source\UI\main.cpp" />
<ClCompile Include="..\..\Source\UI\menu.cpp" />
<ClCompile Include="..\..\Source\UI\menuitem.cpp" />
<ClCompile Include="..\..\Source\UI\menulist.cpp" />
<ClCompile Include="..\..\Source\UI\platform.cpp" />
<ClCompile Include="..\..\Source\UI\menulist.cpp" />
<ClCompile Include="..\..\Source\UI\pathresolver.cpp" />
<ClCompile Include="..\..\Source\UI\platform.cpp" />
<ClCompile Include="..\..\Source\UI\setting.cpp" />
<ClCompile Include="..\..\Source\UI\softkey.cpp" />
<ClCompile Include="..\..\Source\UI\tapemgr.cpp" />
Expand Down Expand Up @@ -441,7 +442,8 @@
<ClInclude Include="..\..\Source\UI\input.h" />
<ClInclude Include="..\..\Source\UI\menu.h" />
<ClInclude Include="..\..\Source\UI\menuid.h" />
<ClInclude Include="..\..\Source\UI\menuitem.h" />
<ClInclude Include="..\..\Source\UI\menuitem.h" />
<ClInclude Include="..\..\Source\UI\pathresolver.h" />
<ClInclude Include="..\..\Source\UI\menulist.h" />
<ClInclude Include="..\..\Source\UI\os.h" />
<ClInclude Include="..\..\Source\UI\platform.h" />
Expand Down
18 changes: 12 additions & 6 deletions Builder/Windows/XM8.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@
<ClCompile Include="..\..\Source\UI\diskmgr.cpp">
<Filter>ソース ファイル\UI</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\UI\menulist.cpp">
<Filter>ソース ファイル\UI</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\UI\menulist.cpp">
<Filter>ソース ファイル\UI</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\UI\pathresolver.cpp">
<Filter>ソース ファイル\UI</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\UI\converter.cpp">
<Filter>ソース ファイル\UI</Filter>
</ClCompile>
Expand Down Expand Up @@ -284,9 +287,12 @@
<ClInclude Include="..\..\Source\UI\menu.h">
<Filter>ヘッダー ファイル\UI</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\UI\menuitem.h">
<Filter>ヘッダー ファイル\UI</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\UI\menuitem.h">
<Filter>ヘッダー ファイル\UI</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\UI\pathresolver.h">
<Filter>ヘッダー ファイル\UI</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\UI\menulist.h">
<Filter>ヘッダー ファイル\UI</Filter>
</ClInclude>
Expand Down
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ set(PROJECT_VERSION 1.7.8)
# Project Name
project(XM8 VERSION ${PROJECT_VERSION})

if(APPLE)
enable_language(OBJC OBJCXX)
endif()

include(CTest)

# Packaging options
Expand Down Expand Up @@ -116,6 +120,7 @@ set(SRCS
Source/UI/menu.cpp
Source/UI/menuitem.cpp
Source/UI/menulist.cpp
Source/UI/pathresolver.cpp
Source/UI/platform.cpp
Source/UI/setting.cpp
Source/UI/softkey.cpp
Expand Down Expand Up @@ -143,6 +148,10 @@ set(SRCS
Source/ePC-8801MA/vm/pc8801/pc8801.cpp
)

if(APPLE)
list(APPEND SRCS Source/UI/pathresolver_mac.mm)
endif()

set(BIN_TARGET "xm8")
add_executable(${BIN_TARGET} MACOSX_BUNDLE ${SRCS} Builder/macOS/AppIcon.icns)
target_compile_definitions(${BIN_TARGET} PRIVATE SDL _PC8801MA)
Expand Down Expand Up @@ -186,6 +195,9 @@ option(ENABLE_PACKAGING "Enable CPack packaging" ON)

# Link SDL2 and xBRZ to xm8 target using interface target from Dependencies.cmake
target_link_libraries(${BIN_TARGET} PRIVATE XM8::SDL xbrz)
if(APPLE)
target_link_libraries(${BIN_TARGET} PRIVATE "-framework Foundation")
endif()

if(BUILD_TESTING)
add_executable(clidisk_test
Expand All @@ -207,6 +219,28 @@ if(BUILD_TESTING)
target_compile_definitions(d88probe_test PRIVATE SDL _PC8801MA)
target_link_libraries(d88probe_test PRIVATE XM8::SDL)
add_test(NAME d88probe_test COMMAND d88probe_test)

add_executable(pathresolver_test
Tests/pathresolver_test.cpp
Source/UI/pathresolver.cpp
)
if(APPLE)
target_sources(pathresolver_test PRIVATE Source/UI/pathresolver_mac.mm)
target_link_libraries(pathresolver_test PRIVATE "-framework Foundation")
endif()
target_include_directories(pathresolver_test PRIVATE Source/UI)
add_test(NAME pathresolver_test COMMAND pathresolver_test)

if(APPLE)
add_executable(pathresolver_mac_test
Tests/pathresolver_mac_test.mm
Source/UI/pathresolver.cpp
Source/UI/pathresolver_mac.mm
)
target_include_directories(pathresolver_mac_test PRIVATE Source/UI)
target_link_libraries(pathresolver_mac_test PRIVATE "-framework Foundation")
add_test(NAME pathresolver_mac_test COMMAND pathresolver_mac_test)
endif()
endif()

# Packaging
Expand Down
92 changes: 60 additions & 32 deletions Source/UI/diskmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "upd765a.h"
#include "vm.h"
#include "d88probe.h"
#include "pathresolver.h"
#include "diskmgr.h"

//
Expand All @@ -42,7 +43,8 @@ DiskManager::DiskManager()
name_list = NULL;
wp_list = NULL;
signal = 0;
path[0] = '\0';
path[0] = '\0';
resolved_path[0] = '\0';
dir[0] = '\0';
state_path[0] = '\0';
next_bank = 0;
Expand Down Expand Up @@ -105,23 +107,28 @@ void DiskManager::SetVM(VM *v)
//
bool DiskManager::Probe(const char *filename, int *banks)
{
return ProbeD88Image(filename, banks);
char resolved[_MAX_PATH * 3];
return ResolvePathForIO(filename, resolved, sizeof(resolved)) &&
ProbeD88Image(resolved, banks);
}

//
// Open()
// open disk
//
bool DiskManager::Open(const char *filename, int bank)
{
char *ptr;
char *last;

// save path
if (strlen(filename) >= sizeof(path)) {
return false;
}
strcpy(path, filename);
bool DiskManager::Open(const char *filename, int bank)
{
char *ptr;
char *last;
char candidate[_MAX_PATH * 3];

// save path
if (filename == NULL || strlen(filename) >= sizeof(path) ||
ResolvePathForIO(filename, candidate, sizeof(candidate)) == false) {
return false;
}
strcpy(path, filename);
strcpy(resolved_path, candidate);

// save directory
strcpy(dir, path);
Expand All @@ -147,7 +154,11 @@ bool DiskManager::Open(const char *filename, int bank)
// reopen disk
//
bool DiskManager::Open(int bank)
{
{
if (ResolvePath() == false) {
return false;
}

// close
Close();

Expand All @@ -164,7 +175,7 @@ bool DiskManager::Open(int bank)
current_bank = bank;

// open
vm->open_disk(drive, (_TCHAR*)path, current_bank);
vm->open_disk(drive, (_TCHAR*)resolved_path, current_bank);

// ready
ready = true;
Expand Down Expand Up @@ -379,12 +390,15 @@ int DiskManager::GetBanks()
// SetBank
// change disk bank
//
bool DiskManager::SetBank(int bank)
{
if ((bank >= 0) && (bank < num_of_banks)) {
// open (dummy to access file)
vm->close_disk(drive);
vm->open_disk(drive, (_TCHAR*)path, bank);
bool DiskManager::SetBank(int bank)
{
if ((bank >= 0) && (bank < num_of_banks)) {
if (ResolvePath() == false) {
return false;
}
// open (dummy to access file)
vm->close_disk(drive);
vm->open_disk(drive, (_TCHAR*)resolved_path, bank);

// close
vm->close_disk(drive);
Expand All @@ -406,12 +420,17 @@ void DiskManager::ProcessMgr()
{
if (next_timer > 0) {
next_timer--;
if (next_timer == 0) {
current_bank = next_bank;
vm->open_disk(drive, (_TCHAR*)path, current_bank);
}
}
}
if (next_timer == 0) {
current_bank = next_bank;
if (ResolvePath() == true) {
vm->open_disk(drive, (_TCHAR*)resolved_path, current_bank);
}
else {
Close();
}
}
}
}

//
// Load()
Expand Down Expand Up @@ -449,15 +468,24 @@ void DiskManager::Load(FILEIO *fio)
//
void DiskManager::Save(FILEIO *fio)
{
fio->Fwrite(path, 1, sizeof(path));
fio->Fwrite(path, 1, sizeof(path));
fio->FputBool(ready);
fio->FputInt32(current_bank);
fio->FputInt32(next_bank);
fio->FputInt32(next_timer);
}

//
// Analyze()
//
// ResolvePath()
// resolve logical disk path for I/O
//
bool DiskManager::ResolvePath()
{
return ResolvePathForIO(path, resolved_path, sizeof(resolved_path));
}

//
// Analyze()
// analyze d88 header
//
bool DiskManager::Analyze()
Expand All @@ -470,14 +498,14 @@ bool DiskManager::Analyze()
int bank;
char *ptr;

if (ProbeD88Image(path, &num_of_banks, &len) == false) {
if (ProbeD88Image(resolved_path, &num_of_banks, &len) == false) {
return false;
}

if (fio.Fopen(path, FILEIO_READ_BINARY) == false) {
if (fio.Fopen(resolved_path, FILEIO_READ_BINARY) == false) {
return false;
}
readonly = fio.IsProtected(path);
readonly = fio.IsProtected(resolved_path);

// malloc
name_list = (char*)SDL_malloc(len);
Expand Down
8 changes: 6 additions & 2 deletions Source/UI/diskmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class DiskManager
// save state

private:
bool ResolvePath();
// resolve path used for I/O
bool Analyze();
// analyze d88 header
int drive;
Expand All @@ -89,8 +91,10 @@ class DiskManager
// virtual machine
UPD765A *upd765a;
// fdc
char path[_MAX_PATH * 3];
// disk path
char path[_MAX_PATH * 3];
// disk path
char resolved_path[_MAX_PATH * 3];
// disk path used for I/O
char dir[_MAX_PATH * 3];
// disk dir
char state_path[_MAX_PATH * 3];
Expand Down
6 changes: 4 additions & 2 deletions Source/UI/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3083,7 +3083,7 @@ void Menu::CmdFile(int id)
}
#endif // __ANDROID__

if (platform->MakePath(file_target, name) == true) {
if (platform->MakePath(file_target, name, true) == true) {
MakeExpect(name);
strcpy(file_dir, file_target);
EnterFile();
Expand All @@ -3092,7 +3092,9 @@ void Menu::CmdFile(int id)
}

// normal file
platform->MakePath(file_target, name);
if (platform->MakePath(file_target, name, false) == false) {
return;
}

// tape ?
if ((file_id == MENU_CMT_PLAY) || (file_id == MENU_CMT_REC)) {
Expand Down
Loading
Loading