diff --git a/3rdParty/StormLib/src/FileStream.cpp b/3rdParty/StormLib/src/FileStream.cpp index 08a5ac80f..0dc7db051 100644 --- a/3rdParty/StormLib/src/FileStream.cpp +++ b/3rdParty/StormLib/src/FileStream.cpp @@ -91,7 +91,7 @@ static bool BaseFile_Create(TFileStream * pStream) } #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) { intptr_t handle; @@ -141,7 +141,7 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD } #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) { struct stat64 fileinfo; int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR; @@ -212,7 +212,7 @@ static bool BaseFile_Read( } #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) { ssize_t bytes_read; @@ -283,7 +283,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const } #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) { ssize_t bytes_written; @@ -350,7 +350,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) } #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) { if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1) { @@ -394,7 +394,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream) return (bool)MoveFile(pNewStream->szFileName, pStream->szFileName); #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) // "rename" on Linux also works if the target file exists if(rename(pNewStream->szFileName, pStream->szFileName) == -1) { @@ -414,7 +414,7 @@ static void BaseFile_Close(TFileStream * pStream) CloseHandle(pStream->Base.File.hFile); #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) close((intptr_t)pStream->Base.File.hFile); #endif } @@ -493,7 +493,7 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD return false; #endif -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) struct stat64 fileinfo; intptr_t handle; bool bResult = false; @@ -506,7 +506,7 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD if(fstat64(handle, &fileinfo) != -1) { #if !defined(PLATFORM_AMIGA) -#if defined(PLATFORM_SWITCH) +#if defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) pStream->Base.Map.pbFile = (LPBYTE)malloc((size_t)fileinfo.st_size); #else pStream->Base.Map.pbFile = (LPBYTE)mmap(NULL, (size_t)fileinfo.st_size, PROT_READ, MAP_PRIVATE, handle, 0); @@ -568,11 +568,11 @@ static void BaseMap_Close(TFileStream * pStream) UnmapViewOfFile(pStream->Base.Map.pbFile); #endif -#if (defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)) && !defined(PLATFORM_AMIGA) && !defined(PLATFORM_SWITCH) +#if (defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)) && !defined(PLATFORM_AMIGA) && !defined(PLATFORM_SWITCH) && !defined(PLATFORM_CTR) //Todo(Amiga): Fix a proper solution for this if(pStream->Base.Map.pbFile != NULL) munmap(pStream->Base.Map.pbFile, (size_t )pStream->Base.Map.FileSize); -#elif defined(PLATFORM_SWITCH) +#elif defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) if(pStream->Base.Map.pbFile != NULL) free(pStream->Base.Map.pbFile); #endif diff --git a/3rdParty/StormLib/src/StormPort.h b/3rdParty/StormLib/src/StormPort.h index 681ba7584..771426040 100644 --- a/3rdParty/StormLib/src/StormPort.h +++ b/3rdParty/StormLib/src/StormPort.h @@ -174,6 +174,28 @@ #define PLATFORM_DEFINED #endif + +#if !defined(PLATFORM_DEFINED) && defined(__3DS__) + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #define PLATFORM_LITTLE_ENDIAN + + #define PLATFORM_CTR + #define PLATFORM_DEFINED + +#endif + //----------------------------------------------------------------------------- // Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* @@ -275,7 +297,7 @@ #endif // !PLATFORM_WINDOWS // 64-bit calls are supplied by "normal" calls on Mac -#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) #define stat64 stat #define fstat64 fstat #define lseek64 lseek @@ -285,7 +307,7 @@ #endif // Platform-specific error codes for UNIX-based platforms -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) #define ERROR_SUCCESS 0 #define ERROR_FILE_NOT_FOUND ENOENT #define ERROR_ACCESS_DENIED EPERM diff --git a/Packaging/ctr/audio_silent.wav b/Packaging/ctr/audio_silent.wav new file mode 100644 index 000000000..e0b684b62 Binary files /dev/null and b/Packaging/ctr/audio_silent.wav differ diff --git a/Packaging/ctr/banner.png b/Packaging/ctr/banner.png new file mode 100644 index 000000000..d60cb241c Binary files /dev/null and b/Packaging/ctr/banner.png differ diff --git a/Packaging/ctr/banner_hellfire.png b/Packaging/ctr/banner_hellfire.png new file mode 100644 index 000000000..36769b2f4 Binary files /dev/null and b/Packaging/ctr/banner_hellfire.png differ diff --git a/Packaging/ctr/hb_logo.bin b/Packaging/ctr/hb_logo.bin new file mode 100644 index 000000000..dd9db8cda Binary files /dev/null and b/Packaging/ctr/hb_logo.bin differ diff --git a/Packaging/ctr/icon.png b/Packaging/ctr/icon.png new file mode 100644 index 000000000..558d3c47a Binary files /dev/null and b/Packaging/ctr/icon.png differ diff --git a/Packaging/ctr/icon_hellfire.png b/Packaging/ctr/icon_hellfire.png new file mode 100644 index 000000000..a41d1a037 Binary files /dev/null and b/Packaging/ctr/icon_hellfire.png differ diff --git a/Packaging/ctr/template.rsf b/Packaging/ctr/template.rsf new file mode 100644 index 000000000..ff7acd029 --- /dev/null +++ b/Packaging/ctr/template.rsf @@ -0,0 +1,219 @@ +BasicInfo: + Title : DevilutionX + ProductCode : CTR-P-DIABLO + Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem + +RomFs: + # Specifies the root path of the read only file system to include in the ROM. + RootPath : build/romfs + +TitleInfo: + Category : Application + UniqueId : 0x3F395 + +Option: + UseOnSD : true # true if App is to be installed to SD + FreeProductCode : true # Removes limitations on ProductCode + MediaFootPadding : false # If true CCI files are created with padding + EnableCrypt : false # Enables encryption for NCCH and CIA + EnableCompress : true # Compresses where applicable (currently only exefs:/.code) + +AccessControlInfo: + CoreVersion : 2 + + # Exheader Format Version + DescVersion : 2 + + # Minimum Required Kernel Version (below is for 4.5.0) + ReleaseKernelMajor : "02" + ReleaseKernelMinor : "33" + + # ExtData + UseExtSaveData : false # enables ExtData + #ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId + + # FS:USER Archive Access Permissions + # Uncomment as required + FileSystemAccess: + #- CategorySystemApplication + #- CategoryHardwareCheck + - CategoryFileSystemTool + #- Debug + #- TwlCardBackup + #- TwlNandData + #- Boss + - DirectSdmc + #- Core + #- CtrNandRo + #- CtrNandRw + #- CtrNandRoWrite + #- CategorySystemSettings + #- CardBoard + #- ExportImportIvs + #- DirectSdmcWrite + #- SwitchCleanup + #- SaveDataMove + #- Shop + #- Shell + #- CategoryHomeMenu + + # Process Settings + MemoryType : Application # Application/System/Base + SystemMode : 96MB # 64MB(Default)/96MB/80MB/72MB/32MB + IdealProcessor : 0 + AffinityMask : 1 + Priority : 16 + MaxCpu : 0x9E # Default + HandleTableSize : 0x200 + DisableDebug : false + EnableForceDebug : false + CanWriteSharedPage : true + CanUsePrivilegedPriority : false + CanUseNonAlphabetAndNumber : true + PermitMainFunctionArgument : true + CanShareDeviceMemory : true + RunnableOnSleep : false + SpecialMemoryArrange : true + + # New3DS Exclusive Process Settings + SystemModeExt : 124MB # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode + CpuSpeed : 804MHz # 256MHz(Default)/804MHz + EnableL2Cache : true # false(default)/true + CanAccessCore2 : true + + # Virtual Address Mappings + IORegisterMapping: + - 1ff00000-1ff7ffff # DSP memory + MemoryMapping: + - 1f000000-1f5fffff:r # VRAM + + # Accessible SVCs, : + SystemCallAccess: + ArbitrateAddress: 34 + Backdoor: 123 + Break: 60 + CancelTimer: 28 + ClearEvent: 25 + ClearTimer: 29 + CloseHandle: 35 + ConnectToPort: 45 + ControlMemory: 1 + ControlProcessMemory: 112 + CreateAddressArbiter: 33 + CreateEvent: 23 + CreateMemoryBlock: 30 + CreateMutex: 19 + CreateSemaphore: 21 + CreateThread: 8 + CreateTimer: 26 + DuplicateHandle: 39 + ExitProcess: 3 + ExitThread: 9 + GetCurrentProcessorNumber: 17 + GetHandleInfo: 41 + GetProcessId: 53 + GetProcessIdOfThread: 54 + GetProcessIdealProcessor: 6 + GetProcessInfo: 43 + GetResourceLimit: 56 + GetResourceLimitCurrentValues: 58 + GetResourceLimitLimitValues: 57 + GetSystemInfo: 42 + GetSystemTick: 40 + GetThreadContext: 59 + GetThreadId: 55 + GetThreadIdealProcessor: 15 + GetThreadInfo: 44 + GetThreadPriority: 11 + MapMemoryBlock: 31 + OutputDebugString: 61 + QueryMemory: 2 + ReleaseMutex: 20 + ReleaseSemaphore: 22 + SendSyncRequest1: 46 + SendSyncRequest2: 47 + SendSyncRequest3: 48 + SendSyncRequest4: 49 + SendSyncRequest: 50 + SetThreadPriority: 12 + SetTimer: 27 + SignalEvent: 24 + SleepThread: 10 + UnmapMemoryBlock: 32 + WaitSynchronization1: 36 + WaitSynchronizationN: 37 + + # Service List + # Maximum 34 services (32 if firmware is prior to 9.6.0) + ServiceAccessControl: + - APT:U + - ac:u + - am:net + - boss:U + - cam:u + - cecd:u + - cfg:nor + - cfg:u + - csnd:SND + - dsp::DSP + - frd:u + - fs:USER + - gsp::Gpu + - hid:USER + - http:C + - ir:rst + - ir:u + - ir:USER + - mic:u + - ndm:u + - news:u + - nwm::UDS + - ptm:u + - pxi:dev + - soc:U + - ssl:C + - y2r:u + + +SystemControlInfo: + SaveDataSize: 0KB # Change if the app uses savedata + RemasterVersion: 2 + StackSize: 0x40000 + + # Modules that run services listed above should be included below + # Maximum 48 dependencies + # : + Dependency: + ac: 0x0004013000002402 + act: 0x0004013000003802 + am: 0x0004013000001502 + boss: 0x0004013000003402 + camera: 0x0004013000001602 + cecd: 0x0004013000002602 + cfg: 0x0004013000001702 + codec: 0x0004013000001802 + csnd: 0x0004013000002702 + dlp: 0x0004013000002802 + dsp: 0x0004013000001a02 + friends: 0x0004013000003202 + gpio: 0x0004013000001b02 + gsp: 0x0004013000001c02 + hid: 0x0004013000001d02 + http: 0x0004013000002902 + i2c: 0x0004013000001e02 + ir: 0x0004013000003302 + mcu: 0x0004013000001f02 + mic: 0x0004013000002002 + ndm: 0x0004013000002b02 + news: 0x0004013000003502 + nfc: 0x0004013000004002 + nim: 0x0004013000002c02 + nwm: 0x0004013000002d02 + pdn: 0x0004013000002102 + ps: 0x0004013000003102 + ptm: 0x0004013000002202 + qtm: 0x0004013020004202 + ro: 0x0004013000003702 + socket: 0x0004013000002e02 + spi: 0x0004013000002302 + ssl: 0x0004013000002f02 diff --git a/Packaging/ctr/template_hellfire.rsf b/Packaging/ctr/template_hellfire.rsf new file mode 100644 index 000000000..827bdae42 --- /dev/null +++ b/Packaging/ctr/template_hellfire.rsf @@ -0,0 +1,219 @@ +BasicInfo: + Title : DevilutionX + ProductCode : CTR-P-HELLFIRE + Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem + +RomFs: + # Specifies the root path of the read only file system to include in the ROM. + RootPath : build/romfs + +TitleInfo: + Category : Application + UniqueId : 0x3F396 + +Option: + UseOnSD : true # true if App is to be installed to SD + FreeProductCode : true # Removes limitations on ProductCode + MediaFootPadding : false # If true CCI files are created with padding + EnableCrypt : false # Enables encryption for NCCH and CIA + EnableCompress : true # Compresses where applicable (currently only exefs:/.code) + +AccessControlInfo: + CoreVersion : 2 + + # Exheader Format Version + DescVersion : 2 + + # Minimum Required Kernel Version (below is for 4.5.0) + ReleaseKernelMajor : "02" + ReleaseKernelMinor : "33" + + # ExtData + UseExtSaveData : false # enables ExtData + #ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId + + # FS:USER Archive Access Permissions + # Uncomment as required + FileSystemAccess: + #- CategorySystemApplication + #- CategoryHardwareCheck + - CategoryFileSystemTool + #- Debug + #- TwlCardBackup + #- TwlNandData + #- Boss + - DirectSdmc + #- Core + #- CtrNandRo + #- CtrNandRw + #- CtrNandRoWrite + #- CategorySystemSettings + #- CardBoard + #- ExportImportIvs + #- DirectSdmcWrite + #- SwitchCleanup + #- SaveDataMove + #- Shop + #- Shell + #- CategoryHomeMenu + + # Process Settings + MemoryType : Application # Application/System/Base + SystemMode : 96MB # 64MB(Default)/96MB/80MB/72MB/32MB + IdealProcessor : 0 + AffinityMask : 1 + Priority : 16 + MaxCpu : 0x9E # Default + HandleTableSize : 0x200 + DisableDebug : false + EnableForceDebug : false + CanWriteSharedPage : true + CanUsePrivilegedPriority : false + CanUseNonAlphabetAndNumber : true + PermitMainFunctionArgument : true + CanShareDeviceMemory : true + RunnableOnSleep : false + SpecialMemoryArrange : true + + # New3DS Exclusive Process Settings + SystemModeExt : 124MB # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode + CpuSpeed : 804MHz # 256MHz(Default)/804MHz + EnableL2Cache : true # false(default)/true + CanAccessCore2 : true + + # Virtual Address Mappings + IORegisterMapping: + - 1ff00000-1ff7ffff # DSP memory + MemoryMapping: + - 1f000000-1f5fffff:r # VRAM + + # Accessible SVCs, : + SystemCallAccess: + ArbitrateAddress: 34 + Backdoor: 123 + Break: 60 + CancelTimer: 28 + ClearEvent: 25 + ClearTimer: 29 + CloseHandle: 35 + ConnectToPort: 45 + ControlMemory: 1 + ControlProcessMemory: 112 + CreateAddressArbiter: 33 + CreateEvent: 23 + CreateMemoryBlock: 30 + CreateMutex: 19 + CreateSemaphore: 21 + CreateThread: 8 + CreateTimer: 26 + DuplicateHandle: 39 + ExitProcess: 3 + ExitThread: 9 + GetCurrentProcessorNumber: 17 + GetHandleInfo: 41 + GetProcessId: 53 + GetProcessIdOfThread: 54 + GetProcessIdealProcessor: 6 + GetProcessInfo: 43 + GetResourceLimit: 56 + GetResourceLimitCurrentValues: 58 + GetResourceLimitLimitValues: 57 + GetSystemInfo: 42 + GetSystemTick: 40 + GetThreadContext: 59 + GetThreadId: 55 + GetThreadIdealProcessor: 15 + GetThreadInfo: 44 + GetThreadPriority: 11 + MapMemoryBlock: 31 + OutputDebugString: 61 + QueryMemory: 2 + ReleaseMutex: 20 + ReleaseSemaphore: 22 + SendSyncRequest1: 46 + SendSyncRequest2: 47 + SendSyncRequest3: 48 + SendSyncRequest4: 49 + SendSyncRequest: 50 + SetThreadPriority: 12 + SetTimer: 27 + SignalEvent: 24 + SleepThread: 10 + UnmapMemoryBlock: 32 + WaitSynchronization1: 36 + WaitSynchronizationN: 37 + + # Service List + # Maximum 34 services (32 if firmware is prior to 9.6.0) + ServiceAccessControl: + - APT:U + - ac:u + - am:net + - boss:U + - cam:u + - cecd:u + - cfg:nor + - cfg:u + - csnd:SND + - dsp::DSP + - frd:u + - fs:USER + - gsp::Gpu + - hid:USER + - http:C + - ir:rst + - ir:u + - ir:USER + - mic:u + - ndm:u + - news:u + - nwm::UDS + - ptm:u + - pxi:dev + - soc:U + - ssl:C + - y2r:u + + +SystemControlInfo: + SaveDataSize: 0KB # Change if the app uses savedata + RemasterVersion: 2 + StackSize: 0x40000 + + # Modules that run services listed above should be included below + # Maximum 48 dependencies + # : + Dependency: + ac: 0x0004013000002402 + act: 0x0004013000003802 + am: 0x0004013000001502 + boss: 0x0004013000003402 + camera: 0x0004013000001602 + cecd: 0x0004013000002602 + cfg: 0x0004013000001702 + codec: 0x0004013000001802 + csnd: 0x0004013000002702 + dlp: 0x0004013000002802 + dsp: 0x0004013000001a02 + friends: 0x0004013000003202 + gpio: 0x0004013000001b02 + gsp: 0x0004013000001c02 + hid: 0x0004013000001d02 + http: 0x0004013000002902 + i2c: 0x0004013000001e02 + ir: 0x0004013000003302 + mcu: 0x0004013000001f02 + mic: 0x0004013000002002 + ndm: 0x0004013000002b02 + news: 0x0004013000003502 + nfc: 0x0004013000004002 + nim: 0x0004013000002c02 + nwm: 0x0004013000002d02 + pdn: 0x0004013000002102 + ps: 0x0004013000003102 + ptm: 0x0004013000002202 + qtm: 0x0004013020004202 + ro: 0x0004013000003702 + socket: 0x0004013000002e02 + spi: 0x0004013000002302 + ssl: 0x0004013000002f02 diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 622f5a08a..90eb162d2 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -89,6 +89,9 @@ BOOL nthread_recv_turns(BOOL *pfSendAsync) last_tick += tick_delay; return TRUE; } +#ifdef __3DS__ + return FALSE; +#else if (!SNetReceiveTurns(0, MAX_PLRS, (char **)glpMsgTbl, gdwMsgLenTbl, (LPDWORD)player_state)) { if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING) nthread_terminate_game("SNetReceiveTurns"); @@ -107,6 +110,7 @@ BOOL nthread_recv_turns(BOOL *pfSendAsync) last_tick += tick_delay; return TRUE; } +#endif } static unsigned int nthread_handler(void *data) diff --git a/SourceS/config.h b/SourceS/config.h new file mode 100644 index 000000000..fc6486fac --- /dev/null +++ b/SourceS/config.h @@ -0,0 +1,4 @@ +#pragma once + +#define PROJECT_NAME "DevilutionX" +#define PROJECT_VERSION "ctr_v1" diff --git a/SourceS/sdl2_to_1_2_backports.h b/SourceS/sdl2_to_1_2_backports.h index fa2e8315f..3ad21b015 100644 --- a/SourceS/sdl2_to_1_2_backports.h +++ b/SourceS/sdl2_to_1_2_backports.h @@ -759,6 +759,10 @@ inline char *SDL_GetBasePath() } } #endif +#if defined(__3DS__) + retval = SDL_strdup("file:sdmc:/3ds/devilutionx/"); + return retval; +#endif /* is a Linux-style /proc filesystem available? */ if (!retval && (access("/proc", F_OK) == 0)) { @@ -825,6 +829,11 @@ inline char *SDL_GetPrefPath(const char *org, const char *app) char *ptr = NULL; size_t len = 0; +#if defined(__3DS__) + retval = SDL_strdup("sdmc:/3ds/devilutionx/"); + return retval; +#endif + if (!app) { SDL_InvalidParamError("app"); return NULL; diff --git a/SourceX/DiabloUI/selhero.cpp b/SourceX/DiabloUI/selhero.cpp index eb481feae..f1f044f18 100644 --- a/SourceX/DiabloUI/selhero.cpp +++ b/SourceX/DiabloUI/selhero.cpp @@ -13,6 +13,10 @@ #include "DiabloUI/selok.h" #include "DiabloUI/selgame.h" +#ifdef __3DS__ +#include "../platform/ctr/keyboard.h" +#endif + namespace dvl { const char *selhero_GenerateName(uint8_t hero_class); @@ -362,6 +366,8 @@ void selhero_ClassSelector_Select(int value) memset(selhero_heroInfo.name, '\0', sizeof(selhero_heroInfo.name)); #ifdef PREFILL_PLAYER_NAME strncpy(selhero_heroInfo.name, selhero_GenerateName(selhero_heroInfo.heroclass), sizeof(selhero_heroInfo.name) - 1); +#elif defined __3DS__ + ctr_vkbdInput("Enter Hero name..", selhero_GenerateName(selhero_heroInfo.heroclass), selhero_heroInfo.name); #endif selhero_FreeDlgItems(); SDL_Rect rect1 = { PANEL_LEFT + 264, (UI_OFFSET_Y + 211), 320, 33 }; diff --git a/SourceX/DiabloUI/ttf_render_wrapped.cpp b/SourceX/DiabloUI/ttf_render_wrapped.cpp index 8630ae97b..4fd84f5d4 100644 --- a/SourceX/DiabloUI/ttf_render_wrapped.cpp +++ b/SourceX/DiabloUI/ttf_render_wrapped.cpp @@ -1,6 +1,9 @@ #include "DiabloUI/ttf_render_wrapped.h" #include +#ifdef __3DS__ +#include +#endif namespace dvl { @@ -40,7 +43,11 @@ SDL_Surface *RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Colo int w, h; char *spot, *tok, *next_tok, *end; char delim; +#ifdef __3DS__ + size_t str_len = strlen(text); +#else size_t str_len = SDL_strlen(text); +#endif numLines = 0; @@ -50,7 +57,11 @@ SDL_Surface *RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Colo return NULL; } +#ifdef __3DS__ + memcpy(str, text, str_len + 1); +#else SDL_strlcpy(str, text, str_len + 1); +#endif tok = str; end = str + str_len; do { diff --git a/SourceX/display.cpp b/SourceX/display.cpp index 0292036b9..547bb56b5 100644 --- a/SourceX/display.cpp +++ b/SourceX/display.cpp @@ -116,7 +116,11 @@ void CalculatePreferdWindowSize(int &width, int &height, bool useIntegerScaling) bool SpawnWindow(const char *lpWindowName) { +#ifdef __3DS__ + if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) <= -1) { +#else if (SDL_Init(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC) <= -1) { +#endif ErrSdl(); } diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 3bd2004f0..4da175893 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -252,8 +252,9 @@ void LimitFrameRate() void RenderPresent() { SDL_Surface *surface = GetOutputSurface(); +#if !defined(__3DS__) assert(!SDL_MUSTLOCK(surface)); - +#endif if (!gbActive) { LimitFrameRate(); return; diff --git a/SourceX/main.cpp b/SourceX/main.cpp index d49005898..0b1e867dd 100644 --- a/SourceX/main.cpp +++ b/SourceX/main.cpp @@ -2,6 +2,9 @@ #ifdef __SWITCH__ #include "platform/switch/network.h" #endif +#ifdef __3DS__ +#include "platform/ctr/system.h" +#endif #ifdef RUN_TESTS #include #endif @@ -24,6 +27,9 @@ int main(int argc, char **argv) #ifdef __SWITCH__ switch_enable_network(); #endif +#ifdef __3DS__ + ctr_sys_init(); +#endif return dvl::DiabloMain(argc, argv); }