├── .clang-format ├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── compilation.yml ├── .gitignore ├── DeviceSupport.c ├── DeviceSupport.h ├── HDLGManClient ├── .gitignore ├── HDLGManClient.c ├── HDLGManClient.h ├── HDLGManClient.sln ├── HDLGManClient.vcxproj ├── MainWindow.rc ├── OSD.c ├── OSD.h ├── ViewIcon.icn ├── client.c ├── client.h ├── icon_sys.txt ├── install-main.c ├── install.h ├── io.c ├── io.h ├── iso9660.c ├── iso9660.h ├── main.c ├── main.h ├── resource.h ├── system.c └── system.h ├── HDLGameList.c ├── HDLGameList.h ├── HDLGameSvr.c ├── HDLGameSvr.h ├── IconLoader.c ├── IconLoader.h ├── IconRender.c ├── IconRender.h ├── Makefile ├── OSD.c ├── OSD.h ├── Readme.md ├── Research └── partition_sample.txt ├── Rules.make ├── UI.c ├── UI.h ├── apa-hdl ├── Makefile └── src │ ├── apa-opt.h │ ├── hdd.c │ ├── hdd.h │ ├── hdd_fio.c │ ├── hdd_fio.h │ ├── imports.lst │ └── irx_imports.h ├── documentation ├── Developer notes.txt └── Translation notes.txt ├── font.c ├── font.h ├── graphics.c ├── graphics.h ├── hdlfs ├── Makefile ├── README.txt ├── Research.txt ├── Rules.make ├── hdlfs.h ├── imports.lst ├── irx_imports.h └── main.c ├── io.c ├── io.h ├── ipconfig.c ├── ipconfig.h ├── irx ├── hdlfs.irx └── ps2hdd-hdl.irx ├── lang.c ├── lang.h ├── lang ├── LICENSE_OFL.txt ├── NotoSansMono-CondensedBold.ttf ├── fonts.txt ├── labels_DU.txt ├── labels_FR.txt ├── labels_GE.txt ├── labels_IT.txt ├── labels_PO.txt ├── labels_SP.txt ├── strings_DU.txt ├── strings_FR.txt ├── strings_GE.txt ├── strings_IT.txt ├── strings_PO.txt └── strings_SP.txt ├── main.c ├── main.h ├── menu.c ├── menu.h ├── pad.c ├── pad.h ├── res ├── BOOT.XLF ├── SJIS2Unicode.bin ├── icon.ico └── system.cnf ├── resources ├── background.png ├── buttons.png └── devices.png ├── settings.c ├── settings.h ├── sjis.c ├── sjis.h ├── system.c └── system.h /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: true 6 | AlignConsecutiveBitFields: AcrossEmptyLinesAndComments 7 | AlignConsecutiveDeclarations: false 8 | AlignConsecutiveMacros: AcrossComments 9 | AlignEscapedNewlines: Left 10 | AlignOperands: Align 11 | AlignTrailingComments: true 12 | AllowAllArgumentsOnNextLine: false 13 | AllowAllConstructorInitializersOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: Empty 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortEnumsOnASingleLine: true 18 | AllowShortFunctionsOnASingleLine: All 19 | AllowShortIfStatementsOnASingleLine: Never 20 | AllowShortLambdasOnASingleLine: Empty 21 | AllowShortLoopsOnASingleLine: false 22 | AlwaysBreakAfterReturnType: None 23 | AlwaysBreakBeforeMultilineStrings: false 24 | AlwaysBreakTemplateDeclarations: true 25 | BinPackArguments: true 26 | BinPackParameters: true 27 | BitFieldColonSpacing : Both 28 | BreakBeforeBraces: Custom 29 | BraceWrapping: 30 | AfterCaseLabel: false 31 | AfterClass: true 32 | AfterControlStatement: false 33 | AfterEnum: false 34 | AfterFunction: true 35 | AfterNamespace: true 36 | AfterObjCDeclaration: false 37 | AfterStruct: true 38 | AfterUnion: true 39 | AfterExternBlock: false 40 | BeforeCatch: false 41 | BeforeElse: false 42 | BeforeLambdaBody: false 43 | BeforeWhile: false 44 | IndentBraces: false 45 | SplitEmptyFunction: true 46 | SplitEmptyRecord: true 47 | SplitEmptyNamespace: true 48 | BreakBeforeBinaryOperators: None 49 | BreakBeforeConceptDeclarations: true 50 | BreakBeforeTernaryOperators: false 51 | BreakConstructorInitializers: BeforeComma 52 | BreakStringLiterals: true 53 | ColumnLimit: 0 54 | CommentPragmas: '^ (IWYU pragma:|NOLINT)' 55 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 56 | ConstructorInitializerIndentWidth: 4 57 | ContinuationIndentWidth: 4 58 | Cpp11BracedListStyle: true 59 | DeriveLineEnding: true 60 | DerivePointerAlignment: false 61 | DisableFormat: false 62 | EmptyLineBeforeAccessModifier: LogicalBlock 63 | FixNamespaceComments: true 64 | ForEachMacros: [] 65 | IncludeBlocks: Preserve 66 | IndentExternBlock: NoIndent 67 | IndentCaseBlocks: false 68 | IndentCaseLabels: true 69 | IndentGotoLabels: true 70 | IndentWidth: 4 71 | IndentWrappedFunctionNames: false 72 | KeepEmptyLinesAtTheStartOfBlocks: true 73 | MacroBlockBegin: '' 74 | MacroBlockEnd: '' 75 | MaxEmptyLinesToKeep: 3 76 | NamespaceIndentation: None 77 | ObjCBlockIndentWidth: 2 78 | ObjCSpaceAfterProperty: false 79 | ObjCSpaceBeforeProtocolList: true 80 | PenaltyBreakAssignment: 80 81 | PenaltyBreakBeforeFirstCallParameter: 19 82 | PenaltyBreakComment: 300 83 | PenaltyBreakFirstLessLess: 120 84 | PenaltyBreakString: 1000 85 | PenaltyBreakTemplateDeclaration: 80 86 | PenaltyExcessCharacter: 1000000 87 | PenaltyIndentedWhitespace: 80 88 | PenaltyReturnTypeOnItsOwnLine: 60 89 | PointerAlignment: Right 90 | # uncomment below when clang >13 will be out 91 | # IndentPPDirectives: AfterHash 92 | # PPIndentWidth: 1 93 | ReflowComments: true 94 | SortIncludes: false 95 | SpaceAfterCStyleCast: false 96 | SpaceAfterLogicalNot: false 97 | SpaceAroundPointerQualifiers: Default 98 | SpaceBeforeAssignmentOperators: true 99 | SpaceBeforeCaseColon: false 100 | SpaceBeforeCpp11BracedList: true 101 | SpaceBeforeInheritanceColon: false 102 | SpaceBeforeParens: ControlStatements 103 | SpaceBeforeRangeBasedForLoopColon: true 104 | SpaceBeforeSquareBrackets: false 105 | SpaceInEmptyBlock: false 106 | SpaceInEmptyParentheses: false 107 | SpacesBeforeTrailingComments: 1 108 | SpacesInAngles: false 109 | SpacesInConditionalStatement: false 110 | SpacesInContainerLiterals: true 111 | SpacesInCStyleCastParentheses: false 112 | SpacesInParentheses: false 113 | SpacesInSquareBrackets: false 114 | Standard: Cpp11 115 | TabWidth: 4 116 | UseTab: Never 117 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig: http://EditorConfig.org 2 | 3 | # Top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | charset = utf-8 12 | 13 | # 4 space indentation 14 | [*.{c,h,js,css,html}] 15 | indent_style = space 16 | indent_size = 4 17 | 18 | # 2 space indentation 19 | [*.{json,xml,yaml,yml}] 20 | indent_style = space 21 | indent_size = 2 22 | 23 | # Tab indentation 24 | [Makefile*] 25 | indent_style = tab 26 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/workflows/compilation.yml: -------------------------------------------------------------------------------- 1 | name: CI-compile 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | build: 9 | name: HDLGameInstaller compilation 10 | runs-on: ubuntu-latest 11 | container: ps2dev/ps2dev:v1.0 12 | # instead of "ps2dev/ps2dev:latest" you can use different tags, for example for old projects you can use "ps2dev/ps2dev:v1.0" 13 | steps: 14 | - name: Install dependencies 15 | run: | 16 | apk add build-base git zip 17 | 18 | - uses: actions/checkout@v3 19 | - run: | 20 | git config --global --add safe.directory "$GITHUB_WORKSPACE" 21 | git fetch --prune --unshallow 22 | 23 | - name: Compile project 24 | run: | 25 | make 26 | 27 | # commands for compiling your project 28 | - name: Get short SHA and repository name 29 | id: slug 30 | run: | 31 | echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" 32 | echo "::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" 33 | 34 | - name: Upload artifacts 35 | if: ${{ success() }} 36 | uses: actions/upload-artifact@v4 37 | with: 38 | name: ${{ steps.slug.outputs.REPOSITORY_NAME }}-${{ steps.slug.outputs.sha8 }} 39 | path: | 40 | HDLGameInstaller.elf 41 | README.md 42 | lang/* 43 | 44 | build-hdlgmanclient: 45 | name: HDLGManClient compilation 46 | runs-on: windows-latest 47 | 48 | steps: 49 | - name: Checkout Repository 50 | uses: actions/checkout@v3 51 | 52 | - name: Setup msbuild 53 | uses: microsoft/setup-msbuild@v1.0.2 54 | 55 | - name: Build 56 | run: | 57 | cd HDLGManClient 58 | msbuild /p:Configuration=Release 59 | 60 | - uses: actions/upload-artifact@v4 61 | with: 62 | name: HDLGManClient 63 | path: HDLGManClient/Release/HDLGManClient.exe 64 | 65 | release: 66 | needs: [build, build-hdlgmanclient] 67 | runs-on: ubuntu-latest 68 | if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' 69 | steps: 70 | - uses: actions/checkout@v3 71 | 72 | - name: Get short SHA and repository name 73 | id: slug 74 | run: | 75 | echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" 76 | echo "::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" 77 | 78 | - name: Download HDLGameInstaller artifact 79 | uses: actions/download-artifact@v4 80 | with: 81 | name: ${{ steps.slug.outputs.REPOSITORY_NAME }}-${{ steps.slug.outputs.sha8 }} 82 | path: HDLGameInstaller 83 | 84 | - name: Prepare HDLGameInstaller archive 85 | run: | 86 | 7z a ${{ steps.slug.outputs.REPOSITORY_NAME }}-${{ steps.slug.outputs.sha8 }}.7z HDLGameInstaller/* 87 | 88 | - name: Download HDLGManClient artifact 89 | uses: actions/download-artifact@v4 90 | with: 91 | name: HDLGManClient 92 | 93 | - name: Create pre-release 94 | if: github.ref == 'refs/heads/main' 95 | uses: marvinpinto/action-automatic-releases@latest 96 | with: 97 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 98 | prerelease: true 99 | automatic_release_tag: "latest" 100 | title: "Development build" 101 | files: | 102 | ${{ steps.slug.outputs.REPOSITORY_NAME }}-${{ steps.slug.outputs.sha8 }}.7z 103 | HDLGManClient.exe 104 | 105 | - name: Create Tagged Release Draft 106 | if: startsWith(github.ref, 'refs/tags/v') 107 | uses: marvinpinto/action-automatic-releases@latest 108 | with: 109 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 110 | prerelease: false 111 | automatic_release_tag: "stable" 112 | draft: true 113 | files: | 114 | ${{ steps.slug.outputs.REPOSITORY_NAME }}-${{ steps.slug.outputs.sha8 }}.7z 115 | HDLGManClient.exe 116 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE! Please use 'git ls-files -i --exclude-standard -c' 3 | # command after changing this file, to see if there are 4 | # any tracked files which get ignored after the change. 5 | # 6 | # Normal rules 7 | # 8 | .* 9 | *.a 10 | *.diff 11 | *.elf 12 | *.ELF 13 | *.erl 14 | *.exe 15 | *.irx 16 | *.map 17 | *.o 18 | *.patch 19 | *.rej 20 | *.s 21 | *.zip 22 | *.ZIP 23 | *.a 24 | 25 | # 26 | # files that we don't want to ignore 27 | # 28 | !.gitignore 29 | !.gitattributes 30 | !.github 31 | !.editorconfig 32 | !.clang-format 33 | 34 | # 35 | # Generated source files 36 | # 37 | 38 | BOOT_kelf.c 39 | ICON_ico.c 40 | SJIS2Unicode_bin.c 41 | SYSTEM_cnf.c 42 | background.c 43 | buttons.c 44 | devices.c 45 | -------------------------------------------------------------------------------- /DeviceSupport.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "main.h" 10 | #ifdef ENABLE_NETWORK_SUPPORT 11 | #include 12 | #include 13 | #endif 14 | 15 | #include "HDLGameList.h" 16 | #include "system.h" 17 | #include "DeviceSupport.h" 18 | 19 | static int DevicePollingThreadID = -1, MainThreadID = -1; 20 | static volatile int DevicePollingThreadCommand; 21 | static void *DevicePollingThreadStack = NULL; 22 | 23 | enum DEVICE_POLLING_THREAD_COMMANDS { 24 | DEVICE_POLLING_THREAD_CMD_NONE = 0, 25 | DEVICE_POLLING_THREAD_CMD_STOP 26 | }; 27 | 28 | static int McUnitStatus[2]; 29 | static int MassUnitStatus[1]; 30 | 31 | static int IsMcUnitReady(int unit) 32 | { 33 | int type, free, format, result; 34 | 35 | type = MC_TYPE_NONE; 36 | if (mcGetInfo(unit, 0, &type, &free, &format) == 0) { 37 | mcSync(0, NULL, &result); 38 | 39 | result = (type == MC_TYPE_PS2 && format == MC_FORMATTED) ? 1 : 0; 40 | } else 41 | result = 0; 42 | 43 | return result; 44 | } 45 | 46 | static int IsMassUnitReady(int unit) 47 | { 48 | return 1; 49 | } 50 | 51 | static void DevicePollingThread(void) 52 | { 53 | int done; 54 | 55 | done = 0; 56 | while (!done) { 57 | // Process commands. 58 | if (DevicePollingThreadCommand != DEVICE_POLLING_THREAD_CMD_NONE) { 59 | if (DevicePollingThreadCommand == DEVICE_POLLING_THREAD_CMD_STOP) { 60 | WakeupThread(MainThreadID); 61 | done = 1; 62 | continue; 63 | } 64 | 65 | DevicePollingThreadCommand = DEVICE_POLLING_THREAD_CMD_NONE; 66 | } 67 | 68 | // Update the status of all units of all devices. 69 | MassUnitStatus[0] = IsMassUnitReady(0); 70 | McUnitStatus[0] = IsMcUnitReady(0); 71 | McUnitStatus[1] = IsMcUnitReady(1); 72 | } 73 | } 74 | 75 | int StartDevicePollingThread(void) 76 | { 77 | DevicePollingThreadCommand = DEVICE_POLLING_THREAD_CMD_NONE; 78 | MainThreadID = GetThreadId(); 79 | 80 | DevicePollingThreadStack = malloc(0x800); 81 | return (DevicePollingThreadID = SysCreateThread(&DevicePollingThread, DevicePollingThreadStack, 0x800, NULL, 0x78)); 82 | } 83 | 84 | int StopDevicePollingThread(void) 85 | { 86 | DevicePollingThreadCommand = DEVICE_POLLING_THREAD_CMD_STOP; 87 | SleepThread(); // Wait for acknowledgement. 88 | 89 | if (DevicePollingThreadID >= 0) { 90 | TerminateThread(DevicePollingThreadID); 91 | DeleteThread(DevicePollingThreadID); 92 | DevicePollingThreadID = -1; 93 | } 94 | 95 | if (DevicePollingThreadStack != NULL) { 96 | free(DevicePollingThreadStack); 97 | DevicePollingThreadStack = NULL; 98 | } 99 | 100 | return 0; 101 | } 102 | 103 | int GetIsDeviceUnitReady(const char *device, int unit) 104 | { 105 | int result; 106 | 107 | if (strcmp(device, "mc") == 0) { 108 | result = McUnitStatus[unit]; 109 | } else if (strcmp(device, "mass") == 0) { 110 | result = MassUnitStatus[unit]; 111 | } else 112 | result = -ENODEV; 113 | 114 | return result; 115 | } 116 | -------------------------------------------------------------------------------- /DeviceSupport.h: -------------------------------------------------------------------------------- 1 | int StartDevicePollingThread(void); 2 | int StopDevicePollingThread(void); 3 | int GetIsDeviceUnitReady(const char *device, int unit); 4 | -------------------------------------------------------------------------------- /HDLGManClient/.gitignore: -------------------------------------------------------------------------------- 1 | *.sdf 2 | *.suo 3 | *.ipch 4 | *.aps 5 | *.filters 6 | *.user 7 | *.exe 8 | *.log 9 | .vs 10 | Debug 11 | Release 12 | -------------------------------------------------------------------------------- /HDLGManClient/HDLGManClient.h: -------------------------------------------------------------------------------- 1 | #pragma pack(push, 1) 2 | 3 | typedef unsigned int u32; 4 | typedef unsigned short int u16; 5 | typedef unsigned char u8; 6 | typedef unsigned long long int u64; 7 | 8 | enum OSD_RESOURCE_FILE_TYPES { 9 | OSD_SYSTEM_CNF_INDEX = 0, 10 | OSD_ICON_SYS_INDEX, 11 | OSD_VIEW_ICON_INDEX, 12 | OSD_DEL_ICON_INDEX, 13 | OSD_BOOT_KELF_INDEX, 14 | 15 | NUM_OSD_FILES_ENTS 16 | }; 17 | 18 | typedef struct 19 | { 20 | int offset; 21 | int size; 22 | } OSDResFileEnt_t; 23 | 24 | #define GAME_TITLE_MAX_LEN_BYTES 160 // In bytes, when in UTF-8 characters. 25 | #define GAME_TITLE_MAX_LEN (GAME_TITLE_MAX_LEN_BYTES / 2) /* In characters. Note: the original format for HDLoader just has a 160-character space. \ 26 | But UTF-8 characters may have 1 or more bytes each. Hence this is an approximation. */ 27 | #define OSD_TITLE_MAX_LEN_BYTES (OSD_TITLE_MAX_LEN * 4) // In bytes, when in UTF-8 characters. 28 | #define OSD_TITLE_MAX_LEN 16 // In characters 29 | 30 | typedef struct PartAttributeAreaTable 31 | { 32 | char magic[9]; /* "PS2ICON3D" */ 33 | u8 reserved[3]; 34 | int version; /* Must be zero. */ 35 | OSDResFileEnt_t FileEnt[NUM_OSD_FILES_ENTS]; 36 | u8 reserved2[456]; 37 | } t_PartAttrTab; //__attribute__((packed)); 38 | 39 | /* Server configuration */ 40 | #define SERVER_PORT_NUM 45061 41 | #define SERVER_DATA_PORT_NUM 45062 42 | 43 | /* Transfer rate modes. */ 44 | #define ATA_XFER_MODE_PIO 0x08 45 | #define ATA_XFER_MODE_MDMA 0x20 46 | #define ATA_XFER_MODE_UDMA 0x40 47 | 48 | struct HDDToolsPacketHdr 49 | { 50 | u32 command; 51 | u32 PayloadLength; 52 | int result; 53 | }; 54 | 55 | #define SET_COMPAT_MODE_1(var, value) (var = ((var & ~0x01) | (value ? 1 : 0) << 0)) 56 | #define SET_COMPAT_MODE_2(var, value) (var = ((var & ~0x02) | (value ? 1 : 0) << 1)) 57 | #define SET_COMPAT_MODE_3(var, value) (var = ((var & ~0x04) | (value ? 1 : 0) << 2)) 58 | #define SET_COMPAT_MODE_4(var, value) (var = ((var & ~0x08) | (value ? 1 : 0) << 3)) 59 | #define SET_COMPAT_MODE_5(var, value) (var = ((var & ~0x10) | (value ? 1 : 0) << 4)) 60 | #define SET_COMPAT_MODE_6(var, value) (var = ((var & ~0x20) | (value ? 1 : 0) << 5)) 61 | #define SET_COMPAT_MODE_7(var, value) (var = ((var & ~0x40) | (value ? 1 : 0) << 6)) 62 | #define SET_COMPAT_MODE_8(var, value) (var = ((var & ~0x80) | (value ? 1 : 0) << 7)) 63 | 64 | #define GET_COMPAT_MODE_1(var) (var >> 0 & 1) 65 | #define GET_COMPAT_MODE_2(var) (var >> 1 & 1) 66 | #define GET_COMPAT_MODE_3(var) (var >> 2 & 1) 67 | #define GET_COMPAT_MODE_4(var) (var >> 3 & 1) 68 | #define GET_COMPAT_MODE_5(var) (var >> 4 & 1) 69 | #define GET_COMPAT_MODE_6(var) (var >> 5 & 1) 70 | #define GET_COMPAT_MODE_7(var) (var >> 6 & 1) 71 | #define GET_COMPAT_MODE_8(var) (var >> 7 & 1) 72 | 73 | struct HDLGameInfo 74 | { 75 | char GameTitle[GAME_TITLE_MAX_LEN_BYTES + 1]; 76 | char DiscID[11]; /* E.g. SXXX-99999 */ 77 | char StartupFname[14]; /* E.g. "SXXX-999.99;1" */ 78 | u8 DiscType; 79 | u32 SectorsInDiscLayer0; 80 | u32 SectorsInDiscLayer1; 81 | u8 CompatibilityFlags; 82 | u8 TRType; 83 | u8 TRMode; 84 | }; 85 | 86 | struct IOInitReq 87 | { 88 | u32 sectors, offset; 89 | char partition[33]; 90 | }; 91 | 92 | struct OSDResourceInitReq 93 | { 94 | int UseSaveData; 95 | char OSDTitleLine1[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 UTF-8 characters maximum. 96 | char OSDTitleLine2[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 UTF-8 characters maximum. 97 | char DiscID[11]; 98 | char partition[33]; 99 | }; 100 | 101 | struct OSDResourceWriteReq 102 | { 103 | int index; 104 | u32 length; 105 | }; 106 | 107 | struct OSDResourceStat 108 | { 109 | u32 lengths[NUM_OSD_FILES_ENTS]; 110 | }; 111 | 112 | struct OSDResourceStatReq 113 | { 114 | char partition[33]; 115 | }; 116 | 117 | struct OSDResourceReadReq 118 | { 119 | char partition[33]; 120 | int index; 121 | }; 122 | 123 | struct OSD_TitlesTransit 124 | { 125 | char title1[OSD_TITLE_MAX_LEN_BYTES + 1]; 126 | char title2[OSD_TITLE_MAX_LEN_BYTES + 1]; 127 | }; 128 | 129 | struct OSD_MC_ResourceStatReq 130 | { 131 | char DiscID[11]; 132 | }; 133 | 134 | struct OSD_MC_ResourceReq 135 | { 136 | char DiscID[11]; 137 | char filename[32]; 138 | }; 139 | 140 | struct OSD_MC_ResourceReadReq 141 | { 142 | char DiscID[11]; 143 | char filename[32]; 144 | u32 length; 145 | }; 146 | 147 | struct HDLGameEntryTransit 148 | { 149 | char PartName[33]; 150 | char GameTitle[GAME_TITLE_MAX_LEN_BYTES + 1]; 151 | char DiscID[11]; 152 | u8 CompatibilityModeFlags; 153 | u8 TRType; 154 | u8 TRMode; 155 | u8 DiscType; 156 | u32 sectors; // In 2048-byte units 157 | }; 158 | 159 | #pragma pack(pop) 160 | 161 | #define HDLGMAN_SERVER_VERSION 0x0C 162 | #define HDLGMAN_CLIENT_VERSION 0x0C 163 | 164 | enum HDLGMAN_ClientServerCommands { 165 | // Server commands 166 | HDLGMAN_SERVER_RESPONSE = 0, 167 | HDLGMAN_SERVER_GET_VERSION, 168 | 169 | // Client commands 170 | HDLGMAN_CLIENT_SEND_VERSION, 171 | HDLGMAN_CLIENT_VERSION_ERR, // Server rejects connection to client (version mismatch). 172 | 173 | // Game installation commands 174 | HDLGMAN_SERVER_PREP_GAME_INST = 0x10, // Creates a new partition and will also automatically invoke HDLGMAN_SERVER_INIT_GAME_WRITE. 175 | HDLGMAN_SERVER_INIT_GAME_WRITE, // Opens an existing partition for writing. 176 | HDLGMAN_SERVER_INIT_GAME_READ, // Opens an existing partition for reading. 177 | HDLGMAN_SERVER_IO_STATUS, 178 | HDLGMAN_SERVER_CLOSE_GAME, 179 | HDLGMAN_SERVER_LOAD_GAME_LIST, 180 | HDLGMAN_SERVER_READ_GAME_LIST, 181 | HDLGMAN_SERVER_READ_GAME_LIST_ENTRY, 182 | HDLGMAN_SERVER_READ_GAME_ENTRY, 183 | HDLGMAN_SERVER_UPD_GAME_ENTRY, 184 | HDLGMAN_SERVER_DEL_GAME_ENTRY, 185 | HDLGMAN_SERVER_GET_GAME_PART_NAME, 186 | HDLGMAN_SERVER_GET_FREE_SPACE, 187 | 188 | // OSD-resource management 189 | HDLGMAN_SERVER_INIT_OSD_RESOURCES = 0x20, 190 | HDLGMAN_SERVER_OSD_RES_LOAD_INIT, 191 | HDLGMAN_SERVER_OSD_RES_LOAD, 192 | HDLGMAN_SERVER_WRITE_OSD_RESOURCES, 193 | HDLGMAN_SERVER_OSD_RES_WRITE_CANCEL, 194 | HDLGMAN_SERVER_GET_OSD_RES_STAT, 195 | HDLGMAN_SERVER_OSD_RES_READ, 196 | HDLGMAN_SERVER_OSD_RES_READ_TITLES, 197 | HDLGMAN_SERVER_INIT_DEFAULT_OSD_RESOURCES, // Same as HDLGMAN_SERVER_INIT_OSD_RESOURCES, but doesn't require the OSD titles and is designed for subsequent pre-built OSD resource file uploading (with HDLGMAN_SERVER_OSD_RES_LOAD) from the client. 198 | HDLGMAN_SERVER_OSD_MC_SAVE_CHECK = 0x40, 199 | HDLGMAN_SERVER_OSD_MC_GET_RES_STAT, 200 | HDLGMAN_SERVER_OSD_MC_RES_READ, 201 | 202 | HDLGMAN_SERVER_SHUTDOWN = 0xFF, 203 | }; 204 | 205 | #define HDLGMAN_IO_BLOCK_SIZE IO_BANKSIZE 206 | 207 | int HDLGManPrepareGameInstall(const wchar_t *GameTitle, const char *DiscID, const char *StartupFname, u8 DiscType, u32 SectorsInDiscLayer0, u32 SectorsInDiscLayer1, u8 CompatibilityModeFlags, u8 TRType, u8 TRMode); 208 | int HDLGManWriteGame(const void *buffer, u32 NumBytes); 209 | int HDLGManInitGameWrite(const char *partition, u32 sectors, u32 offset); // To open a created game for writing. 210 | int HDLGManInitGameRead(const char *partition, u32 sectors, u32 offset); // To open a created game for reading. 211 | int HDLGManGetIOStatus(void); 212 | int HDLGManReadGame(void *buffer, u32 NumBytes); 213 | int HDLGManCloseGame(void); 214 | int HDLGManLoadGameList(struct HDLGameEntry **GameList); 215 | int HDLGManLoadGameListEntry(struct HDLGameEntry *GameListEntry, int index); 216 | int HDLGManReadGameEntry(const char *partition, struct HDLGameEntry *GameEntry); 217 | int HDLGManUpdateGameEntry(struct HDLGameEntry *GameEntry); 218 | int HDLGManDeleteGameEntry(const char *partition); 219 | int HDLGManGetGamePartName(const char *DiscID, char *partition); 220 | unsigned long int HDLGManGetFreeSpace(void); 221 | 222 | int HDLGManInitOSDDefaultResources(const char *partition); 223 | int HDLGManInitOSDResources(const char *partition, const char *DiscID, const wchar_t *OSDTitleLine1, const wchar_t *OSDTitleLine2, int UseSaveData); 224 | int HDLGManOSDResourceLoad(int index, const void *buffer, u32 length); 225 | int HDLGManWriteOSDResources(void); 226 | int HDLGManOSDResourceWriteCancel(void); 227 | int HDLGManGetOSDResourcesStat(const char *partition, struct OSDResourceStat *stat); 228 | int HDLGManReadOSDResourceFile(const char *partition, int index, void *buffer, u32 length); 229 | int HDLGManGetGameInstallationOSDTitles(const char *partition, struct OSD_Titles *titles); 230 | 231 | int HDLGManCheckExistingMCSaveData(const char *DiscID); 232 | int HDLGManGetMCSaveDataFileStat(const char *DiscID, const char *filename); 233 | int HDLGManReadMCSaveDataFile(const char *DiscID, const char *filename, void *buffer, u32 length); 234 | 235 | int HDLGManPowerOffServer(void); 236 | -------------------------------------------------------------------------------- /HDLGManClient/HDLGManClient.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HDLGManClient", "HDLGManClient.vcxproj", "{A90B1017-392C-4FF5-AED7-56F1BEAC3150}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {A90B1017-392C-4FF5-AED7-56F1BEAC3150}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {A90B1017-392C-4FF5-AED7-56F1BEAC3150}.Debug|Win32.Build.0 = Debug|Win32 14 | {A90B1017-392C-4FF5-AED7-56F1BEAC3150}.Release|Win32.ActiveCfg = Release|Win32 15 | {A90B1017-392C-4FF5-AED7-56F1BEAC3150}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /HDLGManClient/HDLGManClient.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {A90B1017-392C-4FF5-AED7-56F1BEAC3150} 15 | Win32Proj 16 | HDLGManClient 17 | 18 | 19 | 20 | Application 21 | true 22 | Unicode 23 | 24 | 25 | Application 26 | false 27 | true 28 | Unicode 29 | v142 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | true 43 | 44 | 45 | false 46 | 47 | 48 | 49 | 50 | 51 | Level3 52 | Disabled 53 | WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 54 | 55 | 56 | Windows 57 | true 58 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);ws2_32.lib 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 70 | 71 | 72 | Windows 73 | true 74 | true 75 | true 76 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);ws2_32.lib 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /HDLGManClient/MainWindow.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/HDLGManClient/MainWindow.rc -------------------------------------------------------------------------------- /HDLGManClient/OSD.h: -------------------------------------------------------------------------------- 1 | typedef int iconIVECTOR[4]; 2 | typedef float iconFVECTOR[4]; 3 | 4 | typedef struct 5 | { 6 | unsigned char head[4]; // header = "PS2D" 7 | unsigned short type; // filetype, used to be "unknown1" (see MCICON_TYPE_* above) 8 | unsigned short nlOffset; // new line pos within title name 9 | unsigned unknown2; // unknown 10 | unsigned trans; // transparency 11 | iconIVECTOR bgCol[4]; // background color for each of the four points 12 | iconFVECTOR lightDir[3]; // directions of three light sources 13 | iconFVECTOR lightCol[3]; // colors of each of these sources 14 | iconFVECTOR lightAmbient; // ambient light 15 | unsigned short title[34]; // application title - NOTE: stored in sjis, NOT normal ascii 16 | unsigned char view[64]; // list icon filename 17 | unsigned char copy[64]; // copy icon filename 18 | unsigned char del[64]; // delete icon filename 19 | unsigned char unknown3[512]; // unknown 20 | } mcIcon; 21 | 22 | struct IconSysData 23 | { 24 | wchar_t title0[OSD_TITLE_MAX_LEN + 1]; 25 | wchar_t title1[OSD_TITLE_MAX_LEN + 1]; 26 | unsigned char bgcola; 27 | unsigned char bgcol0[3]; 28 | unsigned char bgcol1[3]; 29 | unsigned char bgcol2[3]; 30 | unsigned char bgcol3[3]; 31 | float lightdir0[3]; 32 | float lightdir1[3]; 33 | float lightdir2[3]; 34 | unsigned char lightcolamb[3]; 35 | unsigned char lightcol0[3]; 36 | unsigned char lightcol1[3]; 37 | unsigned char lightcol2[3]; 38 | wchar_t uninstallmes0[61]; 39 | wchar_t uninstallmes1[61]; 40 | wchar_t uninstallmes2[61]; 41 | }; 42 | 43 | struct ConvertedMcIcon 44 | { 45 | unsigned int HDDIconSysSize; 46 | char *HDDIconSys; 47 | unsigned int ListViewIconSize; 48 | void *ListViewIcon; 49 | unsigned int DeleteIconSize; 50 | void *DeleteIcon; 51 | }; 52 | 53 | int LoadIconSysFile(const unsigned char *buffer, int size, struct IconSysData *data); 54 | int GenerateHDDIconSysFile(const struct IconSysData *data, char *HDDIconSys, unsigned int OutputBufferLength); 55 | int GenerateHDDIconSysFileFromMCSave(const mcIcon *McIconSys, char *HDDIconSys, unsigned int OutputBufferLength, const wchar_t *title1, const wchar_t *title2); 56 | int LoadMcSaveSysFromPath(const wchar_t *SaveFilePath, mcIcon *McSaveIconSys); 57 | int VerifyMcSave(const wchar_t *SaveFolderPath); 58 | int ConvertMcSave(const wchar_t *SaveFolderPath, struct ConvertedMcIcon *ConvertedIcon, const wchar_t *OSDTitleLine1, const wchar_t *OSDTitleLine2); 59 | void FreeConvertedMcSave(struct ConvertedMcIcon *ConvertedIcon); 60 | int InstallGameInstallationOSDResources(const char *partition, const char *DiscID, const struct GameSettings *GameSettings, const struct ConvertedMcIcon *ConvertedIcon); 61 | int UpdateGameInstallationOSDResources(const char *partition, const wchar_t *title1, const wchar_t *title2); 62 | -------------------------------------------------------------------------------- /HDLGManClient/ViewIcon.icn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/HDLGManClient/ViewIcon.icn -------------------------------------------------------------------------------- /HDLGManClient/client.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "HDLGManClient.h" 6 | #include "system.h" 7 | #include "client.h" 8 | #include "main.h" 9 | #include "io.h" 10 | 11 | static struct sockaddr_in ServerSocketData; 12 | static SOCKET connection = INVALID_SOCKET; 13 | static SOCKET dataConnection = INVALID_SOCKET; 14 | 15 | static int DoSend(SOCKET s, void *buffer, int length) 16 | { 17 | int result, remaining; 18 | char *ptr; 19 | 20 | for (ptr = (char *)buffer, remaining = length, result = 0; remaining > 0; remaining -= result, ptr += result) { 21 | if ((result = send(s, ptr, remaining, 0)) <= 0) { 22 | // rcode = WSAGetLastError(); 23 | result = -EEXTCONNLOST; 24 | break; 25 | } 26 | } 27 | 28 | if (result > 0) 29 | result = length; 30 | 31 | return result; 32 | } 33 | 34 | int SendCmdPacket(const void *buffer, unsigned int command, int NumBytes) 35 | { 36 | int result; 37 | struct HDDToolsPacketHdr header; 38 | 39 | header.command = command; 40 | header.result = 0; 41 | header.PayloadLength = NumBytes; 42 | 43 | if ((result = DoSend(connection, (void *)&header, sizeof(header))) == sizeof(header)) { 44 | if (NumBytes > 0) 45 | result = DoSend(connection, (void *)buffer, NumBytes); 46 | else 47 | result = 0; 48 | } 49 | 50 | return result; 51 | } 52 | 53 | int SendData(const void *buffer, int NumBytes) 54 | { 55 | return DoSend(dataConnection, (void *)buffer, NumBytes); 56 | } 57 | 58 | static int DoRecv(SOCKET s, void *buffer, int length) 59 | { 60 | struct timeval timeout; 61 | int result, remaining; 62 | char *ptr; 63 | FD_SET readFDs; 64 | 65 | for (ptr = (char *)buffer, remaining = length, result = 0; remaining > 0; remaining -= result, ptr += result) { 66 | timeout.tv_sec = 30; 67 | timeout.tv_usec = 0; 68 | FD_ZERO(&readFDs); 69 | FD_SET(s, &readFDs); 70 | if (select(s + 1, &readFDs, NULL, NULL, &timeout) == 1) { 71 | if ((result = recv(s, ptr, remaining, 0)) <= 0) { 72 | // rcode = WSAGetLastError(); 73 | result = -EEXTCONNLOST; 74 | break; 75 | } 76 | } else { 77 | result = -EEXTCONNLOST; 78 | DisconnectSocketConnection(); 79 | break; 80 | } 81 | } 82 | 83 | if (result > 0) 84 | result = length; 85 | 86 | return result; 87 | } 88 | 89 | int GetResponse(void *buffer, int NumBytes) 90 | { 91 | int result; 92 | struct HDDToolsPacketHdr header; 93 | 94 | // Receive header. 95 | if ((result = DoRecv(connection, (void *)&header, sizeof(header))) == sizeof(header)) { 96 | // Receive payload. 97 | if (NumBytes > 0 && header.PayloadLength > 0) { 98 | if ((result = DoRecv(connection, buffer, (int)header.PayloadLength > NumBytes ? NumBytes : header.PayloadLength)) > 0) 99 | result = header.result; 100 | } else 101 | result = header.result; 102 | } 103 | 104 | return result; 105 | } 106 | 107 | int GetPayload(void *buffer, int NumBytes) 108 | { 109 | return DoRecv(connection, buffer, NumBytes); 110 | } 111 | 112 | int RecvData(void *buffer, int NumBytes) 113 | { 114 | return DoRecv(dataConnection, buffer, NumBytes); 115 | } 116 | 117 | int InitializeClientSys(void) 118 | { 119 | // Must be done at the beginning of every WinSock program 120 | WSADATA w; // used to store information about WinSock version 121 | 122 | if (WSAStartup(0x0202, &w)) { // there was an error 123 | return -EIO; 124 | } 125 | 126 | if (w.wVersion != 0x0202) { // wrong WinSock version! 127 | WSACleanup(); // unload ws2_32.dll 128 | return -EINVAL; 129 | } 130 | 131 | return 0; 132 | } 133 | 134 | void DeinitializeClientSys(void) 135 | { 136 | WSACleanup(); 137 | } 138 | 139 | int ConnectToServer(const char *ipAddress) 140 | { 141 | int result, value; 142 | 143 | connection = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Create socket 144 | 145 | ServerSocketData.sin_family = AF_INET; 146 | ServerSocketData.sin_port = htons(SERVER_PORT_NUM); 147 | ServerSocketData.sin_addr.s_addr = inet_addr(ipAddress); 148 | value = HDLGMAN_IO_BLOCK_SIZE * 2048; 149 | setsockopt(connection, SOL_SOCKET, SO_RCVBUF, (const char *)&value, sizeof(value)); 150 | 151 | result = connect(connection, (SOCKADDR *)&ServerSocketData, sizeof(ServerSocketData)); 152 | 153 | return (result >= 0 ? 0 : result); 154 | } 155 | 156 | int PrepareDataConnection(void) 157 | { 158 | struct sockaddr_in addr; 159 | SOCKET s; 160 | 161 | s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 162 | 163 | addr.sin_family = AF_INET; 164 | addr.sin_port = htons(SERVER_DATA_PORT_NUM); 165 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 166 | if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) == 0 && listen(s, 1) == 0) 167 | return s; 168 | 169 | return INVALID_SOCKET; 170 | } 171 | 172 | int AcceptDataConnection(int s) 173 | { 174 | SOCKET peer; 175 | struct timeval timeout; 176 | FD_SET readFDs; 177 | int result; 178 | 179 | timeout.tv_sec = 80; // Give more time than a standard TCP client may take to connect. 180 | timeout.tv_usec = 0; 181 | FD_ZERO(&readFDs); 182 | FD_SET(s, &readFDs); 183 | if (select(s + 1, &readFDs, NULL, NULL, &timeout) == 1) { 184 | peer = accept(s, NULL, 0); 185 | result = 0; 186 | } else { 187 | result = -EEXTCONNLOST; 188 | } 189 | 190 | shutdown(s, SD_BOTH); 191 | closesocket(s); 192 | 193 | if (result >= 0) { 194 | dataConnection = peer; 195 | return 0; 196 | } 197 | 198 | return result; 199 | } 200 | 201 | void CloseDataConnection(void) 202 | { 203 | char dummy; 204 | 205 | shutdown(dataConnection, SD_SEND); 206 | // Wait for remote to close the socket, which shall take place after all sent data has been received. 207 | while (recv(dataConnection, &dummy, sizeof(dummy), 0) > 0) 208 | ; 209 | closesocket(dataConnection); 210 | } 211 | 212 | void ClosePendingDataConnection(int s) 213 | { 214 | shutdown(s, SD_SEND); 215 | closesocket(s); 216 | } 217 | 218 | int ReconnectToServer(void) 219 | { 220 | int result, value; 221 | 222 | connection = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Create socket 223 | value = HDLGMAN_IO_BLOCK_SIZE * 2048; 224 | setsockopt(connection, SOL_SOCKET, SO_RCVBUF, (const char *)&value, sizeof(value)); 225 | if ((result = connect(connection, (SOCKADDR *)&ServerSocketData, sizeof(ServerSocketData))) >= 0) { 226 | result = ExchangeHandshakesWithServer(); 227 | } 228 | 229 | return result; 230 | } 231 | 232 | int ReconnectToServerForRead(const char *partition, u32 sectors, u32 offset) 233 | { 234 | s32 result; 235 | 236 | if ((result = HDLGManInitGameRead(partition, sectors, offset)) >= 0) 237 | result = 0; 238 | 239 | return result; 240 | } 241 | 242 | int ReconnectToServerForWrite(const char *DiscID, u32 sectors, u32 offset) 243 | { 244 | s32 result; 245 | char partition[33]; 246 | 247 | if ((result = HDLGManGetGamePartName(DiscID, partition)) >= 0) { 248 | if ((result = HDLGManInitGameWrite(partition, sectors, offset)) >= 0) 249 | result = 0; 250 | } 251 | 252 | return result; 253 | } 254 | 255 | int DisconnectSocketConnection(void) 256 | { 257 | shutdown(connection, SD_BOTH); 258 | return closesocket(connection); 259 | } 260 | 261 | int ExchangeHandshakesWithServer(void) 262 | { 263 | int version, result; 264 | 265 | // printf("Exchanging handshakes..."); 266 | 267 | version = -1; 268 | if ((result = SendCmdPacket(NULL, HDLGMAN_SERVER_GET_VERSION, 0)) >= 0) { 269 | if ((result = GetResponse(&version, sizeof(version))) == 0) { 270 | if (version != HDLGMAN_SERVER_VERSION) { 271 | // printf("Error: Unsupported server version - 0x%04x\n", version); 272 | result = -EINVAL; 273 | } else { 274 | /* Now, send the client's version. */ 275 | version = HDLGMAN_CLIENT_VERSION; 276 | SendCmdPacket(&version, HDLGMAN_CLIENT_SEND_VERSION, sizeof(version)); 277 | if ((result = GetResponse(NULL, 0)) != 0) { 278 | // printf("Server rejected connection, code: 0x%04x\n", result); 279 | } else { 280 | // printf("done\n"); 281 | } 282 | } 283 | } else { 284 | // printf("Error: Unable to retrieve the server's version number: %d\n", result); 285 | } 286 | } else { 287 | // printf("Error: Unable to send SERVER_GET_VERSION\n"); 288 | } 289 | 290 | return result; 291 | } 292 | -------------------------------------------------------------------------------- /HDLGManClient/client.h: -------------------------------------------------------------------------------- 1 | int SendCmdPacket(const void *buffer, unsigned int command, int NumBytes); // Command 2 | int SendData(const void *buffer, int NumBytes); // Data 3 | int GetResponse(void *buffer, int NumBytes); // Command 4 | int GetPayload(void *buffer, int NumBytes); // Command 5 | int RecvData(void *buffer, int NumBytes); // Data 6 | int ExchangeHandshakesWithServer(void); 7 | int DisconnectSocketConnection(void); 8 | 9 | int InitializeClientSys(void); 10 | void DeinitializeClientSys(void); 11 | int ConnectToServer(const char *ipAddress); 12 | int PrepareDataConnection(void); 13 | void CloseDataConnection(void); 14 | void ClosePendingDataConnection(int s); 15 | int AcceptDataConnection(int s); 16 | int ReconnectToServerForWrite(const char *DiscID, u32 sectors, u32 offset); 17 | int ReconnectToServerForRead(const char *partition, u32 sectors, u32 offset); 18 | int ReconnectToServer(void); 19 | -------------------------------------------------------------------------------- /HDLGManClient/icon_sys.txt: -------------------------------------------------------------------------------- 1 | PS2X 2 | title0 = 123 3 | title1 = 4 | bgcola = 64 5 | bgcol0 = 82,27,97 6 | bgcol1 = 127,85,70 7 | bgcol2 = 97,45,88 8 | bgcol3 = 127,65,79 9 | lightdir0 = 10.6422,-8.9692,-18.6699 10 | lightdir1 = -5.5809,-23.0448,21.7609 11 | lightdir2 = -19.7401,-21.2052,-7.6639 12 | lightcolamb = 38,38,38 13 | lightcol0 = 38,38,38 14 | lightcol1 = 38,38,38 15 | lightcol2 = 38,38,38 16 | uninstallmes0 = This will delete the game. 17 | uninstallmes1 = 18 | uninstallmes2 = 19 | -------------------------------------------------------------------------------- /HDLGManClient/install.h: -------------------------------------------------------------------------------- 1 | struct GameSettings 2 | { 3 | wchar_t FullTitle[GAME_TITLE_MAX_LEN + 1]; 4 | wchar_t OSDTitleLine1[OSD_TITLE_MAX_LEN + 1]; 5 | wchar_t OSDTitleLine2[OSD_TITLE_MAX_LEN + 1]; 6 | unsigned char CompatibilityModeFlags; 7 | unsigned char UseMDMA0; 8 | unsigned char DiscType; 9 | unsigned char IconSource; 10 | unsigned char source; 11 | wchar_t *SourcePath; 12 | wchar_t *IconSourcePath; // Valid and only used if IconSource=2. 13 | }; 14 | 15 | struct JobParams 16 | { 17 | int count; 18 | struct GameSettings *games; 19 | }; 20 | 21 | struct InstallerThreadParams 22 | { 23 | HWND ParentDialog; 24 | struct JobParams *jobs; 25 | }; 26 | 27 | struct RetrieveThreadParams 28 | { 29 | HWND ParentDialog; 30 | u32 sectors; 31 | char partition[33]; 32 | wchar_t *destination; 33 | }; 34 | 35 | enum InstallerThreadRemoteCommandValues { 36 | INSTALLER_CMD_NONE = 0, 37 | INSTALLER_CMD_ABORT, 38 | }; 39 | 40 | void StartInstallation(struct InstallerThreadParams *params); 41 | void StartCopy(struct RetrieveThreadParams *params); 42 | -------------------------------------------------------------------------------- /HDLGManClient/io.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "system.h" 7 | #include "iso9660.h" 8 | #include "io.h" 9 | 10 | enum IO_THREAD_CMD { 11 | IO_THREAD_CMD_NONE = 0, 12 | IO_THREAD_CMD_WRITE, 13 | IO_THREAD_CMD_WRITE_END, // Finish writing outstanding data and terminate. 14 | IO_THREAD_CMD_READ, 15 | IO_THREAD_CMD_READ_END 16 | }; 17 | 18 | struct IOState 19 | { 20 | void *buffer; 21 | struct BuffDesc *bd; 22 | unsigned short int WritePtr, ReadPtr; 23 | unsigned short int bufmax, nbufs; 24 | unsigned char state, command, sectorType; 25 | unsigned int remaining, lsn; 26 | unsigned int opt; 27 | HANDLE id, CmdAckEvent, InBufSema, OutBufSema, ioFD, IoThreadEvent; 28 | }; 29 | 30 | static struct IOState IOState; 31 | 32 | static int IOExecWriteNext(void) 33 | { 34 | void *buffer; 35 | const struct BuffDesc *bd; 36 | int result; 37 | 38 | result = 0; 39 | while (WaitForSingleObject(IOState.OutBufSema, 0) == WAIT_OBJECT_0) { 40 | buffer = (unsigned char *)IOState.buffer + IOState.ReadPtr * (unsigned int)IOState.bufmax * 2048; 41 | bd = &IOState.bd[IOState.ReadPtr]; 42 | 43 | do { 44 | result = writeFile(IOState.ioFD, buffer, bd->length); 45 | } while (result < 0 && result != -EIO); 46 | 47 | if (result >= 0) { // Update state 48 | IOState.ReadPtr = (IOState.ReadPtr + 1) % IOState.nbufs; 49 | ReleaseSemaphore(IOState.InBufSema, 1, NULL); 50 | } 51 | } 52 | 53 | return result; 54 | } 55 | 56 | static int IOExecReadNext(void) 57 | { 58 | void *buffer; 59 | struct BuffDesc *bd; 60 | unsigned short int sectors; 61 | unsigned int bytes; 62 | int result; 63 | 64 | result = 0; 65 | while ((IOState.remaining > 0) && (WaitForSingleObject(IOState.InBufSema, 0) == WAIT_OBJECT_0)) { 66 | sectors = IOState.remaining < IOState.bufmax ? IOState.remaining : IOState.bufmax; 67 | bytes = (unsigned int)sectors * 2048; 68 | 69 | buffer = (unsigned char *)IOState.buffer + IOState.WritePtr * (unsigned int)IOState.bufmax * 2048; 70 | bd = &IOState.bd[IOState.WritePtr]; 71 | 72 | // Read raw data 73 | do { 74 | result = ReadSectors(IOState.ioFD, IOState.sectorType, IOState.lsn, sectors, buffer); 75 | } while (result < 0 && result != -EIO); 76 | 77 | if (result >= 0) { 78 | bd->length = bytes; 79 | 80 | // Update state 81 | IOState.WritePtr = (IOState.WritePtr + 1) % IOState.nbufs; 82 | ReleaseSemaphore(IOState.OutBufSema, 1, NULL); 83 | IOState.remaining -= sectors; 84 | IOState.lsn += sectors; 85 | } 86 | } 87 | 88 | return result; 89 | } 90 | 91 | static DWORD WINAPI IOThread(void *arg) 92 | { 93 | int result; 94 | 95 | while (1) { 96 | WaitForSingleObject(IOState.IoThreadEvent, INFINITE); 97 | 98 | switch (IOState.command) { 99 | case IO_THREAD_CMD_WRITE: 100 | if (IOExecWriteNext() < 0) { 101 | IOState.state = IO_THREAD_STATE_ERROR; 102 | return IO_THREAD_STATE_ERROR; 103 | } 104 | break; 105 | case IO_THREAD_CMD_WRITE_END: 106 | // Finish writing all data 107 | while ((result = IOExecWriteNext()) > 0) {}; 108 | if (result < 0) 109 | IOState.state = IO_THREAD_STATE_ERROR; 110 | 111 | SetEvent(IOState.CmdAckEvent); 112 | return 0; 113 | case IO_THREAD_CMD_READ: 114 | if (IOExecReadNext() < 0) { 115 | IOState.state = IO_THREAD_STATE_ERROR; 116 | return IO_THREAD_STATE_ERROR; 117 | } 118 | break; 119 | case IO_THREAD_CMD_READ_END: 120 | SetEvent(IOState.CmdAckEvent); 121 | return 0; 122 | } 123 | } 124 | } 125 | 126 | static void IOExec(unsigned char cmd) 127 | { 128 | IOState.command = cmd; 129 | SetEvent(IOState.IoThreadEvent); 130 | } 131 | 132 | static void IOExecWait(unsigned char cmd) 133 | { 134 | IOState.command = cmd; 135 | SetEvent(IOState.IoThreadEvent); 136 | WaitForSingleObject(IOState.CmdAckEvent, INFINITE); 137 | } 138 | 139 | static int IOInitCommon(HANDLE fd, struct BuffDesc *bd, void *buffers, unsigned short int bufmax, unsigned short int nbufs) 140 | { 141 | int result; 142 | 143 | if ((IOState.IoThreadEvent = CreateEvent(NULL, FALSE, FALSE, L"io-CmdThread")) != NULL) { 144 | if ((IOState.CmdAckEvent = CreateEvent(NULL, FALSE, FALSE, L"io-CmdAck")) != NULL) { 145 | if ((IOState.InBufSema = CreateSemaphore(NULL, nbufs, nbufs, L"io-InBufSema")) != NULL) { 146 | if ((IOState.OutBufSema = CreateSemaphore(NULL, 0, nbufs, L"io-OutBufSema")) != NULL) { 147 | IOState.command = IO_THREAD_CMD_NONE; 148 | IOState.state = IO_THREAD_STATE_OK; 149 | IOState.bd = bd; 150 | IOState.buffer = buffers; 151 | IOState.bufmax = bufmax; 152 | IOState.nbufs = nbufs; 153 | IOState.WritePtr = 0; 154 | IOState.ReadPtr = 0; 155 | IOState.ioFD = fd; 156 | IOState.id = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&IOThread, NULL, 0, NULL); 157 | 158 | if (IOState.id == NULL) { 159 | result = GetLastError(); 160 | CloseHandle(IOState.IoThreadEvent); 161 | CloseHandle(IOState.CmdAckEvent); 162 | CloseHandle(IOState.InBufSema); 163 | } else 164 | result = 0; 165 | } else { 166 | CloseHandle(IOState.IoThreadEvent); 167 | CloseHandle(IOState.InBufSema); 168 | CloseHandle(IOState.CmdAckEvent); 169 | result = GetLastError(); 170 | } 171 | } else { 172 | CloseHandle(IOState.IoThreadEvent); 173 | CloseHandle(IOState.CmdAckEvent); 174 | result = GetLastError(); 175 | } 176 | } else { 177 | CloseHandle(IOState.IoThreadEvent); 178 | result = GetLastError(); 179 | } 180 | } else 181 | result = GetLastError(); 182 | 183 | return result; 184 | } 185 | 186 | int IOWriteInit(HANDLE fd, struct BuffDesc *bd, void *buffers, unsigned short int bufmax, unsigned short int nbufs) 187 | { 188 | return IOInitCommon(fd, bd, buffers, bufmax, nbufs); 189 | } 190 | 191 | int IOReadInit(HANDLE fd, struct BuffDesc *bd, void *buffers, unsigned short int bufmax, unsigned short int nbufs, unsigned int remaining, unsigned char sectorType) 192 | { 193 | int result; 194 | IOState.remaining = remaining; 195 | IOState.lsn = 0; 196 | IOState.sectorType = sectorType; 197 | if ((result = IOInitCommon(fd, bd, buffers, bufmax, nbufs)) >= 0) 198 | IOExec(IO_THREAD_CMD_READ); 199 | 200 | return result; 201 | } 202 | 203 | // Note: a call to IOSignalWriteDone() must follow a call to IOGetNextWrBuffer()! 204 | void *IOGetNextWrBuffer(void) 205 | { 206 | WaitForSingleObject(IOState.InBufSema, INFINITE); 207 | return ((unsigned char *)IOState.buffer + IOState.bufmax * (unsigned int)IOState.WritePtr * 2048); 208 | } 209 | 210 | void IOSignalWriteDone(int length) 211 | { 212 | struct BuffDesc *bd; 213 | 214 | bd = &IOState.bd[IOState.WritePtr]; 215 | bd->length = length; 216 | IOState.WritePtr = (IOState.WritePtr + 1) % IOState.nbufs; 217 | ReleaseSemaphore(IOState.OutBufSema, 1, NULL); 218 | IOExec(IO_THREAD_CMD_WRITE); 219 | } 220 | 221 | int IORead(void *buffer) 222 | { 223 | struct BuffDesc *bd; 224 | const void *pReadData; 225 | int length; 226 | 227 | WaitForSingleObject(IOState.OutBufSema, INFINITE); 228 | bd = &IOState.bd[IOState.ReadPtr]; 229 | pReadData = (const void *)((unsigned char *)IOState.buffer + IOState.ReadPtr * (unsigned int)IOState.bufmax * 2048); 230 | IOState.ReadPtr = (IOState.ReadPtr + 1) % IOState.nbufs; 231 | 232 | // Copy out the data read 233 | memcpy(buffer, pReadData, bd->length); 234 | length = (int)bd->length; 235 | 236 | ReleaseSemaphore(IOState.InBufSema, 1, NULL); 237 | 238 | // Continue reading 239 | IOExec(IO_THREAD_CMD_READ); 240 | 241 | return length; 242 | } 243 | 244 | int IOReadNext(const void **buffer) 245 | { 246 | struct BuffDesc *bd; 247 | int length; 248 | 249 | WaitForSingleObject(IOState.OutBufSema, INFINITE); 250 | bd = &IOState.bd[IOState.ReadPtr]; 251 | *buffer = (const void *)((unsigned char *)IOState.buffer + IOState.ReadPtr * (unsigned int)IOState.bufmax * 2048); 252 | IOState.ReadPtr = (IOState.ReadPtr + 1) % IOState.nbufs; 253 | length = (int)bd->length; 254 | 255 | return length; 256 | } 257 | 258 | void IOReadAdvance(void) 259 | { 260 | ReleaseSemaphore(IOState.InBufSema, 1, NULL); 261 | 262 | // Continue reading 263 | IOExec(IO_THREAD_CMD_READ); 264 | } 265 | 266 | static void IOEnd(void) 267 | { 268 | CloseHandle(IOState.IoThreadEvent); 269 | CloseHandle(IOState.CmdAckEvent); 270 | CloseHandle(IOState.InBufSema); 271 | CloseHandle(IOState.OutBufSema); 272 | } 273 | 274 | int IOEndWrite(void) 275 | { 276 | IOExecWait(IO_THREAD_CMD_WRITE_END); 277 | IOEnd(); 278 | 279 | return IOState.state; 280 | } 281 | 282 | int IOEndRead(void) 283 | { 284 | IOExecWait(IO_THREAD_CMD_READ_END); 285 | IOEnd(); 286 | 287 | return IOState.state; 288 | } 289 | 290 | int IOGetStatus(void) 291 | { 292 | return IOState.state; 293 | } 294 | 295 | int IOAlloc(struct BuffDesc **bdOut, void **ioBufferOut) 296 | { 297 | struct BuffDesc *bd; 298 | void *ioBuffer; 299 | int result; 300 | 301 | if ((bd = malloc(sizeof(struct BuffDesc) * IO_BANKMAX)) != NULL) { 302 | if ((ioBuffer = malloc(IO_BANKMAX * IO_BANKSIZE * 2048)) != NULL) { 303 | *bdOut = bd; 304 | *ioBufferOut = ioBuffer; 305 | result = 0; 306 | } else { 307 | free(bd); 308 | result = -ENOMEM; 309 | } 310 | } else 311 | result = -ENOMEM; 312 | 313 | return result; 314 | } 315 | 316 | void IOFree(struct BuffDesc **bdOut, void **ioBufferOut) 317 | { 318 | if (*bdOut != NULL) { 319 | free(*bdOut); 320 | *bdOut = NULL; 321 | } 322 | if (*ioBufferOut != NULL) { 323 | free(*ioBufferOut); 324 | *ioBufferOut = NULL; 325 | } 326 | } 327 | -------------------------------------------------------------------------------- /HDLGManClient/io.h: -------------------------------------------------------------------------------- 1 | struct BuffDesc 2 | { 3 | int length; 4 | }; 5 | 6 | enum IO_THREAD_STATE { 7 | IO_THREAD_STATE_OK = 0, 8 | IO_THREAD_STATE_ERROR, // Thread will also no longer receive commands. 9 | }; 10 | 11 | // IO parameters 12 | #define IO_BANKMAX 32 13 | #define IO_BANKSIZE 2048 // 256 * 2048 (0.5MB) * 32 banks = 16MB total 14 | 15 | int IOWriteInit(HANDLE fd, struct BuffDesc *bd, void *buffers, unsigned short int bufmax, unsigned short int nbufs); 16 | int IOReadInit(HANDLE fd, struct BuffDesc *bd, void *buffers, unsigned short int bufmax, unsigned short int nbufs, unsigned int remaining, unsigned char sectorType); 17 | void *IOGetNextWrBuffer(void); 18 | void IOSignalWriteDone(int length); 19 | int IOReadNext(const void **buffer); 20 | void IOReadAdvance(void); 21 | int IORead(void *buffer); 22 | int IOEndWrite(void); 23 | int IOEndRead(void); 24 | int IOGetStatus(void); 25 | int IOAlloc(struct BuffDesc **bdOut, void **ioBufferOut); 26 | void IOFree(struct BuffDesc **bdOut, void **ioBufferOut); 27 | -------------------------------------------------------------------------------- /HDLGManClient/iso9660.h: -------------------------------------------------------------------------------- 1 | #pragma pack(push, 1) 2 | 3 | /* ISO9660 filesystem directory record */ 4 | struct iso9660_dirRec 5 | { 6 | u8 lenDR; 7 | u8 lenExAttr; 8 | 9 | u32 extentLoc_LE; 10 | u32 extentLoc_BE; 11 | 12 | u32 dataLen_LE; 13 | u32 dataLen_BE; 14 | 15 | u8 recDateTime[7]; 16 | 17 | u8 fileFlags; 18 | u8 fileUnitSz; 19 | u8 interleaveGapSz; 20 | 21 | u16 volumeSeqNum_LE; 22 | u16 volumeSeqNum_BE; 23 | 24 | u8 lenFI; 25 | u8 fileIdentifier; /* The actual length is specified by lenFI */ 26 | 27 | /* There are more fields after this. */ 28 | /* Padding field; Only present if the length of the file identifier is an even number. */ 29 | /* Field for system use; up to lenDR */ 30 | }; 31 | 32 | /* ISO9660 filesystem file path table */ 33 | struct iso9660_pathtable 34 | { 35 | u8 lenDI; 36 | u8 lenExRec; 37 | 38 | u32 extLoc; 39 | 40 | u16 parentDirNum; 41 | 42 | u8 dirIdentifier; /* The actual length is specified by lenDI. */ 43 | 44 | /* There are more fields after this. */ 45 | /* Padding field; Only present if the length of the directory identifier is an even number. */ 46 | }; 47 | 48 | #pragma pack(pop) 49 | 50 | int ParsePS2CNF(void *discimg, char *DiscID, char *StartupFilename, u8 *targetpath, u8 sectortype); 51 | u32 GetFileLSN(const char *path, void *discimg, u8 sectortype, unsigned int *file_size); 52 | int GetDiscInfo(u8 source, void *discImg, u32 *nSectorsLayer0, u32 *nSectorsLayer1, u8 *discType); 53 | int ReadSectors(void *discImg, u8 sectortype, u32 lsn, unsigned int sectors, void *buffer); 54 | -------------------------------------------------------------------------------- /HDLGManClient/main.h: -------------------------------------------------------------------------------- 1 | //#define DEBUG_MODE /* Define this to enable verbose debugging messages */ 2 | //#define UI_TEST_MODE //Define this to enable UI testing mode (Will simulate a server connection, but no connection will take place). 3 | 4 | // Extended error codes. 5 | #define EEXTCONNLOST 0x2000 6 | #define EEXTABORT 0x4000 7 | 8 | #ifdef DEBUG_MODE 9 | #define DEBUG_PRINTF printf 10 | #else 11 | #define DEBUG_PRINTF(...) 12 | #endif 13 | 14 | #define IO_BUFFER_SIZE IO_BANKSIZE 15 | #define RETRY_COUNT 3 // Maximum number of attempts to make, for failures to read/write to the server. 16 | #define RECONNECT_COUNT 5 /* Maximum number of reconnection attempts to make, for every failed attempt to read/write. \ 17 | Note that the maximum number of connection attempts would be equal to RETRY_COUNT*RECONNECT_COUNT. */ 18 | 19 | /* SCE disc types */ 20 | #define SCECdPSCD 0x10 21 | #define SCECdPSCDDA 0x11 22 | #define SCECdPS2CD 0x12 23 | #define SCECdPS2CDDA 0x13 24 | #define SCECdPS2DVD 0x14 25 | 26 | struct HDLGameEntry 27 | { 28 | char PartName[33]; 29 | wchar_t GameTitle[GAME_TITLE_MAX_LEN + 1]; 30 | char DiscID[11]; 31 | u8 CompatibilityModeFlags; 32 | u8 TRType; 33 | u8 TRMode; 34 | u8 DiscType; 35 | u32 sectors; // In 2048-byte units 36 | }; 37 | 38 | struct OSD_Titles 39 | { 40 | wchar_t title1[OSD_TITLE_MAX_LEN + 1]; 41 | wchar_t title2[OSD_TITLE_MAX_LEN + 1]; 42 | }; 43 | -------------------------------------------------------------------------------- /HDLGManClient/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/HDLGManClient/resource.h -------------------------------------------------------------------------------- /HDLGManClient/system.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "HDLGManClient.h" 9 | #include "main.h" 10 | #include "system.h" 11 | 12 | /* Platform specific functions are located below here. */ 13 | 14 | #define _WIN32_WINNT 0x500 15 | 16 | #include 17 | // #include //Not available in Microsoft Visual Studio 2010. 18 | #include 19 | 20 | #ifndef IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX 21 | #define IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX 0x24050 22 | #endif 23 | 24 | int SystemDriveGetDiscInfo(void *driveH, u32 *nSectors, u8 *discType) 25 | { 26 | DWORD dwNotUsed; 27 | DISK_GEOMETRY_EX discGeometry; 28 | 29 | if (!DeviceIoControl(driveH, IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX, NULL, 0, &discGeometry, sizeof(discGeometry), &dwNotUsed, NULL)) { 30 | return (-EIO); 31 | } 32 | 33 | *nSectors = (u32)(discGeometry.DiskSize.QuadPart / discGeometry.Geometry.BytesPerSector); 34 | 35 | if (discGeometry.Geometry.BytesPerSector != 2048) { 36 | return (-1); 37 | } 38 | 39 | #if 0 40 | if ((discGeometry.Geometry.BytesPerSector == 2352)) { 41 | *discType = 1; /* Assume that it's a ISO9660 MODE 1/2048 filesystem disc first. */ 42 | 43 | } else 44 | #endif 45 | *discType = 0xFF; /* The disc has 2048 byte sectors. */ 46 | 47 | return (0); 48 | } 49 | 50 | void displayAlertMsg(const wchar_t *message, ...) 51 | { 52 | wchar_t TextBuffer[128]; 53 | 54 | va_list args; 55 | va_start(args, message); 56 | vswprintf(TextBuffer, sizeof(TextBuffer) / sizeof(wchar_t), message, args); 57 | MessageBoxW(NULL, TextBuffer, L"Error", MB_OK | MB_ICONERROR); 58 | va_end(args); 59 | } 60 | 61 | void *openFile(wchar_t *path, int mode) 62 | { 63 | DWORD dwDesiredAccess = 0, dwCreationDisposition = 0, dwShareMode = 0; 64 | void *handle; 65 | 66 | if (mode & O_RDONLY) { 67 | dwDesiredAccess = GENERIC_READ; 68 | dwCreationDisposition = OPEN_EXISTING; 69 | dwShareMode = FILE_SHARE_READ; 70 | } 71 | if (mode & O_WRONLY) { 72 | dwDesiredAccess = GENERIC_WRITE; 73 | if (mode & (O_CREAT | O_TRUNC)) 74 | dwCreationDisposition = CREATE_ALWAYS; 75 | else 76 | dwCreationDisposition = OPEN_EXISTING; 77 | } 78 | 79 | handle = CreateFile(path, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); 80 | 81 | return ((handle != INVALID_HANDLE_VALUE) ? handle : NULL); 82 | } 83 | 84 | void closeFile(void *handle) 85 | { 86 | CloseHandle(handle); 87 | } 88 | 89 | int readFile(void *handle, void *buffer, int nbytes) 90 | { 91 | u32 numberOfBytesRead; 92 | 93 | return ((ReadFile(handle, buffer, nbytes, &numberOfBytesRead, NULL)) ? nbytes : 0); 94 | } 95 | 96 | int writeFile(void *handle, void *buffer, int nbytes) 97 | { 98 | u32 numberOfBytesRead; 99 | 100 | return ((WriteFile(handle, buffer, nbytes, &numberOfBytesRead, NULL)) ? nbytes : 0); 101 | } 102 | 103 | s64 seekFile(void *handle, s64 offset, int origin) 104 | { 105 | LARGE_INTEGER NewFilePointer, FilePointer; 106 | BOOL result; 107 | 108 | NewFilePointer.QuadPart = offset; 109 | 110 | result = SetFilePointerEx(handle, NewFilePointer, &FilePointer, origin); 111 | 112 | return ((result != 0) ? FilePointer.QuadPart : (-1)); 113 | } 114 | 115 | unsigned long int timemsec(void) 116 | { 117 | return GetTickCount(); 118 | } 119 | 120 | unsigned long int diffmsec(unsigned long int d1, unsigned long int d2) 121 | { 122 | if (d2 < d1) 123 | return (ULONG_MAX - d1 + d2); 124 | else 125 | return (d2 - d1); 126 | } 127 | -------------------------------------------------------------------------------- /HDLGManClient/system.h: -------------------------------------------------------------------------------- 1 | typedef signed char s8; 2 | typedef unsigned char u8; 3 | typedef signed short int s16; 4 | typedef unsigned short int u16; 5 | typedef signed int s32; 6 | typedef unsigned int u32; 7 | typedef signed long long int s64; 8 | typedef unsigned long long int u64; 9 | 10 | int SystemDriveGetDiscInfo(void *driveH, u32 *nSectors, u8 *discType); 11 | void *openFile(wchar_t *path, int mode); 12 | void closeFile(void *handle); 13 | int readFile(void *handle, void *buffer, int nbytes); 14 | int writeFile(void *handle, void *buffer, int nbytes); 15 | s64 seekFile(void *handle, s64 offset, int origin); 16 | unsigned long int timemsec(void); 17 | unsigned long int diffmsec(unsigned long int d1, unsigned long int d2); 18 | 19 | void displayAlertMsg(const wchar_t *message, ...); 20 | 21 | #ifndef O_RDONLY 22 | #define O_RDONLY 1 23 | #define O_WRONLY 2 24 | #define O_RDWR 3 25 | 26 | #define O_CREAT 00100 27 | #define O_TRUNC 01000 28 | #define O_APPEND 02000 /* set append mode */ 29 | #endif 30 | -------------------------------------------------------------------------------- /HDLGameList.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include "main.h" 16 | #ifdef ENABLE_NETWORK_SUPPORT 17 | #include 18 | #include 19 | #endif 20 | 21 | #include "HDLGameList.h" 22 | #include "system.h" 23 | #include "hdlfs/hdlfs.h" 24 | 25 | struct HDLGameLinkedListNode 26 | { 27 | struct HDLGameLinkedListNode *next; 28 | struct HDLGameEntry HDLGameEntry; 29 | }; 30 | 31 | static int LoadHDLGameListIntoBuffer(struct HDLGameEntry **GameList); 32 | static void FreeHDLGameListInBuffer(struct HDLGameEntry *GameList); 33 | static unsigned int CurrentHDLGameListGeneration = 0; 34 | 35 | static struct HDLGameEntry *CentralGameList = NULL; 36 | static int NumGamesInCentralGameList = 0; 37 | static int CentralGameListLockSemaID; 38 | 39 | extern struct RuntimeData RuntimeData; 40 | 41 | void LockCentralHDLGameList(void) 42 | { 43 | WaitSema(CentralGameListLockSemaID); 44 | } 45 | 46 | void UnlockCentralHDLGameList(void) 47 | { 48 | SignalSema(CentralGameListLockSemaID); 49 | } 50 | 51 | void InitCentralHDLGameList(void) 52 | { 53 | ee_sema_t sema; 54 | sema.init_count = 1; 55 | sema.max_count = 1; 56 | sema.attr = 0; 57 | sema.option = (u32) "GameListLock"; 58 | CentralGameListLockSemaID = CreateSema(&sema); 59 | } 60 | 61 | void DeinitCentralHDLGameList(void) 62 | { 63 | WaitSema(CentralGameListLockSemaID); 64 | DeleteSema(CentralGameListLockSemaID); 65 | FreeHDLGameList(); 66 | } 67 | 68 | static int GameEntryComparator(const void *e1, const void *e2) 69 | { 70 | return (strcmp(((struct HDLGameEntry *)e1)->GameTitle, ((struct HDLGameEntry *)e2)->GameTitle)); 71 | } 72 | 73 | int LoadHDLGameList(struct HDLGameEntry **GameList) 74 | { 75 | LockCentralHDLGameList(); 76 | 77 | FreeHDLGameListInBuffer(CentralGameList); 78 | NumGamesInCentralGameList = LoadHDLGameListIntoBuffer(&CentralGameList); 79 | if (RuntimeData.SortTitles) 80 | qsort(CentralGameList, NumGamesInCentralGameList, sizeof(struct HDLGameEntry), &GameEntryComparator); 81 | 82 | CurrentHDLGameListGeneration++; 83 | 84 | UnlockCentralHDLGameList(); 85 | 86 | if (GameList != NULL) 87 | *GameList = CentralGameList; 88 | 89 | return NumGamesInCentralGameList; 90 | } 91 | 92 | unsigned int GetHDLGameListGeneration(void) 93 | { 94 | return CurrentHDLGameListGeneration; 95 | } 96 | 97 | int GetHDLGameList(struct HDLGameEntry **GameList) 98 | { 99 | if (GameList != NULL) 100 | *GameList = CentralGameList; 101 | return NumGamesInCentralGameList; 102 | } 103 | 104 | void FreeHDLGameList(void) 105 | { 106 | FreeHDLGameListInBuffer(CentralGameList); 107 | NumGamesInCentralGameList = 0; 108 | CentralGameList = NULL; 109 | } 110 | 111 | static int LoadHDLGameListIntoBuffer(struct HDLGameEntry **GameList) 112 | { 113 | struct HDLGameLinkedListNode *LinkedList, *first, *prev; 114 | struct HDLGameEntry GameEntry; 115 | iox_dirent_t dirent; 116 | int result, fd; 117 | unsigned int NumGames, i; 118 | 119 | DEBUG_PRINTF("Loading game list...\n"); 120 | 121 | NumGames = 0; 122 | first = NULL; 123 | LinkedList = NULL; 124 | *GameList = NULL; 125 | result = 0; 126 | if ((fd = fileXioDopen("hdd0:")) >= 0) { 127 | while (fileXioDread(fd, &dirent) > 0) { 128 | /* The APA driver stores the partition type in the mode field. */ 129 | if (dirent.stat.mode == HDL_FS_MAGIC && !(dirent.stat.attr & APA_FLAG_SUB)) { 130 | if (RetrieveGameInstallationSector(dirent.stat.private_5, dirent.name, &GameEntry) == 0) { 131 | /* The head of the list needs to be formed first. */ 132 | if (first == NULL) { 133 | LinkedList = malloc(sizeof(struct HDLGameLinkedListNode)); 134 | first = LinkedList; 135 | } else { 136 | LinkedList->next = malloc(sizeof(struct HDLGameLinkedListNode)); 137 | LinkedList = LinkedList->next; 138 | } 139 | 140 | NumGames++; 141 | memcpy(&LinkedList->HDLGameEntry, &GameEntry, sizeof(LinkedList->HDLGameEntry)); 142 | LinkedList->next = NULL; 143 | } 144 | } 145 | } 146 | fileXioDclose(fd); 147 | } 148 | 149 | /* Now, if no errors occurred, begin consolidating the game list. */ 150 | if (result >= 0 && NumGames > 0) { 151 | *GameList = malloc(sizeof(struct HDLGameEntry) * NumGames); 152 | LinkedList = first; 153 | for (i = 0; LinkedList != NULL; i++) { 154 | memcpy(&(*GameList)[i], &LinkedList->HDLGameEntry, sizeof(struct HDLGameEntry)); 155 | 156 | prev = LinkedList; 157 | LinkedList = LinkedList->next; 158 | free(prev); 159 | } 160 | 161 | result = NumGames; 162 | } 163 | 164 | DEBUG_PRINTF("Game list loaded. result: %d\n", result); 165 | 166 | return (result < 0 ? 0 : result); 167 | } 168 | 169 | static void FreeHDLGameListInBuffer(struct HDLGameEntry *GameList) 170 | { 171 | if (GameList != NULL) 172 | free(GameList); 173 | } 174 | -------------------------------------------------------------------------------- /HDLGameList.h: -------------------------------------------------------------------------------- 1 | struct HDLGameEntry 2 | { 3 | char PartName[33]; 4 | char DiscID[11]; 5 | u8 CompatibilityModeFlags; 6 | u8 TRType; 7 | u8 TRMode; 8 | u8 DiscType; 9 | u32 sectors; 10 | char GameTitle[GAME_TITLE_MAX_LEN_BYTES + 1]; 11 | }; 12 | 13 | /* Function prototypes */ 14 | void LockCentralHDLGameList(void); 15 | void UnlockCentralHDLGameList(void); 16 | void InitCentralHDLGameList(void); 17 | void DeinitCentralHDLGameList(void); 18 | int LoadHDLGameList(struct HDLGameEntry **GameList); 19 | unsigned int GetHDLGameListGeneration(void); 20 | int GetHDLGameList(struct HDLGameEntry **GameList); 21 | void FreeHDLGameList(void); 22 | -------------------------------------------------------------------------------- /HDLGameSvr.h: -------------------------------------------------------------------------------- 1 | /* Server configuration */ 2 | #define MAX_CLIENTS 1 3 | #define SERVER_PORT_NUM 45061 4 | #define SERVER_DATA_PORT_NUM 45062 5 | #define SERVER_MAIN_THREAD_PRIORITY 0x10 6 | #define SERVER_CLIENT_THREAD_PRIORITY 0x11 7 | #define SERVER_IO_THREAD_PRIORITY 0x12 8 | #define SERVER_THREAD_STACK_SIZE 0xA00 9 | #define CLIENT_THREAD_STACK_SIZE 0xA00 10 | #define CLIENT_DATA_THREAD_STACK_SIZE 0xA00 11 | 12 | struct HDDToolsPacketHdr 13 | { 14 | u32 command; 15 | u32 PayloadLength; 16 | int result; 17 | } __attribute__((__packed__)); 18 | 19 | struct HDLGameInfo 20 | { 21 | char GameTitle[GAME_TITLE_MAX_LEN_BYTES + 1]; 22 | char DiscID[11]; /* E.g. SXXX-99999 */ 23 | char StartupFname[14]; /* E.g. "SXXX-999.99;1" */ 24 | u8 DiscType; 25 | u32 SectorsInDiscLayer0; 26 | u32 SectorsInDiscLayer1; 27 | u8 CompatibilityFlags; 28 | u8 TRType; 29 | u8 TRMode; 30 | } __attribute__((__packed__)); 31 | 32 | struct IOInitReq 33 | { 34 | u32 sectors, offset; 35 | char partition[33]; 36 | } __attribute__((__packed__)); 37 | 38 | struct HDLGameEntryTransit 39 | { 40 | char PartName[33]; 41 | char GameTitle[GAME_TITLE_MAX_LEN_BYTES + 1]; 42 | char DiscID[11]; 43 | u8 CompatibilityModeFlags; 44 | u8 TRType; 45 | u8 TRMode; 46 | u8 DiscType; 47 | u32 sectors; // In 2048-byte units 48 | } __attribute__((__packed__)); 49 | 50 | struct OSDResourceInitReq 51 | { 52 | int UseSaveData; 53 | char OSDTitleLine1[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum. 54 | char OSDTitleLine2[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum. 55 | char DiscID[11]; 56 | char partition[33]; 57 | } __attribute__((__packed__)); 58 | 59 | struct OSDResourceWriteReq 60 | { 61 | int index; 62 | u32 length; 63 | } __attribute__((__packed__)); 64 | 65 | struct OSDResourceStat 66 | { 67 | u32 lengths[NUM_OSD_FILES_ENTS]; 68 | } __attribute__((__packed__)); 69 | 70 | struct OSDResourceStatReq 71 | { 72 | char partition[33]; 73 | } __attribute__((__packed__)); 74 | 75 | struct OSDResourceReadReq 76 | { 77 | char partition[33]; 78 | int index; 79 | } __attribute__((__packed__)); 80 | 81 | struct OSD_TitlesTransit 82 | { 83 | char OSDTitleLine1[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum. 84 | char OSDTitleLine2[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum. 85 | } __attribute__((__packed__)); 86 | 87 | struct OSD_MC_ResourceStatReq 88 | { 89 | char DiscID[11]; 90 | } __attribute__((__packed__)); 91 | 92 | struct OSD_MC_ResourceReq 93 | { 94 | char DiscID[11]; 95 | char filename[32]; 96 | } __attribute__((__packed__)); 97 | 98 | struct OSD_MC_ResourceReadReq 99 | { 100 | char DiscID[11]; 101 | char filename[32]; 102 | u32 length; 103 | } __attribute__((__packed__)); 104 | 105 | #define HDLGMAN_SERVER_VERSION 0x0C 106 | #define HDLGMAN_CLIENT_VERSION 0x0C 107 | 108 | enum HDLGMAN_ClientServerCommands { 109 | // Server commands 110 | HDLGMAN_SERVER_RESPONSE = 0x00, 111 | HDLGMAN_SERVER_GET_VERSION, 112 | 113 | // Client commands 114 | HDLGMAN_CLIENT_SEND_VERSION, 115 | HDLGMAN_CLIENT_VERSION_ERR, // Server rejects connection to client (version mismatch). 116 | 117 | // Game installation commands 118 | HDLGMAN_SERVER_PREP_GAME_INST = 0x10, // Creates a new partition and will also automatically invoke HDLGMAN_SERVER_INIT_GAME_WRITE. 119 | HDLGMAN_SERVER_INIT_GAME_WRITE, // Opens an existing partition for writing. 120 | HDLGMAN_SERVER_INIT_GAME_READ, // Opens an existing partition for reading. 121 | HDLGMAN_SERVER_IO_STATUS, 122 | HDLGMAN_SERVER_CLOSE_GAME, 123 | HDLGMAN_SERVER_LOAD_GAME_LIST, 124 | HDLGMAN_SERVER_READ_GAME_LIST, 125 | HDLGMAN_SERVER_READ_GAME_LIST_ENTRY, 126 | HDLGMAN_SERVER_READ_GAME_ENTRY, 127 | HDLGMAN_SERVER_UPD_GAME_ENTRY, 128 | HDLGMAN_SERVER_DEL_GAME_ENTRY, 129 | HDLGMAN_SERVER_GET_GAME_PART_NAME, 130 | HDLGMAN_SERVER_GET_FREE_SPACE, 131 | 132 | // OSD-resource management 133 | HDLGMAN_SERVER_INIT_OSD_RESOURCES = 0x20, 134 | HDLGMAN_SERVER_OSD_RES_LOAD_INIT, 135 | HDLGMAN_SERVER_OSD_RES_LOAD, 136 | HDLGMAN_SERVER_WRITE_OSD_RESOURCES, 137 | HDLGMAN_SERVER_OSD_RES_WRITE_CANCEL, 138 | HDLGMAN_SERVER_GET_OSD_RES_STAT, 139 | HDLGMAN_SERVER_OSD_RES_READ, 140 | HDLGMAN_SERVER_OSD_RES_READ_TITLES, 141 | HDLGMAN_SERVER_INIT_DEFAULT_OSD_RESOURCES, // Same as HDLGMAN_SERVER_INIT_OSD_RESOURCES, but doesn't require the OSD titles and is designed for subsequent pre-built OSD resource file uploading (with HDLGMAN_SERVER_OSD_RES_LOAD) from the client. 142 | HDLGMAN_SERVER_OSD_MC_SAVE_CHECK, 143 | HDLGMAN_SERVER_OSD_MC_GET_RES_STAT, 144 | HDLGMAN_SERVER_OSD_MC_RES_READ, 145 | 146 | HDLGMAN_SERVER_SHUTDOWN = 0xFF, 147 | }; 148 | 149 | // Must be large enough to support sending & receiving all parameters and be a multiple of 64. Only game reading/writing will use external buffers. 150 | #define HDLGMAN_RECV_MAX (128 * 1024) 151 | #define HDLGMAN_SEND_MAX (128 * 1024) 152 | 153 | /* Client status bits */ 154 | #define CLIENT_STATUS_VERSION_VERIFIED 0x01 155 | #define CLIENT_STATUS_OPENED_FILE 0x02 156 | #define CLIENT_STATUS_MOUNTED_FS 0x04 157 | #define CLIENT_STATUS_CONNECTED 0x80 158 | 159 | /* Server status bits */ 160 | #define SERVER_STATUS_THREAD_RUN 0x80 161 | 162 | /* Function prototypes. */ 163 | int InitializeStartServer(void); 164 | void DeinitializeServer(void); // Shut down the server. 165 | -------------------------------------------------------------------------------- /IconLoader.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "IconLoader.h" 7 | 8 | #define ITOF10(x) ((float)(x) / 1024.0f) 9 | #define ITOF12(x) ((float)(x) / 4096.0f) 10 | #define FTOI10(x) ((short)((x)*1024.0f)) 11 | #define FTOI12(x) ((short)((x)*4096.0f)) 12 | 13 | static inline int DecompressRLEData(void *output, unsigned int OutputBufferLength, const void *PackedData) 14 | { 15 | const void *PackedDataPayload; 16 | unsigned int PackedDataLength, offset; 17 | short int *pInput, BlockLength; 18 | unsigned short int *pOutput, i; 19 | 20 | PackedDataLength = *(unsigned int *)PackedData; 21 | PackedDataPayload = (void *)((unsigned int)PackedData + 4); 22 | for (offset = 0, pInput = (short int *)PackedDataPayload, pOutput = (unsigned short int *)output; offset < PackedDataLength && offset < OutputBufferLength;) { 23 | BlockLength = *pInput++; 24 | offset += 2; 25 | if (BlockLength > 0) { 26 | for (i = 0; i < BlockLength; i++, pOutput++) 27 | *pOutput = *pInput; 28 | pInput++; 29 | offset += sizeof(unsigned short); 30 | } else { 31 | BlockLength = -BlockLength; 32 | memcpy(pOutput, pInput, BlockLength * sizeof(unsigned short)); 33 | pOutput += BlockLength; 34 | pInput += BlockLength; 35 | offset += BlockLength * sizeof(unsigned short); 36 | } 37 | } 38 | 39 | return 0; 40 | } 41 | 42 | int LoadPS2IconModel(const char *path, struct PS2IconModel *IconModel) 43 | { 44 | int result, size; 45 | unsigned int vertex, i, sequence, TextureLength; 46 | FILE *IconFile; 47 | void *buffer; 48 | struct IconFileVersionHeader *VersionHeader; 49 | struct IconFileModelSectionHeader *ModelSectionHeader; 50 | struct Vector *PointVector; 51 | void *IconFileDataOffset; 52 | struct IconFileModelAnimSectionHeader *AnimSectionHeader; 53 | struct IconFileModelAnimSequence *AnimSequence; 54 | struct IconFileModelAnimFrame *AnimeFrame; 55 | 56 | memset(IconModel, 0, sizeof(struct PS2IconModel)); 57 | result = 0; 58 | 59 | if ((IconFile = fopen(path, "rb")) != NULL) { 60 | fseek(IconFile, 0, SEEK_END); 61 | size = ftell(IconFile); 62 | rewind(IconFile); 63 | if ((buffer = malloc(size)) != NULL) { 64 | result = fread(buffer, 1, size, IconFile); 65 | } 66 | 67 | fclose(IconFile); 68 | 69 | if (buffer != NULL) { 70 | if (result == size) { 71 | VersionHeader = (struct IconFileVersionHeader *)buffer; 72 | if (VersionHeader->version == ICON_FILE_VERSION) { 73 | ModelSectionHeader = (struct IconFileModelSectionHeader *)((unsigned int)buffer + sizeof(struct IconFileVersionHeader)); 74 | 75 | // printf("LoadIconModel: attrib: 0x%08x, nbvtx: %u, nbsp: %u\n", ModelSectionHeader->attrib, ModelSectionHeader->nbvtx, ModelSectionHeader->nbsp); 76 | 77 | memcpy(&IconModel->ModelSectionHeader, ModelSectionHeader, sizeof(struct IconFileModelSectionHeader)); 78 | IconModel->ModelVertices = (struct IconModelVertex *)malloc(ModelSectionHeader->nbvtx * sizeof(struct IconModelVertex)); 79 | IconFileDataOffset = (void *)((unsigned int)ModelSectionHeader + sizeof(struct IconFileModelSectionHeader)); 80 | for (vertex = 0; vertex < ModelSectionHeader->nbvtx; vertex++) { 81 | // Start with the points of the vertex. 82 | IconModel->ModelVertices[vertex].vtx = malloc(ModelSectionHeader->nbsp * sizeof(struct Vector)); 83 | for (i = 0; i < ModelSectionHeader->nbsp; i++) { 84 | PointVector = &IconModel->ModelVertices[vertex].vtx[i]; 85 | 86 | PointVector->x = ITOF10(((unsigned short int *)IconFileDataOffset)[0]); 87 | PointVector->y = ITOF10(((unsigned short int *)IconFileDataOffset)[1]); 88 | PointVector->z = ITOF10(((unsigned short int *)IconFileDataOffset)[2]); 89 | IconFileDataOffset = (void *)((unsigned int)IconFileDataOffset + 8); 90 | } 91 | 92 | IconModel->ModelVertices[vertex].normal[0] = ITOF12(((unsigned short int *)IconFileDataOffset)[0]); 93 | IconModel->ModelVertices[vertex].normal[1] = ITOF12(((unsigned short int *)IconFileDataOffset)[1]); 94 | IconModel->ModelVertices[vertex].normal[2] = ITOF12(((unsigned short int *)IconFileDataOffset)[2]); 95 | IconFileDataOffset = (void *)((unsigned int)IconFileDataOffset + 8); 96 | 97 | IconModel->ModelVertices[vertex].st[0] = ITOF12(((unsigned short int *)IconFileDataOffset)[0]); 98 | IconModel->ModelVertices[vertex].st[1] = ITOF12(((unsigned short int *)IconFileDataOffset)[1]); 99 | IconFileDataOffset = (void *)((unsigned int)IconFileDataOffset + 4); 100 | 101 | memcpy(IconModel->ModelVertices[vertex].color, IconFileDataOffset, 4); 102 | IconFileDataOffset = (void *)((unsigned int)IconFileDataOffset + 4); 103 | } 104 | 105 | AnimSectionHeader = (struct IconFileModelAnimSectionHeader *)IconFileDataOffset; 106 | IconFileDataOffset = (void *)((unsigned int)IconFileDataOffset + sizeof(struct IconFileModelAnimSectionHeader)); 107 | IconModel->ModelAnimSequences = (struct IconModelAnimSequence *)malloc(AnimSectionHeader->nbseq * sizeof(struct IconModelAnimSequence)); 108 | memcpy(&IconModel->ModelAnimSectionHeader, AnimSectionHeader, sizeof(struct IconFileModelAnimSectionHeader)); 109 | 110 | // printf("AnimSectionHeader->nbseq: %d\n", AnimSectionHeader->nbseq); 111 | for (sequence = 0; sequence < AnimSectionHeader->nbseq; sequence++) { 112 | AnimSequence = (struct IconFileModelAnimSequence *)IconFileDataOffset; 113 | IconModel->ModelAnimSequences[sequence].nbframe = AnimSequence->nbframe; 114 | IconModel->ModelAnimSequences[sequence].speed = AnimSequence->speed; 115 | IconModel->ModelAnimSequences[sequence].offset = AnimSequence->offset; 116 | IconModel->ModelAnimSequences[sequence].nbksp = AnimSequence->nbksp; 117 | IconModel->ModelAnimSequences[sequence].frames = (struct IconModelAnimFrame *)malloc(AnimSequence->nbksp * sizeof(struct IconModelAnimFrame)); 118 | 119 | // printf("AnimSequence->nbksp: %d\n", AnimSequence->nbksp); 120 | 121 | IconFileDataOffset = (void *)((unsigned int)IconFileDataOffset + sizeof(struct IconFileModelAnimSequence)); 122 | for (i = 0; i < AnimSequence->nbksp; i++) { 123 | AnimeFrame = (struct IconFileModelAnimFrame *)IconFileDataOffset; 124 | 125 | IconModel->ModelAnimSequences[sequence].frames[i].kspid = AnimeFrame->kspid; 126 | IconModel->ModelAnimSequences[sequence].frames[i].nbkf = AnimeFrame->nbkf; 127 | IconModel->ModelAnimSequences[sequence].frames[i].keys = (struct IconFileModelAnimFrameKeyData *)malloc(AnimSequence->nbksp * sizeof(struct IconFileModelAnimFrameKeyData)); 128 | memcpy(IconModel->ModelAnimSequences[sequence].frames[i].keys, (void *)((unsigned int)AnimeFrame + sizeof(struct IconFileModelAnimFrame)), AnimSequence->nbksp * sizeof(struct IconFileModelAnimFrameKeyData)); 129 | 130 | IconFileDataOffset = (void *)((unsigned int)IconFileDataOffset + 8 + sizeof(struct IconFileModelAnimFrameKeyData) * AnimSequence->nbksp); 131 | } 132 | } 133 | 134 | // Texture loading. 135 | TextureLength = size - ((unsigned int)IconFileDataOffset - (unsigned int)buffer); 136 | if (ModelSectionHeader->attrib & ICON_MODEL_ATTR_RLE) { 137 | IconModel->texture = memalign(64, 32768); // 2*TextureLength); 138 | result = DecompressRLEData(IconModel->texture, 32768, IconFileDataOffset); 139 | } else { 140 | // if(TextureLength==32768){ 141 | if (TextureLength > 32768) 142 | TextureLength = 32768; 143 | IconModel->texture = memalign(64, 32768); // Should be 128x128x16-bit=32768 144 | memcpy(IconModel->texture, IconFileDataOffset, TextureLength); 145 | result = 0; 146 | /* } 147 | else{ 148 | printf("TextureLength: %d\n", TextureLength); 149 | result=-1; 150 | } */ 151 | } 152 | } else 153 | result = -1; // Unsupported version. 154 | } else 155 | result = EIO; 156 | 157 | free(buffer); 158 | } 159 | } else 160 | result = ENOENT; 161 | 162 | return result; 163 | } 164 | 165 | void UnloadPS2IconModel(struct PS2IconModel *IconModel) 166 | { 167 | unsigned int i, vertex, sequence; 168 | 169 | for (vertex = 0; vertex < IconModel->ModelSectionHeader.nbvtx; vertex++) { 170 | if (IconModel->ModelVertices[vertex].vtx != NULL) 171 | free(IconModel->ModelVertices[vertex].vtx); 172 | } 173 | if (IconModel->ModelVertices != NULL) 174 | free(IconModel->ModelVertices); 175 | for (sequence = 0; sequence < IconModel->ModelAnimSectionHeader.nbseq; sequence++) { 176 | for (i = 0; i < IconModel->ModelAnimSequences[sequence].nbksp; i++) { 177 | if (IconModel->ModelAnimSequences[sequence].frames[i].keys != NULL) 178 | free(IconModel->ModelAnimSequences[sequence].frames[i].keys); 179 | } 180 | if (IconModel->ModelAnimSequences[sequence].frames != NULL) 181 | free(IconModel->ModelAnimSequences[sequence].frames); 182 | } 183 | if (IconModel->ModelAnimSequences != NULL) 184 | free(IconModel->ModelAnimSequences); 185 | if (IconModel->texture != NULL) 186 | free(IconModel->texture); 187 | } 188 | -------------------------------------------------------------------------------- /IconLoader.h: -------------------------------------------------------------------------------- 1 | // For icon file saving/loading: 2 | 3 | #define ICON_FILE_VERSION 0x10000 4 | 5 | struct IconFileVersionHeader 6 | { 7 | unsigned int version; 8 | }; 9 | 10 | #define ICON_MODEL_ATTR_IIP 0x01 // Shading method. 0 = flat, 1 = gouraud. 11 | #define ICON_MODEL_ATTR_ANTI 0x02 // Anti-aliasing on/off. 12 | #define ICON_MODEL_ATTR_TEX 0x04 // Texture pasting on/off. 13 | #define ICON_MODEL_ATTR_RLE 0x08 // Texture compression flag. 0 = Uncompressed, 1 = compressed. 14 | 15 | struct IconFileModelSectionHeader 16 | { 17 | unsigned int nbsp; // Number of key shapes (1, 4, 6 or 8) 18 | unsigned int attrib; // Model attributes 19 | float bface; // Back-face clipping standard value (Normally 1.0). 20 | unsigned int nbvtx; // Number of vertices (Must be a multiple of 3). 21 | }; 22 | 23 | // The following structure is then repeated nbtx times. 24 | /* struct IconFileModelVertex 25 | { 26 | unsigned short int vtx[4 * nbsp]; // 3x6:10 fixed-point elements for each point of every coordinate, with 2-byte padding. 27 | unsigned short int normal[4]; // 3x4:12 fixed-point elements for each point, with 2-byte padding. 28 | unsigned short int st[2]; // Texture coordinates: 2x4:12 fixed-point elements. 29 | unsigned char color[4]; // Vertex color: 1 byte for R, G, B and A. A is ignored. 30 | }; */ 31 | 32 | struct IconFileModelAnimSectionHeader 33 | { 34 | unsigned int nbseq; // Number of sequences (Only 1 is currently supported). 35 | }; 36 | 37 | // The following structure is repeated nbseq times. 38 | struct IconFileModelAnimSequence 39 | { 40 | unsigned int nbframe; // Frame length. 41 | float speed; // Play speed magnification. 42 | unsigned int offset; // Play offset (frame number). 43 | unsigned int nbksp; // Number of shapes to be used (maximum 8). 44 | }; 45 | 46 | struct IconFileModelAnimFrameKeyData 47 | { 48 | float frame; // Frame number of key frame. 49 | float weight; // Shape weight. 50 | }; 51 | 52 | // The following structure is repeated nbksp times 53 | struct IconFileModelAnimFrame 54 | { 55 | unsigned int kspid; // Shape number. 56 | unsigned int nbkf; // Number of key frames (maximum 10). 57 | // struct IconFileModelAnimFrameKeyData keys[]; // Key data goes here in the file. 58 | }; 59 | 60 | /* Texture data begins here. The content depends on whether it's compressed or not. 61 | If it's compressed: 62 | unsigned int size -> size of compressed data. 63 | -> RLE-encoded 128x128 PSMCT16 image, compressed in 2-byte units. 64 | 65 | If is's uncompressed: 66 | -> Uncompressed, raw 128x128 PSMCT16 image. 67 | */ 68 | 69 | /**************************/ 70 | // For icon storage in RAM. 71 | struct Vector 72 | { 73 | float x, y, z; 74 | }; 75 | 76 | struct IconModelVertex 77 | { 78 | struct Vector *vtx; // Repeated nbsp times 79 | float normal[3]; 80 | float st[2]; 81 | unsigned char color[4]; 82 | }; 83 | 84 | struct IconModelAnimFrame 85 | { 86 | unsigned int kspid; // Shape number. 87 | unsigned int nbkf; // Number of key frames (maximum 10). 88 | struct IconFileModelAnimFrameKeyData *keys; // Key data. 89 | }; 90 | 91 | struct IconModelAnimSequence 92 | { 93 | unsigned int nbframe; // Frame length. 94 | float speed; // Play speed magnification. 95 | unsigned int offset; // Play offset (frame number). 96 | unsigned int nbksp; // Number of shapes to be used (maximum 8). 97 | struct IconModelAnimFrame *frames; 98 | }; 99 | 100 | struct PS2IconModel 101 | { 102 | struct IconFileModelSectionHeader ModelSectionHeader; 103 | struct IconModelVertex *ModelVertices; 104 | struct IconFileModelAnimSectionHeader ModelAnimSectionHeader; 105 | struct IconModelAnimSequence *ModelAnimSequences; 106 | void *texture; 107 | }; 108 | 109 | /**************************/ 110 | // Function prototypes. 111 | int LoadPS2IconModel(const char *path, struct PS2IconModel *IconModel); 112 | void UnloadPS2IconModel(struct PS2IconModel *IconModel); 113 | -------------------------------------------------------------------------------- /IconRender.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "IconLoader.h" 16 | #include "IconRender.h" 17 | 18 | extern GSFONTM *gsFontM; 19 | extern GSGLOBAL *gsGlobal; 20 | 21 | void ResetIconModelRuntimeData(const struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData) 22 | { 23 | unsigned int i, shape; 24 | 25 | for (i = 0; i < IconModel->ModelSectionHeader.nbvtx; i++) { 26 | for (shape = 0; shape < IconModel->ModelSectionHeader.nbsp; shape++) { 27 | memcpy(IconRuntimeData->vertices[i], IconModel->ModelVertices[i].vtx, sizeof(struct Vector) * IconModel->ModelSectionHeader.nbsp); 28 | } 29 | } 30 | } 31 | 32 | int InitIconModelRuntimeData(const struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData) 33 | { 34 | unsigned int i; 35 | 36 | memset(IconRuntimeData, 0, sizeof(struct IconModelAnimRuntimeData)); 37 | 38 | IconRuntimeData->vertices = malloc(sizeof(struct Vector *) * IconModel->ModelSectionHeader.nbvtx); 39 | for (i = 0; i < IconModel->ModelSectionHeader.nbvtx; i++) { 40 | IconRuntimeData->vertices[i] = malloc(sizeof(struct Vector) * IconModel->ModelSectionHeader.nbsp); 41 | } 42 | 43 | ResetIconModelRuntimeData(IconModel, IconRuntimeData); 44 | 45 | return 0; 46 | } 47 | 48 | void FreeIconModelRuntimeData(const struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData) 49 | { 50 | unsigned int i; 51 | 52 | for (i = 0; i < IconModel->ModelSectionHeader.nbvtx; i++) { 53 | if (IconRuntimeData->vertices[i] != NULL) 54 | free(IconRuntimeData->vertices[i]); 55 | } 56 | 57 | if (IconRuntimeData->vertices != NULL) 58 | free(IconRuntimeData->vertices); 59 | } 60 | 61 | int UploadIcon(const struct PS2IconModel *IconModel, GSTEXTURE *texture) 62 | { 63 | texture->Width = 128; 64 | texture->Height = 128; 65 | texture->Filter = GS_FILTER_LINEAR; 66 | texture->PSM = GS_PSM_CT16; 67 | texture->Clut = NULL; 68 | texture->VramClut = 0; 69 | texture->Delayed = GS_SETTING_ON; 70 | 71 | gsKit_setup_tbw(texture); 72 | gsKit_texture_send_inline(gsGlobal, IconModel->texture, texture->Width, texture->Height, texture->Vram, texture->PSM, texture->TBW, texture->VramClut); 73 | 74 | return 0; 75 | } 76 | 77 | void TransformIcon(unsigned int frame, float x, float y, int z, float scale, const struct PS2IconModel *IconModel, const struct IconModelAnimRuntimeData *IconRuntimeData) 78 | { 79 | unsigned int shape, vertex; 80 | VECTOR ResultVector, SourceVector, ScaleVector, TranslateVector; //, RotationVector; 81 | MATRIX TransformMatrix; 82 | 83 | matrix_unit(TransformMatrix); 84 | 85 | // TODO: How to handle the animation data? D: 86 | 87 | // Handle scaling. 88 | ScaleVector[0] = scale; 89 | ScaleVector[1] = scale; 90 | ScaleVector[2] = scale; 91 | matrix_scale(TransformMatrix, TransformMatrix, ScaleVector); 92 | 93 | // Handle translation. 94 | TranslateVector[0] = x; 95 | TranslateVector[1] = y; 96 | TranslateVector[2] = z; 97 | matrix_translate(TransformMatrix, TransformMatrix, TranslateVector); 98 | 99 | // Handle rotation 100 | /* RotationVector[0]=(frame%3600)/3600.0f; 101 | RotationVector[1]=0; 102 | RotationVector[2]=-(frame%3600)/3600.0f; 103 | matrix_rotate(TransformMatrix, TransformMatrix, RotationVector); 104 | matrix_multiply(TransformMatrix, TransformMatrix, LocalWorldMatrix); */ 105 | 106 | // Transform! 107 | for (vertex = 0; vertex < IconModel->ModelSectionHeader.nbvtx; vertex++) { 108 | for (shape = 0; shape < IconModel->ModelSectionHeader.nbsp; shape++) { 109 | SourceVector[0] = IconModel->ModelVertices[vertex].vtx[shape].x; 110 | SourceVector[1] = IconModel->ModelVertices[vertex].vtx[shape].y; 111 | SourceVector[2] = IconModel->ModelVertices[vertex].vtx[shape].z; 112 | vector_apply(ResultVector, SourceVector, TransformMatrix); 113 | IconRuntimeData->vertices[vertex][shape].x = ResultVector[0]; 114 | IconRuntimeData->vertices[vertex][shape].y = ResultVector[1]; 115 | IconRuntimeData->vertices[vertex][shape].z = ResultVector[2]; 116 | } 117 | } 118 | } 119 | 120 | void DrawIcon(const struct PS2IconModel *IconModel, const struct IconModelAnimRuntimeData *IconRuntimeData, GSTEXTURE *IconModelTexture) 121 | { 122 | unsigned int i, shape; 123 | struct IconModelVertex *ModelVertices; 124 | struct Vector **RuntimeVertexData; 125 | shape = 0; 126 | 127 | if (IconModel->ModelVertices != NULL) { 128 | for (i = 0, ModelVertices = IconModel->ModelVertices, RuntimeVertexData = IconRuntimeData->vertices; i < IconModel->ModelSectionHeader.nbvtx; i += 3, ModelVertices += 3, RuntimeVertexData += 3) { 129 | gsKit_prim_triangle_texture_3d(gsGlobal, IconModelTexture, 130 | RuntimeVertexData[0][shape].x, RuntimeVertexData[0][shape].y, 0, ModelVertices[0].st[0] * IconModelTexture->Width, ModelVertices[0].st[1] * IconModelTexture->Height, 131 | RuntimeVertexData[1][shape].x, RuntimeVertexData[1][shape].y, 0, ModelVertices[1].st[0] * IconModelTexture->Width, ModelVertices[1].st[1] * IconModelTexture->Height, 132 | RuntimeVertexData[2][shape].x, RuntimeVertexData[2][shape].y, 0, ModelVertices[2].st[0] * IconModelTexture->Width, ModelVertices[2].st[1] * IconModelTexture->Height, GS_SETREG_RGBAQ(0x80, 0x80, 0x80, 0x80, 0x00)); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /IconRender.h: -------------------------------------------------------------------------------- 1 | struct IconModelAnimRuntimeData 2 | { 3 | struct Vector **vertices; 4 | }; 5 | 6 | void ResetIconModelRuntimeData(const struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData); 7 | int InitIconModelRuntimeData(const struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData); 8 | void FreeIconModelRuntimeData(const struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData); 9 | int UploadIcon(const struct PS2IconModel *IconModel, GSTEXTURE *texture); 10 | void TransformIcon(unsigned int frame, float x, float y, int z, float scale, const struct PS2IconModel *IconModel, const struct IconModelAnimRuntimeData *IconRuntimeData); 11 | void DrawIcon(const struct PS2IconModel *IconModel, const struct IconModelAnimRuntimeData *IconRuntimeData, GSTEXTURE *IconModelTexture); 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EE_BIN = HDLGameInstaller.elf 2 | 3 | IRX_PATH = irx 4 | 5 | RDB_DEBUG_SUPPORT ?= 0 6 | STRIP ?= 1 7 | 8 | EE_RES_OBJS = buttons.o devices.o background.o SJIS2Unicode_bin.o SYSTEM_cnf.o ICON_ico.o BOOT_kelf.o 9 | EE_OBJS = main.o settings.o system.o io.o sjis.o graphics.o UI.o menu.o OSD.o pad.o HDLGameList.o DeviceSupport.o font.o IconLoader.o IconRender.o $(EE_RES_OBJS) $(EE_IOP_OBJS) ipconfig.o HDLGameSvr.o 10 | 11 | #IOP modules 12 | EE_IOP_OBJS = IOMANX_irx.o FILEXIO_irx.o SIO2MAN_irx.o MCMAN_irx.o MCSERV_irx.o PADMAN_irx.o POWEROFF_irx.o DEV9_irx.o ATAD_irx.o HDD_irx.o PFS_irx.o HDLFS_irx.o SMAP_irx.o NETMAN_irx.o USBD_irx.o USBHDFSD_irx.o 13 | 14 | EE_INCS := -I$(PS2SDK)/ports/include -I$(PS2SDK)/ports/include/freetype2 -I$(PS2DEV)/gsKit/include -I./FreeType -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include 15 | EE_LDFLAGS := -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L. -L$(PS2SDK)/ee/lib 16 | EE_LIBS = -lpatches -lgskit -ldmakit -lpng -lz -lpadx -lmc -lpoweroff -lfileXio -lcdvd -lhdd -lps2ip -lnetman -lmath3d -lm -lfreetype 17 | 18 | EE_GPVAL = -G9760 19 | EE_CFLAGS += -Os -mgpopt $(EE_GPVAL) 20 | 21 | EE_TEMP_FILES = IOMANX_irx.c FILEXIO_irx.c SIO2MAN_irx.c MCMAN_irx.c MCSERV_irx.c PADMAN_irx.c POWEROFF_irx.c DEV9_irx.c ATAD_irx.c HDD_irx.c PFS_irx.c HDLFS_irx.c SMAP_irx.c NETMAN_irx.c USBD_irx.c USBHDFSD_irx.c buttons.c devices.c background.c SJIS2Unicode_bin.c SYSTEM_cnf.c ICON_ico.c BOOT_kelf.c 22 | 23 | ifeq ($(RDB_DEBUG_SUPPORT),1) 24 | EE_CFLAGS += -DRDB_DEBUG_SUPPORT=1 -g 25 | STRIP=0 26 | endif 27 | 28 | ifeq ($(STRIP),1) 29 | EE_LDFLAGS += -s 30 | endif 31 | 32 | %.o : %.c 33 | $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ 34 | 35 | %.o : %.S 36 | $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ 37 | 38 | %.o : %.s 39 | $(EE_AS) $(EE_ASFLAGS) $< -o $@ 40 | 41 | $(EE_BIN) : $(EE_OBJS) 42 | $(EE_CC) $(EE_CFLAGS) $(EE_LDFLAGS) -o $(EE_BIN) $(EE_OBJS) $(EE_LIBS) 43 | 44 | all: 45 | $(MAKE) $(EE_BIN) 46 | 47 | clean: 48 | rm -f $(EE_BIN) $(EE_OBJS) $(EE_TEMP_FILES) 49 | 50 | IOMANX_irx.c: 51 | bin2c $(PS2SDK)/iop/irx/iomanX.irx IOMANX_irx.c IOMANX_irx 52 | 53 | FILEXIO_irx.c: 54 | bin2c $(PS2SDK)/iop/irx/fileXio.irx FILEXIO_irx.c FILEXIO_irx 55 | 56 | SIO2MAN_irx.c: 57 | bin2c $(PS2SDK)/iop/irx/freesio2.irx SIO2MAN_irx.c SIO2MAN_irx 58 | 59 | MCMAN_irx.c: 60 | bin2c $(PS2SDK)/iop/irx/mcman.irx MCMAN_irx.c MCMAN_irx 61 | 62 | MCSERV_irx.c: 63 | bin2c $(PS2SDK)/iop/irx/mcserv.irx MCSERV_irx.c MCSERV_irx 64 | 65 | PADMAN_irx.c: 66 | bin2c $(PS2SDK)/iop/irx/freepad.irx PADMAN_irx.c PADMAN_irx 67 | 68 | POWEROFF_irx.c: 69 | bin2c $(PS2SDK)/iop/irx/poweroff.irx POWEROFF_irx.c POWEROFF_irx 70 | 71 | DEV9_irx.c: 72 | bin2c $(PS2SDK)/iop/irx/ps2dev9.irx DEV9_irx.c DEV9_irx 73 | 74 | ATAD_irx.c: 75 | bin2c $(PS2SDK)/iop/irx/ps2atad.irx ATAD_irx.c ATAD_irx 76 | 77 | HDD_irx.c: 78 | bin2c $(IRX_PATH)/ps2hdd-hdl.irx HDD_irx.c HDD_irx 79 | 80 | PFS_irx.c: 81 | bin2c $(PS2SDK)/iop/irx/ps2fs.irx PFS_irx.c PFS_irx 82 | 83 | HDLFS_irx.c: 84 | bin2c $(IRX_PATH)/hdlfs.irx HDLFS_irx.c HDLFS_irx 85 | 86 | SMAP_irx.c: 87 | bin2c $(PS2SDK)/iop/irx/smap.irx SMAP_irx.c SMAP_irx 88 | 89 | NETMAN_irx.c: 90 | bin2c $(PS2SDK)/iop/irx/netman.irx NETMAN_irx.c NETMAN_irx 91 | 92 | USBD_irx.c: 93 | bin2c $(PS2SDK)/iop/irx/usbd.irx USBD_irx.c USBD_irx 94 | 95 | USBHDFSD_irx.c: 96 | bin2c $(PS2SDK)/iop/irx/usbhdfsd.irx USBHDFSD_irx.c USBHDFSD_irx 97 | 98 | SJIS2Unicode_bin.c: 99 | bin2c res/SJIS2Unicode.bin SJIS2Unicode_bin.c SJIS2Unicode_bin 100 | 101 | SYSTEM_cnf.c: 102 | bin2c res/system.cnf SYSTEM_cnf.c SYSTEM_cnf 103 | 104 | ICON_ico.c: 105 | bin2c res/icon.ico ICON_ico.c ICON_ico 106 | 107 | BOOT_kelf.c: 108 | bin2c res/BOOT.XLF BOOT_kelf.c BOOT_kelf 109 | 110 | background.c: 111 | bin2c resources/background.png background.c background 112 | 113 | buttons.c: 114 | bin2c resources/buttons.png buttons.c buttons 115 | 116 | devices.c: 117 | bin2c resources/devices.png devices.c devices 118 | 119 | include $(PS2SDK)/samples/Makefile.pref 120 | -------------------------------------------------------------------------------- /OSD.h: -------------------------------------------------------------------------------- 1 | enum OSD_RESOURCE_FILE_TYPES { 2 | OSD_SYSTEM_CNF_INDEX = 0, 3 | OSD_ICON_SYS_INDEX, 4 | OSD_VIEW_ICON_INDEX, 5 | OSD_DEL_ICON_INDEX, 6 | OSD_BOOT_KELF_INDEX, 7 | 8 | NUM_OSD_FILES_ENTS 9 | }; 10 | 11 | #define HDL_GAME_DATA_OFFSET 0x100000 /* Starts at sector 0x800, and spans across sectors 0x800 and 0x801. */ 12 | 13 | struct GameSettings 14 | { 15 | wchar_t FullTitle[GAME_TITLE_MAX_LEN + 1]; 16 | wchar_t OSDTitleLine1[OSD_TITLE_MAX_LEN + 1]; 17 | wchar_t OSDTitleLine2[OSD_TITLE_MAX_LEN + 1]; 18 | unsigned char CompatibilityModeFlags; 19 | unsigned char UseMDMA0; 20 | }; 21 | 22 | typedef struct 23 | { 24 | int offset; 25 | int size; 26 | } OSDResFileEnt_t; 27 | 28 | typedef struct PartAttributeAreaTable 29 | { 30 | char magic[9]; /* "PS2ICON3D" */ 31 | unsigned char reserved[3]; 32 | int version; /* Must be zero. */ 33 | OSDResFileEnt_t FileEnt[NUM_OSD_FILES_ENTS]; 34 | unsigned char reserved2[456]; 35 | } t_PartAttrTab __attribute__((packed)); 36 | 37 | struct OSDResourceFileEntry 38 | { 39 | const char *FileName; 40 | void *buffer; 41 | int size; 42 | unsigned int flags; 43 | }; 44 | 45 | struct IconSysData 46 | { 47 | wchar_t title0[OSD_TITLE_MAX_LEN + 1]; 48 | wchar_t title1[OSD_TITLE_MAX_LEN + 1]; 49 | unsigned char bgcola; 50 | unsigned char bgcol0[3]; 51 | unsigned char bgcol1[3]; 52 | unsigned char bgcol2[3]; 53 | unsigned char bgcol3[3]; 54 | float lightdir0[3]; 55 | float lightdir1[3]; 56 | float lightdir2[3]; 57 | unsigned char lightcolamb[3]; 58 | unsigned char lightcol0[3]; 59 | unsigned char lightcol1[3]; 60 | unsigned char lightcol2[3]; 61 | wchar_t uninstallmes0[121]; 62 | wchar_t uninstallmes1[121]; 63 | wchar_t uninstallmes2[121]; 64 | }; 65 | 66 | struct IconInfo 67 | { 68 | char foldername[33]; 69 | wchar_t title[33]; 70 | }; 71 | 72 | #define FILE_FLAGS_OPTIONAL 0x01 73 | #define FILE_FLAGS_ALLOCATED 0x02 // Buffer was allocated and should be free when no longer needed. 74 | 75 | enum ICON_SOURCE { 76 | ICON_SOURCE_DEFAULT = 0, 77 | ICON_SOURCE_SAVE, 78 | ICON_SOURCE_EXTERNAL 79 | }; 80 | 81 | void InitOSDResourceFiles(void); 82 | void ConvertMcTitle(const mcIcon *icon, wchar_t *title1, wchar_t *title2); 83 | int CheckExistingMcSave(const char *DiscID); 84 | int ReadExistingFileInMcSave(const char *DiscID, const char *filename, void *buffer, unsigned int length); 85 | int LoadMcSaveSysFromPath(const char *SaveFolderPath, mcIcon *McSaveIconSys); 86 | int LoadMcSaveSys(char *SaveFolderPath, mcIcon *McSaveIconSys, const char *DiscID); 87 | int PrepareOSDResources(const char *SaveFolderPath, const mcIcon *McSaveIconSys, const wchar_t *OSDTitleLine1, const wchar_t *OSDTitleLine2, struct OSDResourceFileEntry *InstFileList); 88 | int LoadOSDResource(unsigned int index, struct OSDResourceFileEntry *InstFileList, void *buffer, unsigned int length, unsigned char IsAllocatedBuffer); 89 | void FreeOSDResources(struct OSDResourceFileEntry *InstFileList); 90 | int LoadIconSysFile(const unsigned char *buffer, int size, struct IconSysData *data); 91 | int GetOSDResourceFileStats(const char *partition, OSDResFileEnt_t *files); 92 | int GetExistingFileInMcSaveStat(const char *DiscID, const char *filename, iox_stat_t *stat); 93 | int ReadOSDResourceFile(const char *partition, int index, const OSDResFileEnt_t *files, void *buffer); 94 | int InstallOSDFiles(const char *partition, struct OSDResourceFileEntry *InstFileList); 95 | void PrepareOSDDefaultResources(struct OSDResourceFileEntry *InstFileList); 96 | int InstallGameInstallationOSDResources(const char *partition, const struct GameSettings *GameSettings, const mcIcon *McSaveIconSys, const char *SaveDataPath); 97 | int UpdateGameInstallationOSDResources(const char *partition, const wchar_t *OSDTitleLine1, const wchar_t *OSDTitleLine2); 98 | int GetGameInstallationOSDIconSys(const char *partition, struct IconSysData *IconSys); 99 | int GetIconListFromDevice(const char *device, struct IconInfo **IconList); 100 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # HDLGameInstaller 2 | 3 | ##### [Original download site](https://sites.google.com/view/ysai187/home/projects/hdlgameinstaller) 4 | 5 | The HDLoader game installer 6 | 7 | ## Introduction 8 | 9 | The HDLoader game installer allows the user to install PlayStation 2 games onto the installed Harddisk Drive, for direct booting with the HDDOSD (Browser v2.00 update). 10 | 11 | It can also be used as an alternative to HDLDump, as this software does not use the HDLDump protocol and hence entirely uses TCP for data transfer. This means that, unlike HDLDump, it's more reliable. 12 | 13 | It has the following features: 14 | 15 | - Installs all PlayStation 2 games from the CD/DVD drive. 16 | - Installs all PlayStation 2 games remotely from a PC, over a network. 17 | - Installed games can be booted directly from the HDDOSD. 18 | - Allows the user to manage games locally on the PlayStation 2 console itself. 19 | - Allows the user to manage games remotely from a PC, over a network. 20 | - Network performance uses the latest ethernet modules from the PS2SDK, giving about 4MB/s. 21 | - Allows the user to specify the savedata icon to use with the game. 22 | - Supports games >4GB and DVD-DL games. 23 | - The game list can be sorted alphabetically (controlled from the PlayStation 2). 24 | - Supports the Dynamic Host Configuration Protocol (DHCP), for easy setup. 25 | 26 | ## Setting Storage 27 | 28 | Settings are now saved into the HDLGameInstaller save data folder: 29 | 30 | hdd0:__common/Your Saves/HDLGAMEINSTALLER 31 | 32 | If you wish to delete the save, you may do so with the HDD Browser or compatible homebrew (e.g. wLaunchELF). 33 | 34 | ## Notes on network support 35 | 36 | - HDLGameInstaller now maintains its network configuration file on the HDD unit. 37 | - If you have not configured HDLGameInstaller before, your existing homebrew network settings will be automatically imported from IPCONFIG.DAT. 38 | - Network settings can now be configured from the Options menu. 39 | - Please ensure that TCP ports 45061 and 45062 are allowed in your network. 40 | - If you use the Windows Firewall, you may have to allow "public" access for HDLGManClient.exe. 41 | - Pad support worsens performance. However, it is possible to connect to the PS2 at any time, even when the options screen is displayed. If this is done, then the software will not disable pad input until the options menu is closed. For best performance, keep the options menu closed. 42 | 43 | ## Supported Devices 44 | 45 | HDLGameInstaller may be installed (copied) onto and can be booted from: 46 | 47 | - USB Mass Storage Devices. 48 | - Only USB disks are supported. Multi-function devices are not supported. 49 | - The disk must have only one partition. Otherwise, the first partition will be accessed. 50 | - PlayStation 2 HDD Unit. 51 | 52 | **Other devices are not supported.** 53 | 54 | ## Known limitations/bugs 55 | 56 | - The icon preview does not look correct. I don't have the knowledge or resources to commit to fixing it up. Someone else will have to solve this, sorry. 57 | - The UI isn't the nicest one, but it works. 58 | - No Japanese input support on the PS2 installer's end. 59 | - DVD9 games are supported from the PC client only, as the CDVDMAN module within the boot ROMs of all consoles does not support DVD9 layer 1. 60 | - Not compatible with the APAEXT partitioning scheme (i.e. ToxicOS). **!!! Do not use this software with a disk formatted with APAEXT, or data loss will occur!!!** 61 | - As the variable-width font may result in an uneven number of characters being displayed on the screen as a line is scrolled, the user may observe that the cursor might jump back by one place while scrolling. This is not a bug. 62 | 63 | ### Changelog for v0.821 64 | 65 | - Disabled pad input when a PC client is connected, to improve performance. 66 | - Network status will be displayed when a PC client is connected, every 10s. 67 | - NEW 2018/12/09 - Fixed the problem with the soft keyboard not waiting for the circle/cross button to be released before considering the user's intended input. 68 | 69 | ### Changelog for the PC client 70 | 71 | - Increased data connection timeout to 80s, to allow the server's connection attempts to be exhausted before the PC client indicates an error. 72 | - Added a prompt to delete the game if it was already installed, when the user adds a game to install. 73 | 74 | ## Supported languages 75 | 76 | For more information on supported languages, click here. A template for translating this software is provided in the downloads section of this page. 77 | 78 | Supported languages and their translation status: 79 | 80 | - Japanese - Unassigned. 81 | - French - Translated by DaSA. 82 | - Spanish - Translated by ElPatas. 83 | - German - Translated by Delta_force. 84 | - Italian - Translated by master991. 85 | - Dutch - Translated by an anonymous person. 86 | - Portuguese - Translated by GillBert. 87 | 88 | ## What is HDLGManClient? 89 | 90 | HDLGameInstaller allows the user to install and manage PlayStation 2 games. This can be done either with the PlayStation 2 console itself or remotely over the network with a PC. HDLGManClient is the PC client that allows the user to connect to HDLGameInstaller, when it's left running on the user's PlayStation 2 console. 91 | 92 | ## What is HDLGameUpdater? 93 | 94 | The HDLoader game updater automatically updates the bootstrap program of all your HDLoader games (the program which makes these games bootable from the HDD OSD/browser updater v2.00, aka Mini OPL/Diskload). 95 | 96 | This software will not automatically make games which are not already bootable, bootable. The current version is meant to be used for updating your games to have the same bootstrap program as the one installed by latest version of HDLGameInstaller. 97 | -------------------------------------------------------------------------------- /Research/partition_sample.txt: -------------------------------------------------------------------------------- 1 | Each partition has a 4MB attribute area, that I think comes immediately after the APA header */ 2 | The start of the resource area contains: 3 | 1. system.cnf 4 | 2. icon.sys 5 | 3. list-view icon 6 | 4. deletion icon 7 | 5. KELF (This is undocumented!) 8 | 9 | typedef struct PartAttributeAreaTable{ 10 | char magic[9]; /* "PS2ICON3D" */ 11 | unsigned char reserved[3]; 12 | int version; /* Must be zero. */ 13 | struct{ 14 | int offset; 15 | int size; 16 | }FileEnt[5]; 17 | 18 | unsigned char reserved2[456]; 19 | } t_PartAttrTab; 20 | 21 | *** ALL RESERVED/UNUSED AREAS IN THE ATTRIBUTE AREA MUST BE ZERO-FILLED!! *** 22 | The offset fields for each file descriptor are in bytes (In multiples of 512 bytes), relative to the start of the attribute area. 23 | The format of the icons is the same as the format of the icons used on regular Playstation 2 Memory Cards. 24 | 25 | The format of SYSTEM.CNF is exactly the same as the format of any SYSTEM.CNF files were found on an SCE CD/DVD disc. 26 | A new field is added: HDDUNITPOWER. Setting HDDUNITPOWER to NIC causes the HDD to be powered-down after the program is launched, but the Network Adaptor will still be powered-up. 27 | Setting HDDUNITPOWER to NICHDD keeps the Network Adaptor and HDD powered up. 28 | 29 | (UNDOCUMENTED) Setting BOOT2 to PATINFO causes an embedded KELF to be launched when the program is selected. 30 | (UNDOCUMENTED) Setting BOOT2 to NOBOOT causes the partition to be marked as being unbootable. The message "This program cannot be started" will be displayed. 31 | -------------------------------------------------------------------------------- /Rules.make: -------------------------------------------------------------------------------- 1 | # _____ ___ ____ ___ ____ 2 | # ____| | ____| | | |____| 3 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 4 | #----------------------------------------------------------------------- 5 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 6 | # Licenced under Academic Free License version 2.0 7 | # Review ps2sdk README & LICENSE files for further details. 8 | 9 | EE_CC_VERSION := $(shell $(EE_CC) --version 2>&1 | sed -n 's/^.*(GCC) //p') 10 | 11 | EE_OBJS_DIR ?= obj/ 12 | EE_SRC_DIR ?= src/ 13 | EE_INC_DIR ?= include/ 14 | EE_SAMPLE_DIR ?= samples/ 15 | 16 | EE_INCS := $(EE_INCS) -I$(EE_SRC_DIR) -I$(EE_SRC_DIR)include -I$(EE_INC_DIR) -I$(PS2SDKSRC)/ee/kernel/include -I$(PS2SDKSRC)/common/include -I$(PS2SDKSRC)/ee/libc/include -I$(PS2SDKSRC)/ee/erl/include 17 | 18 | # C compiler flags 19 | EE_CFLAGS := -D_EE -G0 -O2 -Wall $(EE_INCS) $(EE_CFLAGS) 20 | 21 | # C++ compiler flags 22 | EE_CXXFLAGS := -D_EE -G0 -O2 -Wall $(EE_INCS) $(EE_CXXFLAGS) 23 | 24 | # Linker flags 25 | # EE_LDFLAGS := $(EE_LDFLAGS) 26 | 27 | # Assembler flags 28 | EE_ASFLAGS := $(EE_ASFLAGS) 29 | 30 | EE_SAMPLES := $(EE_SAMPLES:%=$(EE_SAMPLE_DIR)%) 31 | 32 | EE_OBJS := $(EE_OBJS:%=$(EE_OBJS_DIR)%) 33 | 34 | # Externally defined variables: EE_BIN, EE_OBJS, EE_LIB 35 | 36 | # These macros can be used to simplify certain build rules. 37 | EE_C_COMPILE = $(EE_CC) $(EE_CFLAGS) 38 | EE_CXX_COMPILE = $(EE_CXX) $(EE_CXXFLAGS) 39 | 40 | # Extra macro for disabling the automatic inclusion of the built-in CRT object(s) 41 | ifeq ($(EE_CC_VERSION),3.2.2) 42 | EE_NO_CRT = -mno-crt0 43 | endif 44 | ifeq ($(EE_CC_VERSION),3.2.3) 45 | EE_NO_CRT = -mno-crt0 46 | endif 47 | ifneq ($(EE_CC_VERSION),3.2.2) 48 | ifneq ($(EE_CC_VERSION),3.2.3) 49 | EE_NO_CRT = -nostartfiles 50 | endif 51 | endif 52 | 53 | $(EE_OBJS_DIR)%.o: $(EE_SRC_DIR)%.c 54 | $(EE_C_COMPILE) -c $< -o $@ 55 | 56 | $(EE_OBJS_DIR)%.o: $(EE_SRC_DIR)%.cpp 57 | $(EE_CXX_COMPILE) -c $< -o $@ 58 | 59 | $(EE_OBJS_DIR)%.o: $(EE_SRC_DIR)%.S 60 | $(EE_C_COMPILE) -c $< -o $@ 61 | 62 | $(EE_OBJS_DIR)%.o: $(EE_SRC_DIR)%.s 63 | $(EE_AS) $(EE_ASFLAGS) $< -o $@ 64 | 65 | $(EE_LIB_DIR): 66 | $(MKDIR) -p $(EE_LIB_DIR) 67 | 68 | $(EE_BIN_DIR): 69 | $(MKDIR) -p $(EE_BIN_DIR) 70 | 71 | $(EE_OBJS_DIR): 72 | $(MKDIR) -p $(EE_OBJS_DIR) 73 | 74 | $(EE_OBJS): | $(EE_OBJS_DIR) 75 | 76 | $(EE_BIN): $(EE_OBJS) $(PS2SDKSRC)/ee/startup/obj/crt0.o | $(EE_BIN_DIR) 77 | $(EE_CC) $(EE_NO_CRT) -T$(PS2SDKSRC)/ee/startup/src/linkfile $(EE_CFLAGS) \ 78 | -o $(EE_BIN) $(PS2SDKSRC)/ee/startup/obj/crt0.o $(EE_OBJS) $(EE_LDFLAGS) $(EE_LIBS) 79 | 80 | $(EE_LIB): $(EE_OBJS) $(EE_LIB:%.a=%.erl) | $(EE_LIB_DIR) 81 | $(EE_AR) cru $(EE_LIB) $(EE_OBJS) 82 | 83 | $(EE_LIB:%.a=%.erl): $(EE_OBJS) | $(EE_LIB_DIR) 84 | $(EE_CC) $(EE_NO_CRT) -Wl,-r -Wl,-d -o $(EE_LIB:%.a=%.erl) $(EE_OBJS) 85 | $(EE_STRIP) --strip-unneeded -R .mdebug.eabi64 -R .reginfo -R .comment $(EE_LIB:%.a=%.erl) 86 | -------------------------------------------------------------------------------- /UI.h: -------------------------------------------------------------------------------- 1 | #include "lang.h" 2 | 3 | #define UI_OFFSET_X 8 4 | #define UI_OFFSET_Y 8 5 | #define UI_FONT_WIDTH FNT_CHAR_WIDTH 6 | #define UI_FONT_HEIGHT FNT_CHAR_HEIGHT 7 | #define UI_TAB_STOPS FNT_TAB_STOPS 8 | 9 | // In VSYNC ticks 10 | #define UI_PAD_REPEAT_START_DELAY 20 11 | #define UI_PAD_REPEAT_DELAY 5 12 | 13 | enum MENU_ITEM { 14 | MITEM_SEPERATOR, 15 | MITEM_TAB, 16 | MITEM_SPACE, 17 | MITEM_BREAK, 18 | MITEM_DASH, 19 | MITEM_COLON, 20 | MITEM_DOT, 21 | MITEM_SLASH, 22 | MITEM_PROGRESS, 23 | MITEM_LABEL, // Last non-selectable item. 24 | 25 | MITEM_STRING, 26 | MITEM_VALUE, 27 | MITEM_BUTTON, 28 | MITEM_TOGGLE, 29 | MITEM_ENUM, 30 | 31 | MITEM_TERMINATOR, 32 | 33 | MITEM_COUNT 34 | }; 35 | 36 | enum MENU_ITEM_FORMAT { 37 | MITEM_FORMAT_DEC = 0, 38 | MITEM_FORMAT_UDEC, 39 | MITEM_FORMAT_HEX, 40 | MITEM_FORMAT_POINTER, 41 | MITEM_FORMAT_FLOAT, 42 | 43 | MITEM_FORMAT_COUNT 44 | }; 45 | 46 | #define MITEM_FLAG_HIDDEN 0x01 47 | #define MITEM_FLAG_READONLY 0x02 48 | #define MITEM_FLAG_DISABLED 0x04 49 | #define MITEM_FLAG_UNIT_PREFIX 0x08 // For formats with a unit prefix, show it. 50 | #define MITEM_FLAG_POS_ABS 0x10 // Coordinates are absolute. 51 | #define MITEM_FLAG_POS_MID 0x20 // Aligned to the middle. Only for buttons. 52 | 53 | struct UIMenuItem 54 | { 55 | unsigned char type; 56 | unsigned char id; // ID 0 is reserved for items that do not need to be tracked (i.e. labels). 57 | unsigned char flags; 58 | unsigned char format; 59 | unsigned char width; 60 | short int x; 61 | short int y; 62 | union 63 | { // Limits do not have to be specified, if the values are not going to be changeable by the user. 64 | struct 65 | { 66 | int value; 67 | int min, max; 68 | } value; 69 | struct 70 | { 71 | const char *buffer; 72 | int maxlen; 73 | } string; 74 | struct 75 | { 76 | const int *labels; 77 | int count; 78 | int selectedIndex; 79 | } enumeration; 80 | struct 81 | { 82 | int id; 83 | int TextWidth; 84 | } label; 85 | }; 86 | }; 87 | 88 | struct UIBtnHint 89 | { 90 | short int button; 91 | short int label; 92 | }; 93 | 94 | struct UIMenu 95 | { 96 | struct UIMenu *next, *prev; 97 | struct UIMenuItem *items; 98 | struct UIBtnHint hints[2]; 99 | }; 100 | 101 | enum UI_MENU_TRANSITION { 102 | UIMT_LEFT_OUT, 103 | UIMT_RIGHT_OUT, 104 | UIMT_LEFT_IN, 105 | UIMT_RIGHT_IN, 106 | UIMT_FADE_IN, 107 | UIMT_FADE_OUT, 108 | }; 109 | 110 | const char *GetUIString(unsigned int id); 111 | const char *GetUILabel(unsigned int id); 112 | int InitializeUI(int BufferFont); 113 | int ReinitializeUI(void); 114 | void DeinitializeUI(void); 115 | int ShowMessageBox(int Option1Label, int Option2Label, int Option3Label, int Option4Label, const char *message, int title); 116 | void DisplayWarningMessage(unsigned int message); 117 | void DisplayErrorMessage(unsigned int message); 118 | void DisplayInfoMessage(unsigned int message); 119 | int DisplayPromptMessage(unsigned int message, unsigned char Button1Label, unsigned char Button2Label); 120 | void DisplayFlashStatusUpdate(unsigned int message); 121 | 122 | struct UIMenuItem *UIGetItem(struct UIMenu *menu, unsigned char id); 123 | void UISetVisible(struct UIMenu *menu, unsigned char id, int visible); 124 | void UISetReadonly(struct UIMenu *menu, unsigned char id, int readonly); 125 | void UISetEnabled(struct UIMenu *menu, unsigned char id, int enabled); 126 | void UISetValue(struct UIMenu *menu, unsigned char id, int value); 127 | int UIGetValue(struct UIMenu *menu, unsigned char id); 128 | void UISetLabel(struct UIMenu *menu, unsigned char id, int label); 129 | void UISetString(struct UIMenu *menu, unsigned char id, const char *string); 130 | void UISetType(struct UIMenu *menu, unsigned char id, unsigned char type); 131 | void UISetFormat(struct UIMenu *menu, unsigned char id, unsigned char format, unsigned char width); 132 | void UISetEnum(struct UIMenu *menu, unsigned char id, const int *labels, int count); 133 | void UISetEnumSelectedIndex(struct UIMenu *menu, unsigned char id, int selectedIndex); 134 | int UIGetEnumSelectedIndex(struct UIMenu *menu, unsigned char id); 135 | void UIDrawMenu(struct UIMenu *menu, unsigned short int frame, short int StartX, short int StartY, short int selection); 136 | void UITransition(struct UIMenu *menu, int type, int SelectedOption); 137 | int UIExecMenu(struct UIMenu *FirstMenu, short int SelectedItem, struct UIMenu **CurrentMenu, int (*callback)(struct UIMenu *menu, unsigned short int frame, int selection, u32 padstatus)); 138 | -------------------------------------------------------------------------------- /apa-hdl/Makefile: -------------------------------------------------------------------------------- 1 | # _____ ___ ____ ___ ____ 2 | # ____| | ____| | | |____| 3 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 4 | #----------------------------------------------------------------------- 5 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 6 | # Licenced under Academic Free License version 2.0 7 | # Review ps2sdk README & LICENSE files for further details. 8 | 9 | LIBAPA_PATH = $(PS2SDKSRC)/iop/hdd/libapa/ 10 | 11 | LIBAPA_SRC_DIR = $(LIBAPA_PATH)src/ 12 | 13 | IOP_BIN ?= ps2hdd-hdl.irx 14 | 15 | IOP_INCS += -I$(PS2SDKSRC)/iop/dev9/poweroff/include -I$(PS2SDKSRC)/iop/dev9/dev9/include -I$(PS2SDKSRC)/iop/dev9/atad/include -I$(LIBAPA_PATH)include 16 | IOP_CFLAGS += -DAPA_OSD_VER 17 | 18 | APA_OBJS = password.o misc.o cache.o apa.o journal.o free.o 19 | IOP_OBJS = hdd_fio.o hdd.o imports.o $(APA_OBJS) 20 | 21 | include $(PS2SDKSRC)/Defs.make 22 | include $(PS2SDKSRC)/iop/Rules.bin.make 23 | include $(PS2SDKSRC)/iop/Rules.make 24 | include $(PS2SDKSRC)/iop/Rules.release 25 | 26 | $(IOP_OBJS_DIR)%.o: $(LIBAPA_SRC_DIR)%.c 27 | $(IOP_CC) $(IOP_CFLAGS) -c $< -o $@ 28 | -------------------------------------------------------------------------------- /apa-hdl/src/apa-opt.h: -------------------------------------------------------------------------------- 1 | #ifndef _APA_OPT_H 2 | #define _APA_OPT_H 3 | 4 | #define APA_PRINTF(format, ...) printf(format, ##__VA_ARGS__) 5 | #define APA_DRV_NAME "hdd" 6 | 7 | /* Define APA_OSD_VER in your Makefile to build an OSD version, which will: 8 | 1. (currently disabled) When formatting, do not create any partitions other than __mbr. 9 | 2. __mbr will be formatted with its password. 10 | 3. All partitions can be accessed, even without the right password. 11 | 4. The starting LBA of the partition will be returned in 12 | the private_5 field of the stat structure (returned by getstat and dread). */ 13 | 14 | #ifdef APA_OSD_VER 15 | #define APA_STAT_RETURN_PART_LBA 1 16 | #define APA_FORMAT_LOCK_MBR 1 17 | #define APA_FORMAT_MAKE_PARTITIONS 1 // For now, define this because I don't think we're ready (and want to) deal with the official passwords. 18 | #else 19 | #define APA_ENABLE_PASSWORDS 1 20 | #define APA_FORMAT_MAKE_PARTITIONS 1 21 | #endif 22 | 23 | // Module version 24 | #define APA_MODVER_MAJOR 2 25 | #define APA_MODVER_MINOR 5 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /apa-hdl/src/hdd.c: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # Start Up routines 11 | */ 12 | 13 | #include 14 | #ifdef _IOP 15 | #include 16 | #include 17 | #else 18 | #include 19 | #include 20 | #endif 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "apa-opt.h" 29 | #include 30 | #include "hdd.h" 31 | #include "hdd_fio.h" 32 | 33 | #ifdef _IOP 34 | IRX_ID("hdd_driver", APA_MODVER_MAJOR, APA_MODVER_MINOR); 35 | #endif 36 | 37 | static iop_device_ops_t hddOps = { 38 | hddInit, 39 | hddDeinit, 40 | hddFormat, 41 | hddOpen, 42 | hddClose, 43 | hddRead, 44 | hddWrite, 45 | hddLseek, 46 | (void *)hddUnsupported, 47 | hddRemove, 48 | (void *)hddUnsupported, 49 | (void *)hddUnsupported, 50 | hddDopen, 51 | hddClose, 52 | hddDread, 53 | hddGetStat, 54 | (void *)hddUnsupported, 55 | hddReName, 56 | (void *)hddUnsupported, 57 | (void *)hddUnsupported, 58 | (void *)hddUnsupported, 59 | (void *)hddUnsupported, 60 | (void *)hddUnsupported, 61 | hddDevctl, 62 | (void *)hddUnsupported, 63 | (void *)hddUnsupported, 64 | hddIoctl2, 65 | }; 66 | static iop_device_t hddFioDev = { 67 | "hdd", 68 | IOP_DT_BLOCK | IOP_DT_FSEXT, 69 | 1, 70 | "HDD", 71 | (struct _iop_device_ops *)&hddOps, 72 | }; 73 | 74 | apa_device_t hddDevices[2] = { 75 | {0, 0, 0, 3}, 76 | {0, 0, 0, 3}}; 77 | 78 | extern int apaMaxOpen; 79 | extern hdd_file_slot_t *hddFileSlots; 80 | 81 | static int inputError(char *input); 82 | static int unlockDrive(s32 device); 83 | static void hddShutdownCb(void); 84 | static int hddInitError(void); 85 | 86 | int hddCheckPartitionMax(s32 device, u32 size) 87 | { 88 | return (hddDevices[device].partitionMaxSize >= size) ? 0 : -EINVAL; 89 | } 90 | 91 | apa_cache_t *hddAddPartitionHere(s32 device, const apa_params_t *params, u32 *emptyBlocks, 92 | u32 sector, int *err) 93 | { 94 | apa_cache_t *clink_this; 95 | apa_cache_t *clink_next; 96 | apa_cache_t *clink_new; 97 | apa_header_t *header; 98 | u32 i; 99 | u32 tmp, some_size, part_end; 100 | u32 tempSize; 101 | 102 | // walk empty blocks in case can use one :) 103 | for (i = 0; i < 32; i++) { 104 | if ((u32)(1 << i) >= params->size && emptyBlocks[i] != 0) 105 | return apaInsertPartition(device, params, emptyBlocks[i], err); 106 | } 107 | clink_this = apaCacheGetHeader(device, sector, APA_IO_MODE_READ, err); 108 | header = clink_this->header; 109 | part_end = header->start + header->length; 110 | some_size = (part_end % params->size); 111 | tmp = some_size ? params->size - some_size : 0; 112 | 113 | if (hddDevices[device].totalLBA < (part_end + params->size + tmp) 114 | // Non-SONY: when dealing with large disks, this check may overflow (therefore, check for overflows!). 115 | || (part_end < sector)) { 116 | *err = -ENOSPC; 117 | apaCacheFree(clink_this); 118 | return NULL; 119 | } 120 | 121 | if ((clink_next = apaCacheGetHeader(device, 0, APA_IO_MODE_READ, err)) == NULL) { 122 | apaCacheFree(clink_this); 123 | return NULL; 124 | } 125 | 126 | tempSize = params->size; 127 | while (part_end % params->size) { 128 | tempSize = params->size >> 1; 129 | while (0x3FFFF < tempSize) { 130 | if (!(part_end % tempSize)) { 131 | clink_new = apaRemovePartition(device, part_end, 0, 132 | clink_this->header->start, tempSize); 133 | clink_this->header->next = part_end; 134 | clink_this->flags |= APA_CACHE_FLAG_DIRTY; 135 | clink_next->header->prev = clink_new->header->start; 136 | part_end += tempSize; 137 | clink_next->flags |= APA_CACHE_FLAG_DIRTY; 138 | apaCacheFlushAllDirty(device); 139 | apaCacheFree(clink_this); 140 | clink_this = clink_new; 141 | break; 142 | } 143 | tempSize >>= 1; 144 | } 145 | } 146 | if ((clink_new = apaFillHeader(device, params, part_end, 0, clink_this->header->start, 147 | params->size, err)) != NULL) { 148 | clink_this->header->next = part_end; 149 | clink_this->flags |= APA_CACHE_FLAG_DIRTY; 150 | clink_next->header->prev = clink_new->header->start; 151 | clink_next->flags |= APA_CACHE_FLAG_DIRTY; 152 | apaCacheFlushAllDirty(device); 153 | } 154 | apaCacheFree(clink_this); 155 | apaCacheFree(clink_next); 156 | return clink_new; 157 | } 158 | 159 | static int inputError(char *input) 160 | { 161 | APA_PRINTF(APA_DRV_NAME ": Error: Usage: %s [-o ] [-n ]\n", input); 162 | return MODULE_NO_RESIDENT_END; 163 | } 164 | 165 | static void printStartup(void) 166 | { 167 | APA_PRINTF(APA_DRV_NAME ": PS2 APA Driver v%d.%d (c) 2003 Vector\n", APA_MODVER_MAJOR, APA_MODVER_MINOR); 168 | return; 169 | } 170 | 171 | static int unlockDrive(s32 device) 172 | { 173 | u8 id[32]; 174 | int rv; 175 | if ((rv = apaGetIlinkID(id)) == 0) 176 | return ata_device_sce_sec_unlock(device, id); 177 | return rv; 178 | } 179 | 180 | int _start(int argc, char **argv) 181 | { 182 | int i, ret; 183 | char *input; 184 | int cacheSize = 3; 185 | apa_ps2time_t tm; 186 | ata_devinfo_t *hddInfo; 187 | 188 | printStartup(); 189 | 190 | if ((input = strrchr(argv[0], '/'))) 191 | input++; 192 | else 193 | input = argv[0]; 194 | 195 | argc--; 196 | argv++; 197 | while (argc) { 198 | if (argv[0][0] != '-') 199 | break; 200 | if (strcmp("-o", argv[0]) == 0) { 201 | argc--; 202 | argv++; 203 | if (!argc) 204 | return inputError(input); 205 | i = strtol(argv[0], 0, 10); 206 | if (i - 1 < 32) 207 | apaMaxOpen = i; 208 | } else if (strcmp("-n", argv[0]) == 0) { 209 | argc--; 210 | argv++; 211 | if (!argc) 212 | return inputError(input); 213 | i = strtol(*argv, 0, 10); 214 | if (cacheSize < i) 215 | cacheSize = i; 216 | } 217 | argc--; 218 | argv++; 219 | } 220 | 221 | APA_PRINTF(APA_DRV_NAME ": max open = %d, %d buffers\n", apaMaxOpen, cacheSize); 222 | if (dev9RegisterShutdownCb(0, &hddShutdownCb) != 0) { 223 | APA_PRINTF(APA_DRV_NAME ": error: dev9 may not be resident.\n"); 224 | return hddInitError(); 225 | } 226 | 227 | if (apaGetTime(&tm) != 0) { 228 | APA_PRINTF(APA_DRV_NAME ": error: could not get date.\n"); 229 | return hddInitError(); 230 | } 231 | 232 | APA_PRINTF(APA_DRV_NAME ": %02d:%02d:%02d %02d/%02d/%d\n", 233 | tm.hour, tm.min, tm.sec, tm.month, tm.day, tm.year); 234 | for (i = 0; i < 2; i++) { 235 | if (!(hddInfo = ata_get_devinfo(i))) { 236 | APA_PRINTF(APA_DRV_NAME ": Error: ata initialization failed.\n"); 237 | return hddInitError(); 238 | } 239 | if (hddInfo->exists != 0 && hddInfo->has_packet == 0) { 240 | hddDevices[i].status--; 241 | hddDevices[i].totalLBA = hddInfo->total_sectors; 242 | hddDevices[i].partitionMaxSize = apaGetPartitionMax(hddInfo->total_sectors); 243 | if (unlockDrive(i) == 0) 244 | hddDevices[i].status--; 245 | APA_PRINTF(APA_DRV_NAME ": disk%d: 0x%08lx sectors, max 0x%08lx\n", i, 246 | hddDevices[i].totalLBA, hddDevices[i].partitionMaxSize); 247 | } 248 | } 249 | hddFileSlots = apaAllocMem(apaMaxOpen * sizeof(hdd_file_slot_t)); 250 | ret = (hddFileSlots == NULL) ? -ENOMEM : 0; 251 | if (ret != 0) { 252 | APA_PRINTF(APA_DRV_NAME ": error: file descriptor initialization failed.\n"); 253 | return hddInitError(); 254 | } 255 | 256 | memset(hddFileSlots, 0, apaMaxOpen * sizeof(hdd_file_slot_t)); 257 | 258 | if (apaCacheInit(cacheSize) != 0) { 259 | APA_PRINTF(APA_DRV_NAME ": error: cache buffer initialization failed.\n"); 260 | return hddInitError(); 261 | } 262 | 263 | for (i = 0; i < 2; i++) { 264 | if (hddDevices[i].status < 2) { 265 | if (apaJournalRestore(i) != 0) { 266 | APA_PRINTF(APA_DRV_NAME ": error: log check failed.\n"); 267 | return hddInitError(); 268 | } 269 | if (apaGetFormat(i, &hddDevices[i].format)) 270 | hddDevices[i].status--; 271 | APA_PRINTF(APA_DRV_NAME ": drive status %d, format version %08x\n", 272 | hddDevices[i].status, hddDevices[i].format); 273 | } 274 | } 275 | DelDrv("hdd"); 276 | if (AddDrv(&hddFioDev) == 0) { 277 | #ifdef APA_OSD_VER 278 | APA_PRINTF(APA_DRV_NAME ": version %04x driver start. This is OSD version!\n", IRX_VER(APA_MODVER_MAJOR, APA_MODVER_MINOR)); 279 | #else 280 | APA_PRINTF(APA_DRV_NAME ": version %04x driver start.\n", IRX_VER(APA_MODVER_MAJOR, APA_MODVER_MINOR)); 281 | #endif 282 | return MODULE_RESIDENT_END; 283 | } else { 284 | APA_PRINTF(APA_DRV_NAME ": error: add device failed.\n"); 285 | return hddInitError(); 286 | } 287 | } 288 | 289 | static void hddShutdownCb(void) 290 | { 291 | int i; 292 | 293 | for (i = 0; i < 2; i++) { 294 | if (hddDevices[i].status == 0) 295 | ata_device_smart_save_attr(i); 296 | } 297 | } 298 | 299 | static int hddInitError(void) 300 | { 301 | dev9RegisterShutdownCb(0, NULL); 302 | return MODULE_NO_RESIDENT_END; 303 | } 304 | -------------------------------------------------------------------------------- /apa-hdl/src/hdd.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # HDD.IRX APA Header file 11 | */ 12 | 13 | #ifndef _HDD_H 14 | #define _HDD_H 15 | 16 | typedef struct 17 | { 18 | iop_file_t *f; // used to see if open... 19 | u32 post; // offset/post.... 20 | u16 nsub; 21 | u16 type; 22 | char id[APA_IDMAX]; 23 | apa_sub_t parts[APA_MAXSUB + 1]; // Partition data (0 = main partition, 1+ = sub-partition) 24 | } hdd_file_slot_t; 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | // Function declarations 28 | int hddCheckPartitionMax(s32 device, u32 size); 29 | apa_cache_t *hddAddPartitionHere(s32 device, const apa_params_t *params, u32 *EmptyBlocks, u32 sector, int *err); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /apa-hdl/src/hdd_fio.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | */ 10 | 11 | #ifndef _HDD_FIO_H 12 | #define _HDD_FIO_H 13 | 14 | // I/O functions 15 | int hddInit(iop_device_t *f); 16 | int hddDeinit(iop_device_t *f); 17 | int hddFormat(iop_file_t *f, const char *dev, const char *blockdev, void *arg, int arglen); 18 | int hddOpen(iop_file_t *f, const char *name, int flags, int mode); 19 | int hddClose(iop_file_t *f); 20 | int hddRead(iop_file_t *f, void *buf, int size); 21 | int hddWrite(iop_file_t *f, void *buf, int size); 22 | int hddLseek(iop_file_t *f, int post, int whence); 23 | int hddIoctl2(iop_file_t *f, int request, void *argp, unsigned int arglen, void *bufp, unsigned intbuflen); 24 | int hddRemove(iop_file_t *f, const char *name); 25 | int hddDopen(iop_file_t *f, const char *name); 26 | int hddDread(iop_file_t *f, iox_dirent_t *dirent); 27 | int hddGetStat(iop_file_t *f, const char *name, iox_stat_t *stat); 28 | int hddReName(iop_file_t *f, const char *oldname, const char *newname); 29 | int hddDevctl(iop_file_t *f, const char *devname, int cmd, void *arg, unsigned int arglen, void *bufp, unsigned int buflen); 30 | 31 | int hddUnsupported(iop_file_t *f); 32 | 33 | #endif /* _HDD_FIO_H */ 34 | -------------------------------------------------------------------------------- /apa-hdl/src/imports.lst: -------------------------------------------------------------------------------- 1 | 2 | atad_IMPORTS_start 3 | I_ata_get_devinfo 4 | I_ata_device_sector_io 5 | I_ata_device_sce_sec_unlock 6 | I_ata_device_idle 7 | I_ata_device_sce_identify_drive 8 | I_ata_device_smart_get_status 9 | I_ata_device_smart_save_attr 10 | I_ata_device_flush_cache 11 | I_ata_device_idle_immediate 12 | atad_IMPORTS_end 13 | 14 | cdvdman_IMPORTS_start 15 | I_sceCdReadClock 16 | I_sceCdRI 17 | cdvdman_IMPORTS_end 18 | 19 | dev9_IMPORTS_start 20 | I_dev9Shutdown 21 | I_dev9RegisterShutdownCb 22 | dev9_IMPORTS_end 23 | 24 | intrman_IMPORTS_start 25 | I_CpuSuspendIntr 26 | I_CpuResumeIntr 27 | intrman_IMPORTS_end 28 | 29 | iomanX_IMPORTS_start 30 | I_AddDrv 31 | I_DelDrv 32 | iomanX_IMPORTS_end 33 | 34 | stdio_IMPORTS_start 35 | I_printf 36 | stdio_IMPORTS_end 37 | 38 | sysclib_IMPORTS_start 39 | I_memcmp 40 | I_memcpy 41 | I_memset 42 | I_strchr 43 | I_strcmp 44 | I_strcpy 45 | I_strlen 46 | I_strncmp 47 | I_strncpy 48 | I_strrchr 49 | I_strtol 50 | sysclib_IMPORTS_end 51 | 52 | sysmem_IMPORTS_start 53 | I_AllocSysMemory 54 | I_FreeSysMemory 55 | sysmem_IMPORTS_end 56 | 57 | thbase_IMPORTS_start 58 | I_DelayThread 59 | thbase_IMPORTS_end 60 | 61 | thsemap_IMPORTS_start 62 | I_CreateSema 63 | I_DeleteSema 64 | I_SignalSema 65 | I_WaitSema 66 | thsemap_IMPORTS_end 67 | -------------------------------------------------------------------------------- /apa-hdl/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright (c) 2003 Marcus R. Brown 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # Defines all IRX imports. 11 | */ 12 | 13 | #ifndef IOP_IRX_IMPORTS_H 14 | #define IOP_IRX_IMPORTS_H 15 | 16 | #include 17 | 18 | /* Please keep these in alphabetical order! */ 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #endif /* IOP_IRX_IMPORTS_H */ 31 | -------------------------------------------------------------------------------- /documentation/Developer notes.txt: -------------------------------------------------------------------------------- 1 | To compile this software, you need: 2 | 1. An updated PS2SDK (https://github.com/ps2dev/ps2sdk). 3 | 2. libpng and all its dependencies (zlib and libmath). If you can't compile libpng for use on a Windows development environment, you may need to do so in Linux before copying the compiled library over. 4 | 3. gsKit, as well as FreeType and its dependencies. 5 | -------------------------------------------------------------------------------- /documentation/Translation notes.txt: -------------------------------------------------------------------------------- 1 | The PlayStation universally supports 8 languages: 2 | 1. Japanese 3 | 2. English 4 | 3. French 5 | 4. Spanish 6 | 5. German 7 | 6. Italian 8 | 7. Dutch 9 | 8. Portuguese 10 | 11 | These languages are also supported on certain models (localized fat PS2s and all slimline), but aren't recognized by the System Configuration (SCF) library that Sony uses in games: 12 | 1. Russian 13 | 2. Korean 14 | 3. Traditional Chinese. 15 | 4. Simplified Chinese 16 | 17 | ***At this point, only the basic 8 languages are supported.*** 18 | 19 | Customizable files under the "lang" folder: 20 | fonts.txt -> Contains the filenames of the font to use for each language. One file on each line for each language. 21 | labels_XX.txt -> Contains labels. One label per line. This file should be saved in the UTF-8 encoding. 22 | strings_XX.txt -> Contains strings (messages). One string per line. This file should be saved in the UTF-8 encoding. 23 | *.ttf -> Font files. Only files specified in fonts.txt will be used. If your language needs characters not found in the English script, add a font file that can be loaded by FreeType and update the appropriate line within fonts.txt. 24 | 25 | XX = a two-letter code representing each language. If the file cannot be loaded, the system will use its defaults (English-language resources). 26 | 27 | Language codes: 28 | Language: Code: Line number (in fonts.txt): 29 | Japanese JA 1 30 | English EN 2 31 | French FR 3 32 | Spanish SP 4 33 | German GE 5 34 | Italian IT 6 35 | Dutch DU 7 36 | Portuguese PO 8 37 | -------------------------------------------------------------------------------- /font.h: -------------------------------------------------------------------------------- 1 | #define FNT_ATLAS_WIDTH 128 2 | #define FNT_ATLAS_HEIGHT 128 3 | #define FNT_MAX_ATLASES 4 4 | #define FNT_CHAR_WIDTH 16 5 | #define FNT_CHAR_HEIGHT 16 6 | #define FNT_TAB_STOPS 4 7 | 8 | int FontInit(GSGLOBAL *gsGlobal, const char *FontFile); 9 | int FontInitWithBuffer(GSGLOBAL *gsGlobal, void *buffer, unsigned int size); 10 | int AddSubFont(GSGLOBAL *gsGlobal, const char *FontFile); 11 | int AddSubFontWithBuffer(GSGLOBAL *gsGlobal, void *buffer, unsigned int size); 12 | void FontDeinit(void); 13 | int FontReset(GSGLOBAL *gsGlobal); // Performs a partial re-initialization of the Font library and re-allocates VRAM. Used when VRAM has been cleared. 14 | void FontPrintfWithFeedback(GSGLOBAL *gsGlobal, short int x, short int y, short int z, float scale, u64 colour, const char *string, short int *xRel, short int *yRel); 15 | void FontPrintf(GSGLOBAL *gsGlobal, short int x, short int y, short int z, float scale, u64 colour, const char *string); 16 | void FontGetPrintPos(GSGLOBAL *gsGlobal, short int *x_rel, short int *y_rel, float scale, const char *string, int pos); 17 | int FontGetGlyphWidth(GSGLOBAL *gsGlobal, wint_t character); 18 | void wFontPrintfWithFeedback(GSGLOBAL *gsGlobal, short x, short int y, short int z, float scale, u64 colour, const wchar_t *string, short int *xRel, short int *yRel); 19 | void wFontPrintf(GSGLOBAL *gsGlobal, short int x, short int y, short int z, float scale, u64 colour, const wchar_t *string); 20 | int wFontPrintField(GSGLOBAL *gsGlobal, short int x, short int y, short int z, float scale, u64 colour, const wchar_t *string, unsigned int spacePix, int cursor); 21 | int wFontPrintTitle(GSGLOBAL *gsGlobal, short int x, short int y, short int z, float scale, u64 colour, const wchar_t *string, unsigned int spacePix); 22 | -------------------------------------------------------------------------------- /graphics.h: -------------------------------------------------------------------------------- 1 | // Define if the background should be centered instead of being stretched. 2 | // #define CENTRE_BACKGROUND 1 3 | 4 | #define GS_WHITE GS_SETREG_RGBAQ(0xFF, 0xFF, 0xFF, 0x00, 0x00) 5 | #define GS_BLACK GS_SETREG_RGBAQ(0x00, 0x00, 0x00, 0x00, 0x00) 6 | #define GS_GREY GS_SETREG_RGBAQ(0x30, 0x30, 0x30, 0x00, 0x00) 7 | #define GS_LGREY GS_SETREG_RGBAQ(0x50, 0x50, 0x50, 0x00, 0x00) 8 | #define GS_DBLUE GS_SETREG_RGBAQ(0x00, 0x00, 0x50, 0x00, 0x00) 9 | #define GS_BLUE GS_SETREG_RGBAQ(0x00, 0x00, 0x80, 0x00, 0x00) 10 | #define GS_LBLUE_TRANS GS_SETREG_RGBAQ(0x00, 0x00, 0x80, 0x30, 0x00) 11 | #define GS_YELLOW GS_SETREG_RGBAQ(0x80, 0x80, 0x30, 0x00, 0x00) 12 | #define GS_LRED_TRANS GS_SETREG_RGBAQ(0x80, 0x00, 0x00, 0x30, 0x00) 13 | 14 | #define GS_WHITE_FONT GS_SETREG_RGBAQ(0x80, 0x80, 0x80, 0x80, 0x00) 15 | #define GS_GREY_FONT GS_SETREG_RGBAQ(0x30, 0x30, 0x30, 0x80, 0x00) 16 | #define GS_YELLOW_FONT GS_SETREG_RGBAQ(0x80, 0x80, 0x30, 0x80, 0x00) 17 | #define GS_BLUE_FONT GS_SETREG_RGBAQ(0x30, 0x30, 0x80, 0x80, 0x00) 18 | 19 | /* Button types, for use with DrawButtonLegend() */ 20 | enum BUTTON_TYPE { 21 | BUTTON_TYPE_CIRCLE = 0, 22 | BUTTON_TYPE_CROSS, 23 | BUTTON_TYPE_SQUARE, 24 | BUTTON_TYPE_TRIANGLE, 25 | BUTTON_TYPE_L1, 26 | BUTTON_TYPE_R1, 27 | BUTTON_TYPE_L2, 28 | BUTTON_TYPE_R2, 29 | BUTTON_TYPE_L3, 30 | BUTTON_TYPE_R3, 31 | BUTTON_TYPE_START, 32 | BUTTON_TYPE_SELECT, 33 | BUTTON_TYPE_RSTICK, 34 | BUTTON_TYPE_UP_RSTICK, 35 | BUTTON_TYPE_DOWN_RSTICK, 36 | BUTTON_TYPE_LEFT_RSTICK, 37 | BUTTON_TYPE_RIGHT_RSTICK, 38 | BUTTON_TYPE_LSTICK, 39 | BUTTON_TYPE_UP_LSTICK, 40 | BUTTON_TYPE_DOWN_LSTICK, 41 | BUTTON_TYPE_LEFT_LSTICK, 42 | BUTTON_TYPE_RIGHT_LSTICK, 43 | BUTTON_TYPE_DPAD, 44 | BUTTON_TYPE_LR_DPAD, 45 | BUTTON_TYPE_UD_DPAD, 46 | BUTTON_TYPE_UP_DPAD, 47 | BUTTON_TYPE_DOWN_DPAD, 48 | BUTTON_TYPE_LEFT_DPAD, 49 | BUTTON_TYPE_RIGHT_DPAD, 50 | 51 | BUTTON_TYPE_COUNT 52 | }; 53 | 54 | enum DEVICE_TYPE { 55 | DEVICE_TYPE_FOLDER, 56 | DEVICE_TYPE_FILE, 57 | DEVICE_TYPE_DISK, 58 | DEVICE_TYPE_USB_DISK, 59 | DEVICE_TYPE_ROM, 60 | DEVICE_TYPE_SD_CARD, 61 | DEVICE_TYPE_DISC, 62 | 63 | DEVICE_TYPE_COUNT 64 | }; 65 | 66 | #define DEVICE_ICON_SCALE 2 67 | 68 | // Special button types 69 | #define BUTTON_TYPE_SYS_SELECT 0x40 70 | #define BUTTON_TYPE_SYS_CANCEL 0x41 71 | 72 | int UploadTexture(GSGLOBAL *gsGlobal, GSTEXTURE *Texture); 73 | int LoadBackground(GSGLOBAL *gsGlobal, GSTEXTURE *Texture); 74 | int LoadPadGraphics(GSGLOBAL *gsGlobal, GSTEXTURE *Texture); 75 | int LoadDeviceIcons(GSGLOBAL *gsGlobal, GSTEXTURE *Texture); 76 | 77 | void DrawBackground(GSGLOBAL *gsGlobal, GSTEXTURE *background); 78 | void DrawButtonLegendWithFeedback(GSGLOBAL *gsGlobal, GSTEXTURE *PadGraphicsTexture, unsigned char ButtonType, short int x, short int y, short int z, short int *xRel); 79 | void DrawButtonLegend(GSGLOBAL *gsGlobal, GSTEXTURE *PadGraphicsTexture, unsigned char ButtonType, short int x, short int y, short int z); 80 | void DrawDeviceIconWithFeedback(GSGLOBAL *gsGlobal, GSTEXTURE *IconTexture, unsigned char icon, short int x, short int y, short int z, short int *xRel); 81 | void DrawDeviceIcon(GSGLOBAL *gsGlobal, GSTEXTURE *IconTexture, unsigned char icon, short int x, short int y, short int z); 82 | void DrawProgressBar(GSGLOBAL *gsGlobal, float percentage, short int x, short int y, short int z, short int len, u64 colour); 83 | 84 | void SyncFlipFB(void); 85 | -------------------------------------------------------------------------------- /hdlfs/Makefile: -------------------------------------------------------------------------------- 1 | IOP_BIN = hdlfs.irx 2 | IOP_OBJS = main.o imports.o 3 | 4 | IOP_CFLAGS += -Wall -fno-builtin 5 | IOP_LDFLAGS += -s 6 | IOP_INCS += -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include 7 | 8 | all: $(IOP_BIN) 9 | 10 | clean: 11 | rm -f $(IOP_BIN) $(IOP_OBJS) 12 | 13 | include $(PS2SDK)/Defs.make 14 | include Rules.make 15 | -------------------------------------------------------------------------------- /hdlfs/README.txt: -------------------------------------------------------------------------------- 1 | How this driver is designed to be used for creating game partitions: 2 | -------------------------------------------------------------------- 3 | 4 | 1. A partition is created with the accompanying modified PS2HDD module. If the partition is not large enough to hold the entire game, create sufficient sub-partitions to store the entire game. 5 | Note: The size of the sub-partitions is expected to be of the same size as the main partition, with the exception of the last subpartition. All partitions are expected to be of the largest allowable size, except for the last partition (Which may be smaller). 6 | 2. mount the created partition with HDLFS. 7 | HDLFS shall allocate a handle for future I/O access to the partition. 8 | 3. Format the partition, specifying the game's data. 9 | HDLFS shall initialize the HDL Game information area (Sector offset 0x800 in the partition extended attribute area) with the specified parameters. 10 | 4. Open the mount point and begin writing to the partition. 11 | HDLFS will automatically determine the partition to write data to. 12 | 5. Close the mount point. 13 | 6. Unmount the mount point. Failing to do so might result in data loss. 14 | HDLFS might update game installation data and will close the mounted volume at this point. 15 | -------------------------------------------------------------------------------- /hdlfs/Research.txt: -------------------------------------------------------------------------------- 1 | An APA partition can have a parent and child partition(s). All APA partitions (Regardless of whether they are Child or Parent partitions), have a 2-sector area reserved for storing the APA partition header. 2 | 3 | There is also a reserved area at the beginning of each parent partition, known as the attribute area. It contains information about the contents of the partition and boot information. It also contains resources like icons for a Sony dashboard to use for display. 4 | Parent partitions have a 4MB (0x2000 512-byte sectors) attribute area, which includes it's APA partition header area (2 sectors long). 5 | 6 | File READ/WRITE I/O operations to the APA device is used for reading and writing to the attribute area of the parent partition. 7 | Child partitions do not have such an area, and hence file READ/WRITE I/O operations should not be performed with child partitions. 8 | 9 | When data is written to the attribute area via the READ/WRITE I/O operation functions of the APA driver, data is written to sector 8 onwards. 10 | 11 | IOCTL2 calls to the APA device are used for reading and writing data to the partition. As parent partitions have a 4MB attribute area and an APA header at the beginning of it, therefore, data transfers should begin at logical sector 0x2000. 12 | As for child partitions, they still have the 2-sector APA header. Therefore, data transfers should begin from logical sector 2 onwards. 13 | 14 | HDLoader has the game's information stored at sector 0x800 to 0x801 of the parent partition's attribute area when accessed via the APA driver's file I/O operation functions. 15 | (Therefore, their actual offsets are 0x808 and 0x809 from the start of the partition, respectively) 16 | -------------------------------------------------------------------------------- /hdlfs/Rules.make: -------------------------------------------------------------------------------- 1 | # _____ ___ ____ ___ ____ 2 | # ____| | ____| | | |____| 3 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 4 | #----------------------------------------------------------------------- 5 | # Copyright 2001-2004. 6 | # Licenced under Academic Free License version 2.0 7 | # Review ps2sdk README & LICENSE files for further details. 8 | 9 | 10 | IOP_CC_VERSION := $(shell $(IOP_CC) -v 2>&1 | sed -n 's/^.*version //p') 11 | 12 | ASFLAGS_TARGET = -mcpu=r3000 13 | 14 | ifeq ($(IOP_CC_VERSION),3.2.2) 15 | CFLAGS_TARGET = -miop 16 | ASFLAGS_TARGET = -march=r3000 17 | LDFLAGS_TARGET = -miop 18 | endif 19 | 20 | ifeq ($(IOP_CC_VERSION),3.2.3) 21 | CFLAGS_TARGET = -miop 22 | ASFLAGS_TARGET = -march=r3000 23 | LDFLAGS_TARGET = -miop 24 | endif 25 | 26 | IOP_INCS := $(IOP_INCS) -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include 27 | 28 | IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 -D_IOP -c $(IOP_INCS) $(IOP_CFLAGS) 29 | IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS) 30 | IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib $(IOP_LDFLAGS) 31 | 32 | # Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB 33 | 34 | %.o : %.c 35 | $(IOP_CC) $(IOP_CFLAGS) $< -o $@ 36 | 37 | %.o : %.s 38 | $(IOP_AS) $(IOP_ASFLAGS) $< -o $@ 39 | 40 | # A rule to build imports.lst. 41 | %.o : %.lst 42 | echo "#include \"irx_imports.h\"" > build-imports.c 43 | cat $< >> build-imports.c 44 | $(IOP_CC) $(IOP_CFLAGS) build-imports.c -o $@ 45 | -rm -f build-imports.c 46 | 47 | # A rule to build exports.tab. 48 | %.o : %.tab 49 | echo "#include \"irx.h\"" > build-exports.c 50 | cat $< >> build-exports.c 51 | $(IOP_CC) $(IOP_CFLAGS) build-exports.c -o $@ 52 | -rm -f build-exports.c 53 | 54 | 55 | $(IOP_BIN) : $(IOP_OBJS) 56 | $(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS) 57 | 58 | $(IOP_LIB) : $(IOP_OBJS) 59 | $(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS) 60 | 61 | -------------------------------------------------------------------------------- /hdlfs/hdlfs.h: -------------------------------------------------------------------------------- 1 | #define HDL_FS_MAGIC 0x1337 2 | #define APA_FLAG_SUB 0x0001 3 | #define HDL_INFO_MAGIC 0xDEADFEED 4 | #define HDL_GAME_DATA_OFFSET 0x100000 5 | 6 | #define HDLFS_GAME_TITLE_LEN 160 7 | #define HDLFS_STARTUP_PTH_LEN 60 8 | 9 | typedef struct 10 | { 11 | unsigned int part_offset; // In CD-ROM (2048-byte) sectors 12 | unsigned int data_start; // In 512-byte HDD sectors 13 | unsigned int part_size; // In bytes 14 | } part_specs_t; 15 | 16 | typedef struct // size = 1024 bytes 17 | { 18 | unsigned int magic; 19 | unsigned short int reserved; 20 | unsigned short int version; 21 | char gamename[HDLFS_GAME_TITLE_LEN]; 22 | unsigned char hdl_compat_flags; 23 | unsigned char ops2l_compat_flags; 24 | unsigned char dma_type; 25 | unsigned char dma_mode; 26 | char startup[HDLFS_STARTUP_PTH_LEN]; /* NOTE: The startup file name here must be without the ";1" suffix. */ 27 | unsigned int layer1_start; 28 | unsigned int discType; 29 | int num_partitions; 30 | part_specs_t part_specs[65]; 31 | } hdl_game_info; 32 | 33 | enum HDLFS_DEVCTL_codes { 34 | HDLFS_DEVCTL_GET_STARTUP_PATH = 0x1000, 35 | HDLFS_DEVCTL_GET_TITLE, 36 | HDLFS_DEVCTL_SET_TITLE 37 | }; 38 | 39 | struct HDLFS_FormatArgs 40 | { 41 | unsigned char CompatFlags, DiscType; 42 | unsigned char TRType, TRMode; 43 | unsigned int NumSectors, Layer1Start; 44 | char GameTitle[HDLFS_GAME_TITLE_LEN]; // In UTF-8 45 | char StartupPath[HDLFS_STARTUP_PTH_LEN]; /* NOTE: The startup file name here must be without the ";1" suffix. */ 46 | }; 47 | -------------------------------------------------------------------------------- /hdlfs/imports.lst: -------------------------------------------------------------------------------- 1 | iomanX_IMPORTS_start 2 | I_open 3 | I_close 4 | I_getstat 5 | I_read 6 | I_write 7 | I_lseek 8 | I_dopen 9 | I_dclose 10 | I_dread 11 | I_devctl 12 | I_ioctl2 13 | I_AddDrv 14 | I_DelDrv 15 | iomanX_IMPORTS_end 16 | 17 | thsemap_IMPORTS_start 18 | I_CreateSema 19 | I_DeleteSema 20 | I_WaitSema 21 | I_SignalSema 22 | thsemap_IMPORTS_end 23 | 24 | stdio_IMPORTS_start 25 | I_printf 26 | stdio_IMPORTS_end 27 | 28 | sysclib_IMPORTS_start 29 | I_memcpy 30 | I_memset 31 | I_sprintf 32 | I_strncpy 33 | I_strtok 34 | I_strtoul 35 | I_strlen 36 | I_strcmp 37 | I_strncmp 38 | I_strcpy 39 | I_strchr 40 | sysclib_IMPORTS_end 41 | 42 | intrman_IMPORTS_start 43 | I_CpuSuspendIntr 44 | I_CpuResumeIntr 45 | intrman_IMPORTS_end 46 | 47 | sysmem_IMPORTS_start 48 | I_AllocSysMemory 49 | I_FreeSysMemory 50 | sysmem_IMPORTS_end 51 | -------------------------------------------------------------------------------- /hdlfs/irx_imports.h: -------------------------------------------------------------------------------- 1 | /* 2 | * irx_imports.h - Defines all IRX imports. 3 | */ 4 | 5 | #ifndef IOP_IRX_IMPORTS_H 6 | #define IOP_IRX_IMPORTS_H 7 | 8 | #include 9 | 10 | /* Please keep these in alphabetical order! */ 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #endif /* IOP_IRX_IMPORTS_H */ 20 | -------------------------------------------------------------------------------- /io.h: -------------------------------------------------------------------------------- 1 | struct BuffDesc 2 | { 3 | int length; 4 | }; 5 | 6 | enum IO_THREAD_STATE { 7 | IO_THREAD_STATE_OK = 0, 8 | IO_THREAD_STATE_ERROR, // Thread will also no longer receive commands. 9 | }; 10 | 11 | // IO parameters 12 | #define IO_BANKMAX 32 13 | #define IO_BANKSIZE 256 // 256 * 2048 (0.5MB) * 32 banks = 16MB total 14 | 15 | int IOWriteInit(int fd, struct BuffDesc *bd, void *buffers, unsigned short int bufmax, unsigned short int nbufs, int prio); 16 | int IOReadInit(int fd, struct BuffDesc *bd, void *buffers, unsigned short int bufmax, unsigned short int nbufs, unsigned int remaining, int prio); 17 | void *IOGetNextWrBuffer(void); 18 | void IOSignalWriteDone(int length); 19 | int IORead(void *buffer); 20 | int IOReadNext(const void **buffer); 21 | void IOReadAdvance(void); 22 | int IOEndWrite(void); 23 | int IOEndRead(void); 24 | int IOGetStatus(void); 25 | int IOAlloc(struct BuffDesc **bdOut, void **ioBufferOut); 26 | void IOFree(struct BuffDesc **bdOut, void **ioBufferOut); 27 | -------------------------------------------------------------------------------- /ipconfig.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "ipconfig.h" 10 | 11 | static char *GetNextToken(char *line, char delimiter) 12 | { 13 | char *field_end, *result; 14 | static char *current_line = NULL; 15 | 16 | result = NULL; 17 | 18 | if (line != NULL) { 19 | current_line = line; 20 | } 21 | 22 | while (*current_line == delimiter) 23 | current_line++; 24 | if (current_line[0] != '\0') { 25 | if ((field_end = strchr(current_line, delimiter)) == NULL) { 26 | field_end = ¤t_line[strlen(current_line)]; 27 | } 28 | 29 | *field_end = '\0'; 30 | 31 | if (current_line[1] != '\0') { // Test to see if there is another token after this one. 32 | result = current_line; 33 | current_line = field_end + 1; 34 | } else 35 | current_line = NULL; 36 | } else 37 | current_line = NULL; 38 | 39 | return result; 40 | } 41 | 42 | int ParseConfig(const char *path, char *ip_address, char *subnet_mask, char *gateway) 43 | { 44 | int fd, result, size; 45 | char *FileBuffer, *line, *field; 46 | unsigned int i, DataLineNum; 47 | 48 | if ((fd = fileXioOpen(path, O_RDONLY)) >= 0) { 49 | size = fileXioLseek(fd, 0, SEEK_END); 50 | fileXioLseek(fd, 0, SEEK_SET); 51 | if ((FileBuffer = malloc(size)) != NULL) { 52 | if (fileXioRead(fd, FileBuffer, size) == size) { 53 | if ((line = strtok(FileBuffer, "\r\n")) != NULL) { 54 | result = EINVAL; 55 | DataLineNum = 0; 56 | do { 57 | i = 0; 58 | while (line[i] == ' ') 59 | i++; 60 | if (line[i] != '#' && line[i] != '\0') { 61 | if (DataLineNum == 0) { 62 | if ((field = GetNextToken(line, ' ')) != NULL) { 63 | strncpy(ip_address, field, 15); 64 | ip_address[15] = '\0'; 65 | if ((field = GetNextToken(NULL, ' ')) != NULL) { 66 | strncpy(subnet_mask, field, 15); 67 | subnet_mask[15] = '\0'; 68 | if ((field = GetNextToken(NULL, ' ')) != NULL) { 69 | strncpy(gateway, field, 15); 70 | gateway[15] = '\0'; 71 | result = 0; 72 | DataLineNum++; 73 | } 74 | } 75 | } 76 | } 77 | } 78 | } while ((line = strtok(NULL, "\r\n")) != NULL); 79 | } else 80 | result = EINVAL; 81 | } else 82 | result = EIO; 83 | 84 | free(FileBuffer); 85 | } else 86 | result = ENOMEM; 87 | 88 | fileXioClose(fd); 89 | } else 90 | result = fd; 91 | 92 | return result; 93 | } 94 | -------------------------------------------------------------------------------- /ipconfig.h: -------------------------------------------------------------------------------- 1 | int ParseConfig(const char *path, char *ip_address, char *subnet_mask, char *gateway); 2 | -------------------------------------------------------------------------------- /irx/hdlfs.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/irx/hdlfs.irx -------------------------------------------------------------------------------- /irx/ps2hdd-hdl.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/irx/ps2hdd-hdl.irx -------------------------------------------------------------------------------- /lang.c: -------------------------------------------------------------------------------- 1 | static const char *DefaultLanguageStringTable[SYS_UI_MSG_COUNT] = { 2 | "System initialization error.", 3 | "Proceed?", 4 | "Cancel input?", 5 | "Please fill the full game title!", 6 | "Please fill OSD title 1!", 7 | "Change game icon?", 8 | "Unable to load selected icon. Continue with default icon?", 9 | "Failed to install OSD files.", 10 | "No harddisk drive was detected.", 11 | "Harddisk drive not formatted. Format?\nWarning: All data will be erased.", 12 | "Quit program?", 13 | "Game updated successfully!", 14 | "An error occurred while updating the game.", 15 | "Delete game?", 16 | "Please wait...", 17 | "This game was already installed.\nOverwrite old installation?", 18 | "Game installed successfully!", 19 | "Unsupported disc inserted.\nPlease insert a Playstation 2 game disc.", 20 | "Please insert a disc.", 21 | "Reading disc...", 22 | "An error occurred while reading the disc.", 23 | "An error occurred while parsing SYSTEM.CNF.\nPlease insert another disc.", 24 | "Cancel game installation?", 25 | "A read fault occurred.\nPlease check the condition of your disc.", 26 | "A write fault occurred.\nPlease send your disk for repair.", 27 | "Lack of memory.\nPlease restart the installer.", 28 | "Game installation canceled.", 29 | "Failed to access partition.", 30 | "A computer is connected to this console.\n\nPlease do not disconnect or switch off the console.", 31 | "No icons found.", 32 | "Error: there is no network connection.", 33 | "Connecting to network. Please wait.", 34 | "Error: failed to acquire an IP address from the DHCP server.", 35 | "There is insufficient space on the HardDisk Drive (HDD) unit.", 36 | "Saving. Please do not switch off or disconnect your console.", 37 | "Error: failed to save settings.", 38 | }; 39 | 40 | static const char *DefaultLanguageLabelStringTable[SYS_UI_LBL_COUNT] = { 41 | "OK", 42 | "Cancel", 43 | "Yes", 44 | "No", 45 | "Next", 46 | "Back", 47 | "Enabled", 48 | "Disabled", 49 | "Toggle option", 50 | "Select field", 51 | "Select game", 52 | "Game options", 53 | "Delete game", 54 | "Install game", 55 | "Select key", 56 | "Move cursor", 57 | "Toggle keyboard", 58 | "Enter", 59 | "Backspace", 60 | "Insert space", 61 | "Quit program", 62 | "Select icon", 63 | "Select device", 64 | "Warning", 65 | "Error", 66 | "Information", 67 | "Confirmation", 68 | "Please wait", 69 | "Remote administration mode", 70 | "Icon source:", 71 | "Now installing...", 72 | "Title:", 73 | "Disc ID:", 74 | "Disc type:", 75 | "Rate:", 76 | "Time\nremaining:", 77 | "Full title (Max 80 characters):", 78 | "OSD title line 1 (Max 16 characters):", 79 | "OSD title line 2 (Max 16 characters):", 80 | "Accurate reading:", 81 | "Synchronous reading:", 82 | "Unhook syscalls:", 83 | "Disable PSS videos:", 84 | "Emulate DVD9 support:", 85 | "Disable IGR:", 86 | "Unused:", 87 | "Hide DEV9 module:", 88 | "Use MWDMA0:", 89 | "Memory card", 90 | "Slot 1", 91 | "Slot 2", 92 | "USB mass storage", 93 | "Default", 94 | "Game save", 95 | "External icon", 96 | "Network Status", 97 | "MAC Address", 98 | "IP Address", 99 | "Netmask", 100 | "Gateway", 101 | "Link State", 102 | "Link Mode", 103 | "Up", 104 | "Down", 105 | "Unknown", 106 | "10Mbps HDX", 107 | "10Mbps FDX", 108 | "100Mbps HDX", 109 | "100Mbps FDX", 110 | "Flow-Control", 111 | "Dropped Tx Frames", 112 | "Dropped Rx Frames", 113 | "Tx LOSSCR", 114 | "Rx Overrun", 115 | "Tx EDEFER", 116 | "Rx Bad Length", 117 | "Tx Collision", 118 | "Rx Bad FCS", 119 | "Tx Underrun", 120 | "Rx Bad Alignment", 121 | "Auto Negotiation", 122 | "Options", 123 | "Network Options", 124 | "Advanced Settings", 125 | "Use DHCP", 126 | "Address Type", 127 | "Sort Titles", 128 | "Static", 129 | "DHCP", 130 | }; 131 | -------------------------------------------------------------------------------- /lang.h: -------------------------------------------------------------------------------- 1 | enum SYS_UI_MESSAGES { 2 | SYS_UI_MSG_INIT_ERROR = 0, 3 | SYS_UI_MSG_PROCEED, 4 | SYS_UI_MSG_CANCEL_INPUT, 5 | SYS_UI_MSG_FULL_GAME_TITLE, 6 | SYS_UI_MSG_OSD_TITLE_1, 7 | SYS_UI_MSG_CHANGE_ICON, 8 | SYS_UI_MSG_ICON_LOAD_FAIL, 9 | SYS_UI_MSG_OSD_INST_FAILED, 10 | SYS_UI_MSG_NO_HDD, 11 | SYS_UI_MSG_HDD_FORMAT, 12 | SYS_UI_MSG_QUIT, 13 | SYS_UI_MSG_GAME_UPDATE_COMPLETE, 14 | SYS_UI_MSG_GAME_UPDATE_FAIL, 15 | SYS_UI_MSG_PROMPT_DELETE_GAME, 16 | SYS_UI_MSG_PLEASE_WAIT, 17 | SYS_UI_MSG_INST_OVERWRITE, 18 | SYS_UI_MSG_INST_COMPLETE, 19 | SYS_UI_MSG_UNSUP_DISC, 20 | SYS_UI_MSG_NO_DISC, 21 | SYS_UI_MSG_READING_DISC, 22 | SYS_UI_MSG_DISC_READ_ERR, 23 | SYS_UI_MSG_SYS_CNF_PARSE_FAIL, 24 | SYS_UI_MSG_CANCEL_INST, 25 | SYS_UI_MSG_DISC_READ_FAULT, 26 | SYS_UI_MSG_HDD_WRITE_FAULT, 27 | SYS_UI_MSG_LACK_OF_MEM, 28 | SYS_UI_MSG_INST_CANCELLED, 29 | SYS_UI_MSG_PART_ACC_ERR, 30 | SYS_UI_MSG_REMOTE_CONN, 31 | SYS_UI_MSG_NO_ICONS, 32 | SYS_UI_MSG_NO_NETWORK_CONNECTION, 33 | SYS_UI_MSG_CONNECTING, 34 | SYS_UI_MSG_DHCP_ERROR, 35 | SYS_UI_MSG_INSUFFICIENT_HDD_SPACE, 36 | SYS_UI_MSG_SAVING_HDD, 37 | SYS_UI_MSG_ERROR_SAVING_SETTINGS, 38 | 39 | SYS_UI_MSG_COUNT 40 | }; 41 | 42 | enum SYS_UI_LABEL_TEXT { 43 | SYS_UI_LBL_OK = 0, 44 | SYS_UI_LBL_CANCEL, 45 | SYS_UI_LBL_YES, 46 | SYS_UI_LBL_NO, 47 | SYS_UI_LBL_NEXT, 48 | SYS_UI_LBL_BACK, 49 | SYS_UI_LBL_ENABLED, 50 | SYS_UI_LBL_DISABLED, 51 | SYS_UI_LBL_TOGGLE_OPTION, 52 | SYS_UI_LBL_SELECT_FIELD, 53 | SYS_UI_LBL_SELECT_GAME, 54 | SYS_UI_LBL_GAME_OPTIONS, 55 | SYS_UI_LBL_DELETE_GAME, 56 | SYS_UI_LBL_INSTALL_GAME, 57 | SYS_UI_LBL_SELECT_KEY, 58 | SYS_UI_LBL_MOVE_CURSOR, 59 | SYS_UI_LBL_TOGGLE_CHAR_SET, 60 | SYS_UI_LBL_ENTER, 61 | SYS_UI_LBL_DELETE_CHAR, 62 | SYS_UI_LBL_INSERT_SPACE, 63 | SYS_UI_LBL_QUIT, 64 | SYS_UI_LBL_SELECT_ICON, 65 | SYS_UI_LBL_SELECT_DEVICE, 66 | SYS_UI_LBL_WARNING, 67 | SYS_UI_LBL_ERROR, 68 | SYS_UI_LBL_INFO, 69 | SYS_UI_LBL_CONFIRM, 70 | SYS_UI_LBL_WAIT, 71 | SYS_UI_LBL_REMOTE_CONN, 72 | SYS_UI_LBL_ICON_SOURCE, 73 | SYS_UI_LBL_NOW_INSTALLING, 74 | SYS_UI_LBL_TITLE, 75 | SYS_UI_LBL_DISC_ID, 76 | SYS_UI_LBL_DISC_TYPE, 77 | SYS_UI_LBL_RATE, 78 | SYS_UI_LBL_TIME_REMAINING, 79 | SYS_UI_LBL_INST_FULL_TITLE, 80 | SYS_UI_LBL_INST_OSD_TITLE_1, 81 | SYS_UI_LBL_INST_OSD_TITLE_2, 82 | SYS_UI_LBL_INST_OPTION_1, 83 | SYS_UI_LBL_INST_OPTION_2, 84 | SYS_UI_LBL_INST_OPTION_3, 85 | SYS_UI_LBL_INST_OPTION_4, 86 | SYS_UI_LBL_INST_OPTION_5, 87 | SYS_UI_LBL_INST_OPTION_6, 88 | SYS_UI_LBL_INST_OPTION_7, 89 | SYS_UI_LBL_INST_OPTION_8, 90 | SYS_UI_LBL_INST_TRANSFER_OPTION, 91 | SYS_UI_LBL_DEV_MC, 92 | SYS_UI_LBL_MC_SLOT_1, 93 | SYS_UI_LBL_MC_SLOT_2, 94 | SYS_UI_LBL_DEV_MASS, 95 | SYS_UI_LBL_ICON_SEL_DEFAULT, 96 | SYS_UI_LBL_ICON_SEL_SAVE_DATA, 97 | SYS_UI_LBL_ICON_SEL_EXTERNAL, 98 | SYS_UI_LBL_NETWORK_STATUS, 99 | SYS_UI_LBL_MAC_ADDRESS, 100 | SYS_UI_LBL_IP_ADDRESS, 101 | SYS_UI_LBL_NM_ADDRESS, 102 | SYS_UI_LBL_GW_ADDRESS, 103 | SYS_UI_LBL_LINK_STATE, 104 | SYS_UI_LBL_LINK_MODE, 105 | SYS_UI_LBL_UP, 106 | SYS_UI_LBL_DOWN, 107 | SYS_UI_LBL_UNKNOWN, 108 | SYS_UI_LBL_MODE_10MBIT_HDX, 109 | SYS_UI_LBL_MODE_10MBIT_FDX, 110 | SYS_UI_LBL_MODE_100MBIT_HDX, 111 | SYS_UI_LBL_MODE_100MBIT_FDX, 112 | SYS_UI_LBL_FLOW_CONTROL, 113 | SYS_UI_LBL_DROPPED_TX_FRAMES, 114 | SYS_UI_LBL_DROPPED_RX_FRAMES, 115 | SYS_UI_LBL_TX_LOSSCR, 116 | SYS_UI_LBL_RX_OVERRUN, 117 | SYS_UI_LBL_TX_EDEFER, 118 | SYS_UI_LBL_RX_BADLEN, 119 | SYS_UI_LBL_TX_COLLISON, 120 | SYS_UI_LBL_RX_BADFCS, 121 | SYS_UI_LBL_TX_UNDERRUN, 122 | SYS_UI_LBL_RX_BADALIGN, 123 | SYS_UI_LBL_MODE_AUTO, 124 | SYS_UI_LBL_OPTIONS, 125 | SYS_UI_LBL_NETWORK_OPTIONS, 126 | SYS_UI_LBL_ADVANCED_SETTINGS, 127 | SYS_UI_LBL_USE_DHCP, 128 | SYS_UI_LBL_ADDRESS_TYPE, 129 | SYS_UI_LBL_SORT_TITLES, 130 | SYS_UI_LBL_IP_STATIC, 131 | SYS_UI_LBL_IP_DHCP, 132 | 133 | SYS_UI_LBL_COUNT 134 | }; 135 | -------------------------------------------------------------------------------- /lang/LICENSE_OFL.txt: -------------------------------------------------------------------------------- 1 | This Font Software is licensed under the SIL Open Font License, 2 | Version 1.1. 3 | 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | ----------------------------------------------------------- 8 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 9 | ----------------------------------------------------------- 10 | 11 | PREAMBLE 12 | The goals of the Open Font License (OFL) are to stimulate worldwide 13 | development of collaborative font projects, to support the font 14 | creation efforts of academic and linguistic communities, and to 15 | provide a free and open framework in which fonts may be shared and 16 | improved in partnership with others. 17 | 18 | The OFL allows the licensed fonts to be used, studied, modified and 19 | redistributed freely as long as they are not sold by themselves. The 20 | fonts, including any derivative works, can be bundled, embedded, 21 | redistributed and/or sold with any software provided that any reserved 22 | names are not used by derivative works. The fonts and derivatives, 23 | however, cannot be released under any other type of license. The 24 | requirement for fonts to remain under this license does not apply to 25 | any document created using the fonts or their derivatives. 26 | 27 | DEFINITIONS 28 | "Font Software" refers to the set of files released by the Copyright 29 | Holder(s) under this license and clearly marked as such. This may 30 | include source files, build scripts and documentation. 31 | 32 | "Reserved Font Name" refers to any names specified as such after the 33 | copyright statement(s). 34 | 35 | "Original Version" refers to the collection of Font Software 36 | components as distributed by the Copyright Holder(s). 37 | 38 | "Modified Version" refers to any derivative made by adding to, 39 | deleting, or substituting -- in part or in whole -- any of the 40 | components of the Original Version, by changing formats or by porting 41 | the Font Software to a new environment. 42 | 43 | "Author" refers to any designer, engineer, programmer, technical 44 | writer or other person who contributed to the Font Software. 45 | 46 | PERMISSION & CONDITIONS 47 | Permission is hereby granted, free of charge, to any person obtaining 48 | a copy of the Font Software, to use, study, copy, merge, embed, 49 | modify, redistribute, and sell modified and unmodified copies of the 50 | Font Software, subject to the following conditions: 51 | 52 | 1) Neither the Font Software nor any of its individual components, in 53 | Original or Modified Versions, may be sold by itself. 54 | 55 | 2) Original or Modified Versions of the Font Software may be bundled, 56 | redistributed and/or sold with any software, provided that each copy 57 | contains the above copyright notice and this license. These can be 58 | included either as stand-alone text files, human-readable headers or 59 | in the appropriate machine-readable metadata fields within text or 60 | binary files as long as those fields can be easily viewed by the user. 61 | 62 | 3) No Modified Version of the Font Software may use the Reserved Font 63 | Name(s) unless explicit written permission is granted by the 64 | corresponding Copyright Holder. This restriction only applies to the 65 | primary font name as presented to the users. 66 | 67 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 68 | Software shall not be used to promote, endorse or advertise any 69 | Modified Version, except to acknowledge the contribution(s) of the 70 | Copyright Holder(s) and the Author(s) or with their explicit written 71 | permission. 72 | 73 | 5) The Font Software, modified or unmodified, in part or in whole, 74 | must be distributed entirely under this license, and must not be 75 | distributed under any other license. The requirement for fonts to 76 | remain under this license does not apply to any document created using 77 | the Font Software. 78 | 79 | TERMINATION 80 | This license becomes null and void if any of the above conditions are 81 | not met. 82 | 83 | DISCLAIMER 84 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 85 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 86 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 87 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 88 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 89 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 90 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 91 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 92 | OTHER DEALINGS IN THE FONT SOFTWARE. 93 | -------------------------------------------------------------------------------- /lang/NotoSansMono-CondensedBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/lang/NotoSansMono-CondensedBold.ttf -------------------------------------------------------------------------------- /lang/fonts.txt: -------------------------------------------------------------------------------- 1 | NotoSansCJKjp-Bold.otf 2 | NotoSansMono-CondensedBold.ttf 3 | NotoSansMono-CondensedBold.ttf 4 | NotoSansMono-CondensedBold.ttf 5 | NotoSansMono-CondensedBold.ttf 6 | NotoSansMono-CondensedBold.ttf 7 | NotoSansMono-CondensedBold.ttf 8 | NotoSansMono-CondensedBold.ttf 9 | -------------------------------------------------------------------------------- /lang/labels_DU.txt: -------------------------------------------------------------------------------- 1 | OK 2 | Annuleren 3 | Ja 4 | Nee 5 | Volgende 6 | Terug 7 | Aan 8 | Uit 9 | Toggle opties 10 | Selecteer veld 11 | Selecteer spel 12 | Spelopties 13 | Verwijder spel 14 | Installeer spel 15 | Selecteer toets 16 | Verplaats cursor 17 | Toetsenbord aan/uit 18 | Enter 19 | Backspace 20 | Spatie 21 | Stop programma 22 | Selecteer icoon 23 | Select apparaat 24 | Waarschuwing 25 | Fout 26 | Informatie 27 | Bevestiging 28 | Even geduld... 29 | Remote administration mode 30 | Icoon lokatie: 31 | Installeren... 32 | Titel: 33 | Disc ID: 34 | Disc type: 35 | Snelheid: 36 | Tijd\nresterend: 37 | Volledige titel (Max 80 characters): 38 | OSD titel regel 1 (Max 16 characters): 39 | OSD titel regel 2 (Max 16 characters): 40 | Alternatieve EE core: 41 | Multithreaded reading: 42 | Unhook syscalls: 43 | PSS video's: 44 | DVD9 ondersteuning: 45 | IGR: 46 | Ongebruikt: 47 | Verberg DEV9 module: 48 | Vertraagd lezen van data: 49 | Memory card 50 | Slot 1 51 | Slot 2 52 | USB massaopslag 53 | Standaardinstellingen 54 | Spel save 55 | Extern icoon 56 | Netwerkstatus 57 | MAC Address 58 | IP Address 59 | Netmask 60 | Gateway 61 | Link State 62 | Link Mode 63 | Up 64 | Down 65 | Unknown 66 | 10Mbps HDX 67 | 10Mbps FDX 68 | 100Mbps HDX 69 | 100Mbps FDX 70 | Flow-Control 71 | Dropped Tx Frames 72 | Dropped Rx Frames 73 | Tx LOSSCR 74 | Rx Overrun 75 | Tx EDEFER 76 | Rx Bad Length 77 | Tx Collision 78 | Rx Bad FCS 79 | Tx Underrun 80 | Rx Bad Alignment 81 | Auto Negotiation 82 | Options 83 | Network Options 84 | Advanced Settings 85 | Use DHCP 86 | Address Type 87 | Sort Titles 88 | Static 89 | DHCP 90 | -------------------------------------------------------------------------------- /lang/labels_FR.txt: -------------------------------------------------------------------------------- 1 | Ok 2 | Annuler 3 | Oui 4 | Non 5 | Suivant 6 | Précédent 7 | Activé 8 | Désactivé 9 | Parcourir les options 10 | Choisir ligne 11 | Choisir un jeu 12 | Options du jeu 13 | Supprimer 14 | Installer un jeu 15 | Choix caractère 16 | Déplacer le curseur 17 | Min./Maj. 18 | Valider 19 | Retour 20 | Espace 21 | Quitter 22 | Choisir l'icône 23 | Choisir la source 24 | Attention 25 | Erreur 26 | Information 27 | Confirmation 28 | Veuillez patienter 29 | Mode d'aministration à distance 30 | Choix de l'icône: 31 | Installation en cours... 32 | Titre: 33 | ID du jeu: 34 | Média: 35 | Vitesse de transfert: 36 | Temps\n restant: 37 | Nom complet du jeu (80 caractères max.): 38 | Titre OSD Ligne 1 (16 caractères max.): 39 | Titre OSD Ligne 2 (16 caractères max.): 40 | Utiliser le coeur alternatif: 41 | Méthode de lecture alternative: 42 | Désactiver syscalls: 43 | Passer les vidéos PSS: 44 | Désactiver le support DVD9: 45 | Désactiver l'IGR: 46 | Inutilisé: 47 | Cacher le module DEV9: 48 | Ralentir lecture données: 49 | Carte mém. 50 | Slot 1 51 | Slot 2 52 | Périph. USB 53 | Par défaut 54 | Sauvegarde \ndu jeu 55 | Icône \npersonnalisée 56 | Status du réseau 57 | MAC Address 58 | IP Address 59 | Netmask 60 | Gateway 61 | Link State 62 | Link Mode 63 | Up 64 | Down 65 | Unknown 66 | 10Mbps HDX 67 | 10Mbps FDX 68 | 100Mbps HDX 69 | 100Mbps FDX 70 | Flow-Control 71 | Dropped Tx Frames 72 | Dropped Rx Frames 73 | Tx LOSSCR 74 | Rx Overrun 75 | Tx EDEFER 76 | Rx Bad Length 77 | Tx Collision 78 | Rx Bad FCS 79 | Tx Underrun 80 | Rx Bad Alignment 81 | Auto Negotiation 82 | Options 83 | Network Options 84 | Advanced Settings 85 | Use DHCP 86 | Address Type 87 | Sort Titles 88 | Static 89 | DHCP 90 | -------------------------------------------------------------------------------- /lang/labels_GE.txt: -------------------------------------------------------------------------------- 1 | OK 2 | Abbrechen 3 | Ja 4 | Nein 5 | Weiter 6 | Zurück 7 | Aktiviert 8 | Deaktiviert 9 | Option ändern 10 | Feld auswählen 11 | Spiel wählen 12 | Spieloptionen 13 | Spiel löschen 14 | Spiel installieren 15 | Taste Auswählen 16 | Cursor bewegen 17 | Tastatur de-/aktivieren 18 | Eingabe 19 | Rücktaste 20 | Leerzeichen einfügen 21 | Programm beenden 22 | Icon auswählen 23 | Gerät auswählen 24 | Warnung 25 | Fehler 26 | Information 27 | Bestätigung 28 | Bitte warten 29 | Fernzugriffsmodus 30 | Iconquelle: 31 | Installiere... 32 | Titel: 33 | CD/DVD ID: 34 | CD/DVD Typ: 35 | Geschwindigkeit: 36 | Zeit\nverbleibend: 37 | Vollständiger Titel (Max 80 Zeichen): 38 | OSD-Titel Zeile 1 (Max 16 Zeichen): 39 | OSD-Titel Zeile 2 (Max 16 Zeichen): 40 | Alternativen EE Core benutzen: 41 | Multithreaded reading: 42 | Unhook syscalls: 43 | Deaktiviere PSS Videos: 44 | Deaktiviere DVD9 Unterstützung: 45 | Deaktiviere IGR: 46 | Ungenutzt: 47 | DEV9 Modul verbergen: 48 | Datenlesegeschwindigkeit reduzieren: 49 | Memory Card 50 | Steckplatz 1 51 | Steckplatz 2 52 | USB Massenspeicher 53 | Standart 54 | Speicherstand 55 | Externes Icon 56 | Netzwerkstatus 57 | MAC Address 58 | IP Address 59 | Netmask 60 | Gateway 61 | Link State 62 | Link Mode 63 | Up 64 | Down 65 | Unknown 66 | 10Mbps HDX 67 | 10Mbps FDX 68 | 100Mbps HDX 69 | 100Mbps FDX 70 | Flow-Control 71 | Dropped Tx Frames 72 | Dropped Rx Frames 73 | Tx LOSSCR 74 | Rx Overrun 75 | Tx EDEFER 76 | Rx Bad Length 77 | Tx Collision 78 | Rx Bad FCS 79 | Tx Underrun 80 | Rx Bad Alignment 81 | Auto Negotiation 82 | Options 83 | Network Options 84 | Advanced Settings 85 | Use DHCP 86 | Address Type 87 | Sort Titles 88 | Static 89 | DHCP 90 | -------------------------------------------------------------------------------- /lang/labels_IT.txt: -------------------------------------------------------------------------------- 1 | OK 2 | Cancella 3 | Si 4 | No 5 | Avanti 6 | Indietro 7 | Attivato 8 | Disattivato 9 | Togli opzione 10 | Seleziona il campo 11 | Seleziona il gioco 12 | Opzioni gioco 13 | Cancella il gioco 14 | Installa il gioco 15 | Seleziona la chiave 16 | Muovi il cursore 17 | Togli la tastiera 18 | Entra 19 | Backspace 20 | spazio 21 | Esci dal programma 22 | Seleziona icona 23 | Seleziona dispositivo 24 | Attenzione 25 | Errore 26 | Informazione 27 | Conferma 28 | Attendere 29 | Modalità amministratore remoto 30 | Sorgente icona: 31 | Intallazione... 32 | Titolo: 33 | ID disco: 34 | Tipo disco: 35 | Voto: 36 | Tempo\nrimanente: 37 | Titolo completo (Massimo 80 caratteri): 38 | Linea titolo OSD 1 (Massimo 16 caratteri): 39 | Linea titolo OSD 2 (Massimo 16 caratteri): 40 | Usa EE core alternativo: 41 | Lettura Multithread: 42 | Apri syscalls: 43 | Disattiva video PSS: 44 | Disattiva supporto DVD9: 45 | Disattiva IGR: 46 | Inutilizzato: 47 | Nascondi i moduli DEV9: 48 | Rallenta la lettura dei dati: 49 | Memory card 50 | Slot 1 51 | Slot 2 52 | Unità archiviazione USB 53 | Default 54 | Save gioco 55 | Icona esterna 56 | Stato network 57 | MAC Address 58 | IP Address 59 | Netmask 60 | Gateway 61 | Link State 62 | Link Mode 63 | Up 64 | Down 65 | Unknown 66 | 10Mbps HDX 67 | 10Mbps FDX 68 | 100Mbps HDX 69 | 100Mbps FDX 70 | Flow-Control 71 | Dropped Tx Frames 72 | Dropped Rx Frames 73 | Tx LOSSCR 74 | Rx Overrun 75 | Tx EDEFER 76 | Rx Bad Length 77 | Tx Collision 78 | Rx Bad FCS 79 | Tx Underrun 80 | Rx Bad Alignment 81 | Auto Negotiation 82 | Options 83 | Network Options 84 | Advanced Settings 85 | Use DHCP 86 | Address Type 87 | Sort Titles 88 | Static 89 | DHCP 90 | -------------------------------------------------------------------------------- /lang/labels_PO.txt: -------------------------------------------------------------------------------- 1 | OK 2 | Cancelar 3 | Sim 4 | Não 5 | Próximo 6 | Voltar 7 | Habilitado 8 | Desabilitado 9 | Alternar opção 10 | Escolher campo 11 | Escolher jogo 12 | Opções do jogo 13 | Apagar jogo 14 | Instalar jogo 15 | Escolher tecla 16 | Mover cursor 17 | Alternar teclado 18 | Enter 19 | Voltar 20 | Inserir espaço 21 | Sair 22 | Selecionar ícone 23 | Selecionar dispositivo 24 | Cuidado 25 | Erro 26 | Informação 27 | Confirmação 28 | Por favor, espere 29 | Modo administração remota 30 | Origem do ícone: 31 | Instalando... 32 | Título: 33 | ID: 34 | Mídia: 35 | Taxa: 36 | Tempo: 37 | Título do jogo (80 caracteres máx): 38 | Título OSD linha 1 (16 caracteres máx): 39 | Título OSD linha 2 (16 caracteres máx): 40 | Carregar núcleo alternativo 41 | Modo de leitura alternativa 42 | Excluir chamadas de sistema 43 | Desativar vídeos PSS 44 | Desativar suporte DEV9 45 | Desativar IGR 46 | - não usado - 47 | Esconder módulo DEV9 48 | Reduzir velocidade leitura 49 | Memory Card 50 | Slot 1 51 | Slot 2 52 | Dispositivo USB 53 | Padrão 54 | Save do jogo 55 | Icone externo 56 | Definições de rede 57 | MAC Address 58 | IP Address 59 | Netmask 60 | Gateway 61 | Link State 62 | Link Mode 63 | Up 64 | Down 65 | Unknown 66 | 10Mbps HDX 67 | 10Mbps FDX 68 | 100Mbps HDX 69 | 100Mbps FDX 70 | Flow-Control 71 | Dropped Tx Frames 72 | Dropped Rx Frames 73 | Tx LOSSCR 74 | Rx Overrun 75 | Tx EDEFER 76 | Rx Bad Length 77 | Tx Collision 78 | Rx Bad FCS 79 | Tx Underrun 80 | Rx Bad Alignment 81 | Auto Negotiation 82 | Options 83 | Network Options 84 | Advanced Settings 85 | Use DHCP 86 | Address Type 87 | Sort Titles 88 | Static 89 | DHCP 90 | -------------------------------------------------------------------------------- /lang/labels_SP.txt: -------------------------------------------------------------------------------- 1 | OK 2 | Cancelar 3 | Sí 4 | No 5 | Siguiente 6 | Atrás 7 | Activado 8 | Desactivado 9 | Cambiar opción 10 | Escoger campo 11 | Escoger juego 12 | Opciones del juego 13 | Borrar juego 14 | Instalar juego 15 | Escoger tecla 16 | Mover cursor 17 | Cambiar teclado 18 | Introducir 19 | Retroceso 20 | Insertar espacio 21 | Salir 22 | Seleccionar icono 23 | Seleccionar unidad 24 | Peligro 25 | Error 26 | Información 27 | Confirmación 28 | Por favor espera 29 | Modo de administración remoto 30 | Fuente del icono: 31 | Instalando... 32 | Título: 33 | ID disco: 34 | Medio: 35 | Tasa: 36 | Tiempo\nrestante: 37 | Nombre completo (Máx 80 caracteres): 38 | Línea 1 de título OSD (Máx 16 caracteres): 39 | Línea 2 de título OSD (Máx 16 caracteres): 40 | Cargar núcleo alternativo: 41 | Método lectura alternativo: 42 | Eliminar llamadas sistema: 43 | Omitir lectura vídeos PSS: 44 | Sin soporte DVD-DL: 45 | Sin soporte IGR: 46 | No usado: 47 | Ocultar módulo dev9: 48 | Bajar velocidad lectura: 49 | Tarjeta 50 | Ranura 1 51 | Ranura 2 52 | Medio USB 53 | Predeterminado 54 | Partida juego 55 | Icono externo 56 | Estado de red 57 | Dirección MAC 58 | Dirección IP 59 | Mascara de red 60 | Puerta de enlace 61 | Estado del vínculo 62 | Modo de vínculo 63 | Arriba 64 | Abajo 65 | Desconocido 66 | 10Mbps HDX 67 | 10Mbps FDX 68 | 100Mbps HDX 69 | 100Mbps FDX 70 | Control de flujo 71 | Dropped Tx Frames 72 | Dropped Rx Frames 73 | Tx LOSSCR 74 | Rx Overrun 75 | Tx EDEFER 76 | Rx Bad Length 77 | Tx Colisión 78 | Rx FCS malo 79 | Tx Underrun 80 | Rx mal alineamiento 81 | Auto Negociación 82 | Opciones 83 | Opciones de red 84 | Ajustes avanzados 85 | Usar DHCP 86 | Tipo de dirección 87 | Ordenar títulos 88 | Estático 89 | DHCP 90 | -------------------------------------------------------------------------------- /lang/strings_DU.txt: -------------------------------------------------------------------------------- 1 | Systeeminitialisatiefout. 2 | Doorgaan? 3 | Invoeren annuleren? 4 | Volledige titel invoeren aub! 5 | OSD regel 1 invoeren aub! 6 | Spelicoon wijzigen? 7 | Kan geselecteerde icoon niet laden. Doorgaan met standaardicoon? 8 | Installeren OSD bestanden mislukt. 9 | Geen harde schijf gedetecteerd. 10 | Harde schijf is niet geformatteerd. Formatteren?\nWaarschuwing: Alle data wordt gewist. 11 | Stop programma? 12 | Spel succesvol geupdatet! 13 | Fout tijdens updaten. 14 | Spel verwijderen? 15 | Even geduld... 16 | Dit spel is al geinstalleerd.\nOude installatie overschrijven? 17 | Spel succesvol geinstalleerd! 18 | Schijf wordt niet ondersteund.\nVoeren een Playstation 2 spel in aub. 19 | Schijf invoeren aub. 20 | Schijf wordt gelezen... 21 | Fout tijdens het lezen van de schijf. 22 | Fout tijdens het parsen van SYSTEM.CNF.\nVoeren een andere schijf in aub. 23 | Spelinstallatie annuleren? 24 | Leesfout.\nControleer de staat van de schijf aub. 25 | Schrijffout.\nRepareer de schijf. 26 | Onvoldoende geheugen.\nInstallatieprogramma opnieuw opstarten aub. 27 | Spelinstallatie geannuleerd. 28 | Toegang tot partitie mislukt. 29 | Een PC is verbonden met deze spelcomputer.\n\nVerinding niet verbreken en spelcomputer niet uitschakelen. 30 | Geen iconen gevonden. 31 | Error: there is no network connection. 32 | Connecting to network. Please wait. 33 | Error: failed to acquire an IP address from the DHCP server. 34 | There is insufficient space on the HardDisk Drive (HDD) unit. 35 | Saving. Please do not switch off or disconnect your console. 36 | Error: failed to save settings. 37 | -------------------------------------------------------------------------------- /lang/strings_FR.txt: -------------------------------------------------------------------------------- 1 | Erreur d'initialisation du système. 2 | Continuer? 3 | Annuler les changements? 4 | Indiquer le titre complet du jeu: 5 | Titre OSD Ligne 1: 6 | Changer l'icône du jeu? 7 | Impossible de charger l'icône sélectionnée. Poursuivre avec l'icône par défaut? 8 | Echec de l'installataion des fichiers OSD. 9 | Disque dur non détecté. 10 | Le disque dur n'est pas formaté. Le formater?\nAttention : toutes les données seront effacées. 11 | Quitter le programme. 12 | Jeu mis à jour avec succès! 13 | Une erreur est survenue lors de la mise à jour du jeu. 14 | Supprimer le jeu? 15 | Veuillez patienter... 16 | Ce jeu est déjà installé. \nVoulez-vous le réinstaller? 17 | Le jeu a été installé avec succès! 18 | Format du disque non supporté. \nVeuillez insérer un disque au format PS2. 19 | Veuillez insérer un disque. 20 | Lecture du disque en cours... 21 | Erreur lors de la lecture du disque.. 22 | Une erreur s'est produite lors de l'analyse du fichier SYSTEM.CNF. \nVeuillez insérer un autre disque. 23 | Annuler l'installation du jeu? 24 | Erreur de lecture. \Veuillez vérifier l'état du disque. 25 | Erreur d'écriture. \Veuillez réparer votre disque. 26 | Erreur mémoire. \n Veuillez relancer l'installeur. 27 | Installation du jeu annulée. 28 | Echec de l'accès à la partition. 29 | L'ordinateur est connecté à la console. \n\nVeuillez ne pas déconnecter ni éteindre la console. 30 | Aucune icône n'a été trouvée. 31 | Error: there is no network connection. 32 | Connecting to network. Please wait. 33 | Error: failed to acquire an IP address from the DHCP server. 34 | There is insufficient space on the HardDisk Drive (HDD) unit. 35 | Saving. Please do not switch off or disconnect your console. 36 | Error: failed to save settings. 37 | -------------------------------------------------------------------------------- /lang/strings_GE.txt: -------------------------------------------------------------------------------- 1 | Initialisierungsfehler. 2 | Fortfahren? 3 | Eingabe abbrechen? 4 | Bitte den vollständigen Titel eingeben! 5 | Bitte den OSD-Titel 1 eingeben! 6 | Spiel-Icon ändern? 7 | Konnte gewähltes Icon nicht laden. Mit Standart-Icon fortfahren? 8 | Konnte OSD-Dateien nicht installieren. 9 | Keine Festplatte gefunden. 10 | Festplatte ist nicht formatiert. Formatieren?\nAchtung: Alle vorhandenen Daten werden gelöscht. 11 | Programm beenden? 12 | Spiel erfolgreich aktualisiert! 13 | Beim Aktualisieren des Spiels ist ein fehler aufgetreten. 14 | Spiel löschen? 15 | Bitte warten... 16 | Dieses Spiel ist bereits installiert.\nAlte Installation überschreiben? 17 | Spiel erfolgreich installiert! 18 | Eingelegte CD/DVD wird nicht unterstützt.\nBitte eine Playstation 2 Spiele-CD/DVD einlegen. 19 | Bitte eine CD/DVD einlegen. 20 | Lese CD/DVD... 21 | Beim Lesen der CD/DVD ist ein Fehler aufgetreten. 22 | Beim Einleden der SYSTEM.CNF Datei ist ein Fehler aufgetreten.\nBitte eine andere CD/DVD einlegen. 23 | Spieleinstallation abbrechen? 24 | Ein Lesefehler ist aufgetreten.\nBitte prüfen Sie den Zustand der CD/DVD. 25 | Ein Schreibfehler ist aufgetreten.\nTauschen Sie ihre Festplatte aus. 26 | Nicht genügend Speicher frei.\nBitte starten Sie den Installer erneut. 27 | Spieleinstallation abgebrochen. 28 | Konnte nicht auf Partition zugreifen. 29 | Ein Computer ist mit dieser Konsole verbunden.\n\nBitte trennen Sie die Konsole nicht vom Netzwerk und schalten Sie sie nicht ab. 30 | Keine Icons gefunden. 31 | Error: there is no network connection. 32 | Connecting to network. Please wait. 33 | Error: failed to acquire an IP address from the DHCP server. 34 | There is insufficient space on the HardDisk Drive (HDD) unit. 35 | Saving. Please do not switch off or disconnect your console. 36 | Error: failed to save settings. 37 | -------------------------------------------------------------------------------- /lang/strings_IT.txt: -------------------------------------------------------------------------------- 1 | Impossibile avviare il sistema. 2 | Procedi? 3 | Cancellare input? 4 | Inserisci l'intero titolo del gioco! 5 | Inserisci il titolo 1 dell'OSD! 6 | Cambiare l'icona del gioco? 7 | Impossibile caricare l'icona scelta. Continuare con quella di default? 8 | Errore durante l'installazione dei file dell'OSD. 9 | Nessun harddisk rilevato. 10 | Harddisk non formattato. Formatta?\nAttenzione: Tutti i dati precedenti verranno persi. 11 | Esci dal programma? 12 | Gioco aggiornato con successo! 13 | Si è verificato un errore durante l'aggionamento del gioco. 14 | Cancellare il gioco? 15 | Attendere... 16 | Gioco già installato.\nSovrascrivere la vecchia installazione? 17 | Gioco installato con successo! 18 | Disco inserito non supportato.\nInserisci un gioco Playstation 2. 19 | Inserire disco. 20 | Lettura disco... 21 | Errore durante la lettura del disco. 22 | Errore durante l'analisi del file SYSTEM.CNF.\nInserisci un altro disco. 23 | Cancellare l'installazione del gioco? 24 | Errore lettura.\nConstrolla lo stato del tuo disco. 25 | Errore scrittura.\nDisco danneggiato. 26 | Memoria insufficiente.\nRiavviare l'installer. 27 | Installazione del gioco annulata. 28 | Errore durante l'accesso alla partizione. 29 | La console è collegata ad un computer.\n\nNon disconnetere o spegnere la console. 30 | Nessuna icona trovata. 31 | Error: there is no network connection. 32 | Connecting to network. Please wait. 33 | Error: failed to acquire an IP address from the DHCP server. 34 | There is insufficient space on the HardDisk Drive (HDD) unit. 35 | Saving. Please do not switch off or disconnect your console. 36 | Error: failed to save settings. 37 | -------------------------------------------------------------------------------- /lang/strings_PO.txt: -------------------------------------------------------------------------------- 1 | Falha na inicialização do sistema 2 | Continuar? 3 | Cancelar as definições? 4 | Preencha o campo: \n"Título do jogo" 5 | Preencha o campo: \n"Título OSD linha 1" 6 | Mudar o ícone do jogo? 7 | Incapaz de carregar o ícone selecionado. Continuar com o ícone padrão? 8 | Falhou ao instalar os arquivos OSD 9 | Nenhum HDD foi detectado. 10 | O HDD não está formatado \nDeseja formatar o HDD? \nCUIDADO! \nTodos os dados serão apagados! 11 | Sair do programa? 12 | Jogo atualizado com sucesso! 13 | Ocorreu um erro ao atualizar o jogo 14 | Apagar jogo? 15 | Por favor espere... 16 | Este jogo já está instalado.\nSobreescrever instalação antiga? 17 | Jogo instalado com sucesso! 18 | Disco inserido não suportado.\nPor favor insira um disco de Playstation 2 válido 19 | Por favor insira um disco 20 | Lendo disco... 21 | Ocorreu um erro ao ler o disco 22 | Ocorreu um erro ao analisar o arquivo SYSTEM.CNF.\nPor favor insira outro disco 23 | Cancelar a instalação do jogo? 24 | Ocorreu uma falha na leitura.\nPor favor verifique as condições de seu disco 25 | Ocorreu um erro de escrita.\nPor favor efetue uma reparação no seu HDD 26 | Memória insuficiente.\nPor favor reinicie o instalador 27 | Instalação do jogo cancelada 28 | Falha ao acessar a partição 29 | Um computador está conectado a este console.\n\nPor favor não desconecte ou desligue o console 30 | Nenhum ícone encontrado. 31 | Error: there is no network connection. 32 | Connecting to network. Please wait. 33 | Error: failed to acquire an IP address from the DHCP server. 34 | There is insufficient space on the HardDisk Drive (HDD) unit. 35 | Saving. Please do not switch off or disconnect your console. 36 | Error: failed to save settings. 37 | -------------------------------------------------------------------------------- /lang/strings_SP.txt: -------------------------------------------------------------------------------- 1 | Error de inicialización del sistema. 2 | ¿Proceder? 3 | ¿Cancelar entrada? 4 | ¡Por favor pon un nombre al juego! 5 | ¡Por favor pon nombre a la línea 1 del título OSD! 6 | ¿Cambiar icono del juego? 7 | Imposible cargar el icono seleccionado. ¿Continuar con el icono predeterminado? 8 | Fallo al instalar los archivos OSD. 9 | No se ha detectado unidad de disco duro. 10 | Unidad de disco duro no formateado. ¿Formatear?\nPeligro: Todos los datos serán eliminados. 11 | ¿Seguro qué deseas salir? 12 | ¡Juego actualizado! 13 | Ha ocurrido un error al actualizar el juego. 14 | ¿Borrar juego? 15 | Por favor espera... 16 | Este juego ya se había instalado.\nSobrescribir la antigua instalación? 17 | ¡Juego instalado! 18 | Disco insertado no soportado.\nPor favor inserta un juego de Playstation 2. 19 | Por favor inserta un disco. 20 | Leyendo disco... 21 | Ha ocurrido un error al leer el disco. 22 | Ha ocurrido un error al procesar el archivo SYSTEM.CNF.\nPor favor inserta otro disco. 23 | ¿Cancelar instalación del juego? 24 | Ha ocurrido un fallo de lectura.\nPor favor comprueba la condición del disco. 25 | Ha ocurrido un fallo de escritura.\nPor favor lleva el disco a reparar. 26 | Falta de memoria.\nPor favor reinicia el instalador. 27 | Instalación del juego cancelada. 28 | Fallo al acceder a la partición. 29 | Un ordenador está conectado a esta consola.\n\nPor favor no desconectes o apagues la consola. 30 | No se han encontrado iconos. 31 | Error: No hay conección de red. 32 | Connectabdi a la red. Por favor espere... 33 | Error: Fallo al recuperar Dirección IP del DHCP. 34 | No hay suficiente espacio en el Disco duro. 35 | Guardando. Por favor no apague o desconecte la consola. 36 | Error: fallo al guardar ajustes. 37 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include "main.h" 23 | #ifdef ENABLE_NETWORK_SUPPORT 24 | #include 25 | #include 26 | #endif 27 | 28 | #include "io.h" 29 | #include "HDLGameList.h" 30 | #include "system.h" 31 | #include "OSD.h" 32 | #include "UI.h" 33 | #include "menu.h" 34 | #include "graphics.h" 35 | #include "settings.h" 36 | #ifdef ENABLE_NETWORK_SUPPORT 37 | #include "HDLGameSvr.h" 38 | #endif 39 | 40 | extern unsigned char IOMANX_irx[]; 41 | extern unsigned int size_IOMANX_irx; 42 | 43 | extern unsigned char SIO2MAN_irx[]; 44 | extern unsigned int size_SIO2MAN_irx; 45 | 46 | extern unsigned char PADMAN_irx[]; 47 | extern unsigned int size_PADMAN_irx; 48 | 49 | extern unsigned char MCMAN_irx[]; 50 | extern unsigned int size_MCMAN_irx; 51 | 52 | extern unsigned char MCSERV_irx[]; 53 | extern unsigned int size_MCSERV_irx; 54 | 55 | extern unsigned char FILEXIO_irx[]; 56 | extern unsigned int size_FILEXIO_irx; 57 | 58 | extern unsigned char POWEROFF_irx[]; 59 | extern unsigned int size_POWEROFF_irx; 60 | 61 | extern unsigned char DEV9_irx[]; 62 | extern unsigned int size_DEV9_irx; 63 | 64 | extern unsigned char ATAD_irx[]; 65 | extern unsigned int size_ATAD_irx; 66 | 67 | extern unsigned char HDD_irx[]; 68 | extern unsigned int size_HDD_irx; 69 | 70 | extern unsigned char PFS_irx[]; 71 | extern unsigned int size_PFS_irx; 72 | 73 | extern unsigned char HDLFS_irx[]; 74 | extern unsigned int size_HDLFS_irx; 75 | 76 | extern unsigned char USBD_irx[]; 77 | extern unsigned int size_USBD_irx; 78 | 79 | extern unsigned char USBHDFSD_irx[]; 80 | extern unsigned int size_USBHDFSD_irx; 81 | 82 | #ifdef ENABLE_NETWORK_SUPPORT 83 | extern unsigned char SMAP_irx[]; 84 | extern unsigned int size_SMAP_irx; 85 | 86 | extern unsigned char NETMAN_irx[]; 87 | extern unsigned int size_NETMAN_irx; 88 | #endif 89 | 90 | extern void *_gp; 91 | extern GSGLOBAL *gsGlobal; 92 | extern GSTEXTURE BackgroundTexture; 93 | 94 | struct RuntimeData RuntimeData; 95 | 96 | struct SystemInitThreadParam 97 | { 98 | char **argv; 99 | int SystemInitSema; 100 | struct RuntimeData *RuntimeData; 101 | }; 102 | 103 | static void LoadHDDModules(void) 104 | { 105 | static const char HDD_args[] = "-o\0" 106 | "4" 107 | "\0" 108 | "-n\0" 109 | "128"; 110 | static const char PFS_args[] = "-m\0" 111 | "2" 112 | "\0" 113 | "-o\0" 114 | "4" 115 | "-n\0" 116 | "12"; 117 | 118 | SifExecModuleBuffer(ATAD_irx, size_ATAD_irx, 0, NULL, NULL); 119 | SifExecModuleBuffer(HDD_irx, size_HDD_irx, sizeof(HDD_args), HDD_args, NULL); 120 | SifExecModuleBuffer(PFS_irx, size_PFS_irx, sizeof(PFS_args), PFS_args, NULL); 121 | } 122 | 123 | 124 | static void SystemInitThread(void *arg) 125 | { 126 | SifExecModuleBuffer(MCSERV_irx, size_MCSERV_irx, 0, NULL, NULL); 127 | 128 | if (((struct SystemInitThreadParam *)arg)->RuntimeData->BootDeviceID != BOOT_DEVICE_HDD) { 129 | LoadHDDModules(); 130 | } 131 | 132 | if (LoadSettings() != 0) { 133 | ImportIPConfigDat(); 134 | SaveSettings(); 135 | } 136 | 137 | #ifdef ENABLE_NETWORK_SUPPORT 138 | SifExecModuleBuffer(NETMAN_irx, size_NETMAN_irx, 0, NULL, NULL); 139 | SifExecModuleBuffer(SMAP_irx, size_SMAP_irx, 0, NULL, NULL); 140 | 141 | // Initialization will be done in the background. The usability of the network interface will be confirmed later on, with ethValidate(). 142 | ethInit(); 143 | #endif 144 | 145 | SifExecModuleBuffer(HDLFS_irx, size_HDLFS_irx, 0, NULL, NULL); 146 | 147 | mcInit(MC_TYPE_XMC); 148 | NetManInit(); 149 | 150 | // Load the game list, so that both the UI and the server can access it immediately after initialization completes. 151 | LoadHDLGameList(NULL); 152 | 153 | SignalSema(((struct SystemInitThreadParam *)arg)->SystemInitSema); 154 | ExitDeleteThread(); 155 | } 156 | 157 | int VBlankStartSema; 158 | 159 | static int VBlankStartHandler(int cause) 160 | { 161 | ee_sema_t sema; 162 | iReferSemaStatus(VBlankStartSema, &sema); 163 | if (sema.count < sema.max_count) 164 | iSignalSema(VBlankStartSema); 165 | ExitHandler(); 166 | return 0; 167 | } 168 | 169 | // Terminate all ongoing installations, unmount all unmounted partitions and shutdown the PS2. 170 | /* static void poweroffCallback(void *arg) 171 | { 172 | printf("Power button pressed.\n"); 173 | 174 | //Close all files and unmount all partitions. 175 | #ifdef ENABLE_NETWORK_SUPPORT 176 | DeinitializeServer(); 177 | #endif 178 | //TODO: terminate any installations via CD/DVD. 179 | 180 | //Shut down DEV9 181 | fileXioDevctl("dev9x:", DDIOC_OFF, NULL, 0, NULL, 0); 182 | 183 | poweroffShutdown(); 184 | } */ 185 | 186 | #define SYSTEM_INIT_THREAD_STACK_SIZE 0x800 187 | 188 | static void DeinitServices(void) 189 | { 190 | sceCdInit(SCECdEXIT); 191 | 192 | DeinitPads(); 193 | 194 | DeleteSema(RuntimeData.InstallationLockSema); 195 | DisableIntc(kINTC_VBLANK_START); 196 | RemoveIntcHandler(kINTC_VBLANK_START, 0); 197 | DeleteSema(VBlankStartSema); 198 | 199 | // pfs0 is mounted, if booted from the HDD. Do not check on the return value because it will not be mounted, otherwise. 200 | fileXioUmount("pfs0:"); 201 | fileXioExit(); 202 | 203 | SifExitRpc(); 204 | } 205 | 206 | int main(int argc, char *argv[]) 207 | { 208 | ee_sema_t ThreadSema; 209 | struct SystemInitThreadParam InitThreadParam; 210 | unsigned int FrameNum; 211 | void *SysInitThreadStack; 212 | char BlockDevice[16], *FullPath[256]; 213 | const char *MountPoint; 214 | int result; 215 | 216 | #ifdef RDB_DEBUG_SUPPORT 217 | chdir("mass:/HDLGameInstaller/"); 218 | #endif 219 | if ((RuntimeData.BootDeviceID = GetBootDeviceID()) == BOOT_DEVICE_UNKNOWN) { 220 | return ENODEV; 221 | } 222 | 223 | SifInitRpc(0); 224 | #ifndef RDB_DEBUG_SUPPORT 225 | while (!SifIopReset("", 0)) {}; 226 | #endif 227 | 228 | /* Do as many things as possible as the IOP slowly resets itself. */ 229 | InitOSDResourceFiles(); 230 | 231 | RuntimeData.ReadMode.trycount = 255; 232 | RuntimeData.ReadMode.spindlctrl = SCECdSpinMax; 233 | RuntimeData.ReadMode.datapattern = SCECdSecS2048; 234 | RuntimeData.ReadMode.pad = 0; 235 | 236 | InitThreadParam.argv = argv; 237 | InitThreadParam.RuntimeData = &RuntimeData; 238 | 239 | ThreadSema.init_count = 0; 240 | ThreadSema.max_count = 1; 241 | ThreadSema.attr = 0; 242 | ThreadSema.option = (u32) "InitThreadParam"; 243 | InitThreadParam.SystemInitSema = CreateSema(&ThreadSema); 244 | 245 | ThreadSema.init_count = 1; 246 | ThreadSema.max_count = 1; 247 | ThreadSema.attr = 0; 248 | ThreadSema.option = (u32) "Install-Lock"; 249 | RuntimeData.InstallationLockSema = CreateSema(&ThreadSema); 250 | 251 | SysInitThreadStack = malloc(SYSTEM_INIT_THREAD_STACK_SIZE); 252 | 253 | InitCentralHDLGameList(); 254 | 255 | ThreadSema.init_count = 0; 256 | ThreadSema.max_count = 1; 257 | ThreadSema.attr = 0; 258 | ThreadSema.option = (u32) "VBlank"; 259 | VBlankStartSema = CreateSema(&ThreadSema); 260 | 261 | AddIntcHandler(kINTC_VBLANK_START, &VBlankStartHandler, 0); 262 | EnableIntc(kINTC_VBLANK_START); 263 | 264 | LoadDefaults(); 265 | 266 | while (!SifIopSync()) {}; 267 | 268 | SifInitRpc(0); 269 | SifInitIopHeap(); 270 | SifLoadFileInit(); 271 | 272 | sbv_patch_enable_lmb(); 273 | 274 | SifExecModuleBuffer(IOMANX_irx, size_IOMANX_irx, 0, NULL, NULL); 275 | SifExecModuleBuffer(FILEXIO_irx, size_FILEXIO_irx, 0, NULL, NULL); 276 | fileXioInit(); 277 | fileXioSetRWBufferSize(FILEIO_BLOCK_SIZE); 278 | 279 | SifExecModuleBuffer(USBD_irx, size_USBD_irx, 0, NULL, NULL); 280 | SifExecModuleBuffer(USBHDFSD_irx, size_USBHDFSD_irx, 0, NULL, NULL); 281 | 282 | SifExecModuleBuffer(SIO2MAN_irx, size_SIO2MAN_irx, 0, NULL, NULL); 283 | SifExecModuleBuffer(MCMAN_irx, size_MCMAN_irx, 0, NULL, NULL); 284 | SifExecModuleBuffer(PADMAN_irx, size_PADMAN_irx, 0, NULL, NULL); 285 | 286 | SifExecModuleBuffer(POWEROFF_irx, size_POWEROFF_irx, 0, NULL, NULL); 287 | #ifndef RDB_DEBUG_SUPPORT 288 | SifExecModuleBuffer(DEV9_irx, size_DEV9_irx, 0, NULL, NULL); 289 | #endif 290 | 291 | sceCdInit(SCECdINoD); 292 | InitPads(); 293 | 294 | // Initialize poweroff library. 295 | poweroffInit(); 296 | 297 | // Set poweroff callback function 298 | // For now, we have no callback. Not setting a callback will also disable automatic poweroff. 299 | // poweroffSetCallback(&poweroffCallback, NULL); 300 | 301 | if (RuntimeData.BootDeviceID == BOOT_DEVICE_HDD) 302 | LoadHDDModules(); 303 | 304 | SysCreateThread(SystemInitThread, SysInitThreadStack, SYSTEM_INIT_THREAD_STACK_SIZE, &InitThreadParam, 2); 305 | 306 | if (SysBootDeviceInit() != 0) { 307 | WaitSema(InitThreadParam.SystemInitSema); 308 | DeinitServices(); 309 | return -1; 310 | } 311 | 312 | if (InitializeUI(0) != 0) { 313 | DeinitializeUI(); 314 | 315 | WaitSema(InitThreadParam.SystemInitSema); 316 | DeinitServices(); 317 | return -1; 318 | } 319 | 320 | FrameNum = 0; 321 | /* Draw something nice here while waiting... */ 322 | do { 323 | RedrawLoadingScreen(FrameNum); 324 | FrameNum++; 325 | } while (PollSema(InitThreadParam.SystemInitSema) != InitThreadParam.SystemInitSema); 326 | DeleteSema(InitThreadParam.SystemInitSema); 327 | free(SysInitThreadStack); 328 | 329 | SifLoadFileExit(); 330 | SifExitIopHeap(); 331 | 332 | DisplayFlashStatusUpdate(SYS_UI_MSG_CONNECTING); 333 | #ifdef ENABLE_NETWORK_SUPPORT 334 | ethValidate(); 335 | InitializeStartServer(); 336 | #endif 337 | 338 | MainMenu(); 339 | 340 | #ifdef ENABLE_NETWORK_SUPPORT 341 | DeinitializeServer(); 342 | #endif 343 | 344 | DeinitCentralHDLGameList(); 345 | 346 | DeinitializeUI(); 347 | DeinitServices(); 348 | 349 | return 0; 350 | } 351 | -------------------------------------------------------------------------------- /main.h: -------------------------------------------------------------------------------- 1 | //#define DEBUG_TTY_FEEDBACK /* Comment out to disable debugging messages */ 2 | 3 | // Extended error codes. 4 | #define EEXTCONNLOST 0x2000 5 | 6 | #define FILEIO_BLOCK_SIZE (256 * 2048) // Size of the FILEIO Read/Write buffer. 7 | 8 | #define GAME_TITLE_MAX_LEN_BYTES 160 // In bytes, when in UTF-8 characters. 9 | #define GAME_TITLE_MAX_LEN (GAME_TITLE_MAX_LEN_BYTES / 2) /* In characters. Note: the original format for HDLoader just has a 160-character space. \ 10 | But UTF-8 characters may have 1 or more bytes each. Hence this is an approximation. */ 11 | #define OSD_TITLE_MAX_LEN_BYTES (OSD_TITLE_MAX_LEN * 4) // In bytes, when in UTF-8 characters 12 | #define OSD_TITLE_MAX_LEN 16 // In characters 13 | 14 | #ifdef DEBUG_TTY_FEEDBACK 15 | #define DEBUG_PRINTF(args...) printf(args) 16 | #else 17 | #define DEBUG_PRINTF(args...) 18 | #endif 19 | 20 | #define HDLGAME_INSTALLER_VERSION "0.821" 21 | 22 | #define ENABLE_NETWORK_SUPPORT 23 | //#define UI_TEST_MODE 24 | 25 | #ifdef DEBUG_TTY_FEEDBACK 26 | #ifdef ENABLE_NETWORK_SUPPORT 27 | #error When DEBUG_TTY_FEEDBACK is defined, do not define ENABLE_NETWORK_SUPPORT 28 | #endif 29 | #endif 30 | 31 | struct RuntimeData 32 | { 33 | sceCdRMode ReadMode; 34 | char BootDeviceID; 35 | volatile unsigned char IsRemoteClientConnected; 36 | int InstallationLockSema; // For game I/O (Installation and reading), to protect access to the hdl0: device. Updating and deleting games doesn't require locking since the hdl0: device won't be accessed then. 37 | unsigned char ip_address[4], subnet_mask[4], gateway[4]; 38 | unsigned char UseDHCP, SortTitles, EthernetFlowControl, AdvancedNetworkSettings; 39 | short int EthernetLinkMode; 40 | }; 41 | -------------------------------------------------------------------------------- /menu.h: -------------------------------------------------------------------------------- 1 | #define GAME_LIST_WIDTH 600 2 | #define GAME_LIST_MAX_DISPLAYED_GAMES 15 3 | #define GAME_LIST_TITLE_MAX_CHARS 36 4 | #define GAME_LIST_TITLE_MAX_PIX (GAME_LIST_TITLE_MAX_CHARS * FNT_CHAR_WIDTH) 5 | #define GAME_LIST_TITLE_SCROLL_INTERVAL 10 6 | #define GAME_LIST_TITLE_SCROLL_START_PAUSE_INTERVAL (1 * 60) // Number of frames to pause by, when the title is scrolled to the end. 7 | #define GAME_LIST_TITLE_SCROLL_END_PAUSE_INTERVAL (3 * 60) // Number of frames to pause by, when the title is scrolled to the end. 8 | 9 | #define PROGRESS_BAR_START_X 5 10 | #define PROGRESS_BAR_START_Y 320 11 | #define PROGRESS_BAR_LENGTH 600 12 | 13 | #define SOFT_KEYBOARD_DISPLAY_X_LOCATION 70 14 | #define SOFT_KEYBOARD_DISPLAY_Y_LOCATION 70 15 | #define SOFT_KEYBOARD_X_LOCATION 90 16 | #define SOFT_KEYBOARD_Y_LOCATION 140 17 | #define SOFT_KEYBOARD_MAX_DISPLAYED_CHARS 33 18 | #define SOFT_KEYBOARD_MAX_DISPLAYED_WIDTH (SOFT_KEYBOARD_MAX_DISPLAYED_CHARS * (short int)(SOFT_KEYBOARD_CHAR_WIDTH)) 19 | #define SOFT_KEYBOARD_FONT_SCALE 1.0f 20 | #define SOFT_KEYBOARD_CHAR_WIDTH (16 * SOFT_KEYBOARD_FONT_SCALE) 21 | #define SOFT_KEYBOARD_CHAR_HEIGHT (16 * SOFT_KEYBOARD_FONT_SCALE) 22 | #define SOFT_KEYBOARD_CURSOR_HEIGHT 36 23 | 24 | #define MAX_DEVICES_IN_ROW 2 25 | #define DEVICE_LIST_X 128 26 | #define DEVICE_LIST_Y 64 27 | 28 | #define MENU_BLANK_MAX_CHARS 38 29 | #define MENU_BLANK_MAX_WIDTH (MENU_BLANK_MAX_CHARS * FNT_CHAR_WIDTH) 30 | #define MAX_BTN_LAB_LEN 16 31 | #define BTN_FNT_CHAR_WIDTH 8 32 | 33 | #define UPDATE_INTERVAL 300 // Update interval: 5s (5 * 60FPS = 300) 34 | #define NETSTAT_UPDATE_INTERVAL 600 // Update interval: 10s (10 * 60FPS = 600) 35 | 36 | void MainMenu(void); 37 | void RedrawLoadingScreen(unsigned int frame); 38 | 39 | void DrawInstallGameScreen(const wchar_t *GameTitle, const char *DiscID, unsigned char DiscType, float percentage, unsigned int rate, unsigned int SecondsRemaining); 40 | int DisplaySoftKeyboard(wchar_t *buffer, unsigned int length, unsigned int options); 41 | int ShowWaitForDiscDialog(void); 42 | -------------------------------------------------------------------------------- /pad.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "pad.h" 6 | 7 | static u8 PadArea[2][256] __attribute__((aligned(64))); 8 | static unsigned int old_pad[2] = {0, 0}; 9 | 10 | void InitPads(void) 11 | { 12 | padInit(0); 13 | padPortOpen(0, 0, PadArea[0]); 14 | padPortOpen(1, 0, PadArea[1]); 15 | } 16 | 17 | void DeinitPads(void) 18 | { 19 | padPortClose(0, 0); 20 | padPortClose(1, 0); 21 | padEnd(); 22 | } 23 | 24 | int ReadPadStatus_raw(int port, int slot) 25 | { 26 | struct padButtonStatus buttons; 27 | unsigned int paddata; 28 | 29 | paddata = 0; 30 | if (padRead(port, slot, &buttons) != 0) { 31 | paddata = 0xffff ^ buttons.btns; 32 | } 33 | 34 | return paddata; 35 | } 36 | 37 | int ReadCombinedPadStatus_raw(void) 38 | { 39 | return (ReadPadStatus_raw(0, 0) | ReadPadStatus_raw(1, 0)); 40 | } 41 | 42 | void WaitPadClear(int port, int slot) 43 | { 44 | while (ReadPadStatus_raw(port, slot) != 0) {}; 45 | } 46 | 47 | int ReadPadStatus(int port, int slot) 48 | { 49 | struct padButtonStatus buttons; 50 | unsigned int paddata, new_pad; 51 | 52 | new_pad = 0; 53 | if (padRead(port, slot, &buttons) != 0) { 54 | paddata = 0xffff ^ buttons.btns; 55 | new_pad = paddata & ~old_pad[port]; 56 | old_pad[port] = paddata; 57 | } 58 | 59 | return new_pad; 60 | } 61 | 62 | int ReadCombinedPadStatus(void) 63 | { 64 | return (ReadPadStatus(0, 0) | ReadPadStatus(1, 0)); 65 | } 66 | -------------------------------------------------------------------------------- /pad.h: -------------------------------------------------------------------------------- 1 | void InitPads(void); 2 | void DeinitPads(void); 3 | int ReadPadStatus_raw(int port, int slot); 4 | int ReadCombinedPadStatus_raw(void); 5 | void WaitPadClear(int port, int slot); 6 | int ReadPadStatus(int port, int slot); 7 | int ReadCombinedPadStatus(void); 8 | -------------------------------------------------------------------------------- /res/BOOT.XLF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/res/BOOT.XLF -------------------------------------------------------------------------------- /res/SJIS2Unicode.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/res/SJIS2Unicode.bin -------------------------------------------------------------------------------- /res/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/res/icon.ico -------------------------------------------------------------------------------- /res/system.cnf: -------------------------------------------------------------------------------- 1 | BOOT2 = PATINFO 2 | VER = 1.00 3 | VMODE = NTSC 4 | HDDUNITPOWER = NICHDD 5 | -------------------------------------------------------------------------------- /resources/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/resources/background.png -------------------------------------------------------------------------------- /resources/buttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/resources/buttons.png -------------------------------------------------------------------------------- /resources/devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ps2homebrew/HDLGameInstaller/ec37c81f8edb6fc45e2be51c86a322780641275a/resources/devices.png -------------------------------------------------------------------------------- /settings.h: -------------------------------------------------------------------------------- 1 | #define COMMON_SAVE_FOLDER "pfs1:/Your Saves" 2 | #define COMMON_SAVE_FOLDER_MODE 0777 3 | #define TITLE_SAVE_FOLDER "HDLGAMEINSTALLER" 4 | #define TITLE_SAVE_FOLDER_FULL COMMON_SAVE_FOLDER "/" TITLE_SAVE_FOLDER 5 | #define TITLE_SAVE_FOLDER_ATTR 0xC4A7 6 | #define TITLE_SAVE_FOLDER_MODE 0777 7 | #define TITLE_SAVE_FILE_ATTR 0x8497 8 | #define TITLE_SAVE_FILE_MODE 0666 9 | #define TITLE_SAVE_MIN_FREE_SPC (40 * 1024) 10 | 11 | void LoadDefaults(void); 12 | int ImportIPConfigDat(void); 13 | int LoadSettings(void); 14 | int SaveSettings(void); 15 | -------------------------------------------------------------------------------- /sjis.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "sjis.h" 7 | 8 | static unsigned int *LookupTable; 9 | static unsigned int NumLookupTableEntries; 10 | 11 | int SetSJISToUnicodeLookupTable(void *table, unsigned int TableLength) 12 | { 13 | LookupTable = table; 14 | NumLookupTableEntries = TableLength / sizeof(unsigned int) / 2; 15 | return 0; 16 | } 17 | 18 | wchar_t ConvertSJISToUnicodeChar(unsigned short int SourceChar) 19 | { 20 | unsigned int index; 21 | wchar_t UnicodeChar; 22 | 23 | if (SourceChar < 0x80) { 24 | UnicodeChar = SourceChar; 25 | } else { 26 | UnicodeChar = UNICODE_REPLACEMENT_CHAR; 27 | for (index = 0; index < NumLookupTableEntries; index++) { 28 | if (LookupTable[index * 2 + 0] == SourceChar) { 29 | UnicodeChar = LookupTable[index * 2 + 1]; 30 | break; 31 | } 32 | } 33 | } 34 | 35 | return UnicodeChar; 36 | } 37 | 38 | int SJISToUnicode(const unsigned char *SJISStringIn, int length, wchar_t *UnicodeStringOut, unsigned int NumUChars) 39 | { 40 | unsigned int i, NumChars; 41 | const char *SourceString; 42 | unsigned short int SJISCharacter; 43 | int result; 44 | 45 | for (result = 0, i = 0, SourceString = SJISStringIn, NumChars = 0; NumChars < NumUChars; i += GetSJISCharLength(SJISCharacter), NumChars++) { 46 | if (length > 0 && i >= length) 47 | break; 48 | 49 | if ((SJISCharacter = GetNextSJISChar(&SourceString)) == '\0') { 50 | UnicodeStringOut[NumChars++] = '\0'; 51 | break; 52 | } 53 | 54 | UnicodeStringOut[NumChars] = ConvertSJISToUnicodeChar(SJISCharacter); 55 | } 56 | 57 | return (result == 0 ? NumChars : result); 58 | } 59 | 60 | int GetSJISCharLengthFromString(const char *SJISCharacter) 61 | { 62 | return ((SJISCharacter[0] & 0x80) ? 2 : 1); 63 | } 64 | 65 | int GetSJISCharLength(unsigned short int SJISCharacter) 66 | { 67 | return ((SJISCharacter & 0x8000) ? 2 : 1); 68 | } 69 | 70 | unsigned short int GetNextSJISChar(const char **string) 71 | { 72 | int CharLength; 73 | unsigned short int NextSJISChar; 74 | 75 | CharLength = GetSJISCharLengthFromString(*string); 76 | if (CharLength == 1) { 77 | NextSJISChar = (*string)[0]; 78 | (*string)++; 79 | } else { 80 | ((unsigned char *)&NextSJISChar)[1] = (*string)[0]; 81 | ((unsigned char *)&NextSJISChar)[0] = (*string)[1]; 82 | (*string) += 2; 83 | } 84 | 85 | return NextSJISChar; 86 | } 87 | -------------------------------------------------------------------------------- /sjis.h: -------------------------------------------------------------------------------- 1 | #define UNICODE_REPLACEMENT_CHAR 0xFFFD 2 | #define SJIS_REPLACEMENT_CHAR 0x0080 3 | 4 | int SetSJISToUnicodeLookupTable(void *table, unsigned int TableLength); 5 | 6 | wchar_t ConvertSJISToUnicodeChar(unsigned short int SourceChar); 7 | int SJISToUnicode(const unsigned char *SJISStringIn, int length, wchar_t *UnicodeStringOut, unsigned int NumUChars); 8 | 9 | int GetSJISCharLength(unsigned short int SJISCharacter); 10 | int GetSJISCharLengthFromString(const char *SJISCharacter); 11 | unsigned short int GetNextSJISChar(const char **string); 12 | -------------------------------------------------------------------------------- /system.h: -------------------------------------------------------------------------------- 1 | enum BootDeviceIDs { 2 | BOOT_DEVICE_UNKNOWN = -1, 3 | BOOT_DEVICE_MC0 = 0, 4 | BOOT_DEVICE_MC1, 5 | BOOT_DEVICE_CDROM, 6 | BOOT_DEVICE_MASS, 7 | BOOT_DEVICE_HDD, 8 | 9 | BOOT_DEVICE_COUNT, 10 | }; 11 | 12 | enum CONSOLE_REGION { 13 | CONSOLE_REGION_JAPAN = 0, 14 | CONSOLE_REGION_USA, // USA and Asia 15 | CONSOLE_REGION_EUROPE, 16 | CONSOLE_REGION_CHINA, 17 | 18 | CONSOLE_REGION_COUNT 19 | }; 20 | 21 | /* Transfer rate modes. */ 22 | #define ATA_XFER_MODE_PIO 0x08 23 | #define ATA_XFER_MODE_MDMA 0x20 24 | #define ATA_XFER_MODE_UDMA 0x40 25 | 26 | /* Parameters */ 27 | #define CDVD_INSTALL_IO_PRIORITY 0x71 28 | #define CDVD_INSTALL_MAIN_PRIORITY 0x70 29 | 30 | int GetBootDeviceID(void); 31 | int GetConsoleRegion(void); 32 | int GetConsoleVMode(void); 33 | int GetDiscIDFromStartupFilename(const char *filename, char *DiscID); 34 | int InitGameCDVDInformation(sceCdRMode *ReadMode, char *DiscID, char *StartupFname, unsigned char *discType, unsigned int *SectorsInDiscLayer0, unsigned int *SectorsInDiscLayer1); 35 | int RetrieveGameInstallationSector(u32 lba, const char *partition, struct HDLGameEntry *GameEntry); 36 | int RetrieveGameInstallationData(const char *partition, struct HDLGameEntry *GameEntry); 37 | int RemoveGameInstallation(const char *PartPath); 38 | int UpdateGameInstallation(const char *partition, const wchar_t *title, unsigned char CompatModeFlags, unsigned char TRType, unsigned char TRMode, unsigned char DiscType); 39 | int CheckForExistingGameInstallation(const char *DiscID, char *ExistingPartName, unsigned int BufferSize); 40 | void GeneratePartName(char *PartName, const char *DiscID, const wchar_t *title); 41 | int PrepareInstallHDLGame(const wchar_t *GameTitle, const char *DiscID, const char *StartupFname, const char *TargetPartName, unsigned int SectorsInDiscLayer0, unsigned int SectorsInDiscLayer1, unsigned char DiscType, unsigned char CompatibilityModeFlags, unsigned char TRType, unsigned char TRMode); 42 | int InstallGameFromCDVDDrive(sceCdRMode *ReadMode, const char *InstallPath, const wchar_t *title, const char *DiscID, const char *StartupFname, unsigned char DiscType, unsigned int SectorsInDiscLayer0, unsigned int SectorsInDiscLayer1, unsigned char CompatibilityModeFlags, unsigned char TRType, unsigned char TRMode); 43 | int SysCreateThread(void *function, void *stack, unsigned int StackSize, void *arg, int priority); 44 | 45 | int SysBootDeviceInit(void); 46 | void sysGetFreeDiskSpaceDisplay(char *space); 47 | 48 | #ifdef ENABLE_NETWORK_SUPPORT 49 | int ethApplyNetIFConfig(int mode); 50 | int ethGetNetIFLinkStatus(void); 51 | int ethWaitValidNetIFLinkState(void); 52 | int ethWaitValidDHCPState(void); 53 | int ethApplyIPConfig(int use_dhcp, const struct ip4_addr *ip, const struct ip4_addr *netmask, const struct ip4_addr *gateway); 54 | void ethInit(void); 55 | void ethReinit(void); 56 | void ethValidate(void); 57 | void ethGetIPAddressDisplay(char *ip); 58 | #endif 59 | --------------------------------------------------------------------------------