Skip to content

Commit

Permalink
Initial 3DS port
Browse files Browse the repository at this point in the history
  • Loading branch information
masterfeizz committed Feb 25, 2019
1 parent d2ef74e commit d40d911
Show file tree
Hide file tree
Showing 39 changed files with 1,532 additions and 51 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
*.so
*.a
*.framework
*.elf
*.3dsx
*.cia
*.smdh

romfs/

# Other
*.save
Expand Down
5 changes: 2 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[submodule "hlsdk"]
path = hlsdk
url = https://github.com/SDLash3D/halflife
url = https://github.com/masterfeizz/hlsdk_3ds
[submodule "mainui"]
path = mainui
url = https://github.com/FWGS/mainui_cpp
url = https://github.com/masterfeizz/mainui_3ds
Binary file added banner.bnr
Binary file not shown.
Binary file added banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
218 changes: 218 additions & 0 deletions cia.rsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
BasicInfo:
Title : "Half-Life 3DS"
CompanyCode : "00"
ProductCode : "CTR-P-HLIFE1"
ContentType : Application
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem

TitleInfo:
UniqueId : 0xFF128
Category : Application

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"

# 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 : 80MB # 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 # 268MHz(Default)/804MHz
EnableL2Cache : true # false(default)/true
CanAccessCore2 : true

# Virtual Address Mappings
IORegisterMapping:
- 1ff00000-1ff7ffff # DSP memory
MemoryMapping:
- 1f000000-1f5fffff:r # VRAM

# Accessible SVCs, <Name>:<ID>
SystemCallAccess:
ArbitrateAddress: 34
Break: 60
CancelTimer: 28
ClearEvent: 25
ClearTimer: 29
CloseHandle: 35
ConnectToPort: 45
ControlMemory: 1
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
Backdoor: 123

# Service List
# Maximum 34 services (32 if firmware is prior to 9.6.0)
ServiceAccessControl:
- cfg:u
- fs:USER
- gsp::Gpu
- gsp::Lcd
- hid:USER
- ndm:u
- pxi:dev
- APT:U
- ac:u
- act:u
- am:net
- boss:U
- cam:u
- cecd:u
- csnd:SND
- dsp::DSP
- frd:u
- http:C
- ir:USER
- ir:u
- ir:rst
- ldr:ro
- mic:u
- news:u
- nfc:u
- nim:aoc
- nwm::UDS
- ptm:u
- ptm:sysm
- qtm:u
- soc:U
- ssl:C
- y2r:u


SystemControlInfo:
RemasterVersion: 2
StackSize: 0x4000
# Modules that run services listed above should be included below
# Maximum 48 dependencies
# If a module is listed that isn't present on the 3DS, the title will get stuck at the logo (3ds waves)
# So act, nfc and qtm are commented for 4.x support. Uncomment if you need these.
# <module name>:<module titleid>
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
5 changes: 5 additions & 0 deletions common/backends.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,32 @@ GNU General Public License for more details.
#define VIDEO_NULL 0
#define VIDEO_SDL 1
#define VIDEO_ANDROID 2
#define VIDEO_CTR 3

// audio backends (XASH_SOUND)
#define SOUND_NULL 0
#define SOUND_SDL 1
#define SOUND_OPENSLES 2
#define SOUND_CTR 3

// crash handler (XASH_CRASHHANDLER)
#define CRASHHANDLER_NULL 0
#define CRASHHANDLER_UCONTEXT 1
#define CRASHHANDLER_DBGHELP 2
#define CRASHHANDLER_WIN32 3
#define CRASHHANDLER_CTR 4

// input (XASH_INPUT)
#define INPUT_NULL 0
#define INPUT_SDL 1
#define INPUT_ANDROID 2
#define INPUT_CTR 3

// timer (XASH_TIMER)
#define TIMER_NULL 0 // not used
#define TIMER_SDL 1
#define TIMER_LINUX 2
#define TIMER_WIN32 3
#define TIMER_CTR 4

#endif /* BACKENDS_H */
19 changes: 19 additions & 0 deletions common/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ SETUP BACKENDS DEFINITIONS
#endif
#endif // android case

#if defined _3DS && !defined XASH_SDL

#ifndef XASH_VIDEO
#define XASH_VIDEO VIDEO_CTR
#endif

#ifndef XASH_TIMER
#define XASH_TIMER TIMER_CTR
#endif

#ifndef XASH_INPUT
#define XASH_INPUT INPUT_CTR
#endif

#ifndef XASH_SOUND
#define XASH_SOUND SOUND_CTR
#endif
#endif // ctr case

#endif // XASH_DEDICATED

// select crashhandler based on defines
Expand Down
11 changes: 10 additions & 1 deletion common/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ GNU General Public License for more details.

#if !defined(_WIN32)
#include <limits.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <unistd.h>

#if !defined(_3DS)
#include <dlfcn.h>
#else
#define RTLD_NOW 0
#endif

#if defined(__APPLE__)
#include <sys/syslimits.h>
#define OS_LIB_EXT "dylib"
Expand Down Expand Up @@ -88,6 +93,10 @@ GNU General Public License for more details.
#define CLIENTDLL "libclient" POSTFIX ARCH_SUFFIX "." OS_LIB_EXT
#define SERVERDLL "libserver" POSTFIX ARCH_SUFFIX "." OS_LIB_EXT
#define PACKAGE "/Xash3D"
#elif defined(_3DS)
#define MENUDLL "menu"
#define CLIENTDLL "client"
#define SERVERDLL "server"
#else
#define MENUDLL "libxashmenu" ARCH_SUFFIX "." OS_LIB_EXT
#define CLIENTDLL "client" ARCH_SUFFIX "." OS_LIB_EXT
Expand Down
2 changes: 1 addition & 1 deletion engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ void CL_InitLocal( void )
bottomcolor = Cvar_Get( "bottomcolor", "0", CVAR_USERINFO|CVAR_ARCHIVE, "player bottom color" );
rate = Cvar_Get( "rate", "25000", CVAR_USERINFO|CVAR_ARCHIVE, "player network rate" );
hltv = Cvar_Get( "hltv", "0", CVAR_USERINFO|CVAR_LATCH, "HLTV mode" );
cl_showfps = Cvar_Get( "cl_showfps", "1", CVAR_ARCHIVE, "show client fps" );
cl_showfps = Cvar_Get( "cl_showfps", "0", CVAR_ARCHIVE, "show client fps" );
cl_showpos = Cvar_Get( "cl_showpos", "0", CVAR_ARCHIVE, "show local player position and velocity" );
cl_cmdbackup = Cvar_Get( "cl_cmdbackup", "10", CVAR_ARCHIVE, "how many additional history commands are sent" );
cl_cmdrate = Cvar_Get( "cl_cmdrate", "30", CVAR_ARCHIVE, "max number of command packets sent to server per second" );
Expand Down
9 changes: 9 additions & 0 deletions engine/client/gl_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,15 @@ void GL_RoundImageDimensions( word *width, word *height, texFlags_t flags, qbool
scaledHeight = NearestPOW( scaledHeight, gl_round_down->integer );
}

#ifdef _3DS
if( flags == (TF_FONT | TF_NEAREST) )
{
*width = scaledWidth;
*height = scaledHeight;
return;
}
#endif

if( flags & TF_SKYSIDE )
{
// let people sample down the sky textures for speed
Expand Down
30 changes: 21 additions & 9 deletions engine/client/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,27 @@ GNU General Public License for more details.

extern byte *r_temppool;

#define BLOCK_SIZE world.block_size // lightmap blocksize
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
#define BLOCK_SIZE_MAX 1024

#define MAX_TEXTURES 4096
#define MAX_DETAIL_TEXTURES 256
#define MAX_LIGHTMAPS 256
#define SUBDIVIDE_SIZE 64
#define MAX_MIRRORS 32 // per one frame!
#ifdef _3DS
#define BLOCK_SIZE world.block_size // lightmap blocksize
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
#define BLOCK_SIZE_MAX 128

#define MAX_TEXTURES 2048
#define MAX_DETAIL_TEXTURES 128
#define MAX_LIGHTMAPS 128
#define SUBDIVIDE_SIZE 64
#define MAX_MIRRORS 32 // per one frame!
#else
#define BLOCK_SIZE world.block_size // lightmap blocksize
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
#define BLOCK_SIZE_MAX 1024

#define MAX_TEXTURES 4096
#define MAX_DETAIL_TEXTURES 256
#define MAX_LIGHTMAPS 256
#define SUBDIVIDE_SIZE 64
#define MAX_MIRRORS 32 // per one frame!
#endif

#define NUMVERTEXNORMALS 162
#define SHADEDOT_QUANT 16 // precalculated dot products for quantized angles
Expand Down
Loading

0 comments on commit d40d911

Please sign in to comment.